From b37bf2e156556c589aea3e1f58a377f2b1189665 Mon Sep 17 00:00:00 2001 From: Apple Date: Tue, 24 Jun 2008 20:33:06 +0000 Subject: [PATCH] JavaScriptCore-461.tar.gz --- API/APICast.h | 120 + API/JSBase.cpp | 87 + API/JSBase.h | 125 + API/JSCallbackConstructor.cpp | 82 + API/JSCallbackConstructor.h | 59 + API/JSCallbackFunction.cpp | 68 + API/JSCallbackFunction.h | 56 + API/JSCallbackObject.cpp | 41 + API/JSCallbackObject.h | 95 + API/JSCallbackObjectFunctions.h | 495 + API/JSClassRef.cpp | 164 + API/JSClassRef.h | 97 + API/JSContextRef.cpp | 76 + API/JSContextRef.h | 77 + API/JSNode.c | 197 + API/JSNode.h | 38 + API/JSNodeList.c | 124 + API/JSNodeList.h | 35 + API/JSObjectRef.cpp | 374 + API/JSObjectRef.h | 645 + API/JSRetainPtr.h | 173 + API/JSStringRef.cpp | 125 + API/JSStringRef.h | 143 + API/JSStringRefBSTR.cpp | 43 + API/JSStringRefBSTR.h | 63 + API/JSStringRefCF.cpp | 57 + API/JSStringRefCF.h | 61 + API/JSValueRef.cpp | 259 + API/JSValueRef.h | 277 + API/JavaScript.h | 37 + API/JavaScriptCore.h | 33 + API/Node.c | 86 + API/Node.h | 51 + API/NodeList.c | 82 + API/NodeList.h | 43 + API/minidom.c | 128 + API/minidom.html | 9 + API/minidom.js | 111 + API/testapi.c | 944 ++ API/testapi.js | 132 + AUTHORS | 2 + COPYING.LIB | 488 + DerivedSources.make | 65 + ForwardingHeaders/JavaScriptCore/APICast.h | 1 + ForwardingHeaders/JavaScriptCore/JSBase.h | 1 + .../JavaScriptCore/JSContextRef.h | 1 + ForwardingHeaders/JavaScriptCore/JSLock.h | 1 + .../JavaScriptCore/JSObjectRef.h | 1 + .../JavaScriptCore/JSRetainPtr.h | 1 + .../JavaScriptCore/JSStringRef.h | 1 + .../JavaScriptCore/JSStringRefCF.h | 1 + ForwardingHeaders/JavaScriptCore/JSValueRef.h | 1 + ForwardingHeaders/JavaScriptCore/JavaScript.h | 1 + .../JavaScriptCore/JavaScriptCore.h | 1 + GNUmakefile.am | 171 + Info.plist | 24 + JavaScriptCore.exp | 294 + JavaScriptCore.order | 1532 +++ JavaScriptCore.pri | 155 + JavaScriptCorePrefix.h | 35 + JavaScriptCoreSources.bkl | 119 + Makefile | 2 + THANKS | 8 + bindings/NP_jsobject.cpp | 406 + bindings/NP_jsobject.h | 55 + bindings/c/c_class.cpp | 123 + bindings/c/c_class.h | 61 + bindings/c/c_instance.cpp | 212 + bindings/c/c_instance.h | 80 + bindings/c/c_runtime.cpp | 96 + bindings/c/c_runtime.h | 67 + bindings/c/c_utility.cpp | 185 + bindings/c/c_utility.h | 72 + bindings/jni/jni_class.cpp | 140 + bindings/jni/jni_class.h | 66 + bindings/jni/jni_instance.cpp | 358 + bindings/jni/jni_instance.h | 103 + bindings/jni/jni_jsobject.cpp | 590 + bindings/jni/jni_jsobject.h | 129 + bindings/jni/jni_objc.mm | 82 + bindings/jni/jni_runtime.cpp | 549 + bindings/jni/jni_runtime.h | 190 + bindings/jni/jni_utility.cpp | 992 ++ bindings/jni/jni_utility.h | 125 + bindings/make_testbindings | 2 + bindings/npapi.h | 720 + bindings/npruntime.cpp | 226 + bindings/npruntime.h | 358 + bindings/npruntime_impl.h | 65 + bindings/npruntime_internal.h | 39 + bindings/npruntime_priv.h | 41 + bindings/objc/WebScriptObject.h | 46 + bindings/objc/objc_class.h | 61 + bindings/objc/objc_class.mm | 258 + bindings/objc/objc_header.h | 53 + bindings/objc/objc_instance.h | 81 + bindings/objc/objc_instance.mm | 349 + bindings/objc/objc_runtime.h | 128 + bindings/objc/objc_runtime.mm | 295 + bindings/objc/objc_utility.h | 87 + bindings/objc/objc_utility.mm | 372 + bindings/qt/qt_class.cpp | 223 + bindings/qt/qt_class.h | 55 + bindings/qt/qt_instance.cpp | 394 + bindings/qt/qt_instance.h | 85 + bindings/qt/qt_runtime.cpp | 1590 +++ bindings/qt/qt_runtime.h | 217 + bindings/runtime.cpp | 154 + bindings/runtime.h | 174 + bindings/runtime_array.cpp | 118 + bindings/runtime_array.h | 65 + bindings/runtime_method.cpp | 94 + bindings/runtime_method.h | 51 + bindings/runtime_object.cpp | 254 + bindings/runtime_object.h | 74 + bindings/runtime_root.cpp | 309 + bindings/runtime_root.h | 109 + bindings/test.js | 19 + bindings/testC.js | 21 + bindings/testM.js | 29 + bindings/testbindings.cpp | 422 + bindings/testbindings.mm | 289 + bindings/testbindings.pro | 8 + bindings/testqtbindings.cpp | 142 + headers.pri | 9 + icu/LICENSE | 25 + icu/README | 4 + icu/unicode/platform.h | 267 + icu/unicode/putil.h | 180 + icu/unicode/uchar.h | 2798 ++++ icu/unicode/ucnv.h | 1817 +++ icu/unicode/ucnv_err.h | 456 + icu/unicode/uconfig.h | 186 + icu/unicode/uenum.h | 129 + icu/unicode/uiter.h | 707 + icu/unicode/umachine.h | 371 + icu/unicode/urename.h | 1468 +++ icu/unicode/ustring.h | 1320 ++ icu/unicode/utf.h | 221 + icu/unicode/utf16.h | 605 + icu/unicode/utf8.h | 627 + icu/unicode/utf_old.h | 0 icu/unicode/utypes.h | 745 ++ icu/unicode/uversion.h | 216 + jscore.bkl | 114 + kjs/Activation.h | 99 + kjs/AllInOneFile.cpp | 73 + kjs/CollectorHeapIntrospector.cpp | 94 + kjs/CollectorHeapIntrospector.h | 75 + kjs/CommonIdentifiers.cpp | 47 + kjs/CommonIdentifiers.h | 72 + kjs/DateMath.cpp | 506 + kjs/DateMath.h | 154 + kjs/ExecState.cpp | 215 + kjs/ExecState.h | 241 + kjs/JSGlobalObject.cpp | 568 + kjs/JSGlobalObject.h | 262 + kjs/JSImmediate.cpp | 82 + kjs/JSImmediate.h | 278 + kjs/JSLock.cpp | 183 + kjs/JSLock.h | 81 + kjs/JSLockC.h | 19 + kjs/JSType.h | 43 + kjs/JSVariableObject.cpp | 106 + kjs/JSVariableObject.h | 121 + kjs/JSWrapperObject.cpp | 34 + kjs/JSWrapperObject.h | 84 + kjs/LabelStack.h | 84 + kjs/LocalStorage.h | 56 + kjs/NodeInfo.h | 44 + kjs/Parser.cpp | 91 + kjs/Parser.h | 99 + kjs/PropertyNameArray.cpp | 43 + kjs/PropertyNameArray.h | 56 + kjs/SavedBuiltins.h | 94 + kjs/SymbolTable.h | 68 + kjs/array_instance.cpp | 612 + kjs/array_instance.h | 72 + kjs/array_object.cpp | 760 ++ kjs/array_object.h | 71 + kjs/bool_object.cpp | 117 + kjs/bool_object.h | 65 + kjs/collector.cpp | 1078 ++ kjs/collector.h | 193 + kjs/completion.h | 60 + kjs/config.h | 88 + kjs/create_hash_table | 250 + kjs/date_object.cpp | 1542 +++ kjs/date_object.h | 135 + kjs/debugger.cpp | 134 + kjs/debugger.h | 225 + kjs/dtoa.cpp | 3300 +++++ kjs/dtoa.h | 31 + kjs/error_object.cpp | 153 + kjs/error_object.h | 77 + kjs/function.cpp | 881 ++ kjs/function.h | 159 + kjs/function_object.cpp | 244 + kjs/function_object.h | 61 + kjs/grammar.y | 1261 ++ kjs/identifier.cpp | 205 + kjs/identifier.h | 100 + kjs/internal.cpp | 302 + kjs/internal.h | 122 + kjs/interpreter.cpp | 156 + kjs/interpreter.h | 71 + kjs/keywords.table | 72 + kjs/lexer.cpp | 897 ++ kjs/lexer.h | 149 + kjs/list.cpp | 76 + kjs/list.h | 118 + kjs/lookup.cpp | 81 + kjs/lookup.h | 342 + kjs/math_object.cpp | 243 + kjs/math_object.h | 65 + kjs/nodes.cpp | 4725 +++++++ kjs/nodes.h | 2907 ++++ kjs/nodes2string.cpp | 973 ++ kjs/number_object.cpp | 525 + kjs/number_object.h | 76 + kjs/object.cpp | 681 + kjs/object.h | 605 + kjs/object_object.cpp | 216 + kjs/object_object.h | 57 + kjs/operations.cpp | 128 + kjs/operations.h | 35 + kjs/property_map.cpp | 850 ++ kjs/property_map.h | 184 + kjs/property_slot.cpp | 46 + kjs/property_slot.h | 142 + kjs/protect.h | 143 + kjs/regexp.cpp | 120 + kjs/regexp.h | 75 + kjs/regexp_object.cpp | 475 + kjs/regexp_object.h | 105 + kjs/scope_chain.cpp | 63 + kjs/scope_chain.h | 156 + kjs/scope_chain_mark.h | 49 + kjs/string_object.cpp | 1055 ++ kjs/string_object.h | 153 + kjs/testkjs.cpp | 344 + kjs/testkjs.pro | 34 + kjs/types.h | 25 + kjs/ustring.cpp | 1288 ++ kjs/ustring.h | 470 + kjs/value.cpp | 232 + kjs/value.h | 523 + make-generated-sources.sh | 11 + os-win32/stdbool.h | 45 + os-win32/stdint.h | 54 + pcre/AUTHORS | 12 + pcre/COPYING | 35 + pcre/dftables | 264 + pcre/pcre.h | 68 + pcre/pcre.pri | 34 + pcre/pcre_compile.cpp | 2671 ++++ pcre/pcre_exec.cpp | 2066 +++ pcre/pcre_internal.h | 419 + pcre/pcre_tables.cpp | 71 + pcre/pcre_ucp_searchfuncs.cpp | 98 + pcre/pcre_xclass.cpp | 114 + pcre/ucpinternal.h | 126 + pcre/ucptable.cpp | 2968 +++++ tests/mozilla/Getopt/Mixed.pm | 754 ++ tests/mozilla/Makefile | 3 + tests/mozilla/README-jsDriver.html | 344 + tests/mozilla/ecma/Array/15.4-1.js | 126 + tests/mozilla/ecma/Array/15.4-2.js | 83 + tests/mozilla/ecma/Array/15.4.1.1.js | 88 + tests/mozilla/ecma/Array/15.4.1.2.js | 98 + tests/mozilla/ecma/Array/15.4.1.3.js | 86 + tests/mozilla/ecma/Array/15.4.1.js | 133 + tests/mozilla/ecma/Array/15.4.2.1-1.js | 92 + tests/mozilla/ecma/Array/15.4.2.1-2.js | 83 + tests/mozilla/ecma/Array/15.4.2.1-3.js | 112 + tests/mozilla/ecma/Array/15.4.2.2-1.js | 124 + tests/mozilla/ecma/Array/15.4.2.2-2.js | 89 + tests/mozilla/ecma/Array/15.4.2.3.js | 74 + tests/mozilla/ecma/Array/15.4.3.1-2.js | 66 + tests/mozilla/ecma/Array/15.4.3.2.js | 57 + tests/mozilla/ecma/Array/15.4.3.js | 63 + tests/mozilla/ecma/Array/15.4.4.1.js | 57 + tests/mozilla/ecma/Array/15.4.4.2.js | 83 + tests/mozilla/ecma/Array/15.4.4.3-1.js | 159 + tests/mozilla/ecma/Array/15.4.4.4-1.js | 272 + tests/mozilla/ecma/Array/15.4.4.4-2.js | 163 + tests/mozilla/ecma/Array/15.4.4.5-1.js | 223 + tests/mozilla/ecma/Array/15.4.4.5-2.js | 224 + tests/mozilla/ecma/Array/15.4.4.5-3.js | 181 + tests/mozilla/ecma/Array/15.4.4.js | 77 + tests/mozilla/ecma/Array/15.4.5.1-1.js | 172 + tests/mozilla/ecma/Array/15.4.5.1-2.js | 150 + tests/mozilla/ecma/Array/15.4.5.2-1.js | 93 + tests/mozilla/ecma/Array/15.4.5.2-2.js | 123 + tests/mozilla/ecma/Boolean/15.6.1.js | 96 + tests/mozilla/ecma/Boolean/15.6.2.js | 160 + tests/mozilla/ecma/Boolean/15.6.3.1-1.js | 72 + tests/mozilla/ecma/Boolean/15.6.3.1-2.js | 69 + tests/mozilla/ecma/Boolean/15.6.3.1-3.js | 69 + tests/mozilla/ecma/Boolean/15.6.3.1-4.js | 79 + tests/mozilla/ecma/Boolean/15.6.3.1-5.js | 61 + tests/mozilla/ecma/Boolean/15.6.3.1.js | 72 + tests/mozilla/ecma/Boolean/15.6.3.js | 67 + tests/mozilla/ecma/Boolean/15.6.4-1.js | 73 + tests/mozilla/ecma/Boolean/15.6.4-2.js | 67 + tests/mozilla/ecma/Boolean/15.6.4.1.js | 65 + tests/mozilla/ecma/Boolean/15.6.4.2-1.js | 97 + tests/mozilla/ecma/Boolean/15.6.4.2-2.js | 79 + tests/mozilla/ecma/Boolean/15.6.4.2-3.js | 67 + tests/mozilla/ecma/Boolean/15.6.4.2-4-n.js | 70 + tests/mozilla/ecma/Boolean/15.6.4.3-1.js | 91 + tests/mozilla/ecma/Boolean/15.6.4.3-2.js | 67 + tests/mozilla/ecma/Boolean/15.6.4.3-3.js | 71 + tests/mozilla/ecma/Boolean/15.6.4.3-4-n.js | 71 + tests/mozilla/ecma/Boolean/15.6.4.3.js | 97 + tests/mozilla/ecma/Boolean/15.6.4.js | 77 + tests/mozilla/ecma/Date/15.9.1.1-1.js | 87 + tests/mozilla/ecma/Date/15.9.1.1-2.js | 82 + tests/mozilla/ecma/Date/15.9.2.1.js | 108 + tests/mozilla/ecma/Date/15.9.2.2-1.js | 105 + tests/mozilla/ecma/Date/15.9.2.2-2.js | 99 + tests/mozilla/ecma/Date/15.9.2.2-3.js | 92 + tests/mozilla/ecma/Date/15.9.2.2-4.js | 85 + tests/mozilla/ecma/Date/15.9.2.2-5.js | 78 + tests/mozilla/ecma/Date/15.9.2.2-6.js | 72 + tests/mozilla/ecma/Date/15.9.3.1-1.js | 274 + tests/mozilla/ecma/Date/15.9.3.1-2.js | 231 + tests/mozilla/ecma/Date/15.9.3.1-3.js | 209 + tests/mozilla/ecma/Date/15.9.3.1-4.js | 193 + tests/mozilla/ecma/Date/15.9.3.1-5.js | 170 + tests/mozilla/ecma/Date/15.9.3.2-1.js | 241 + tests/mozilla/ecma/Date/15.9.3.2-2.js | 219 + tests/mozilla/ecma/Date/15.9.3.2-3.js | 205 + tests/mozilla/ecma/Date/15.9.3.2-4.js | 188 + tests/mozilla/ecma/Date/15.9.3.2-5.js | 170 + tests/mozilla/ecma/Date/15.9.3.8-1.js | 300 + tests/mozilla/ecma/Date/15.9.3.8-2.js | 275 + tests/mozilla/ecma/Date/15.9.3.8-3.js | 253 + tests/mozilla/ecma/Date/15.9.3.8-4.js | 222 + tests/mozilla/ecma/Date/15.9.3.8-5.js | 190 + tests/mozilla/ecma/Date/15.9.4.2-1.js | 63 + tests/mozilla/ecma/Date/15.9.4.2.js | 213 + tests/mozilla/ecma/Date/15.9.4.3.js | 209 + tests/mozilla/ecma/Date/15.9.5.1.js | 59 + tests/mozilla/ecma/Date/15.9.5.10-1.js | 111 + tests/mozilla/ecma/Date/15.9.5.10-10.js | 102 + tests/mozilla/ecma/Date/15.9.5.10-11.js | 101 + tests/mozilla/ecma/Date/15.9.5.10-12.js | 100 + tests/mozilla/ecma/Date/15.9.5.10-13.js | 97 + tests/mozilla/ecma/Date/15.9.5.10-2.js | 110 + tests/mozilla/ecma/Date/15.9.5.10-3.js | 109 + tests/mozilla/ecma/Date/15.9.5.10-4.js | 107 + tests/mozilla/ecma/Date/15.9.5.10-5.js | 107 + tests/mozilla/ecma/Date/15.9.5.10-6.js | 106 + tests/mozilla/ecma/Date/15.9.5.10-7.js | 105 + tests/mozilla/ecma/Date/15.9.5.10-8.js | 104 + tests/mozilla/ecma/Date/15.9.5.10-9.js | 103 + tests/mozilla/ecma/Date/15.9.5.11-1.js | 99 + tests/mozilla/ecma/Date/15.9.5.11-2.js | 96 + tests/mozilla/ecma/Date/15.9.5.11-3.js | 95 + tests/mozilla/ecma/Date/15.9.5.11-4.js | 95 + tests/mozilla/ecma/Date/15.9.5.11-5.js | 95 + tests/mozilla/ecma/Date/15.9.5.11-6.js | 96 + tests/mozilla/ecma/Date/15.9.5.11-7.js | 98 + tests/mozilla/ecma/Date/15.9.5.12-1.js | 105 + tests/mozilla/ecma/Date/15.9.5.12-2.js | 104 + tests/mozilla/ecma/Date/15.9.5.12-3.js | 103 + tests/mozilla/ecma/Date/15.9.5.12-4.js | 102 + tests/mozilla/ecma/Date/15.9.5.12-5.js | 101 + tests/mozilla/ecma/Date/15.9.5.12-6.js | 100 + tests/mozilla/ecma/Date/15.9.5.12-7.js | 98 + tests/mozilla/ecma/Date/15.9.5.12-8.js | 95 + tests/mozilla/ecma/Date/15.9.5.13-1.js | 78 + tests/mozilla/ecma/Date/15.9.5.13-2.js | 75 + tests/mozilla/ecma/Date/15.9.5.13-3.js | 75 + tests/mozilla/ecma/Date/15.9.5.13-4.js | 75 + tests/mozilla/ecma/Date/15.9.5.13-5.js | 75 + tests/mozilla/ecma/Date/15.9.5.13-6.js | 78 + tests/mozilla/ecma/Date/15.9.5.13-7.js | 80 + tests/mozilla/ecma/Date/15.9.5.13-8.js | 95 + tests/mozilla/ecma/Date/15.9.5.14.js | 96 + tests/mozilla/ecma/Date/15.9.5.15.js | 97 + tests/mozilla/ecma/Date/15.9.5.16.js | 96 + tests/mozilla/ecma/Date/15.9.5.17.js | 97 + tests/mozilla/ecma/Date/15.9.5.18.js | 97 + tests/mozilla/ecma/Date/15.9.5.19.js | 97 + tests/mozilla/ecma/Date/15.9.5.2-1.js | 152 + tests/mozilla/ecma/Date/15.9.5.2-2-n.js | 77 + tests/mozilla/ecma/Date/15.9.5.2.js | 152 + tests/mozilla/ecma/Date/15.9.5.20.js | 97 + tests/mozilla/ecma/Date/15.9.5.21-1.js | 97 + tests/mozilla/ecma/Date/15.9.5.21-2.js | 95 + tests/mozilla/ecma/Date/15.9.5.21-3.js | 78 + tests/mozilla/ecma/Date/15.9.5.21-4.js | 78 + tests/mozilla/ecma/Date/15.9.5.21-5.js | 78 + tests/mozilla/ecma/Date/15.9.5.21-6.js | 79 + tests/mozilla/ecma/Date/15.9.5.21-7.js | 78 + tests/mozilla/ecma/Date/15.9.5.21-8.js | 86 + tests/mozilla/ecma/Date/15.9.5.22-1.js | 100 + tests/mozilla/ecma/Date/15.9.5.22-2.js | 99 + tests/mozilla/ecma/Date/15.9.5.22-3.js | 98 + tests/mozilla/ecma/Date/15.9.5.22-4.js | 97 + tests/mozilla/ecma/Date/15.9.5.22-5.js | 96 + tests/mozilla/ecma/Date/15.9.5.22-6.js | 95 + tests/mozilla/ecma/Date/15.9.5.22-7.js | 93 + tests/mozilla/ecma/Date/15.9.5.22-8.js | 90 + tests/mozilla/ecma/Date/15.9.5.23-1.js | 157 + tests/mozilla/ecma/Date/15.9.5.23-10.js | 156 + tests/mozilla/ecma/Date/15.9.5.23-11.js | 155 + tests/mozilla/ecma/Date/15.9.5.23-12.js | 153 + tests/mozilla/ecma/Date/15.9.5.23-13.js | 150 + tests/mozilla/ecma/Date/15.9.5.23-14.js | 148 + tests/mozilla/ecma/Date/15.9.5.23-15.js | 144 + tests/mozilla/ecma/Date/15.9.5.23-16.js | 143 + tests/mozilla/ecma/Date/15.9.5.23-17.js | 142 + tests/mozilla/ecma/Date/15.9.5.23-18.js | 139 + tests/mozilla/ecma/Date/15.9.5.23-2.js | 111 + tests/mozilla/ecma/Date/15.9.5.23-3-n.js | 70 + tests/mozilla/ecma/Date/15.9.5.23-4.js | 122 + tests/mozilla/ecma/Date/15.9.5.23-5.js | 122 + tests/mozilla/ecma/Date/15.9.5.23-6.js | 122 + tests/mozilla/ecma/Date/15.9.5.23-7.js | 122 + tests/mozilla/ecma/Date/15.9.5.23-8.js | 111 + tests/mozilla/ecma/Date/15.9.5.23-9.js | 112 + tests/mozilla/ecma/Date/15.9.5.24-1.js | 151 + tests/mozilla/ecma/Date/15.9.5.24-2.js | 150 + tests/mozilla/ecma/Date/15.9.5.24-3.js | 149 + tests/mozilla/ecma/Date/15.9.5.24-4.js | 148 + tests/mozilla/ecma/Date/15.9.5.24-5.js | 141 + tests/mozilla/ecma/Date/15.9.5.24-6.js | 140 + tests/mozilla/ecma/Date/15.9.5.24-7.js | 139 + tests/mozilla/ecma/Date/15.9.5.24-8.js | 135 + tests/mozilla/ecma/Date/15.9.5.25-1.js | 190 + tests/mozilla/ecma/Date/15.9.5.26-1.js | 203 + tests/mozilla/ecma/Date/15.9.5.27-1.js | 202 + tests/mozilla/ecma/Date/15.9.5.28-1.js | 216 + tests/mozilla/ecma/Date/15.9.5.29-1.js | 210 + tests/mozilla/ecma/Date/15.9.5.3-1-n.js | 73 + tests/mozilla/ecma/Date/15.9.5.3-2.js | 107 + tests/mozilla/ecma/Date/15.9.5.30-1.js | 215 + tests/mozilla/ecma/Date/15.9.5.31-1.js | 212 + tests/mozilla/ecma/Date/15.9.5.32-1.js | 157 + tests/mozilla/ecma/Date/15.9.5.33-1.js | 156 + tests/mozilla/ecma/Date/15.9.5.34-1.js | 220 + tests/mozilla/ecma/Date/15.9.5.35-1.js | 143 + tests/mozilla/ecma/Date/15.9.5.36-1.js | 245 + tests/mozilla/ecma/Date/15.9.5.36-2.js | 231 + tests/mozilla/ecma/Date/15.9.5.36-3.js | 218 + tests/mozilla/ecma/Date/15.9.5.36-4.js | 205 + tests/mozilla/ecma/Date/15.9.5.36-5.js | 192 + tests/mozilla/ecma/Date/15.9.5.36-6.js | 179 + tests/mozilla/ecma/Date/15.9.5.36-7.js | 164 + tests/mozilla/ecma/Date/15.9.5.37-1.js | 235 + tests/mozilla/ecma/Date/15.9.5.37-2.js | 209 + tests/mozilla/ecma/Date/15.9.5.37-3.js | 195 + tests/mozilla/ecma/Date/15.9.5.37-4.js | 177 + tests/mozilla/ecma/Date/15.9.5.37-5.js | 160 + tests/mozilla/ecma/Date/15.9.5.4-1.js | 96 + tests/mozilla/ecma/Date/15.9.5.4-2-n.js | 67 + tests/mozilla/ecma/Date/15.9.5.5.js | 123 + tests/mozilla/ecma/Date/15.9.5.6.js | 114 + tests/mozilla/ecma/Date/15.9.5.7.js | 114 + tests/mozilla/ecma/Date/15.9.5.8.js | 120 + tests/mozilla/ecma/Date/15.9.5.9.js | 120 + tests/mozilla/ecma/Date/15.9.5.js | 81 + .../ecma/ExecutionContexts/10.1.3-1.js | 107 + .../mozilla/ecma/ExecutionContexts/10.1.3.js | 160 + .../ecma/ExecutionContexts/10.1.4-1.js | 100 + .../ecma/ExecutionContexts/10.1.4-10.js | 94 + .../ecma/ExecutionContexts/10.1.4-2.js | 102 + .../ecma/ExecutionContexts/10.1.4-3.js | 98 + .../ecma/ExecutionContexts/10.1.4-4.js | 101 + .../ecma/ExecutionContexts/10.1.4-5.js | 101 + .../ecma/ExecutionContexts/10.1.4-6.js | 83 + .../ecma/ExecutionContexts/10.1.4-7.js | 100 + .../ecma/ExecutionContexts/10.1.4-8.js | 101 + .../ecma/ExecutionContexts/10.1.4-9.js | 98 + .../ecma/ExecutionContexts/10.1.5-1.js | 118 + .../ecma/ExecutionContexts/10.1.5-2.js | 101 + .../ecma/ExecutionContexts/10.1.5-3.js | 119 + .../ecma/ExecutionContexts/10.1.5-4.js | 94 + .../mozilla/ecma/ExecutionContexts/10.1.6.js | 124 + .../ecma/ExecutionContexts/10.1.8-1.js | 132 + .../ecma/ExecutionContexts/10.1.8-2.js | 117 + .../mozilla/ecma/ExecutionContexts/10.2.1.js | 82 + .../ecma/ExecutionContexts/10.2.2-1.js | 119 + .../ecma/ExecutionContexts/10.2.2-2.js | 105 + .../ecma/ExecutionContexts/10.2.3-1.js | 83 + .../ecma/ExecutionContexts/10.2.3-2.js | 89 + tests/mozilla/ecma/Expressions/11.1.1.js | 135 + tests/mozilla/ecma/Expressions/11.10-1.js | 270 + tests/mozilla/ecma/Expressions/11.10-2.js | 269 + tests/mozilla/ecma/Expressions/11.10-3.js | 268 + tests/mozilla/ecma/Expressions/11.12-1.js | 86 + tests/mozilla/ecma/Expressions/11.12-2-n.js | 71 + tests/mozilla/ecma/Expressions/11.12-3.js | 71 + tests/mozilla/ecma/Expressions/11.12-4.js | 71 + tests/mozilla/ecma/Expressions/11.13.1.js | 70 + tests/mozilla/ecma/Expressions/11.13.2-1.js | 122 + tests/mozilla/ecma/Expressions/11.13.2-2.js | 136 + tests/mozilla/ecma/Expressions/11.13.2-3.js | 149 + tests/mozilla/ecma/Expressions/11.13.2-4.js | 137 + tests/mozilla/ecma/Expressions/11.13.2-5.js | 137 + tests/mozilla/ecma/Expressions/11.13.js | 86 + tests/mozilla/ecma/Expressions/11.14-1.js | 73 + tests/mozilla/ecma/Expressions/11.2.1-1.js | 268 + tests/mozilla/ecma/Expressions/11.2.1-2.js | 124 + tests/mozilla/ecma/Expressions/11.2.1-3-n.js | 120 + tests/mozilla/ecma/Expressions/11.2.1-4-n.js | 120 + tests/mozilla/ecma/Expressions/11.2.1-5.js | 124 + tests/mozilla/ecma/Expressions/11.2.2-1-n.js | 98 + tests/mozilla/ecma/Expressions/11.2.2-1.js | 99 + tests/mozilla/ecma/Expressions/11.2.2-10-n.js | 96 + tests/mozilla/ecma/Expressions/11.2.2-11.js | 99 + tests/mozilla/ecma/Expressions/11.2.2-2-n.js | 98 + tests/mozilla/ecma/Expressions/11.2.2-3-n.js | 98 + tests/mozilla/ecma/Expressions/11.2.2-4-n.js | 98 + tests/mozilla/ecma/Expressions/11.2.2-5-n.js | 98 + tests/mozilla/ecma/Expressions/11.2.2-6-n.js | 81 + tests/mozilla/ecma/Expressions/11.2.2-7-n.js | 98 + tests/mozilla/ecma/Expressions/11.2.2-8-n.js | 98 + tests/mozilla/ecma/Expressions/11.2.2-9-n.js | 98 + tests/mozilla/ecma/Expressions/11.2.3-1.js | 121 + tests/mozilla/ecma/Expressions/11.2.3-2-n.js | 90 + tests/mozilla/ecma/Expressions/11.2.3-3-n.js | 81 + tests/mozilla/ecma/Expressions/11.2.3-4-n.js | 81 + tests/mozilla/ecma/Expressions/11.2.3-5.js | 81 + tests/mozilla/ecma/Expressions/11.3.1.js | 154 + tests/mozilla/ecma/Expressions/11.3.2.js | 154 + tests/mozilla/ecma/Expressions/11.4.1.js | 95 + tests/mozilla/ecma/Expressions/11.4.2.js | 85 + tests/mozilla/ecma/Expressions/11.4.3.js | 109 + tests/mozilla/ecma/Expressions/11.4.4.js | 156 + tests/mozilla/ecma/Expressions/11.4.5.js | 154 + tests/mozilla/ecma/Expressions/11.4.6.js | 299 + tests/mozilla/ecma/Expressions/11.4.8.js | 215 + tests/mozilla/ecma/Expressions/11.4.9.js | 90 + tests/mozilla/ecma/Expressions/11.5.1.js | 115 + tests/mozilla/ecma/Expressions/11.5.2.js | 154 + tests/mozilla/ecma/Expressions/11.5.3.js | 160 + tests/mozilla/ecma/Expressions/11.6.1-1.js | 211 + tests/mozilla/ecma/Expressions/11.6.1-2.js | 203 + tests/mozilla/ecma/Expressions/11.6.1-3.js | 181 + tests/mozilla/ecma/Expressions/11.6.2-1.js | 199 + tests/mozilla/ecma/Expressions/11.6.3.js | 116 + tests/mozilla/ecma/Expressions/11.7.1.js | 229 + tests/mozilla/ecma/Expressions/11.7.2.js | 246 + tests/mozilla/ecma/Expressions/11.7.3.js | 230 + tests/mozilla/ecma/Expressions/11.8.1.js | 121 + tests/mozilla/ecma/Expressions/11.8.2.js | 122 + tests/mozilla/ecma/Expressions/11.8.3.js | 120 + tests/mozilla/ecma/Expressions/11.8.4.js | 122 + tests/mozilla/ecma/Expressions/11.9.1.js | 162 + tests/mozilla/ecma/Expressions/11.9.2.js | 161 + tests/mozilla/ecma/Expressions/11.9.3.js | 161 + .../ecma/FunctionObjects/15.3.1.1-1.js | 90 + .../ecma/FunctionObjects/15.3.1.1-2.js | 118 + .../ecma/FunctionObjects/15.3.1.1-3.js | 96 + .../ecma/FunctionObjects/15.3.2.1-1.js | 94 + .../ecma/FunctionObjects/15.3.2.1-2.js | 111 + .../ecma/FunctionObjects/15.3.2.1-3.js | 96 + .../ecma/FunctionObjects/15.3.3.1-1.js | 62 + .../ecma/FunctionObjects/15.3.3.1-2.js | 70 + .../ecma/FunctionObjects/15.3.3.1-3.js | 79 + .../ecma/FunctionObjects/15.3.3.1-4.js | 70 + .../mozilla/ecma/FunctionObjects/15.3.3.2.js | 60 + .../mozilla/ecma/FunctionObjects/15.3.4-1.js | 80 + .../mozilla/ecma/FunctionObjects/15.3.4.1.js | 62 + tests/mozilla/ecma/FunctionObjects/15.3.4.js | 79 + .../mozilla/ecma/FunctionObjects/15.3.5-1.js | 118 + .../mozilla/ecma/FunctionObjects/15.3.5-2.js | 92 + .../mozilla/ecma/FunctionObjects/15.3.5.1.js | 80 + .../mozilla/ecma/FunctionObjects/15.3.5.3.js | 75 + tests/mozilla/ecma/GlobalObject/15.1-1-n.js | 65 + tests/mozilla/ecma/GlobalObject/15.1-2-n.js | 63 + tests/mozilla/ecma/GlobalObject/15.1.1.1.js | 65 + tests/mozilla/ecma/GlobalObject/15.1.1.2.js | 66 + tests/mozilla/ecma/GlobalObject/15.1.2.1-1.js | 91 + tests/mozilla/ecma/GlobalObject/15.1.2.1-2.js | 66 + tests/mozilla/ecma/GlobalObject/15.1.2.2-1.js | 291 + tests/mozilla/ecma/GlobalObject/15.1.2.2-2.js | 232 + tests/mozilla/ecma/GlobalObject/15.1.2.3-1.js | 444 + tests/mozilla/ecma/GlobalObject/15.1.2.3-2.js | 295 + tests/mozilla/ecma/GlobalObject/15.1.2.4.js | 206 + tests/mozilla/ecma/GlobalObject/15.1.2.5-1.js | 207 + tests/mozilla/ecma/GlobalObject/15.1.2.5-2.js | 184 + tests/mozilla/ecma/GlobalObject/15.1.2.5-3.js | 207 + tests/mozilla/ecma/GlobalObject/15.1.2.6.js | 127 + tests/mozilla/ecma/GlobalObject/15.1.2.7.js | 131 + .../mozilla/ecma/LexicalConventions/7.1-1.js | 86 + .../mozilla/ecma/LexicalConventions/7.1-2.js | 74 + .../mozilla/ecma/LexicalConventions/7.1-3.js | 92 + .../mozilla/ecma/LexicalConventions/7.2-1.js | 75 + .../ecma/LexicalConventions/7.2-2-n.js | 80 + .../ecma/LexicalConventions/7.2-3-n.js | 83 + .../ecma/LexicalConventions/7.2-4-n.js | 82 + .../ecma/LexicalConventions/7.2-5-n.js | 85 + .../mozilla/ecma/LexicalConventions/7.2-6.js | 70 + .../mozilla/ecma/LexicalConventions/7.3-1.js | 79 + .../mozilla/ecma/LexicalConventions/7.3-10.js | 67 + .../mozilla/ecma/LexicalConventions/7.3-11.js | 66 + .../mozilla/ecma/LexicalConventions/7.3-12.js | 66 + .../ecma/LexicalConventions/7.3-13-n.js | 66 + .../mozilla/ecma/LexicalConventions/7.3-2.js | 67 + .../mozilla/ecma/LexicalConventions/7.3-3.js | 67 + .../mozilla/ecma/LexicalConventions/7.3-4.js | 67 + .../mozilla/ecma/LexicalConventions/7.3-5.js | 66 + .../mozilla/ecma/LexicalConventions/7.3-6.js | 68 + .../mozilla/ecma/LexicalConventions/7.3-7.js | 68 + .../mozilla/ecma/LexicalConventions/7.3-8.js | 67 + .../mozilla/ecma/LexicalConventions/7.3-9.js | 66 + .../ecma/LexicalConventions/7.4.1-1-n.js | 71 + .../ecma/LexicalConventions/7.4.1-2-n.js | 70 + .../ecma/LexicalConventions/7.4.1-3-n.js | 70 + .../ecma/LexicalConventions/7.4.2-1-n.js | 76 + .../ecma/LexicalConventions/7.4.2-10-n.js | 76 + .../ecma/LexicalConventions/7.4.2-11-n.js | 76 + .../ecma/LexicalConventions/7.4.2-12-n.js | 77 + .../ecma/LexicalConventions/7.4.2-13-n.js | 76 + .../ecma/LexicalConventions/7.4.2-14-n.js | 76 + .../ecma/LexicalConventions/7.4.2-15-n.js | 77 + .../ecma/LexicalConventions/7.4.2-16-n.js | 76 + .../ecma/LexicalConventions/7.4.2-2-n.js | 75 + .../ecma/LexicalConventions/7.4.2-3-n.js | 75 + .../ecma/LexicalConventions/7.4.2-4-n.js | 76 + .../ecma/LexicalConventions/7.4.2-5-n.js | 76 + .../ecma/LexicalConventions/7.4.2-6-n.js | 76 + .../ecma/LexicalConventions/7.4.2-7-n.js | 73 + .../ecma/LexicalConventions/7.4.2-8-n.js | 73 + .../ecma/LexicalConventions/7.4.2-9-n.js | 76 + .../ecma/LexicalConventions/7.4.3-1-n.js | 71 + .../ecma/LexicalConventions/7.4.3-10-n.js | 71 + .../ecma/LexicalConventions/7.4.3-11-n.js | 70 + .../ecma/LexicalConventions/7.4.3-12-n.js | 72 + .../ecma/LexicalConventions/7.4.3-13-n.js | 72 + .../ecma/LexicalConventions/7.4.3-14-n.js | 70 + .../ecma/LexicalConventions/7.4.3-15-n.js | 72 + .../ecma/LexicalConventions/7.4.3-16-n.js | 69 + .../ecma/LexicalConventions/7.4.3-2-n.js | 72 + .../ecma/LexicalConventions/7.4.3-3-n.js | 72 + .../ecma/LexicalConventions/7.4.3-4-n.js | 72 + .../ecma/LexicalConventions/7.4.3-5-n.js | 70 + .../ecma/LexicalConventions/7.4.3-6-n.js | 70 + .../ecma/LexicalConventions/7.4.3-7-n.js | 70 + .../ecma/LexicalConventions/7.4.3-8-n.js | 70 + .../ecma/LexicalConventions/7.4.3-9-n.js | 70 + .../mozilla/ecma/LexicalConventions/7.5-1.js | 65 + .../ecma/LexicalConventions/7.5-10-n.js | 70 + .../ecma/LexicalConventions/7.5-2-n.js | 65 + .../ecma/LexicalConventions/7.5-3-n.js | 65 + .../ecma/LexicalConventions/7.5-4-n.js | 65 + .../ecma/LexicalConventions/7.5-5-n.js | 65 + .../mozilla/ecma/LexicalConventions/7.5-6.js | 65 + .../mozilla/ecma/LexicalConventions/7.5-7.js | 65 + .../ecma/LexicalConventions/7.5-8-n.js | 65 + .../ecma/LexicalConventions/7.5-9-n.js | 70 + tests/mozilla/ecma/LexicalConventions/7.6.js | 309 + .../mozilla/ecma/LexicalConventions/7.7.1.js | 72 + .../mozilla/ecma/LexicalConventions/7.7.2.js | 75 + .../ecma/LexicalConventions/7.7.3-1.js | 197 + .../ecma/LexicalConventions/7.7.3-2.js | 93 + .../mozilla/ecma/LexicalConventions/7.7.3.js | 337 + .../mozilla/ecma/LexicalConventions/7.7.4.js | 275 + .../ecma/LexicalConventions/7.8.2-n.js | 48 + tests/mozilla/ecma/Math/15.8-1.js | 84 + tests/mozilla/ecma/Math/15.8-2-n.js | 83 + tests/mozilla/ecma/Math/15.8-3-n.js | 81 + tests/mozilla/ecma/Math/15.8.1.1-1.js | 62 + tests/mozilla/ecma/Math/15.8.1.1-2.js | 65 + tests/mozilla/ecma/Math/15.8.1.2-1.js | 62 + tests/mozilla/ecma/Math/15.8.1.2-2.js | 63 + tests/mozilla/ecma/Math/15.8.1.3-1.js | 63 + tests/mozilla/ecma/Math/15.8.1.3-2.js | 69 + tests/mozilla/ecma/Math/15.8.1.4-1.js | 64 + tests/mozilla/ecma/Math/15.8.1.4-2.js | 65 + tests/mozilla/ecma/Math/15.8.1.5-1.js | 67 + tests/mozilla/ecma/Math/15.8.1.5-2.js | 66 + tests/mozilla/ecma/Math/15.8.1.6-1.js | 63 + tests/mozilla/ecma/Math/15.8.1.6-2.js | 64 + tests/mozilla/ecma/Math/15.8.1.7-1.js | 64 + tests/mozilla/ecma/Math/15.8.1.7-2.js | 64 + tests/mozilla/ecma/Math/15.8.1.8-1.js | 64 + tests/mozilla/ecma/Math/15.8.1.8-2.js | 63 + tests/mozilla/ecma/Math/15.8.1.8-3.js | 61 + tests/mozilla/ecma/Math/15.8.1.js | 86 + tests/mozilla/ecma/Math/15.8.2.1.js | 103 + tests/mozilla/ecma/Math/15.8.2.10.js | 86 + tests/mozilla/ecma/Math/15.8.2.11.js | 98 + tests/mozilla/ecma/Math/15.8.2.12.js | 96 + tests/mozilla/ecma/Math/15.8.2.13.js | 132 + tests/mozilla/ecma/Math/15.8.2.14.js | 83 + tests/mozilla/ecma/Math/15.8.2.15.js | 113 + tests/mozilla/ecma/Math/15.8.2.16.js | 78 + tests/mozilla/ecma/Math/15.8.2.17.js | 99 + tests/mozilla/ecma/Math/15.8.2.18.js | 98 + tests/mozilla/ecma/Math/15.8.2.2.js | 86 + tests/mozilla/ecma/Math/15.8.2.3.js | 90 + tests/mozilla/ecma/Math/15.8.2.4.js | 88 + tests/mozilla/ecma/Math/15.8.2.5.js | 105 + tests/mozilla/ecma/Math/15.8.2.6.js | 108 + tests/mozilla/ecma/Math/15.8.2.7.js | 111 + tests/mozilla/ecma/Math/15.8.2.8.js | 84 + tests/mozilla/ecma/Math/15.8.2.9.js | 105 + tests/mozilla/ecma/NativeObjects/15-1.js | 95 + tests/mozilla/ecma/NativeObjects/15-2.js | 78 + tests/mozilla/ecma/Number/15.7.1.js | 90 + tests/mozilla/ecma/Number/15.7.2.js | 173 + tests/mozilla/ecma/Number/15.7.3.1-1.js | 68 + tests/mozilla/ecma/Number/15.7.3.1-2.js | 75 + tests/mozilla/ecma/Number/15.7.3.1-3.js | 70 + tests/mozilla/ecma/Number/15.7.3.2-1.js | 63 + tests/mozilla/ecma/Number/15.7.3.2-2.js | 64 + tests/mozilla/ecma/Number/15.7.3.2-3.js | 66 + tests/mozilla/ecma/Number/15.7.3.2-4.js | 66 + tests/mozilla/ecma/Number/15.7.3.3-1.js | 64 + tests/mozilla/ecma/Number/15.7.3.3-2.js | 66 + tests/mozilla/ecma/Number/15.7.3.3-3.js | 67 + tests/mozilla/ecma/Number/15.7.3.3-4.js | 69 + tests/mozilla/ecma/Number/15.7.3.4-1.js | 63 + tests/mozilla/ecma/Number/15.7.3.4-2.js | 67 + tests/mozilla/ecma/Number/15.7.3.4-3.js | 71 + tests/mozilla/ecma/Number/15.7.3.4-4.js | 71 + tests/mozilla/ecma/Number/15.7.3.5-1.js | 61 + tests/mozilla/ecma/Number/15.7.3.5-2.js | 72 + tests/mozilla/ecma/Number/15.7.3.5-3.js | 67 + tests/mozilla/ecma/Number/15.7.3.5-4.js | 68 + tests/mozilla/ecma/Number/15.7.3.6-1.js | 60 + tests/mozilla/ecma/Number/15.7.3.6-2.js | 64 + tests/mozilla/ecma/Number/15.7.3.6-3.js | 68 + tests/mozilla/ecma/Number/15.7.3.6-4.js | 66 + tests/mozilla/ecma/Number/15.7.3.js | 68 + tests/mozilla/ecma/Number/15.7.4-1.js | 63 + tests/mozilla/ecma/Number/15.7.4.1.js | 64 + tests/mozilla/ecma/Number/15.7.4.2-1.js | 80 + tests/mozilla/ecma/Number/15.7.4.2-2-n.js | 70 + tests/mozilla/ecma/Number/15.7.4.2-3-n.js | 68 + tests/mozilla/ecma/Number/15.7.4.2-4.js | 68 + tests/mozilla/ecma/Number/15.7.4.3-1.js | 72 + tests/mozilla/ecma/Number/15.7.4.3-2.js | 63 + tests/mozilla/ecma/Number/15.7.4.3-3-n.js | 66 + tests/mozilla/ecma/Number/15.7.4.js | 86 + tests/mozilla/ecma/ObjectObjects/15.2.1.1.js | 151 + tests/mozilla/ecma/ObjectObjects/15.2.1.2.js | 85 + tests/mozilla/ecma/ObjectObjects/15.2.2.1.js | 139 + tests/mozilla/ecma/ObjectObjects/15.2.2.2.js | 81 + tests/mozilla/ecma/ObjectObjects/15.2.3-1.js | 65 + .../mozilla/ecma/ObjectObjects/15.2.3.1-1.js | 68 + .../mozilla/ecma/ObjectObjects/15.2.3.1-2.js | 70 + .../mozilla/ecma/ObjectObjects/15.2.3.1-3.js | 69 + .../mozilla/ecma/ObjectObjects/15.2.3.1-4.js | 70 + tests/mozilla/ecma/ObjectObjects/15.2.3.js | 68 + tests/mozilla/ecma/ObjectObjects/15.2.4.1.js | 63 + tests/mozilla/ecma/ObjectObjects/15.2.4.2.js | 128 + tests/mozilla/ecma/ObjectObjects/15.2.4.3.js | 115 + tests/mozilla/ecma/ObjectObjects/15.2.4.js | 60 + tests/mozilla/ecma/SourceText/6-1.js | 124 + tests/mozilla/ecma/SourceText/6-2.js | 129 + tests/mozilla/ecma/Statements/12.10-1.js | 151 + tests/mozilla/ecma/Statements/12.10.js | 64 + tests/mozilla/ecma/Statements/12.2-1.js | 70 + tests/mozilla/ecma/Statements/12.5-1.js | 98 + tests/mozilla/ecma/Statements/12.5-2.js | 96 + tests/mozilla/ecma/Statements/12.6.1-1.js | 68 + tests/mozilla/ecma/Statements/12.6.2-1.js | 75 + tests/mozilla/ecma/Statements/12.6.2-2.js | 76 + tests/mozilla/ecma/Statements/12.6.2-3.js | 67 + tests/mozilla/ecma/Statements/12.6.2-4.js | 66 + tests/mozilla/ecma/Statements/12.6.2-5.js | 71 + tests/mozilla/ecma/Statements/12.6.2-6.js | 75 + tests/mozilla/ecma/Statements/12.6.2-7.js | 72 + tests/mozilla/ecma/Statements/12.6.2-8.js | 69 + tests/mozilla/ecma/Statements/12.6.2-9-n.js | 65 + tests/mozilla/ecma/Statements/12.6.3-1.js | 71 + tests/mozilla/ecma/Statements/12.6.3-10.js | 112 + tests/mozilla/ecma/Statements/12.6.3-11.js | 93 + tests/mozilla/ecma/Statements/12.6.3-12.js | 100 + tests/mozilla/ecma/Statements/12.6.3-19.js | 114 + tests/mozilla/ecma/Statements/12.6.3-2.js | 66 + tests/mozilla/ecma/Statements/12.6.3-3.js | 70 + tests/mozilla/ecma/Statements/12.6.3-4.js | 193 + tests/mozilla/ecma/Statements/12.6.3-5-n.js | 102 + tests/mozilla/ecma/Statements/12.6.3-6-n.js | 102 + tests/mozilla/ecma/Statements/12.6.3-7-n.js | 102 + tests/mozilla/ecma/Statements/12.6.3-8-n.js | 102 + tests/mozilla/ecma/Statements/12.6.3-9-n.js | 102 + tests/mozilla/ecma/Statements/12.7-1-n.js | 67 + tests/mozilla/ecma/Statements/12.8-1-n.js | 69 + tests/mozilla/ecma/Statements/12.9-1-n.js | 64 + tests/mozilla/ecma/String/15.5.1.js | 137 + tests/mozilla/ecma/String/15.5.2.js | 112 + tests/mozilla/ecma/String/15.5.3.1-1.js | 73 + tests/mozilla/ecma/String/15.5.3.1-2.js | 70 + tests/mozilla/ecma/String/15.5.3.1-3.js | 67 + tests/mozilla/ecma/String/15.5.3.1-4.js | 68 + tests/mozilla/ecma/String/15.5.3.2-1.js | 195 + tests/mozilla/ecma/String/15.5.3.2-2.js | 80 + tests/mozilla/ecma/String/15.5.3.2-3.js | 122 + tests/mozilla/ecma/String/15.5.3.js | 74 + tests/mozilla/ecma/String/15.5.4.1.js | 66 + tests/mozilla/ecma/String/15.5.4.10-1.js | 218 + tests/mozilla/ecma/String/15.5.4.11-1.js | 514 + tests/mozilla/ecma/String/15.5.4.11-2.js | 633 + tests/mozilla/ecma/String/15.5.4.11-3.js | 509 + tests/mozilla/ecma/String/15.5.4.11-4.js | 508 + tests/mozilla/ecma/String/15.5.4.11-5.js | 514 + tests/mozilla/ecma/String/15.5.4.11-6.js | 511 + tests/mozilla/ecma/String/15.5.4.12-1.js | 527 + tests/mozilla/ecma/String/15.5.4.12-2.js | 514 + tests/mozilla/ecma/String/15.5.4.12-3.js | 556 + tests/mozilla/ecma/String/15.5.4.12-4.js | 511 + tests/mozilla/ecma/String/15.5.4.12-5.js | 523 + tests/mozilla/ecma/String/15.5.4.2-1.js | 70 + tests/mozilla/ecma/String/15.5.4.2-2-n.js | 74 + tests/mozilla/ecma/String/15.5.4.2-3.js | 87 + tests/mozilla/ecma/String/15.5.4.2.js | 92 + tests/mozilla/ecma/String/15.5.4.3-1.js | 70 + tests/mozilla/ecma/String/15.5.4.3-2.js | 89 + tests/mozilla/ecma/String/15.5.4.3-3-n.js | 72 + tests/mozilla/ecma/String/15.5.4.4-1.js | 87 + tests/mozilla/ecma/String/15.5.4.4-2.js | 141 + tests/mozilla/ecma/String/15.5.4.4-3.js | 117 + tests/mozilla/ecma/String/15.5.4.4-4.js | 159 + tests/mozilla/ecma/String/15.5.4.5-1.js | 89 + tests/mozilla/ecma/String/15.5.4.5-2.js | 128 + tests/mozilla/ecma/String/15.5.4.5-3.js | 136 + tests/mozilla/ecma/String/15.5.4.5-4.js | 80 + tests/mozilla/ecma/String/15.5.4.5-5.js | 111 + tests/mozilla/ecma/String/15.5.4.5-6.js | 97 + tests/mozilla/ecma/String/15.5.4.6-1.js | 158 + tests/mozilla/ecma/String/15.5.4.6-2.js | 259 + tests/mozilla/ecma/String/15.5.4.7-1.js | 221 + tests/mozilla/ecma/String/15.5.4.7-2.js | 220 + tests/mozilla/ecma/String/15.5.4.7-3.js | 166 + tests/mozilla/ecma/String/15.5.4.8-1.js | 234 + tests/mozilla/ecma/String/15.5.4.8-2.js | 248 + tests/mozilla/ecma/String/15.5.4.8-3.js | 205 + tests/mozilla/ecma/String/15.5.4.9-1.js | 202 + tests/mozilla/ecma/String/15.5.4.js | 74 + tests/mozilla/ecma/String/15.5.5.1.js | 90 + tests/mozilla/ecma/TypeConversion/9.2.js | 111 + tests/mozilla/ecma/TypeConversion/9.3-1.js | 96 + tests/mozilla/ecma/TypeConversion/9.3.1-1.js | 323 + tests/mozilla/ecma/TypeConversion/9.3.1-2.js | 89 + tests/mozilla/ecma/TypeConversion/9.3.1-3.js | 726 + tests/mozilla/ecma/TypeConversion/9.3.js | 89 + tests/mozilla/ecma/TypeConversion/9.4-1.js | 120 + tests/mozilla/ecma/TypeConversion/9.4-2.js | 120 + tests/mozilla/ecma/TypeConversion/9.5-2.js | 171 + tests/mozilla/ecma/TypeConversion/9.6.js | 139 + tests/mozilla/ecma/TypeConversion/9.7.js | 158 + tests/mozilla/ecma/TypeConversion/9.8.1.js | 166 + tests/mozilla/ecma/TypeConversion/9.9-1.js | 143 + tests/mozilla/ecma/Types/8.1.js | 71 + tests/mozilla/ecma/Types/8.4.js | 125 + tests/mozilla/ecma/Types/8.6.2.1-1.js | 105 + tests/mozilla/ecma/browser.js | 80 + tests/mozilla/ecma/jsref.js | 669 + tests/mozilla/ecma/shell.js | 712 + .../mozilla/ecma_2/Exceptions/boolean-001.js | 43 + .../mozilla/ecma_2/Exceptions/boolean-002.js | 47 + tests/mozilla/ecma_2/Exceptions/date-001.js | 57 + tests/mozilla/ecma_2/Exceptions/date-002.js | 51 + tests/mozilla/ecma_2/Exceptions/date-003.js | 53 + tests/mozilla/ecma_2/Exceptions/date-004.js | 47 + .../ecma_2/Exceptions/exception-001.js | 42 + .../ecma_2/Exceptions/exception-002.js | 42 + .../ecma_2/Exceptions/exception-003.js | 46 + .../ecma_2/Exceptions/exception-004.js | 42 + .../ecma_2/Exceptions/exception-005.js | 42 + .../ecma_2/Exceptions/exception-006.js | 53 + .../ecma_2/Exceptions/exception-007.js | 54 + .../ecma_2/Exceptions/exception-008.js | 41 + .../ecma_2/Exceptions/exception-009.js | 50 + .../ecma_2/Exceptions/exception-010-n.js | 36 + .../ecma_2/Exceptions/exception-011-n.js | 35 + .../ecma_2/Exceptions/expression-001.js | 47 + .../ecma_2/Exceptions/expression-002.js | 57 + .../ecma_2/Exceptions/expression-003.js | 52 + .../ecma_2/Exceptions/expression-004.js | 46 + .../ecma_2/Exceptions/expression-005.js | 38 + .../ecma_2/Exceptions/expression-006.js | 43 + .../ecma_2/Exceptions/expression-007.js | 41 + .../ecma_2/Exceptions/expression-008.js | 38 + .../ecma_2/Exceptions/expression-009.js | 39 + .../ecma_2/Exceptions/expression-010.js | 40 + .../ecma_2/Exceptions/expression-011.js | 40 + .../ecma_2/Exceptions/expression-012.js | 41 + .../ecma_2/Exceptions/expression-013.js | 41 + .../ecma_2/Exceptions/expression-014.js | 43 + .../ecma_2/Exceptions/expression-015.js | 37 + .../ecma_2/Exceptions/expression-016.js | 37 + .../ecma_2/Exceptions/expression-017.js | 37 + .../ecma_2/Exceptions/expression-019.js | 41 + .../mozilla/ecma_2/Exceptions/function-001.js | 64 + tests/mozilla/ecma_2/Exceptions/global-001.js | 43 + tests/mozilla/ecma_2/Exceptions/global-002.js | 43 + .../mozilla/ecma_2/Exceptions/lexical-001.js | 49 + .../mozilla/ecma_2/Exceptions/lexical-002.js | 49 + .../mozilla/ecma_2/Exceptions/lexical-003.js | 41 + .../mozilla/ecma_2/Exceptions/lexical-004.js | 49 + .../mozilla/ecma_2/Exceptions/lexical-005.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-006.js | 55 + .../mozilla/ecma_2/Exceptions/lexical-007.js | 48 + .../mozilla/ecma_2/Exceptions/lexical-008.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-009.js | 49 + .../mozilla/ecma_2/Exceptions/lexical-010.js | 48 + .../mozilla/ecma_2/Exceptions/lexical-011.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-012.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-013.js | 49 + .../mozilla/ecma_2/Exceptions/lexical-014.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-015.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-016.js | 48 + .../mozilla/ecma_2/Exceptions/lexical-017.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-018.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-019.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-020.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-021.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-022.js | 50 + .../mozilla/ecma_2/Exceptions/lexical-023.js | 49 + .../mozilla/ecma_2/Exceptions/lexical-024.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-025.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-026.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-027.js | 58 + .../mozilla/ecma_2/Exceptions/lexical-028.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-029.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-030.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-031.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-032.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-033.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-034.js | 55 + .../mozilla/ecma_2/Exceptions/lexical-035.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-036.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-037.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-038.js | 56 + .../mozilla/ecma_2/Exceptions/lexical-039.js | 43 + .../mozilla/ecma_2/Exceptions/lexical-040.js | 43 + .../mozilla/ecma_2/Exceptions/lexical-041.js | 45 + .../mozilla/ecma_2/Exceptions/lexical-042.js | 46 + .../mozilla/ecma_2/Exceptions/lexical-047.js | 47 + .../mozilla/ecma_2/Exceptions/lexical-048.js | 41 + .../mozilla/ecma_2/Exceptions/lexical-049.js | 46 + .../mozilla/ecma_2/Exceptions/lexical-050.js | 42 + .../mozilla/ecma_2/Exceptions/lexical-051.js | 42 + .../mozilla/ecma_2/Exceptions/lexical-052.js | 44 + .../mozilla/ecma_2/Exceptions/lexical-053.js | 42 + .../mozilla/ecma_2/Exceptions/lexical-054.js | 43 + tests/mozilla/ecma_2/Exceptions/number-001.js | 52 + tests/mozilla/ecma_2/Exceptions/number-002.js | 45 + tests/mozilla/ecma_2/Exceptions/number-003.js | 47 + .../ecma_2/Exceptions/statement-001.js | 44 + .../ecma_2/Exceptions/statement-002.js | 66 + .../ecma_2/Exceptions/statement-003.js | 77 + .../ecma_2/Exceptions/statement-004.js | 49 + .../ecma_2/Exceptions/statement-005.js | 48 + .../ecma_2/Exceptions/statement-006.js | 48 + .../ecma_2/Exceptions/statement-007.js | 39 + .../ecma_2/Exceptions/statement-008.js | 39 + .../ecma_2/Exceptions/statement-009.js | 38 + tests/mozilla/ecma_2/Exceptions/string-001.js | 50 + tests/mozilla/ecma_2/Exceptions/string-002.js | 49 + .../ecma_2/Expressions/StrictEquality-001.js | 70 + .../ecma_2/Expressions/instanceof-001.js | 117 + .../ecma_2/Expressions/instanceof-002.js | 124 + .../ecma_2/Expressions/instanceof-003-n.js | 93 + .../ecma_2/Expressions/instanceof-004-n.js | 92 + .../ecma_2/Expressions/instanceof-005-n.js | 84 + .../ecma_2/Expressions/instanceof-006.js | 83 + .../ecma_2/FunctionObjects/apply-001-n.js | 39 + .../mozilla/ecma_2/FunctionObjects/call-1.js | 40 + .../ecma_2/LexicalConventions/keywords-001.js | 31 + .../LexicalConventions/regexp-literals-001.js | 38 + .../LexicalConventions/regexp-literals-002.js | 22 + .../mozilla/ecma_2/RegExp/constructor-001.js | 66 + tests/mozilla/ecma_2/RegExp/exec-001.js | 34 + tests/mozilla/ecma_2/RegExp/exec-002.js | 182 + tests/mozilla/ecma_2/RegExp/function-001.js | 66 + tests/mozilla/ecma_2/RegExp/hex-001.js | 63 + tests/mozilla/ecma_2/RegExp/multiline-001.js | 62 + tests/mozilla/ecma_2/RegExp/octal-001.js | 72 + tests/mozilla/ecma_2/RegExp/octal-002.js | 87 + tests/mozilla/ecma_2/RegExp/octal-003.js | 81 + tests/mozilla/ecma_2/RegExp/properties-001.js | 78 + tests/mozilla/ecma_2/RegExp/properties-002.js | 125 + .../ecma_2/RegExp/regexp-enumerate-001.js | 98 + tests/mozilla/ecma_2/RegExp/regress-001.js | 39 + tests/mozilla/ecma_2/RegExp/unicode-001.js | 53 + .../mozilla/ecma_2/Statements/dowhile-001.js | 41 + .../mozilla/ecma_2/Statements/dowhile-002.js | 68 + .../mozilla/ecma_2/Statements/dowhile-003.js | 60 + .../mozilla/ecma_2/Statements/dowhile-004.js | 64 + .../mozilla/ecma_2/Statements/dowhile-005.js | 70 + .../mozilla/ecma_2/Statements/dowhile-006.js | 86 + .../mozilla/ecma_2/Statements/dowhile-007.js | 94 + tests/mozilla/ecma_2/Statements/forin-001.js | 294 + tests/mozilla/ecma_2/Statements/forin-002.js | 73 + tests/mozilla/ecma_2/Statements/if-001.js | 39 + tests/mozilla/ecma_2/Statements/label-001.js | 39 + tests/mozilla/ecma_2/Statements/label-002.js | 53 + tests/mozilla/ecma_2/Statements/switch-001.js | 64 + tests/mozilla/ecma_2/Statements/switch-002.js | 60 + tests/mozilla/ecma_2/Statements/switch-003.js | 54 + tests/mozilla/ecma_2/Statements/switch-004.js | 91 + tests/mozilla/ecma_2/Statements/try-001.js | 82 + tests/mozilla/ecma_2/Statements/try-003.js | 79 + tests/mozilla/ecma_2/Statements/try-004.js | 51 + tests/mozilla/ecma_2/Statements/try-005.js | 54 + tests/mozilla/ecma_2/Statements/try-006.js | 84 + tests/mozilla/ecma_2/Statements/try-007.js | 89 + tests/mozilla/ecma_2/Statements/try-008.js | 56 + tests/mozilla/ecma_2/Statements/try-009.js | 63 + tests/mozilla/ecma_2/Statements/try-010.js | 70 + tests/mozilla/ecma_2/Statements/try-012.js | 92 + tests/mozilla/ecma_2/Statements/while-001.js | 39 + tests/mozilla/ecma_2/Statements/while-002.js | 83 + tests/mozilla/ecma_2/Statements/while-003.js | 84 + tests/mozilla/ecma_2/Statements/while-004.js | 214 + tests/mozilla/ecma_2/String/match-001.js | 100 + tests/mozilla/ecma_2/String/match-002.js | 168 + tests/mozilla/ecma_2/String/match-003.js | 126 + tests/mozilla/ecma_2/String/match-004.js | 167 + tests/mozilla/ecma_2/String/replace-001.js | 60 + tests/mozilla/ecma_2/String/split-001.js | 106 + tests/mozilla/ecma_2/String/split-002.js | 264 + tests/mozilla/ecma_2/String/split-003.js | 117 + tests/mozilla/ecma_2/browser.js | 83 + .../ecma_2/instanceof/instanceof-001.js | 31 + .../ecma_2/instanceof/instanceof-002.js | 61 + .../ecma_2/instanceof/instanceof-003.js | 46 + .../mozilla/ecma_2/instanceof/regress-7635.js | 74 + tests/mozilla/ecma_2/jsref.js | 629 + tests/mozilla/ecma_2/shell.js | 216 + tests/mozilla/ecma_2/template.js | 39 + tests/mozilla/ecma_3/Array/15.4.4.3-1.js | 66 + tests/mozilla/ecma_3/Array/15.4.4.4-001.js | 148 + tests/mozilla/ecma_3/Array/regress-101488.js | 151 + tests/mozilla/ecma_3/Array/regress-130451.js | 214 + tests/mozilla/ecma_3/Date/15.9.5.3.js | 149 + tests/mozilla/ecma_3/Date/15.9.5.4.js | 194 + tests/mozilla/ecma_3/Date/15.9.5.5.js | 94 + tests/mozilla/ecma_3/Date/15.9.5.6.js | 149 + tests/mozilla/ecma_3/Date/15.9.5.7.js | 211 + tests/mozilla/ecma_3/Date/shell.js | 676 + tests/mozilla/ecma_3/Exceptions/15.11.1.1.js | 132 + .../mozilla/ecma_3/Exceptions/15.11.4.4-1.js | 169 + .../ecma_3/Exceptions/15.11.7.6-001.js | 125 + .../ecma_3/Exceptions/15.11.7.6-002.js | 120 + .../ecma_3/Exceptions/15.11.7.6-003.js | 120 + .../mozilla/ecma_3/Exceptions/binding-001.js | 106 + .../ecma_3/Exceptions/regress-181654.js | 150 + .../ecma_3/Exceptions/regress-181914.js | 189 + .../ecma_3/Exceptions/regress-58946.js | 56 + .../ecma_3/Exceptions/regress-95101.js | 97 + .../ecma_3/ExecutionContexts/10.1.3-1.js | 196 + .../ecma_3/ExecutionContexts/10.1.3-2.js | 157 + .../ecma_3/ExecutionContexts/10.1.3.js | 55 + .../ecma_3/ExecutionContexts/10.1.4-1.js | 58 + .../ecma_3/ExecutionContexts/regress-23346.js | 53 + tests/mozilla/ecma_3/Expressions/11.6.1-1.js | 171 + tests/mozilla/ecma_3/Expressions/11.9.6-1.js | 208 + tests/mozilla/ecma_3/FunExpr/fe-001-n.js | 37 + tests/mozilla/ecma_3/FunExpr/fe-001.js | 39 + tests/mozilla/ecma_3/FunExpr/fe-002.js | 43 + tests/mozilla/ecma_3/Function/15.3.4.3-1.js | 205 + tests/mozilla/ecma_3/Function/15.3.4.4-1.js | 180 + .../mozilla/ecma_3/Function/arguments-001.js | 148 + tests/mozilla/ecma_3/Function/call-001.js | 131 + .../mozilla/ecma_3/Function/regress-104584.js | 56 + .../mozilla/ecma_3/Function/regress-131964.js | 191 + .../mozilla/ecma_3/Function/regress-137181.js | 108 + .../mozilla/ecma_3/Function/regress-193555.js | 131 + .../mozilla/ecma_3/Function/regress-49286.js | 116 + .../mozilla/ecma_3/Function/regress-58274.js | 221 + .../mozilla/ecma_3/Function/regress-85880.js | 152 + .../mozilla/ecma_3/Function/regress-94506.js | 142 + .../mozilla/ecma_3/Function/regress-97921.js | 131 + tests/mozilla/ecma_3/Function/scope-001.js | 249 + tests/mozilla/ecma_3/Function/scope-002.js | 224 + tests/mozilla/ecma_3/Number/15.7.4.5-1.js | 124 + tests/mozilla/ecma_3/Number/15.7.4.6-1.js | 113 + tests/mozilla/ecma_3/Number/15.7.4.7-1.js | 118 + .../ecma_3/NumberFormatting/tostring-001.js | 42 + tests/mozilla/ecma_3/Object/8.6.2.6-001.js | 108 + tests/mozilla/ecma_3/Object/class-001.js | 128 + tests/mozilla/ecma_3/Object/class-002.js | 124 + tests/mozilla/ecma_3/Object/class-003.js | 118 + tests/mozilla/ecma_3/Object/class-004.js | 117 + tests/mozilla/ecma_3/Object/class-005.js | 102 + tests/mozilla/ecma_3/Object/regress-72773.js | 75 + .../ecma_3/Object/regress-79129-001.js | 58 + tests/mozilla/ecma_3/Object/shell.js | 81 + tests/mozilla/ecma_3/Operators/11.13.1-001.js | 147 + tests/mozilla/ecma_3/Operators/11.4.1-001.js | 115 + tests/mozilla/ecma_3/RegExp/15.10.2-1.js | 176 + tests/mozilla/ecma_3/RegExp/15.10.3.1-1.js | 115 + tests/mozilla/ecma_3/RegExp/15.10.3.1-2.js | 123 + tests/mozilla/ecma_3/RegExp/15.10.4.1-1.js | 111 + tests/mozilla/ecma_3/RegExp/15.10.4.1-2.js | 117 + tests/mozilla/ecma_3/RegExp/15.10.4.1-3.js | 124 + tests/mozilla/ecma_3/RegExp/15.10.4.1-4.js | 130 + tests/mozilla/ecma_3/RegExp/15.10.4.1-5-n.js | 113 + tests/mozilla/ecma_3/RegExp/15.10.6.2-1.js | 119 + tests/mozilla/ecma_3/RegExp/15.10.6.2-2.js | 362 + tests/mozilla/ecma_3/RegExp/octal-001.js | 131 + tests/mozilla/ecma_3/RegExp/octal-002.js | 213 + tests/mozilla/ecma_3/RegExp/perlstress-001.js | 3225 +++++ tests/mozilla/ecma_3/RegExp/perlstress-002.js | 1837 +++ tests/mozilla/ecma_3/RegExp/regress-100199.js | 286 + tests/mozilla/ecma_3/RegExp/regress-103087.js | 155 + tests/mozilla/ecma_3/RegExp/regress-105972.js | 136 + tests/mozilla/ecma_3/RegExp/regress-119909.js | 86 + tests/mozilla/ecma_3/RegExp/regress-122076.js | 103 + tests/mozilla/ecma_3/RegExp/regress-123437.js | 107 + tests/mozilla/ecma_3/RegExp/regress-165353.js | 117 + tests/mozilla/ecma_3/RegExp/regress-169497.js | 100 + tests/mozilla/ecma_3/RegExp/regress-169534.js | 90 + tests/mozilla/ecma_3/RegExp/regress-187133.js | 137 + tests/mozilla/ecma_3/RegExp/regress-188206.js | 282 + tests/mozilla/ecma_3/RegExp/regress-191479.js | 193 + tests/mozilla/ecma_3/RegExp/regress-202564.js | 96 + tests/mozilla/ecma_3/RegExp/regress-209067.js | 1101 ++ tests/mozilla/ecma_3/RegExp/regress-209919.js | 169 + tests/mozilla/ecma_3/RegExp/regress-216591.js | 112 + .../ecma_3/RegExp/regress-220367-001.js | 99 + .../ecma_3/RegExp/regress-220367-002.js | 107 + tests/mozilla/ecma_3/RegExp/regress-24712.js | 42 + tests/mozilla/ecma_3/RegExp/regress-28686.js | 39 + tests/mozilla/ecma_3/RegExp/regress-31316.js | 75 + tests/mozilla/ecma_3/RegExp/regress-57572.js | 129 + tests/mozilla/ecma_3/RegExp/regress-57631.js | 128 + tests/mozilla/ecma_3/RegExp/regress-67773.js | 190 + tests/mozilla/ecma_3/RegExp/regress-72964.js | 100 + tests/mozilla/ecma_3/RegExp/regress-76683.js | 93 + tests/mozilla/ecma_3/RegExp/regress-78156.js | 102 + tests/mozilla/ecma_3/RegExp/regress-85721.js | 271 + tests/mozilla/ecma_3/RegExp/regress-87231.js | 124 + tests/mozilla/ecma_3/RegExp/regress-98306.js | 77 + tests/mozilla/ecma_3/RegExp/shell.js | 230 + .../ecma_3/Statements/regress-121744.js | 212 + .../ecma_3/Statements/regress-131348.js | 179 + .../ecma_3/Statements/regress-157509.js | 106 + .../ecma_3/Statements/regress-194364.js | 134 + .../ecma_3/Statements/regress-74474-001.js | 118 + .../ecma_3/Statements/regress-74474-002.js | 9076 +++++++++++++ .../ecma_3/Statements/regress-74474-003.js | 9078 +++++++++++++ .../ecma_3/Statements/regress-83532-001.js | 48 + .../ecma_3/Statements/regress-83532-002.js | 51 + tests/mozilla/ecma_3/Statements/switch-001.js | 122 + tests/mozilla/ecma_3/String/regress-104375.js | 95 + tests/mozilla/ecma_3/String/regress-189898.js | 152 + tests/mozilla/ecma_3/String/regress-83293.js | 193 + tests/mozilla/ecma_3/Unicode/uc-001-n.js | 44 + tests/mozilla/ecma_3/Unicode/uc-001.js | 38 + tests/mozilla/ecma_3/Unicode/uc-002-n.js | 38 + tests/mozilla/ecma_3/Unicode/uc-002.js | 42 + tests/mozilla/ecma_3/Unicode/uc-003.js | 53 + tests/mozilla/ecma_3/Unicode/uc-004.js | 47 + tests/mozilla/ecma_3/Unicode/uc-005.js | 271 + tests/mozilla/ecma_3/shell.js | 180 + tests/mozilla/expected.html | 623 + tests/mozilla/importList.html | 69 + tests/mozilla/js1_1/browser.js | 80 + tests/mozilla/js1_1/jsref.js | 170 + tests/mozilla/js1_1/regress/function-001.js | 76 + tests/mozilla/js1_1/shell.js | 143 + tests/mozilla/js1_2/Array/array_split_1.js | 72 + tests/mozilla/js1_2/Array/general1.js | 62 + tests/mozilla/js1_2/Array/general2.js | 78 + tests/mozilla/js1_2/Array/slice.js | 123 + tests/mozilla/js1_2/Array/splice1.js | 152 + tests/mozilla/js1_2/Array/splice2.js | 150 + tests/mozilla/js1_2/Array/tostring_1.js | 138 + tests/mozilla/js1_2/Array/tostring_2.js | 96 + tests/mozilla/js1_2/Objects/toString-001.js | 117 + tests/mozilla/js1_2/String/charCodeAt.js | 71 + tests/mozilla/js1_2/String/concat.js | 96 + tests/mozilla/js1_2/String/match.js | 62 + tests/mozilla/js1_2/String/slice.js | 123 + tests/mozilla/js1_2/browser.js | 83 + .../mozilla/js1_2/function/Function_object.js | 85 + tests/mozilla/js1_2/function/Number.js | 98 + tests/mozilla/js1_2/function/String.js | 99 + tests/mozilla/js1_2/function/definition-1.js | 73 + .../mozilla/js1_2/function/function-001-n.js | 74 + tests/mozilla/js1_2/function/length.js | 93 + tests/mozilla/js1_2/function/nesting-1.js | 61 + tests/mozilla/js1_2/function/nesting.js | 83 + tests/mozilla/js1_2/function/regexparg-1.js | 98 + tests/mozilla/js1_2/function/regexparg-2-n.js | 66 + tests/mozilla/js1_2/function/tostring-1.js | 143 + tests/mozilla/js1_2/function/tostring-2.js | 185 + tests/mozilla/js1_2/jsref.js | 215 + tests/mozilla/js1_2/operator/equality.js | 72 + .../mozilla/js1_2/operator/strictEquality.js | 92 + .../js1_2/regexp/RegExp_dollar_number.js | 108 + tests/mozilla/js1_2/regexp/RegExp_input.js | 102 + .../js1_2/regexp/RegExp_input_as_array.js | 102 + .../mozilla/js1_2/regexp/RegExp_lastIndex.js | 83 + .../mozilla/js1_2/regexp/RegExp_lastMatch.js | 85 + .../js1_2/regexp/RegExp_lastMatch_as_array.js | 85 + .../mozilla/js1_2/regexp/RegExp_lastParen.js | 100 + .../js1_2/regexp/RegExp_lastParen_as_array.js | 100 + .../js1_2/regexp/RegExp_leftContext.js | 90 + .../regexp/RegExp_leftContext_as_array.js | 90 + .../mozilla/js1_2/regexp/RegExp_multiline.js | 129 + .../js1_2/regexp/RegExp_multiline_as_array.js | 129 + tests/mozilla/js1_2/regexp/RegExp_object.js | 88 + .../js1_2/regexp/RegExp_rightContext.js | 90 + .../regexp/RegExp_rightContext_as_array.js | 90 + tests/mozilla/js1_2/regexp/alphanumeric.js | 129 + tests/mozilla/js1_2/regexp/asterisk.js | 105 + tests/mozilla/js1_2/regexp/backslash.js | 79 + tests/mozilla/js1_2/regexp/backspace.js | 79 + tests/mozilla/js1_2/regexp/beginLine.js | 80 + tests/mozilla/js1_2/regexp/character_class.js | 107 + tests/mozilla/js1_2/regexp/compile.js | 94 + .../js1_2/regexp/control_characters.js | 71 + tests/mozilla/js1_2/regexp/digit.js | 119 + tests/mozilla/js1_2/regexp/dot.js | 95 + tests/mozilla/js1_2/regexp/endLine.js | 80 + tests/mozilla/js1_2/regexp/everything.js | 80 + tests/mozilla/js1_2/regexp/exec.js | 77 + tests/mozilla/js1_2/regexp/flags.js | 84 + tests/mozilla/js1_2/regexp/global.js | 95 + tests/mozilla/js1_2/regexp/hexadecimal.js | 108 + tests/mozilla/js1_2/regexp/ignoreCase.js | 111 + tests/mozilla/js1_2/regexp/interval.js | 115 + tests/mozilla/js1_2/regexp/octal.js | 108 + tests/mozilla/js1_2/regexp/parentheses.js | 107 + tests/mozilla/js1_2/regexp/plus.js | 87 + tests/mozilla/js1_2/regexp/question_mark.js | 99 + tests/mozilla/js1_2/regexp/regress-6359.js | 68 + tests/mozilla/js1_2/regexp/regress-9141.js | 86 + tests/mozilla/js1_2/regexp/simple_form.js | 90 + tests/mozilla/js1_2/regexp/source.js | 87 + .../js1_2/regexp/special_characters.js | 157 + tests/mozilla/js1_2/regexp/string_replace.js | 80 + tests/mozilla/js1_2/regexp/string_search.js | 87 + tests/mozilla/js1_2/regexp/string_split.js | 91 + tests/mozilla/js1_2/regexp/test.js | 87 + tests/mozilla/js1_2/regexp/toString.js | 75 + tests/mozilla/js1_2/regexp/vertical_bar.js | 95 + tests/mozilla/js1_2/regexp/whitespace.js | 122 + tests/mozilla/js1_2/regexp/word_boundary.js | 119 + tests/mozilla/js1_2/regress/regress-144834.js | 76 + tests/mozilla/js1_2/regress/regress-7703.js | 83 + tests/mozilla/js1_2/shell.js | 147 + tests/mozilla/js1_2/statements/break.js | 162 + tests/mozilla/js1_2/statements/continue.js | 175 + tests/mozilla/js1_2/statements/do_while.js | 68 + tests/mozilla/js1_2/statements/switch.js | 127 + tests/mozilla/js1_2/statements/switch2.js | 188 + tests/mozilla/js1_2/version120/boolean-001.js | 73 + .../mozilla/js1_2/version120/regress-99663.js | 172 + tests/mozilla/js1_2/version120/shell.js | 24 + tests/mozilla/js1_3/Boolean/boolean-001.js | 73 + tests/mozilla/js1_3/Script/delete-001.js | 79 + tests/mozilla/js1_3/Script/function-001-n.js | 74 + tests/mozilla/js1_3/Script/function-002.js | 75 + tests/mozilla/js1_3/Script/in-001.js | 52 + tests/mozilla/js1_3/Script/new-001.js | 120 + tests/mozilla/js1_3/Script/script-001.js | 159 + tests/mozilla/js1_3/Script/switch-001.js | 80 + tests/mozilla/js1_3/inherit/proto_1.js | 166 + tests/mozilla/js1_3/inherit/proto_10.js | 152 + tests/mozilla/js1_3/inherit/proto_11.js | 115 + tests/mozilla/js1_3/inherit/proto_12.js | 142 + tests/mozilla/js1_3/inherit/proto_2.js | 122 + tests/mozilla/js1_3/inherit/proto_3.js | 103 + tests/mozilla/js1_3/inherit/proto_4.js | 156 + tests/mozilla/js1_3/inherit/proto_5.js | 146 + tests/mozilla/js1_3/inherit/proto_6.js | 171 + tests/mozilla/js1_3/inherit/proto_7.js | 125 + tests/mozilla/js1_3/inherit/proto_8.js | 123 + tests/mozilla/js1_3/inherit/proto_9.js | 101 + tests/mozilla/js1_3/jsref.js | 198 + tests/mozilla/js1_3/regress/delete-001.js | 79 + tests/mozilla/js1_3/regress/function-001-n.js | 74 + tests/mozilla/js1_3/regress/function-002.js | 75 + tests/mozilla/js1_3/regress/in-001.js | 66 + tests/mozilla/js1_3/regress/new-001.js | 120 + tests/mozilla/js1_3/regress/switch-001.js | 80 + tests/mozilla/js1_3/shell.js | 163 + tests/mozilla/js1_3/template.js | 44 + tests/mozilla/js1_4/Eval/eval-001.js | 75 + tests/mozilla/js1_4/Eval/eval-002.js | 80 + tests/mozilla/js1_4/Eval/eval-003.js | 85 + tests/mozilla/js1_4/Functions/function-001.js | 106 + tests/mozilla/js1_4/Regress/date-001-n.js | 55 + tests/mozilla/js1_4/Regress/function-001.js | 79 + tests/mozilla/js1_4/Regress/function-002.js | 123 + tests/mozilla/js1_4/Regress/function-003.js | 77 + tests/mozilla/js1_4/Regress/function-004-n.js | 51 + tests/mozilla/js1_4/Regress/regress-7224.js | 72 + tests/mozilla/js1_4/Regress/toString-001-n.js | 53 + tests/mozilla/js1_4/browser.js | 80 + tests/mozilla/js1_4/jsref.js | 169 + tests/mozilla/js1_4/shell.js | 138 + tests/mozilla/js1_5/Array/array-001.js | 101 + tests/mozilla/js1_5/Array/regress-101964.js | 98 + tests/mozilla/js1_5/Array/regress-107138.js | 190 + tests/mozilla/js1_5/Array/regress-108440.js | 103 + tests/mozilla/js1_5/Array/regress-154338.js | 119 + tests/mozilla/js1_5/Array/regress-157652.js | 136 + tests/mozilla/js1_5/Array/regress-178722.js | 175 + tests/mozilla/js1_5/Array/regress-94257.js | 99 + .../js1_5/Exceptions/catchguard-001-n.js | 57 + .../js1_5/Exceptions/catchguard-001.js | 64 + .../js1_5/Exceptions/catchguard-002-n.js | 46 + .../js1_5/Exceptions/catchguard-002.js | 60 + .../js1_5/Exceptions/catchguard-003-n.js | 53 + .../js1_5/Exceptions/catchguard-003.js | 69 + .../mozilla/js1_5/Exceptions/errstack-001.js | 274 + .../js1_5/Exceptions/regress-121658.js | 152 + .../js1_5/Exceptions/regress-123002.js | 129 + .../mozilla/js1_5/Exceptions/regress-50447.js | 146 + .../js1_5/Expressions/regress-192288.js | 114 + .../js1_5/Expressions/regress-96526-argsub.js | 120 + .../Expressions/regress-96526-delelem.js | 120 + .../Expressions/regress-96526-noargsub.js | 120 + tests/mozilla/js1_5/Expressions/shell.js | 113 + tests/mozilla/js1_5/GetSet/getset-001.js | 72 + tests/mozilla/js1_5/GetSet/getset-002.js | 68 + tests/mozilla/js1_5/GetSet/getset-003.js | 190 + tests/mozilla/js1_5/GetSet/getset-004.js | 190 + tests/mozilla/js1_5/GetSet/getset-005.js | 199 + tests/mozilla/js1_5/GetSet/getset-006.js | 173 + .../js1_5/LexicalConventions/lexical-001.js | 161 + .../LexicalConventions/regress-177314.js | 105 + tests/mozilla/js1_5/Object/regress-137000.js | 235 + tests/mozilla/js1_5/Object/regress-192105.js | 178 + .../mozilla/js1_5/Object/regress-90596-001.js | 278 + .../mozilla/js1_5/Object/regress-90596-002.js | 278 + .../mozilla/js1_5/Object/regress-90596-003.js | 290 + .../mozilla/js1_5/Object/regress-96284-001.js | 161 + .../mozilla/js1_5/Object/regress-96284-002.js | 161 + tests/mozilla/js1_5/Regress/regress-102725.js | 77 + tests/mozilla/js1_5/Regress/regress-103602.js | 162 + tests/mozilla/js1_5/Regress/regress-104077.js | 635 + tests/mozilla/js1_5/Regress/regress-110286.js | 151 + tests/mozilla/js1_5/Regress/regress-111557.js | 10960 ++++++++++++++++ tests/mozilla/js1_5/Regress/regress-114491.js | 101 + tests/mozilla/js1_5/Regress/regress-114493.js | 109 + tests/mozilla/js1_5/Regress/regress-118849.js | 181 + tests/mozilla/js1_5/Regress/regress-127557.js | 113 + .../js1_5/Regress/regress-131510-001.js | 68 + tests/mozilla/js1_5/Regress/regress-140974.js | 135 + tests/mozilla/js1_5/Regress/regress-146596.js | 154 + tests/mozilla/js1_5/Regress/regress-152646.js | 121 + tests/mozilla/js1_5/Regress/regress-156354.js | 126 + tests/mozilla/js1_5/Regress/regress-159334.js | 124 + tests/mozilla/js1_5/Regress/regress-168347.js | 215 + tests/mozilla/js1_5/Regress/regress-170193.js | 106 + tests/mozilla/js1_5/Regress/regress-172699.js | 94 + tests/mozilla/js1_5/Regress/regress-179524.js | 363 + tests/mozilla/js1_5/Regress/regress-185165.js | 96 + tests/mozilla/js1_5/Regress/regress-191633.js | 102 + tests/mozilla/js1_5/Regress/regress-191668.js | 99 + tests/mozilla/js1_5/Regress/regress-192414.js | 117 + tests/mozilla/js1_5/Regress/regress-192465.js | 152 + tests/mozilla/js1_5/Regress/regress-193418.js | 99 + tests/mozilla/js1_5/Regress/regress-203402.js | 90 + tests/mozilla/js1_5/Regress/regress-203841.js | 159 + tests/mozilla/js1_5/Regress/regress-204210.js | 143 + tests/mozilla/js1_5/Regress/regress-210682.js | 96 + tests/mozilla/js1_5/Regress/regress-216320.js | 1033 ++ tests/mozilla/js1_5/Regress/regress-31255.js | 108 + tests/mozilla/js1_5/Regress/regress-39309.js | 105 + tests/mozilla/js1_5/Regress/regress-44009.js | 63 + tests/mozilla/js1_5/Regress/regress-57043.js | 88 + .../js1_5/Regress/regress-68498-001.js | 56 + .../js1_5/Regress/regress-68498-002.js | 80 + .../js1_5/Regress/regress-68498-003.js | 84 + .../js1_5/Regress/regress-68498-004.js | 112 + tests/mozilla/js1_5/Regress/regress-69607.js | 53 + tests/mozilla/js1_5/Regress/regress-71107.js | 60 + tests/mozilla/js1_5/Regress/regress-76054.js | 139 + tests/mozilla/js1_5/Regress/regress-80981.js | 3137 +++++ tests/mozilla/js1_5/Regress/regress-82306.js | 59 + tests/mozilla/js1_5/Regress/regress-89443.js | 2130 +++ tests/mozilla/js1_5/Regress/regress-89474.js | 62 + tests/mozilla/js1_5/Regress/regress-90445.js | 306 + .../mozilla/js1_5/Regress/regress-96128-n.js | 64 + .../js1_5/Regress/regress-96526-001.js | 530 + .../js1_5/Regress/regress-96526-002.js | 56 + .../js1_5/Regress/regress-96526-003.js | 4431 +++++++ tests/mozilla/js1_5/Scope/regress-154693.js | 96 + tests/mozilla/js1_5/Scope/regress-181834.js | 178 + tests/mozilla/js1_5/Scope/regress-184107.js | 124 + tests/mozilla/js1_5/Scope/regress-185485.js | 158 + tests/mozilla/js1_5/Scope/regress-191276.js | 123 + tests/mozilla/js1_5/Scope/regress-192226.js | 120 + .../mozilla/js1_5/Scope/regress-202678-001.js | 131 + .../mozilla/js1_5/Scope/regress-202678-002.js | 132 + .../mozilla/js1_5/Scope/regress-208496-001.js | 169 + .../mozilla/js1_5/Scope/regress-208496-002.js | 161 + tests/mozilla/js1_5/Scope/regress-220362.js | 111 + tests/mozilla/js1_5/Scope/regress-220584.js | 132 + .../mozilla/js1_5/Scope/regress-77578-001.js | 154 + tests/mozilla/js1_5/Scope/scope-001.js | 110 + tests/mozilla/js1_5/Scope/scope-002.js | 121 + tests/mozilla/js1_5/Scope/scope-003.js | 122 + tests/mozilla/js1_5/Scope/scope-004.js | 204 + tests/mozilla/js1_5/String/regress-107771.js | 104 + tests/mozilla/js1_5/String/regress-179068.js | 154 + tests/mozilla/js1_5/shell.js | 180 + tests/mozilla/js1_6/Array/browser.js | 1 + tests/mozilla/js1_6/Array/regress-290592.js | 693 + tests/mozilla/js1_6/Array/regress-304828.js | 270 + tests/mozilla/js1_6/Array/regress-305002.js | 56 + .../mozilla/js1_6/Array/regress-310425-01.js | 58 + .../mozilla/js1_6/Array/regress-310425-02.js | 48 + tests/mozilla/js1_6/Array/regress-320887.js | 55 + tests/mozilla/js1_6/Array/shell.js | 1 + tests/mozilla/js1_6/README | 1 + tests/mozilla/js1_6/Regress/browser.js | 1 + tests/mozilla/js1_6/Regress/regress-301574.js | 67 + tests/mozilla/js1_6/Regress/regress-309242.js | 75 + .../js1_6/Regress/regress-311157-01.js | 55 + .../js1_6/Regress/regress-311157-02.js | 55 + tests/mozilla/js1_6/Regress/regress-314887.js | 51 + tests/mozilla/js1_6/Regress/regress-320172.js | 56 + tests/mozilla/js1_6/Regress/shell.js | 1 + tests/mozilla/js1_6/String/browser.js | 1 + tests/mozilla/js1_6/String/regress-306591.js | 95 + tests/mozilla/js1_6/String/shell.js | 1 + tests/mozilla/js1_6/browser.js | 147 + tests/mozilla/js1_6/shell.js | 477 + tests/mozilla/js1_6/template.js | 57 + tests/mozilla/jsDriver.pl | 1323 ++ tests/mozilla/menufoot.html | 8 + tests/mozilla/menuhead.html | 138 + tests/mozilla/mkhtml.pl | 84 + tests/mozilla/mklistpage.pl | 261 + tests/mozilla/runtests.pl | 495 + tests/mozilla/template.js | 55 + wtf/ASCIICType.h | 125 + wtf/AlwaysInline.h | 37 + wtf/Assertions.cpp | 163 + wtf/Assertions.h | 232 + wtf/Deque.h | 583 + wtf/DisallowCType.h | 74 + wtf/FastMalloc.cpp | 3649 +++++ wtf/FastMalloc.h | 81 + wtf/Forward.h | 43 + wtf/GetPtr.h | 33 + wtf/HashCountedSet.h | 178 + wtf/HashFunctions.h | 127 + wtf/HashIterators.h | 217 + wtf/HashMap.h | 427 + wtf/HashSet.h | 334 + wtf/HashTable.cpp | 62 + wtf/HashTable.h | 1253 ++ wtf/HashTraits.h | 254 + wtf/ListHashSet.h | 576 + wtf/ListRefPtr.h | 61 + wtf/MallocZoneSupport.h | 65 + wtf/MathExtras.h | 177 + wtf/Noncopyable.h | 42 + wtf/OwnArrayPtr.h | 72 + wtf/OwnPtr.h | 124 + wtf/OwnPtrWin.cpp | 69 + wtf/PassRefPtr.h | 193 + wtf/Platform.h | 309 + wtf/RefCounted.h | 80 + wtf/RefPtr.h | 194 + wtf/RefPtrHashMap.h | 370 + wtf/RetainPtr.h | 212 + wtf/StringExtras.h | 53 + wtf/TCPackedCache.h | 234 + wtf/TCPageMap.h | 289 + wtf/TCSpinLock.h | 234 + wtf/TCSystemAlloc.cpp | 436 + wtf/TCSystemAlloc.h | 65 + wtf/UnusedParam.h | 30 + wtf/Vector.h | 835 ++ wtf/VectorTraits.h | 117 + wtf/unicode/UTF8.cpp | 303 + wtf/unicode/UTF8.h | 75 + wtf/unicode/Unicode.h | 37 + wtf/unicode/icu/UnicodeIcu.h | 239 + wtf/unicode/qt4/UnicodeQt4.h | 547 + 1481 files changed, 273643 insertions(+) create mode 100644 API/APICast.h create mode 100644 API/JSBase.cpp create mode 100644 API/JSBase.h create mode 100644 API/JSCallbackConstructor.cpp create mode 100644 API/JSCallbackConstructor.h create mode 100644 API/JSCallbackFunction.cpp create mode 100644 API/JSCallbackFunction.h create mode 100644 API/JSCallbackObject.cpp create mode 100644 API/JSCallbackObject.h create mode 100644 API/JSCallbackObjectFunctions.h create mode 100644 API/JSClassRef.cpp create mode 100644 API/JSClassRef.h create mode 100644 API/JSContextRef.cpp create mode 100644 API/JSContextRef.h create mode 100644 API/JSNode.c create mode 100644 API/JSNode.h create mode 100644 API/JSNodeList.c create mode 100644 API/JSNodeList.h create mode 100644 API/JSObjectRef.cpp create mode 100644 API/JSObjectRef.h create mode 100644 API/JSRetainPtr.h create mode 100644 API/JSStringRef.cpp create mode 100644 API/JSStringRef.h create mode 100644 API/JSStringRefBSTR.cpp create mode 100644 API/JSStringRefBSTR.h create mode 100644 API/JSStringRefCF.cpp create mode 100644 API/JSStringRefCF.h create mode 100644 API/JSValueRef.cpp create mode 100644 API/JSValueRef.h create mode 100644 API/JavaScript.h create mode 100644 API/JavaScriptCore.h create mode 100644 API/Node.c create mode 100644 API/Node.h create mode 100644 API/NodeList.c create mode 100644 API/NodeList.h create mode 100644 API/minidom.c create mode 100644 API/minidom.html create mode 100644 API/minidom.js create mode 100644 API/testapi.c create mode 100644 API/testapi.js create mode 100644 AUTHORS create mode 100644 COPYING.LIB create mode 100644 DerivedSources.make create mode 100644 ForwardingHeaders/JavaScriptCore/APICast.h create mode 100644 ForwardingHeaders/JavaScriptCore/JSBase.h create mode 100644 ForwardingHeaders/JavaScriptCore/JSContextRef.h create mode 100644 ForwardingHeaders/JavaScriptCore/JSLock.h create mode 100644 ForwardingHeaders/JavaScriptCore/JSObjectRef.h create mode 100644 ForwardingHeaders/JavaScriptCore/JSRetainPtr.h create mode 100644 ForwardingHeaders/JavaScriptCore/JSStringRef.h create mode 100644 ForwardingHeaders/JavaScriptCore/JSStringRefCF.h create mode 100644 ForwardingHeaders/JavaScriptCore/JSValueRef.h create mode 100644 ForwardingHeaders/JavaScriptCore/JavaScript.h create mode 100644 ForwardingHeaders/JavaScriptCore/JavaScriptCore.h create mode 100644 GNUmakefile.am create mode 100644 Info.plist create mode 100644 JavaScriptCore.exp create mode 100644 JavaScriptCore.order create mode 100644 JavaScriptCore.pri create mode 100644 JavaScriptCorePrefix.h create mode 100644 JavaScriptCoreSources.bkl create mode 100644 Makefile create mode 100644 THANKS create mode 100644 bindings/NP_jsobject.cpp create mode 100644 bindings/NP_jsobject.h create mode 100644 bindings/c/c_class.cpp create mode 100644 bindings/c/c_class.h create mode 100644 bindings/c/c_instance.cpp create mode 100644 bindings/c/c_instance.h create mode 100644 bindings/c/c_runtime.cpp create mode 100644 bindings/c/c_runtime.h create mode 100644 bindings/c/c_utility.cpp create mode 100644 bindings/c/c_utility.h create mode 100644 bindings/jni/jni_class.cpp create mode 100644 bindings/jni/jni_class.h create mode 100644 bindings/jni/jni_instance.cpp create mode 100644 bindings/jni/jni_instance.h create mode 100644 bindings/jni/jni_jsobject.cpp create mode 100644 bindings/jni/jni_jsobject.h create mode 100644 bindings/jni/jni_objc.mm create mode 100644 bindings/jni/jni_runtime.cpp create mode 100644 bindings/jni/jni_runtime.h create mode 100644 bindings/jni/jni_utility.cpp create mode 100644 bindings/jni/jni_utility.h create mode 100755 bindings/make_testbindings create mode 100644 bindings/npapi.h create mode 100644 bindings/npruntime.cpp create mode 100644 bindings/npruntime.h create mode 100644 bindings/npruntime_impl.h create mode 100644 bindings/npruntime_internal.h create mode 100644 bindings/npruntime_priv.h create mode 100644 bindings/objc/WebScriptObject.h create mode 100644 bindings/objc/objc_class.h create mode 100644 bindings/objc/objc_class.mm create mode 100644 bindings/objc/objc_header.h create mode 100644 bindings/objc/objc_instance.h create mode 100644 bindings/objc/objc_instance.mm create mode 100644 bindings/objc/objc_runtime.h create mode 100644 bindings/objc/objc_runtime.mm create mode 100644 bindings/objc/objc_utility.h create mode 100644 bindings/objc/objc_utility.mm create mode 100644 bindings/qt/qt_class.cpp create mode 100644 bindings/qt/qt_class.h create mode 100644 bindings/qt/qt_instance.cpp create mode 100644 bindings/qt/qt_instance.h create mode 100644 bindings/qt/qt_runtime.cpp create mode 100644 bindings/qt/qt_runtime.h create mode 100644 bindings/runtime.cpp create mode 100644 bindings/runtime.h create mode 100644 bindings/runtime_array.cpp create mode 100644 bindings/runtime_array.h create mode 100644 bindings/runtime_method.cpp create mode 100644 bindings/runtime_method.h create mode 100644 bindings/runtime_object.cpp create mode 100644 bindings/runtime_object.h create mode 100644 bindings/runtime_root.cpp create mode 100644 bindings/runtime_root.h create mode 100644 bindings/test.js create mode 100644 bindings/testC.js create mode 100644 bindings/testM.js create mode 100644 bindings/testbindings.cpp create mode 100644 bindings/testbindings.mm create mode 100644 bindings/testbindings.pro create mode 100644 bindings/testqtbindings.cpp create mode 100644 headers.pri create mode 100644 icu/LICENSE create mode 100644 icu/README create mode 100644 icu/unicode/platform.h create mode 100644 icu/unicode/putil.h create mode 100644 icu/unicode/uchar.h create mode 100644 icu/unicode/ucnv.h create mode 100644 icu/unicode/ucnv_err.h create mode 100644 icu/unicode/uconfig.h create mode 100644 icu/unicode/uenum.h create mode 100644 icu/unicode/uiter.h create mode 100644 icu/unicode/umachine.h create mode 100644 icu/unicode/urename.h create mode 100644 icu/unicode/ustring.h create mode 100644 icu/unicode/utf.h create mode 100644 icu/unicode/utf16.h create mode 100644 icu/unicode/utf8.h create mode 100644 icu/unicode/utf_old.h create mode 100644 icu/unicode/utypes.h create mode 100644 icu/unicode/uversion.h create mode 100644 jscore.bkl create mode 100644 kjs/Activation.h create mode 100644 kjs/AllInOneFile.cpp create mode 100644 kjs/CollectorHeapIntrospector.cpp create mode 100644 kjs/CollectorHeapIntrospector.h create mode 100644 kjs/CommonIdentifiers.cpp create mode 100644 kjs/CommonIdentifiers.h create mode 100644 kjs/DateMath.cpp create mode 100644 kjs/DateMath.h create mode 100644 kjs/ExecState.cpp create mode 100644 kjs/ExecState.h create mode 100644 kjs/JSGlobalObject.cpp create mode 100644 kjs/JSGlobalObject.h create mode 100644 kjs/JSImmediate.cpp create mode 100644 kjs/JSImmediate.h create mode 100644 kjs/JSLock.cpp create mode 100644 kjs/JSLock.h create mode 100644 kjs/JSLockC.h create mode 100644 kjs/JSType.h create mode 100644 kjs/JSVariableObject.cpp create mode 100644 kjs/JSVariableObject.h create mode 100644 kjs/JSWrapperObject.cpp create mode 100644 kjs/JSWrapperObject.h create mode 100644 kjs/LabelStack.h create mode 100644 kjs/LocalStorage.h create mode 100644 kjs/NodeInfo.h create mode 100644 kjs/Parser.cpp create mode 100644 kjs/Parser.h create mode 100644 kjs/PropertyNameArray.cpp create mode 100644 kjs/PropertyNameArray.h create mode 100644 kjs/SavedBuiltins.h create mode 100644 kjs/SymbolTable.h create mode 100644 kjs/array_instance.cpp create mode 100644 kjs/array_instance.h create mode 100644 kjs/array_object.cpp create mode 100644 kjs/array_object.h create mode 100644 kjs/bool_object.cpp create mode 100644 kjs/bool_object.h create mode 100644 kjs/collector.cpp create mode 100644 kjs/collector.h create mode 100644 kjs/completion.h create mode 100644 kjs/config.h create mode 100755 kjs/create_hash_table create mode 100644 kjs/date_object.cpp create mode 100644 kjs/date_object.h create mode 100644 kjs/debugger.cpp create mode 100644 kjs/debugger.h create mode 100644 kjs/dtoa.cpp create mode 100644 kjs/dtoa.h create mode 100644 kjs/error_object.cpp create mode 100644 kjs/error_object.h create mode 100644 kjs/function.cpp create mode 100644 kjs/function.h create mode 100644 kjs/function_object.cpp create mode 100644 kjs/function_object.h create mode 100644 kjs/grammar.y create mode 100644 kjs/identifier.cpp create mode 100644 kjs/identifier.h create mode 100644 kjs/internal.cpp create mode 100644 kjs/internal.h create mode 100644 kjs/interpreter.cpp create mode 100644 kjs/interpreter.h create mode 100644 kjs/keywords.table create mode 100644 kjs/lexer.cpp create mode 100644 kjs/lexer.h create mode 100644 kjs/list.cpp create mode 100644 kjs/list.h create mode 100644 kjs/lookup.cpp create mode 100644 kjs/lookup.h create mode 100644 kjs/math_object.cpp create mode 100644 kjs/math_object.h create mode 100644 kjs/nodes.cpp create mode 100644 kjs/nodes.h create mode 100644 kjs/nodes2string.cpp create mode 100644 kjs/number_object.cpp create mode 100644 kjs/number_object.h create mode 100644 kjs/object.cpp create mode 100644 kjs/object.h create mode 100644 kjs/object_object.cpp create mode 100644 kjs/object_object.h create mode 100644 kjs/operations.cpp create mode 100644 kjs/operations.h create mode 100644 kjs/property_map.cpp create mode 100644 kjs/property_map.h create mode 100644 kjs/property_slot.cpp create mode 100644 kjs/property_slot.h create mode 100644 kjs/protect.h create mode 100644 kjs/regexp.cpp create mode 100644 kjs/regexp.h create mode 100644 kjs/regexp_object.cpp create mode 100644 kjs/regexp_object.h create mode 100644 kjs/scope_chain.cpp create mode 100644 kjs/scope_chain.h create mode 100644 kjs/scope_chain_mark.h create mode 100644 kjs/string_object.cpp create mode 100644 kjs/string_object.h create mode 100644 kjs/testkjs.cpp create mode 100644 kjs/testkjs.pro create mode 100644 kjs/types.h create mode 100644 kjs/ustring.cpp create mode 100644 kjs/ustring.h create mode 100644 kjs/value.cpp create mode 100644 kjs/value.h create mode 100755 make-generated-sources.sh create mode 100644 os-win32/stdbool.h create mode 100644 os-win32/stdint.h create mode 100644 pcre/AUTHORS create mode 100644 pcre/COPYING create mode 100755 pcre/dftables create mode 100644 pcre/pcre.h create mode 100644 pcre/pcre.pri create mode 100644 pcre/pcre_compile.cpp create mode 100644 pcre/pcre_exec.cpp create mode 100644 pcre/pcre_internal.h create mode 100644 pcre/pcre_tables.cpp create mode 100644 pcre/pcre_ucp_searchfuncs.cpp create mode 100644 pcre/pcre_xclass.cpp create mode 100644 pcre/ucpinternal.h create mode 100644 pcre/ucptable.cpp create mode 100644 tests/mozilla/Getopt/Mixed.pm create mode 100644 tests/mozilla/Makefile create mode 100644 tests/mozilla/README-jsDriver.html create mode 100644 tests/mozilla/ecma/Array/15.4-1.js create mode 100644 tests/mozilla/ecma/Array/15.4-2.js create mode 100644 tests/mozilla/ecma/Array/15.4.1.1.js create mode 100644 tests/mozilla/ecma/Array/15.4.1.2.js create mode 100644 tests/mozilla/ecma/Array/15.4.1.3.js create mode 100644 tests/mozilla/ecma/Array/15.4.1.js create mode 100644 tests/mozilla/ecma/Array/15.4.2.1-1.js create mode 100644 tests/mozilla/ecma/Array/15.4.2.1-2.js create mode 100644 tests/mozilla/ecma/Array/15.4.2.1-3.js create mode 100644 tests/mozilla/ecma/Array/15.4.2.2-1.js create mode 100644 tests/mozilla/ecma/Array/15.4.2.2-2.js create mode 100644 tests/mozilla/ecma/Array/15.4.2.3.js create mode 100644 tests/mozilla/ecma/Array/15.4.3.1-2.js create mode 100644 tests/mozilla/ecma/Array/15.4.3.2.js create mode 100644 tests/mozilla/ecma/Array/15.4.3.js create mode 100644 tests/mozilla/ecma/Array/15.4.4.1.js create mode 100644 tests/mozilla/ecma/Array/15.4.4.2.js create mode 100644 tests/mozilla/ecma/Array/15.4.4.3-1.js create mode 100644 tests/mozilla/ecma/Array/15.4.4.4-1.js create mode 100644 tests/mozilla/ecma/Array/15.4.4.4-2.js create mode 100644 tests/mozilla/ecma/Array/15.4.4.5-1.js create mode 100644 tests/mozilla/ecma/Array/15.4.4.5-2.js create mode 100644 tests/mozilla/ecma/Array/15.4.4.5-3.js create mode 100644 tests/mozilla/ecma/Array/15.4.4.js create mode 100644 tests/mozilla/ecma/Array/15.4.5.1-1.js create mode 100644 tests/mozilla/ecma/Array/15.4.5.1-2.js create mode 100644 tests/mozilla/ecma/Array/15.4.5.2-1.js create mode 100644 tests/mozilla/ecma/Array/15.4.5.2-2.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.1.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.2.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.3.1-1.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.3.1-2.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.3.1-3.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.3.1-4.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.3.1-5.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.3.1.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.3.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4-1.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4-2.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.1.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.2-1.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.2-2.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.2-3.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.2-4-n.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.3-1.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.3-2.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.3-3.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.3-4-n.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.3.js create mode 100644 tests/mozilla/ecma/Boolean/15.6.4.js create mode 100644 tests/mozilla/ecma/Date/15.9.1.1-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.1.1-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.2.1.js create mode 100644 tests/mozilla/ecma/Date/15.9.2.2-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.2.2-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.2.2-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.2.2-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.2.2-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.2.2-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.1-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.1-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.1-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.1-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.1-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.2-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.2-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.2-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.2-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.2-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.8-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.8-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.8-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.8-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.3.8-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.4.2-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.4.2.js create mode 100644 tests/mozilla/ecma/Date/15.9.4.3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-10.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-11.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-12.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-13.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-8.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.10-9.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.11-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.11-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.11-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.11-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.11-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.11-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.11-7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.12-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.12-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.12-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.12-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.12-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.12-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.12-7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.12-8.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.13-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.13-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.13-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.13-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.13-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.13-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.13-7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.13-8.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.14.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.15.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.16.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.17.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.18.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.19.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.2-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.2-2-n.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.20.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.21-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.21-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.21-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.21-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.21-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.21-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.21-7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.21-8.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.22-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.22-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.22-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.22-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.22-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.22-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.22-7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.22-8.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-10.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-11.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-12.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-13.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-14.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-15.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-16.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-17.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-18.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-3-n.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-8.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.23-9.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.24-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.24-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.24-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.24-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.24-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.24-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.24-7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.24-8.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.25-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.26-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.27-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.28-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.29-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.3-1-n.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.3-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.30-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.31-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.32-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.33-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.34-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.35-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.36-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.36-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.36-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.36-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.36-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.36-6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.36-7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.37-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.37-2.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.37-3.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.37-4.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.37-5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.4-1.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.4-2-n.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.5.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.6.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.7.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.8.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.9.js create mode 100644 tests/mozilla/ecma/Date/15.9.5.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.3.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.6.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.1.8-2.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.2.1.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js create mode 100644 tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js create mode 100644 tests/mozilla/ecma/Expressions/11.1.1.js create mode 100644 tests/mozilla/ecma/Expressions/11.10-1.js create mode 100644 tests/mozilla/ecma/Expressions/11.10-2.js create mode 100644 tests/mozilla/ecma/Expressions/11.10-3.js create mode 100644 tests/mozilla/ecma/Expressions/11.12-1.js create mode 100644 tests/mozilla/ecma/Expressions/11.12-2-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.12-3.js create mode 100644 tests/mozilla/ecma/Expressions/11.12-4.js create mode 100644 tests/mozilla/ecma/Expressions/11.13.1.js create mode 100644 tests/mozilla/ecma/Expressions/11.13.2-1.js create mode 100644 tests/mozilla/ecma/Expressions/11.13.2-2.js create mode 100644 tests/mozilla/ecma/Expressions/11.13.2-3.js create mode 100644 tests/mozilla/ecma/Expressions/11.13.2-4.js create mode 100644 tests/mozilla/ecma/Expressions/11.13.2-5.js create mode 100644 tests/mozilla/ecma/Expressions/11.13.js create mode 100644 tests/mozilla/ecma/Expressions/11.14-1.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.1-1.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.1-2.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.1-3-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.1-4-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.1-5.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-1-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-1.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-10-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-11.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-2-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-3-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-4-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-5-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-6-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-7-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-8-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.2-9-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.3-1.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.3-2-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.3-3-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.3-4-n.js create mode 100644 tests/mozilla/ecma/Expressions/11.2.3-5.js create mode 100644 tests/mozilla/ecma/Expressions/11.3.1.js create mode 100644 tests/mozilla/ecma/Expressions/11.3.2.js create mode 100644 tests/mozilla/ecma/Expressions/11.4.1.js create mode 100644 tests/mozilla/ecma/Expressions/11.4.2.js create mode 100644 tests/mozilla/ecma/Expressions/11.4.3.js create mode 100644 tests/mozilla/ecma/Expressions/11.4.4.js create mode 100644 tests/mozilla/ecma/Expressions/11.4.5.js create mode 100644 tests/mozilla/ecma/Expressions/11.4.6.js create mode 100644 tests/mozilla/ecma/Expressions/11.4.8.js create mode 100644 tests/mozilla/ecma/Expressions/11.4.9.js create mode 100644 tests/mozilla/ecma/Expressions/11.5.1.js create mode 100644 tests/mozilla/ecma/Expressions/11.5.2.js create mode 100644 tests/mozilla/ecma/Expressions/11.5.3.js create mode 100644 tests/mozilla/ecma/Expressions/11.6.1-1.js create mode 100644 tests/mozilla/ecma/Expressions/11.6.1-2.js create mode 100644 tests/mozilla/ecma/Expressions/11.6.1-3.js create mode 100644 tests/mozilla/ecma/Expressions/11.6.2-1.js create mode 100644 tests/mozilla/ecma/Expressions/11.6.3.js create mode 100644 tests/mozilla/ecma/Expressions/11.7.1.js create mode 100644 tests/mozilla/ecma/Expressions/11.7.2.js create mode 100644 tests/mozilla/ecma/Expressions/11.7.3.js create mode 100644 tests/mozilla/ecma/Expressions/11.8.1.js create mode 100644 tests/mozilla/ecma/Expressions/11.8.2.js create mode 100644 tests/mozilla/ecma/Expressions/11.8.3.js create mode 100644 tests/mozilla/ecma/Expressions/11.8.4.js create mode 100644 tests/mozilla/ecma/Expressions/11.9.1.js create mode 100644 tests/mozilla/ecma/Expressions/11.9.2.js create mode 100644 tests/mozilla/ecma/Expressions/11.9.3.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.1.1-1.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.1.1-2.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.1.1-3.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.2.1-1.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.2.1-2.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.2.1-3.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.3.1-1.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.3.1-2.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.3.1-3.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.3.1-4.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.3.2.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.4-1.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.4.1.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.4.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.5-1.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.5-2.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.5.1.js create mode 100644 tests/mozilla/ecma/FunctionObjects/15.3.5.3.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1-1-n.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1-2-n.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.1.1.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.1.2.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.1-1.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.1-2.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.2-1.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.2-2.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.3-1.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.3-2.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.4.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.5-1.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.5-2.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.5-3.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.6.js create mode 100644 tests/mozilla/ecma/GlobalObject/15.1.2.7.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.1-1.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.1-2.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.1-3.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.2-1.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.2-2-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.2-3-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.2-4-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.2-5-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.2-6.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-1.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-10.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-11.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-12.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-13-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-2.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-3.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-4.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-5.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-6.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-7.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-8.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.3-9.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.1-1-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.1-2-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.1-3-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-1-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-10-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-11-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-12-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-13-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-14-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-15-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-16-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-2-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-3-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-4-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-5-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-6-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-7-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-8-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.2-9-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-1-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-10-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-11-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-12-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-13-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-14-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-15-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-16-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-2-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-3-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-4-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-5-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-6-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-7-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-8-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.4.3-9-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-1.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-10-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-2-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-3-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-4-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-5-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-6.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-7.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-8-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.5-9-n.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.6.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.7.1.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.7.2.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.7.3-1.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.7.3-2.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.7.3.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.7.4.js create mode 100644 tests/mozilla/ecma/LexicalConventions/7.8.2-n.js create mode 100644 tests/mozilla/ecma/Math/15.8-1.js create mode 100644 tests/mozilla/ecma/Math/15.8-2-n.js create mode 100644 tests/mozilla/ecma/Math/15.8-3-n.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.1-1.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.1-2.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.2-1.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.2-2.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.3-1.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.3-2.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.4-1.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.4-2.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.5-1.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.5-2.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.6-1.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.6-2.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.7-1.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.7-2.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.8-1.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.8-2.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.8-3.js create mode 100644 tests/mozilla/ecma/Math/15.8.1.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.1.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.10.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.11.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.12.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.13.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.14.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.15.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.16.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.17.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.18.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.2.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.3.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.4.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.5.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.6.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.7.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.8.js create mode 100644 tests/mozilla/ecma/Math/15.8.2.9.js create mode 100644 tests/mozilla/ecma/NativeObjects/15-1.js create mode 100644 tests/mozilla/ecma/NativeObjects/15-2.js create mode 100644 tests/mozilla/ecma/Number/15.7.1.js create mode 100644 tests/mozilla/ecma/Number/15.7.2.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.1-1.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.1-2.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.1-3.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.2-1.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.2-2.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.2-3.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.2-4.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.3-1.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.3-2.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.3-3.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.3-4.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.4-1.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.4-2.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.4-3.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.4-4.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.5-1.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.5-2.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.5-3.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.5-4.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.6-1.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.6-2.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.6-3.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.6-4.js create mode 100644 tests/mozilla/ecma/Number/15.7.3.js create mode 100644 tests/mozilla/ecma/Number/15.7.4-1.js create mode 100644 tests/mozilla/ecma/Number/15.7.4.1.js create mode 100644 tests/mozilla/ecma/Number/15.7.4.2-1.js create mode 100644 tests/mozilla/ecma/Number/15.7.4.2-2-n.js create mode 100644 tests/mozilla/ecma/Number/15.7.4.2-3-n.js create mode 100644 tests/mozilla/ecma/Number/15.7.4.2-4.js create mode 100644 tests/mozilla/ecma/Number/15.7.4.3-1.js create mode 100644 tests/mozilla/ecma/Number/15.7.4.3-2.js create mode 100644 tests/mozilla/ecma/Number/15.7.4.3-3-n.js create mode 100644 tests/mozilla/ecma/Number/15.7.4.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.1.1.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.1.2.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.2.1.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.2.2.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.3-1.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.3.1-1.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.3.1-2.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.3.1-3.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.3.1-4.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.3.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.4.1.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.4.2.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.4.3.js create mode 100644 tests/mozilla/ecma/ObjectObjects/15.2.4.js create mode 100644 tests/mozilla/ecma/SourceText/6-1.js create mode 100644 tests/mozilla/ecma/SourceText/6-2.js create mode 100644 tests/mozilla/ecma/Statements/12.10-1.js create mode 100644 tests/mozilla/ecma/Statements/12.10.js create mode 100644 tests/mozilla/ecma/Statements/12.2-1.js create mode 100644 tests/mozilla/ecma/Statements/12.5-1.js create mode 100644 tests/mozilla/ecma/Statements/12.5-2.js create mode 100644 tests/mozilla/ecma/Statements/12.6.1-1.js create mode 100644 tests/mozilla/ecma/Statements/12.6.2-1.js create mode 100644 tests/mozilla/ecma/Statements/12.6.2-2.js create mode 100644 tests/mozilla/ecma/Statements/12.6.2-3.js create mode 100644 tests/mozilla/ecma/Statements/12.6.2-4.js create mode 100644 tests/mozilla/ecma/Statements/12.6.2-5.js create mode 100644 tests/mozilla/ecma/Statements/12.6.2-6.js create mode 100644 tests/mozilla/ecma/Statements/12.6.2-7.js create mode 100644 tests/mozilla/ecma/Statements/12.6.2-8.js create mode 100644 tests/mozilla/ecma/Statements/12.6.2-9-n.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-1.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-10.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-11.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-12.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-19.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-2.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-3.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-4.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-5-n.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-6-n.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-7-n.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-8-n.js create mode 100644 tests/mozilla/ecma/Statements/12.6.3-9-n.js create mode 100644 tests/mozilla/ecma/Statements/12.7-1-n.js create mode 100644 tests/mozilla/ecma/Statements/12.8-1-n.js create mode 100644 tests/mozilla/ecma/Statements/12.9-1-n.js create mode 100644 tests/mozilla/ecma/String/15.5.1.js create mode 100644 tests/mozilla/ecma/String/15.5.2.js create mode 100644 tests/mozilla/ecma/String/15.5.3.1-1.js create mode 100644 tests/mozilla/ecma/String/15.5.3.1-2.js create mode 100644 tests/mozilla/ecma/String/15.5.3.1-3.js create mode 100644 tests/mozilla/ecma/String/15.5.3.1-4.js create mode 100644 tests/mozilla/ecma/String/15.5.3.2-1.js create mode 100644 tests/mozilla/ecma/String/15.5.3.2-2.js create mode 100644 tests/mozilla/ecma/String/15.5.3.2-3.js create mode 100644 tests/mozilla/ecma/String/15.5.3.js create mode 100644 tests/mozilla/ecma/String/15.5.4.1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.10-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.11-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.11-2.js create mode 100644 tests/mozilla/ecma/String/15.5.4.11-3.js create mode 100644 tests/mozilla/ecma/String/15.5.4.11-4.js create mode 100644 tests/mozilla/ecma/String/15.5.4.11-5.js create mode 100644 tests/mozilla/ecma/String/15.5.4.11-6.js create mode 100644 tests/mozilla/ecma/String/15.5.4.12-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.12-2.js create mode 100644 tests/mozilla/ecma/String/15.5.4.12-3.js create mode 100644 tests/mozilla/ecma/String/15.5.4.12-4.js create mode 100644 tests/mozilla/ecma/String/15.5.4.12-5.js create mode 100644 tests/mozilla/ecma/String/15.5.4.2-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.2-2-n.js create mode 100644 tests/mozilla/ecma/String/15.5.4.2-3.js create mode 100644 tests/mozilla/ecma/String/15.5.4.2.js create mode 100644 tests/mozilla/ecma/String/15.5.4.3-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.3-2.js create mode 100644 tests/mozilla/ecma/String/15.5.4.3-3-n.js create mode 100644 tests/mozilla/ecma/String/15.5.4.4-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.4-2.js create mode 100644 tests/mozilla/ecma/String/15.5.4.4-3.js create mode 100644 tests/mozilla/ecma/String/15.5.4.4-4.js create mode 100644 tests/mozilla/ecma/String/15.5.4.5-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.5-2.js create mode 100644 tests/mozilla/ecma/String/15.5.4.5-3.js create mode 100644 tests/mozilla/ecma/String/15.5.4.5-4.js create mode 100644 tests/mozilla/ecma/String/15.5.4.5-5.js create mode 100644 tests/mozilla/ecma/String/15.5.4.5-6.js create mode 100644 tests/mozilla/ecma/String/15.5.4.6-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.6-2.js create mode 100644 tests/mozilla/ecma/String/15.5.4.7-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.7-2.js create mode 100644 tests/mozilla/ecma/String/15.5.4.7-3.js create mode 100644 tests/mozilla/ecma/String/15.5.4.8-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.8-2.js create mode 100644 tests/mozilla/ecma/String/15.5.4.8-3.js create mode 100644 tests/mozilla/ecma/String/15.5.4.9-1.js create mode 100644 tests/mozilla/ecma/String/15.5.4.js create mode 100644 tests/mozilla/ecma/String/15.5.5.1.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.2.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.3-1.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.3.1-1.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.3.1-2.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.3.1-3.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.3.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.4-1.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.4-2.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.5-2.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.6.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.7.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.8.1.js create mode 100644 tests/mozilla/ecma/TypeConversion/9.9-1.js create mode 100644 tests/mozilla/ecma/Types/8.1.js create mode 100644 tests/mozilla/ecma/Types/8.4.js create mode 100644 tests/mozilla/ecma/Types/8.6.2.1-1.js create mode 100644 tests/mozilla/ecma/browser.js create mode 100644 tests/mozilla/ecma/jsref.js create mode 100644 tests/mozilla/ecma/shell.js create mode 100644 tests/mozilla/ecma_2/Exceptions/boolean-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/boolean-002.js create mode 100644 tests/mozilla/ecma_2/Exceptions/date-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/date-002.js create mode 100644 tests/mozilla/ecma_2/Exceptions/date-003.js create mode 100644 tests/mozilla/ecma_2/Exceptions/date-004.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-002.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-003.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-004.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-005.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-006.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-007.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-008.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-009.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-010-n.js create mode 100644 tests/mozilla/ecma_2/Exceptions/exception-011-n.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-002.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-003.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-004.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-005.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-006.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-007.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-008.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-009.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-010.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-011.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-012.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-013.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-014.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-015.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-016.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-017.js create mode 100644 tests/mozilla/ecma_2/Exceptions/expression-019.js create mode 100644 tests/mozilla/ecma_2/Exceptions/function-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/global-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/global-002.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-002.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-003.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-004.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-005.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-006.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-007.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-008.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-009.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-010.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-011.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-012.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-013.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-014.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-015.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-016.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-017.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-018.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-019.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-020.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-021.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-022.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-023.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-024.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-025.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-026.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-027.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-028.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-029.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-030.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-031.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-032.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-033.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-034.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-035.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-036.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-037.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-038.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-039.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-040.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-041.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-042.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-047.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-048.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-049.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-050.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-051.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-052.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-053.js create mode 100644 tests/mozilla/ecma_2/Exceptions/lexical-054.js create mode 100644 tests/mozilla/ecma_2/Exceptions/number-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/number-002.js create mode 100644 tests/mozilla/ecma_2/Exceptions/number-003.js create mode 100644 tests/mozilla/ecma_2/Exceptions/statement-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/statement-002.js create mode 100644 tests/mozilla/ecma_2/Exceptions/statement-003.js create mode 100644 tests/mozilla/ecma_2/Exceptions/statement-004.js create mode 100644 tests/mozilla/ecma_2/Exceptions/statement-005.js create mode 100644 tests/mozilla/ecma_2/Exceptions/statement-006.js create mode 100644 tests/mozilla/ecma_2/Exceptions/statement-007.js create mode 100644 tests/mozilla/ecma_2/Exceptions/statement-008.js create mode 100644 tests/mozilla/ecma_2/Exceptions/statement-009.js create mode 100644 tests/mozilla/ecma_2/Exceptions/string-001.js create mode 100644 tests/mozilla/ecma_2/Exceptions/string-002.js create mode 100644 tests/mozilla/ecma_2/Expressions/StrictEquality-001.js create mode 100644 tests/mozilla/ecma_2/Expressions/instanceof-001.js create mode 100644 tests/mozilla/ecma_2/Expressions/instanceof-002.js create mode 100644 tests/mozilla/ecma_2/Expressions/instanceof-003-n.js create mode 100644 tests/mozilla/ecma_2/Expressions/instanceof-004-n.js create mode 100644 tests/mozilla/ecma_2/Expressions/instanceof-005-n.js create mode 100644 tests/mozilla/ecma_2/Expressions/instanceof-006.js create mode 100644 tests/mozilla/ecma_2/FunctionObjects/apply-001-n.js create mode 100644 tests/mozilla/ecma_2/FunctionObjects/call-1.js create mode 100644 tests/mozilla/ecma_2/LexicalConventions/keywords-001.js create mode 100644 tests/mozilla/ecma_2/LexicalConventions/regexp-literals-001.js create mode 100644 tests/mozilla/ecma_2/LexicalConventions/regexp-literals-002.js create mode 100644 tests/mozilla/ecma_2/RegExp/constructor-001.js create mode 100644 tests/mozilla/ecma_2/RegExp/exec-001.js create mode 100644 tests/mozilla/ecma_2/RegExp/exec-002.js create mode 100644 tests/mozilla/ecma_2/RegExp/function-001.js create mode 100644 tests/mozilla/ecma_2/RegExp/hex-001.js create mode 100644 tests/mozilla/ecma_2/RegExp/multiline-001.js create mode 100644 tests/mozilla/ecma_2/RegExp/octal-001.js create mode 100644 tests/mozilla/ecma_2/RegExp/octal-002.js create mode 100644 tests/mozilla/ecma_2/RegExp/octal-003.js create mode 100644 tests/mozilla/ecma_2/RegExp/properties-001.js create mode 100644 tests/mozilla/ecma_2/RegExp/properties-002.js create mode 100644 tests/mozilla/ecma_2/RegExp/regexp-enumerate-001.js create mode 100644 tests/mozilla/ecma_2/RegExp/regress-001.js create mode 100644 tests/mozilla/ecma_2/RegExp/unicode-001.js create mode 100644 tests/mozilla/ecma_2/Statements/dowhile-001.js create mode 100644 tests/mozilla/ecma_2/Statements/dowhile-002.js create mode 100644 tests/mozilla/ecma_2/Statements/dowhile-003.js create mode 100644 tests/mozilla/ecma_2/Statements/dowhile-004.js create mode 100644 tests/mozilla/ecma_2/Statements/dowhile-005.js create mode 100644 tests/mozilla/ecma_2/Statements/dowhile-006.js create mode 100644 tests/mozilla/ecma_2/Statements/dowhile-007.js create mode 100644 tests/mozilla/ecma_2/Statements/forin-001.js create mode 100644 tests/mozilla/ecma_2/Statements/forin-002.js create mode 100644 tests/mozilla/ecma_2/Statements/if-001.js create mode 100644 tests/mozilla/ecma_2/Statements/label-001.js create mode 100644 tests/mozilla/ecma_2/Statements/label-002.js create mode 100644 tests/mozilla/ecma_2/Statements/switch-001.js create mode 100644 tests/mozilla/ecma_2/Statements/switch-002.js create mode 100644 tests/mozilla/ecma_2/Statements/switch-003.js create mode 100644 tests/mozilla/ecma_2/Statements/switch-004.js create mode 100644 tests/mozilla/ecma_2/Statements/try-001.js create mode 100644 tests/mozilla/ecma_2/Statements/try-003.js create mode 100644 tests/mozilla/ecma_2/Statements/try-004.js create mode 100644 tests/mozilla/ecma_2/Statements/try-005.js create mode 100644 tests/mozilla/ecma_2/Statements/try-006.js create mode 100644 tests/mozilla/ecma_2/Statements/try-007.js create mode 100644 tests/mozilla/ecma_2/Statements/try-008.js create mode 100644 tests/mozilla/ecma_2/Statements/try-009.js create mode 100644 tests/mozilla/ecma_2/Statements/try-010.js create mode 100644 tests/mozilla/ecma_2/Statements/try-012.js create mode 100644 tests/mozilla/ecma_2/Statements/while-001.js create mode 100644 tests/mozilla/ecma_2/Statements/while-002.js create mode 100644 tests/mozilla/ecma_2/Statements/while-003.js create mode 100644 tests/mozilla/ecma_2/Statements/while-004.js create mode 100644 tests/mozilla/ecma_2/String/match-001.js create mode 100644 tests/mozilla/ecma_2/String/match-002.js create mode 100644 tests/mozilla/ecma_2/String/match-003.js create mode 100644 tests/mozilla/ecma_2/String/match-004.js create mode 100644 tests/mozilla/ecma_2/String/replace-001.js create mode 100644 tests/mozilla/ecma_2/String/split-001.js create mode 100644 tests/mozilla/ecma_2/String/split-002.js create mode 100644 tests/mozilla/ecma_2/String/split-003.js create mode 100644 tests/mozilla/ecma_2/browser.js create mode 100644 tests/mozilla/ecma_2/instanceof/instanceof-001.js create mode 100644 tests/mozilla/ecma_2/instanceof/instanceof-002.js create mode 100644 tests/mozilla/ecma_2/instanceof/instanceof-003.js create mode 100644 tests/mozilla/ecma_2/instanceof/regress-7635.js create mode 100644 tests/mozilla/ecma_2/jsref.js create mode 100644 tests/mozilla/ecma_2/shell.js create mode 100644 tests/mozilla/ecma_2/template.js create mode 100644 tests/mozilla/ecma_3/Array/15.4.4.3-1.js create mode 100644 tests/mozilla/ecma_3/Array/15.4.4.4-001.js create mode 100644 tests/mozilla/ecma_3/Array/regress-101488.js create mode 100644 tests/mozilla/ecma_3/Array/regress-130451.js create mode 100644 tests/mozilla/ecma_3/Date/15.9.5.3.js create mode 100644 tests/mozilla/ecma_3/Date/15.9.5.4.js create mode 100644 tests/mozilla/ecma_3/Date/15.9.5.5.js create mode 100644 tests/mozilla/ecma_3/Date/15.9.5.6.js create mode 100644 tests/mozilla/ecma_3/Date/15.9.5.7.js create mode 100644 tests/mozilla/ecma_3/Date/shell.js create mode 100644 tests/mozilla/ecma_3/Exceptions/15.11.1.1.js create mode 100644 tests/mozilla/ecma_3/Exceptions/15.11.4.4-1.js create mode 100644 tests/mozilla/ecma_3/Exceptions/15.11.7.6-001.js create mode 100644 tests/mozilla/ecma_3/Exceptions/15.11.7.6-002.js create mode 100644 tests/mozilla/ecma_3/Exceptions/15.11.7.6-003.js create mode 100644 tests/mozilla/ecma_3/Exceptions/binding-001.js create mode 100644 tests/mozilla/ecma_3/Exceptions/regress-181654.js create mode 100644 tests/mozilla/ecma_3/Exceptions/regress-181914.js create mode 100644 tests/mozilla/ecma_3/Exceptions/regress-58946.js create mode 100644 tests/mozilla/ecma_3/Exceptions/regress-95101.js create mode 100644 tests/mozilla/ecma_3/ExecutionContexts/10.1.3-1.js create mode 100644 tests/mozilla/ecma_3/ExecutionContexts/10.1.3-2.js create mode 100644 tests/mozilla/ecma_3/ExecutionContexts/10.1.3.js create mode 100644 tests/mozilla/ecma_3/ExecutionContexts/10.1.4-1.js create mode 100644 tests/mozilla/ecma_3/ExecutionContexts/regress-23346.js create mode 100644 tests/mozilla/ecma_3/Expressions/11.6.1-1.js create mode 100644 tests/mozilla/ecma_3/Expressions/11.9.6-1.js create mode 100644 tests/mozilla/ecma_3/FunExpr/fe-001-n.js create mode 100644 tests/mozilla/ecma_3/FunExpr/fe-001.js create mode 100644 tests/mozilla/ecma_3/FunExpr/fe-002.js create mode 100644 tests/mozilla/ecma_3/Function/15.3.4.3-1.js create mode 100644 tests/mozilla/ecma_3/Function/15.3.4.4-1.js create mode 100644 tests/mozilla/ecma_3/Function/arguments-001.js create mode 100644 tests/mozilla/ecma_3/Function/call-001.js create mode 100644 tests/mozilla/ecma_3/Function/regress-104584.js create mode 100644 tests/mozilla/ecma_3/Function/regress-131964.js create mode 100644 tests/mozilla/ecma_3/Function/regress-137181.js create mode 100644 tests/mozilla/ecma_3/Function/regress-193555.js create mode 100644 tests/mozilla/ecma_3/Function/regress-49286.js create mode 100644 tests/mozilla/ecma_3/Function/regress-58274.js create mode 100644 tests/mozilla/ecma_3/Function/regress-85880.js create mode 100644 tests/mozilla/ecma_3/Function/regress-94506.js create mode 100644 tests/mozilla/ecma_3/Function/regress-97921.js create mode 100644 tests/mozilla/ecma_3/Function/scope-001.js create mode 100644 tests/mozilla/ecma_3/Function/scope-002.js create mode 100644 tests/mozilla/ecma_3/Number/15.7.4.5-1.js create mode 100644 tests/mozilla/ecma_3/Number/15.7.4.6-1.js create mode 100644 tests/mozilla/ecma_3/Number/15.7.4.7-1.js create mode 100644 tests/mozilla/ecma_3/NumberFormatting/tostring-001.js create mode 100644 tests/mozilla/ecma_3/Object/8.6.2.6-001.js create mode 100644 tests/mozilla/ecma_3/Object/class-001.js create mode 100644 tests/mozilla/ecma_3/Object/class-002.js create mode 100644 tests/mozilla/ecma_3/Object/class-003.js create mode 100644 tests/mozilla/ecma_3/Object/class-004.js create mode 100644 tests/mozilla/ecma_3/Object/class-005.js create mode 100644 tests/mozilla/ecma_3/Object/regress-72773.js create mode 100644 tests/mozilla/ecma_3/Object/regress-79129-001.js create mode 100644 tests/mozilla/ecma_3/Object/shell.js create mode 100644 tests/mozilla/ecma_3/Operators/11.13.1-001.js create mode 100644 tests/mozilla/ecma_3/Operators/11.4.1-001.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.2-1.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.3.1-1.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.3.1-2.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.4.1-1.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.4.1-2.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.4.1-3.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.4.1-4.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.4.1-5-n.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.6.2-1.js create mode 100644 tests/mozilla/ecma_3/RegExp/15.10.6.2-2.js create mode 100644 tests/mozilla/ecma_3/RegExp/octal-001.js create mode 100644 tests/mozilla/ecma_3/RegExp/octal-002.js create mode 100644 tests/mozilla/ecma_3/RegExp/perlstress-001.js create mode 100644 tests/mozilla/ecma_3/RegExp/perlstress-002.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-100199.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-103087.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-105972.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-119909.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-122076.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-123437.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-165353.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-169497.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-169534.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-187133.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-188206.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-191479.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-202564.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-209067.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-209919.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-216591.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-220367-001.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-220367-002.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-24712.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-28686.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-31316.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-57572.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-57631.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-67773.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-72964.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-76683.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-78156.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-85721.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-87231.js create mode 100644 tests/mozilla/ecma_3/RegExp/regress-98306.js create mode 100644 tests/mozilla/ecma_3/RegExp/shell.js create mode 100644 tests/mozilla/ecma_3/Statements/regress-121744.js create mode 100644 tests/mozilla/ecma_3/Statements/regress-131348.js create mode 100644 tests/mozilla/ecma_3/Statements/regress-157509.js create mode 100644 tests/mozilla/ecma_3/Statements/regress-194364.js create mode 100644 tests/mozilla/ecma_3/Statements/regress-74474-001.js create mode 100644 tests/mozilla/ecma_3/Statements/regress-74474-002.js create mode 100644 tests/mozilla/ecma_3/Statements/regress-74474-003.js create mode 100644 tests/mozilla/ecma_3/Statements/regress-83532-001.js create mode 100644 tests/mozilla/ecma_3/Statements/regress-83532-002.js create mode 100644 tests/mozilla/ecma_3/Statements/switch-001.js create mode 100644 tests/mozilla/ecma_3/String/regress-104375.js create mode 100644 tests/mozilla/ecma_3/String/regress-189898.js create mode 100644 tests/mozilla/ecma_3/String/regress-83293.js create mode 100644 tests/mozilla/ecma_3/Unicode/uc-001-n.js create mode 100644 tests/mozilla/ecma_3/Unicode/uc-001.js create mode 100644 tests/mozilla/ecma_3/Unicode/uc-002-n.js create mode 100644 tests/mozilla/ecma_3/Unicode/uc-002.js create mode 100644 tests/mozilla/ecma_3/Unicode/uc-003.js create mode 100644 tests/mozilla/ecma_3/Unicode/uc-004.js create mode 100644 tests/mozilla/ecma_3/Unicode/uc-005.js create mode 100644 tests/mozilla/ecma_3/shell.js create mode 100644 tests/mozilla/expected.html create mode 100644 tests/mozilla/importList.html create mode 100644 tests/mozilla/js1_1/browser.js create mode 100644 tests/mozilla/js1_1/jsref.js create mode 100644 tests/mozilla/js1_1/regress/function-001.js create mode 100644 tests/mozilla/js1_1/shell.js create mode 100644 tests/mozilla/js1_2/Array/array_split_1.js create mode 100644 tests/mozilla/js1_2/Array/general1.js create mode 100644 tests/mozilla/js1_2/Array/general2.js create mode 100644 tests/mozilla/js1_2/Array/slice.js create mode 100644 tests/mozilla/js1_2/Array/splice1.js create mode 100644 tests/mozilla/js1_2/Array/splice2.js create mode 100644 tests/mozilla/js1_2/Array/tostring_1.js create mode 100644 tests/mozilla/js1_2/Array/tostring_2.js create mode 100644 tests/mozilla/js1_2/Objects/toString-001.js create mode 100644 tests/mozilla/js1_2/String/charCodeAt.js create mode 100644 tests/mozilla/js1_2/String/concat.js create mode 100644 tests/mozilla/js1_2/String/match.js create mode 100644 tests/mozilla/js1_2/String/slice.js create mode 100644 tests/mozilla/js1_2/browser.js create mode 100644 tests/mozilla/js1_2/function/Function_object.js create mode 100644 tests/mozilla/js1_2/function/Number.js create mode 100644 tests/mozilla/js1_2/function/String.js create mode 100644 tests/mozilla/js1_2/function/definition-1.js create mode 100644 tests/mozilla/js1_2/function/function-001-n.js create mode 100644 tests/mozilla/js1_2/function/length.js create mode 100644 tests/mozilla/js1_2/function/nesting-1.js create mode 100644 tests/mozilla/js1_2/function/nesting.js create mode 100644 tests/mozilla/js1_2/function/regexparg-1.js create mode 100644 tests/mozilla/js1_2/function/regexparg-2-n.js create mode 100644 tests/mozilla/js1_2/function/tostring-1.js create mode 100644 tests/mozilla/js1_2/function/tostring-2.js create mode 100644 tests/mozilla/js1_2/jsref.js create mode 100644 tests/mozilla/js1_2/operator/equality.js create mode 100644 tests/mozilla/js1_2/operator/strictEquality.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_dollar_number.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_input.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_input_as_array.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_lastIndex.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_lastMatch.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_lastMatch_as_array.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_lastParen.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_lastParen_as_array.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_leftContext.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_leftContext_as_array.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_multiline.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_multiline_as_array.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_object.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_rightContext.js create mode 100644 tests/mozilla/js1_2/regexp/RegExp_rightContext_as_array.js create mode 100644 tests/mozilla/js1_2/regexp/alphanumeric.js create mode 100644 tests/mozilla/js1_2/regexp/asterisk.js create mode 100644 tests/mozilla/js1_2/regexp/backslash.js create mode 100644 tests/mozilla/js1_2/regexp/backspace.js create mode 100644 tests/mozilla/js1_2/regexp/beginLine.js create mode 100644 tests/mozilla/js1_2/regexp/character_class.js create mode 100644 tests/mozilla/js1_2/regexp/compile.js create mode 100644 tests/mozilla/js1_2/regexp/control_characters.js create mode 100644 tests/mozilla/js1_2/regexp/digit.js create mode 100644 tests/mozilla/js1_2/regexp/dot.js create mode 100644 tests/mozilla/js1_2/regexp/endLine.js create mode 100644 tests/mozilla/js1_2/regexp/everything.js create mode 100644 tests/mozilla/js1_2/regexp/exec.js create mode 100644 tests/mozilla/js1_2/regexp/flags.js create mode 100644 tests/mozilla/js1_2/regexp/global.js create mode 100644 tests/mozilla/js1_2/regexp/hexadecimal.js create mode 100644 tests/mozilla/js1_2/regexp/ignoreCase.js create mode 100644 tests/mozilla/js1_2/regexp/interval.js create mode 100644 tests/mozilla/js1_2/regexp/octal.js create mode 100644 tests/mozilla/js1_2/regexp/parentheses.js create mode 100644 tests/mozilla/js1_2/regexp/plus.js create mode 100644 tests/mozilla/js1_2/regexp/question_mark.js create mode 100644 tests/mozilla/js1_2/regexp/regress-6359.js create mode 100644 tests/mozilla/js1_2/regexp/regress-9141.js create mode 100644 tests/mozilla/js1_2/regexp/simple_form.js create mode 100644 tests/mozilla/js1_2/regexp/source.js create mode 100644 tests/mozilla/js1_2/regexp/special_characters.js create mode 100644 tests/mozilla/js1_2/regexp/string_replace.js create mode 100644 tests/mozilla/js1_2/regexp/string_search.js create mode 100644 tests/mozilla/js1_2/regexp/string_split.js create mode 100644 tests/mozilla/js1_2/regexp/test.js create mode 100644 tests/mozilla/js1_2/regexp/toString.js create mode 100644 tests/mozilla/js1_2/regexp/vertical_bar.js create mode 100644 tests/mozilla/js1_2/regexp/whitespace.js create mode 100644 tests/mozilla/js1_2/regexp/word_boundary.js create mode 100644 tests/mozilla/js1_2/regress/regress-144834.js create mode 100644 tests/mozilla/js1_2/regress/regress-7703.js create mode 100644 tests/mozilla/js1_2/shell.js create mode 100644 tests/mozilla/js1_2/statements/break.js create mode 100644 tests/mozilla/js1_2/statements/continue.js create mode 100644 tests/mozilla/js1_2/statements/do_while.js create mode 100644 tests/mozilla/js1_2/statements/switch.js create mode 100644 tests/mozilla/js1_2/statements/switch2.js create mode 100644 tests/mozilla/js1_2/version120/boolean-001.js create mode 100644 tests/mozilla/js1_2/version120/regress-99663.js create mode 100644 tests/mozilla/js1_2/version120/shell.js create mode 100644 tests/mozilla/js1_3/Boolean/boolean-001.js create mode 100644 tests/mozilla/js1_3/Script/delete-001.js create mode 100644 tests/mozilla/js1_3/Script/function-001-n.js create mode 100644 tests/mozilla/js1_3/Script/function-002.js create mode 100644 tests/mozilla/js1_3/Script/in-001.js create mode 100644 tests/mozilla/js1_3/Script/new-001.js create mode 100644 tests/mozilla/js1_3/Script/script-001.js create mode 100644 tests/mozilla/js1_3/Script/switch-001.js create mode 100644 tests/mozilla/js1_3/inherit/proto_1.js create mode 100644 tests/mozilla/js1_3/inherit/proto_10.js create mode 100644 tests/mozilla/js1_3/inherit/proto_11.js create mode 100644 tests/mozilla/js1_3/inherit/proto_12.js create mode 100644 tests/mozilla/js1_3/inherit/proto_2.js create mode 100644 tests/mozilla/js1_3/inherit/proto_3.js create mode 100644 tests/mozilla/js1_3/inherit/proto_4.js create mode 100644 tests/mozilla/js1_3/inherit/proto_5.js create mode 100644 tests/mozilla/js1_3/inherit/proto_6.js create mode 100644 tests/mozilla/js1_3/inherit/proto_7.js create mode 100644 tests/mozilla/js1_3/inherit/proto_8.js create mode 100644 tests/mozilla/js1_3/inherit/proto_9.js create mode 100644 tests/mozilla/js1_3/jsref.js create mode 100644 tests/mozilla/js1_3/regress/delete-001.js create mode 100644 tests/mozilla/js1_3/regress/function-001-n.js create mode 100644 tests/mozilla/js1_3/regress/function-002.js create mode 100644 tests/mozilla/js1_3/regress/in-001.js create mode 100644 tests/mozilla/js1_3/regress/new-001.js create mode 100644 tests/mozilla/js1_3/regress/switch-001.js create mode 100644 tests/mozilla/js1_3/shell.js create mode 100644 tests/mozilla/js1_3/template.js create mode 100644 tests/mozilla/js1_4/Eval/eval-001.js create mode 100644 tests/mozilla/js1_4/Eval/eval-002.js create mode 100644 tests/mozilla/js1_4/Eval/eval-003.js create mode 100644 tests/mozilla/js1_4/Functions/function-001.js create mode 100644 tests/mozilla/js1_4/Regress/date-001-n.js create mode 100644 tests/mozilla/js1_4/Regress/function-001.js create mode 100644 tests/mozilla/js1_4/Regress/function-002.js create mode 100644 tests/mozilla/js1_4/Regress/function-003.js create mode 100644 tests/mozilla/js1_4/Regress/function-004-n.js create mode 100644 tests/mozilla/js1_4/Regress/regress-7224.js create mode 100644 tests/mozilla/js1_4/Regress/toString-001-n.js create mode 100644 tests/mozilla/js1_4/browser.js create mode 100644 tests/mozilla/js1_4/jsref.js create mode 100644 tests/mozilla/js1_4/shell.js create mode 100644 tests/mozilla/js1_5/Array/array-001.js create mode 100644 tests/mozilla/js1_5/Array/regress-101964.js create mode 100644 tests/mozilla/js1_5/Array/regress-107138.js create mode 100644 tests/mozilla/js1_5/Array/regress-108440.js create mode 100644 tests/mozilla/js1_5/Array/regress-154338.js create mode 100644 tests/mozilla/js1_5/Array/regress-157652.js create mode 100644 tests/mozilla/js1_5/Array/regress-178722.js create mode 100644 tests/mozilla/js1_5/Array/regress-94257.js create mode 100644 tests/mozilla/js1_5/Exceptions/catchguard-001-n.js create mode 100644 tests/mozilla/js1_5/Exceptions/catchguard-001.js create mode 100644 tests/mozilla/js1_5/Exceptions/catchguard-002-n.js create mode 100644 tests/mozilla/js1_5/Exceptions/catchguard-002.js create mode 100644 tests/mozilla/js1_5/Exceptions/catchguard-003-n.js create mode 100644 tests/mozilla/js1_5/Exceptions/catchguard-003.js create mode 100644 tests/mozilla/js1_5/Exceptions/errstack-001.js create mode 100644 tests/mozilla/js1_5/Exceptions/regress-121658.js create mode 100644 tests/mozilla/js1_5/Exceptions/regress-123002.js create mode 100644 tests/mozilla/js1_5/Exceptions/regress-50447.js create mode 100644 tests/mozilla/js1_5/Expressions/regress-192288.js create mode 100644 tests/mozilla/js1_5/Expressions/regress-96526-argsub.js create mode 100644 tests/mozilla/js1_5/Expressions/regress-96526-delelem.js create mode 100644 tests/mozilla/js1_5/Expressions/regress-96526-noargsub.js create mode 100644 tests/mozilla/js1_5/Expressions/shell.js create mode 100644 tests/mozilla/js1_5/GetSet/getset-001.js create mode 100644 tests/mozilla/js1_5/GetSet/getset-002.js create mode 100644 tests/mozilla/js1_5/GetSet/getset-003.js create mode 100644 tests/mozilla/js1_5/GetSet/getset-004.js create mode 100644 tests/mozilla/js1_5/GetSet/getset-005.js create mode 100644 tests/mozilla/js1_5/GetSet/getset-006.js create mode 100644 tests/mozilla/js1_5/LexicalConventions/lexical-001.js create mode 100644 tests/mozilla/js1_5/LexicalConventions/regress-177314.js create mode 100644 tests/mozilla/js1_5/Object/regress-137000.js create mode 100644 tests/mozilla/js1_5/Object/regress-192105.js create mode 100644 tests/mozilla/js1_5/Object/regress-90596-001.js create mode 100644 tests/mozilla/js1_5/Object/regress-90596-002.js create mode 100644 tests/mozilla/js1_5/Object/regress-90596-003.js create mode 100644 tests/mozilla/js1_5/Object/regress-96284-001.js create mode 100644 tests/mozilla/js1_5/Object/regress-96284-002.js create mode 100644 tests/mozilla/js1_5/Regress/regress-102725.js create mode 100644 tests/mozilla/js1_5/Regress/regress-103602.js create mode 100644 tests/mozilla/js1_5/Regress/regress-104077.js create mode 100644 tests/mozilla/js1_5/Regress/regress-110286.js create mode 100644 tests/mozilla/js1_5/Regress/regress-111557.js create mode 100644 tests/mozilla/js1_5/Regress/regress-114491.js create mode 100644 tests/mozilla/js1_5/Regress/regress-114493.js create mode 100644 tests/mozilla/js1_5/Regress/regress-118849.js create mode 100644 tests/mozilla/js1_5/Regress/regress-127557.js create mode 100644 tests/mozilla/js1_5/Regress/regress-131510-001.js create mode 100644 tests/mozilla/js1_5/Regress/regress-140974.js create mode 100644 tests/mozilla/js1_5/Regress/regress-146596.js create mode 100644 tests/mozilla/js1_5/Regress/regress-152646.js create mode 100644 tests/mozilla/js1_5/Regress/regress-156354.js create mode 100644 tests/mozilla/js1_5/Regress/regress-159334.js create mode 100644 tests/mozilla/js1_5/Regress/regress-168347.js create mode 100644 tests/mozilla/js1_5/Regress/regress-170193.js create mode 100644 tests/mozilla/js1_5/Regress/regress-172699.js create mode 100644 tests/mozilla/js1_5/Regress/regress-179524.js create mode 100644 tests/mozilla/js1_5/Regress/regress-185165.js create mode 100644 tests/mozilla/js1_5/Regress/regress-191633.js create mode 100644 tests/mozilla/js1_5/Regress/regress-191668.js create mode 100644 tests/mozilla/js1_5/Regress/regress-192414.js create mode 100644 tests/mozilla/js1_5/Regress/regress-192465.js create mode 100644 tests/mozilla/js1_5/Regress/regress-193418.js create mode 100644 tests/mozilla/js1_5/Regress/regress-203402.js create mode 100644 tests/mozilla/js1_5/Regress/regress-203841.js create mode 100644 tests/mozilla/js1_5/Regress/regress-204210.js create mode 100644 tests/mozilla/js1_5/Regress/regress-210682.js create mode 100644 tests/mozilla/js1_5/Regress/regress-216320.js create mode 100644 tests/mozilla/js1_5/Regress/regress-31255.js create mode 100644 tests/mozilla/js1_5/Regress/regress-39309.js create mode 100644 tests/mozilla/js1_5/Regress/regress-44009.js create mode 100644 tests/mozilla/js1_5/Regress/regress-57043.js create mode 100644 tests/mozilla/js1_5/Regress/regress-68498-001.js create mode 100644 tests/mozilla/js1_5/Regress/regress-68498-002.js create mode 100644 tests/mozilla/js1_5/Regress/regress-68498-003.js create mode 100644 tests/mozilla/js1_5/Regress/regress-68498-004.js create mode 100644 tests/mozilla/js1_5/Regress/regress-69607.js create mode 100644 tests/mozilla/js1_5/Regress/regress-71107.js create mode 100644 tests/mozilla/js1_5/Regress/regress-76054.js create mode 100644 tests/mozilla/js1_5/Regress/regress-80981.js create mode 100644 tests/mozilla/js1_5/Regress/regress-82306.js create mode 100644 tests/mozilla/js1_5/Regress/regress-89443.js create mode 100644 tests/mozilla/js1_5/Regress/regress-89474.js create mode 100644 tests/mozilla/js1_5/Regress/regress-90445.js create mode 100644 tests/mozilla/js1_5/Regress/regress-96128-n.js create mode 100644 tests/mozilla/js1_5/Regress/regress-96526-001.js create mode 100644 tests/mozilla/js1_5/Regress/regress-96526-002.js create mode 100644 tests/mozilla/js1_5/Regress/regress-96526-003.js create mode 100644 tests/mozilla/js1_5/Scope/regress-154693.js create mode 100644 tests/mozilla/js1_5/Scope/regress-181834.js create mode 100644 tests/mozilla/js1_5/Scope/regress-184107.js create mode 100644 tests/mozilla/js1_5/Scope/regress-185485.js create mode 100644 tests/mozilla/js1_5/Scope/regress-191276.js create mode 100644 tests/mozilla/js1_5/Scope/regress-192226.js create mode 100644 tests/mozilla/js1_5/Scope/regress-202678-001.js create mode 100644 tests/mozilla/js1_5/Scope/regress-202678-002.js create mode 100644 tests/mozilla/js1_5/Scope/regress-208496-001.js create mode 100644 tests/mozilla/js1_5/Scope/regress-208496-002.js create mode 100644 tests/mozilla/js1_5/Scope/regress-220362.js create mode 100644 tests/mozilla/js1_5/Scope/regress-220584.js create mode 100644 tests/mozilla/js1_5/Scope/regress-77578-001.js create mode 100644 tests/mozilla/js1_5/Scope/scope-001.js create mode 100644 tests/mozilla/js1_5/Scope/scope-002.js create mode 100644 tests/mozilla/js1_5/Scope/scope-003.js create mode 100644 tests/mozilla/js1_5/Scope/scope-004.js create mode 100644 tests/mozilla/js1_5/String/regress-107771.js create mode 100644 tests/mozilla/js1_5/String/regress-179068.js create mode 100644 tests/mozilla/js1_5/shell.js create mode 100644 tests/mozilla/js1_6/Array/browser.js create mode 100644 tests/mozilla/js1_6/Array/regress-290592.js create mode 100644 tests/mozilla/js1_6/Array/regress-304828.js create mode 100644 tests/mozilla/js1_6/Array/regress-305002.js create mode 100644 tests/mozilla/js1_6/Array/regress-310425-01.js create mode 100644 tests/mozilla/js1_6/Array/regress-310425-02.js create mode 100644 tests/mozilla/js1_6/Array/regress-320887.js create mode 100644 tests/mozilla/js1_6/Array/shell.js create mode 100644 tests/mozilla/js1_6/README create mode 100644 tests/mozilla/js1_6/Regress/browser.js create mode 100644 tests/mozilla/js1_6/Regress/regress-301574.js create mode 100644 tests/mozilla/js1_6/Regress/regress-309242.js create mode 100644 tests/mozilla/js1_6/Regress/regress-311157-01.js create mode 100644 tests/mozilla/js1_6/Regress/regress-311157-02.js create mode 100644 tests/mozilla/js1_6/Regress/regress-314887.js create mode 100644 tests/mozilla/js1_6/Regress/regress-320172.js create mode 100644 tests/mozilla/js1_6/Regress/shell.js create mode 100644 tests/mozilla/js1_6/String/browser.js create mode 100644 tests/mozilla/js1_6/String/regress-306591.js create mode 100644 tests/mozilla/js1_6/String/shell.js create mode 100644 tests/mozilla/js1_6/browser.js create mode 100644 tests/mozilla/js1_6/shell.js create mode 100644 tests/mozilla/js1_6/template.js create mode 100644 tests/mozilla/jsDriver.pl create mode 100644 tests/mozilla/menufoot.html create mode 100644 tests/mozilla/menuhead.html create mode 100644 tests/mozilla/mkhtml.pl create mode 100644 tests/mozilla/mklistpage.pl create mode 100644 tests/mozilla/runtests.pl create mode 100644 tests/mozilla/template.js create mode 100644 wtf/ASCIICType.h create mode 100644 wtf/AlwaysInline.h create mode 100644 wtf/Assertions.cpp create mode 100644 wtf/Assertions.h create mode 100644 wtf/Deque.h create mode 100644 wtf/DisallowCType.h create mode 100644 wtf/FastMalloc.cpp create mode 100644 wtf/FastMalloc.h create mode 100644 wtf/Forward.h create mode 100644 wtf/GetPtr.h create mode 100644 wtf/HashCountedSet.h create mode 100644 wtf/HashFunctions.h create mode 100644 wtf/HashIterators.h create mode 100644 wtf/HashMap.h create mode 100644 wtf/HashSet.h create mode 100644 wtf/HashTable.cpp create mode 100644 wtf/HashTable.h create mode 100644 wtf/HashTraits.h create mode 100644 wtf/ListHashSet.h create mode 100644 wtf/ListRefPtr.h create mode 100644 wtf/MallocZoneSupport.h create mode 100644 wtf/MathExtras.h create mode 100644 wtf/Noncopyable.h create mode 100644 wtf/OwnArrayPtr.h create mode 100644 wtf/OwnPtr.h create mode 100755 wtf/OwnPtrWin.cpp create mode 100644 wtf/PassRefPtr.h create mode 100644 wtf/Platform.h create mode 100644 wtf/RefCounted.h create mode 100644 wtf/RefPtr.h create mode 100644 wtf/RefPtrHashMap.h create mode 100644 wtf/RetainPtr.h create mode 100644 wtf/StringExtras.h create mode 100644 wtf/TCPackedCache.h create mode 100644 wtf/TCPageMap.h create mode 100644 wtf/TCSpinLock.h create mode 100644 wtf/TCSystemAlloc.cpp create mode 100644 wtf/TCSystemAlloc.h create mode 100644 wtf/UnusedParam.h create mode 100644 wtf/Vector.h create mode 100644 wtf/VectorTraits.h create mode 100644 wtf/unicode/UTF8.cpp create mode 100644 wtf/unicode/UTF8.h create mode 100644 wtf/unicode/Unicode.h create mode 100644 wtf/unicode/icu/UnicodeIcu.h create mode 100644 wtf/unicode/qt4/UnicodeQt4.h diff --git a/API/APICast.h b/API/APICast.h new file mode 100644 index 0000000..d8c7c18 --- /dev/null +++ b/API/APICast.h @@ -0,0 +1,120 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef APICast_h +#define APICast_h + +#include "ustring.h" +#include "ExecState.h" + +namespace KJS { + class ExecState; + class JSValue; + class JSObject; + class PropertyNameArray; +} + +typedef const struct OpaqueJSContext* JSContextRef; +typedef struct OpaqueJSContext* JSGlobalContextRef; +typedef struct OpaqueJSString* JSStringRef; +typedef struct OpaqueJSPropertyNameAccumulator* JSPropertyNameAccumulatorRef; +typedef const struct OpaqueJSValue* JSValueRef; +typedef struct OpaqueJSValue* JSObjectRef; + +/* Opaque typing convenience methods */ + +inline KJS::ExecState* toJS(JSContextRef c) +{ + return reinterpret_cast(const_cast(c)); +} + +inline KJS::ExecState* toJS(JSGlobalContextRef c) +{ + return reinterpret_cast(c); +} + +inline KJS::JSValue* toJS(JSValueRef v) +{ + return reinterpret_cast(const_cast(v)); +} + +inline KJS::UString::Rep* toJS(JSStringRef b) +{ + return reinterpret_cast(b); +} + +inline KJS::JSObject* toJS(JSObjectRef o) +{ + return reinterpret_cast(o); +} + +inline KJS::PropertyNameArray* toJS(JSPropertyNameAccumulatorRef a) +{ + return reinterpret_cast(a); +} + +inline JSValueRef toRef(KJS::JSValue* v) +{ + return reinterpret_cast(v); +} + +inline JSValueRef* toRef(KJS::JSValue** v) +{ + return reinterpret_cast(const_cast(v)); +} + +inline JSStringRef toRef(KJS::UString::Rep* s) +{ + return reinterpret_cast(s); +} + +inline JSObjectRef toRef(KJS::JSObject* o) +{ + return reinterpret_cast(o); +} + +inline JSObjectRef toRef(const KJS::JSObject* o) +{ + return reinterpret_cast(const_cast(o)); +} + +inline JSContextRef toRef(KJS::ExecState* e) +{ + return reinterpret_cast(e); +} + +inline JSGlobalContextRef toGlobalRef(KJS::ExecState* e) +{ + ASSERT(!e->callingExecState()); + return reinterpret_cast(e); +} + +inline JSPropertyNameAccumulatorRef toRef(KJS::PropertyNameArray* l) +{ + return reinterpret_cast(l); +} + +#endif // APICast_h diff --git a/API/JSBase.cpp b/API/JSBase.cpp new file mode 100644 index 0000000..d8acc42 --- /dev/null +++ b/API/JSBase.cpp @@ -0,0 +1,87 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSBase.h" + +#include "APICast.h" +#include +#include +#include +#include +#include + +using namespace KJS; + +JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSObject* jsThisObject = toJS(thisObject); + UString::Rep* scriptRep = toJS(script); + UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; + // Interpreter::evaluate sets "this" to the global object if it is NULL + Completion completion = Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), UString(sourceURLRep), startingLineNumber, UString(scriptRep), jsThisObject); + + if (completion.complType() == Throw) { + if (exception) + *exception = toRef(completion.value()); + return 0; + } + + if (completion.value()) + return toRef(completion.value()); + + // happens, for example, when the only statement is an empty (';') statement + return toRef(jsUndefined()); +} + +bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) +{ + JSLock lock; + + ExecState* exec = toJS(ctx); + UString::Rep* scriptRep = toJS(script); + UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; + Completion completion = Interpreter::checkSyntax(exec->dynamicGlobalObject()->globalExec(), UString(sourceURLRep), startingLineNumber, UString(scriptRep)); + if (completion.complType() == Throw) { + if (exception) + *exception = toRef(completion.value()); + return false; + } + + return true; +} + +void JSGarbageCollect(JSContextRef) +{ + JSLock lock; + if (!Collector::isBusy()) + Collector::collect(); + // FIXME: Perhaps we should trigger a second mark and sweep + // once the garbage collector is done if this is called when + // the collector is busy. +} diff --git a/API/JSBase.h b/API/JSBase.h new file mode 100644 index 0000000..7cf7c7d --- /dev/null +++ b/API/JSBase.h @@ -0,0 +1,125 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSBase_h +#define JSBase_h + +#include + +/* JavaScript engine interface */ + +/*! @typedef JSContextRef A JavaScript execution context. Holds the global object and other execution state. */ +typedef const struct OpaqueJSContext* JSContextRef; + +/*! @typedef JSGlobalContextRef A global JavaScript execution context. A JSGlobalContext is a JSContext. */ +typedef struct OpaqueJSContext* JSGlobalContextRef; + +/*! @typedef JSStringRef A UTF16 character buffer. The fundamental string representation in JavaScript. */ +typedef struct OpaqueJSString* JSStringRef; + +/*! @typedef JSClassRef A JavaScript class. Used with JSObjectMake to construct objects with custom behavior. */ +typedef struct OpaqueJSClass* JSClassRef; + +/*! @typedef JSPropertyNameArrayRef An array of JavaScript property names. */ +typedef struct OpaqueJSPropertyNameArray* JSPropertyNameArrayRef; + +/*! @typedef JSPropertyNameAccumulatorRef An ordered set used to collect the names of a JavaScript object's properties. */ +typedef struct OpaqueJSPropertyNameAccumulator* JSPropertyNameAccumulatorRef; + + +/* JavaScript data types */ + +/*! @typedef JSValueRef A JavaScript value. The base type for all JavaScript values, and polymorphic functions on them. */ +typedef const struct OpaqueJSValue* JSValueRef; + +/*! @typedef JSObjectRef A JavaScript object. A JSObject is a JSValue. */ +typedef struct OpaqueJSValue* JSObjectRef; + +/* JavaScript symbol exports */ + +#undef JS_EXPORT +#if defined(__GNUC__) + #define JS_EXPORT __attribute__((visibility("default"))) +#elif defined(WIN32) || defined(_WIN32) + // TODO: Export symbols with JS_EXPORT when using MSVC. + // See http://bugs.webkit.org/show_bug.cgi?id=16227 + #define JS_EXPORT +#else + #define JS_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Script Evaluation */ + +/*! +@function +@abstract Evaluates a string of JavaScript. +@param ctx The execution context to use. +@param script A JSString containing the script to evaluate. +@param thisObject The object to use as "this," or NULL to use the global object as "this." +@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. +@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The JSValue that results from evaluating script, or NULL if an exception is thrown. +*/ +JS_EXPORT JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); + +/*! +@function JSCheckScriptSyntax +@abstract Checks for syntax errors in a string of JavaScript. +@param ctx The execution context to use. +@param script A JSString containing the script to check for syntax errors. +@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. +@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. +@param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception. +@result true if the script is syntactically correct, otherwise false. +*/ +JS_EXPORT bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); + +/*! +@function +@abstract Performs a JavaScript garbage collection. +@param ctx This parameter is currently unused. Pass NULL. +@discussion JavaScript values that are on the machine stack, in a register, + protected by JSValueProtect, set as the global object of an execution context, + or reachable from any such value will not be collected. + + During JavaScript execution, you are not required to call this function; the + JavaScript engine will garbage collect as needed. One place you may want to call + this function, however, is after releasing the last reference to a JSGlobalContextRef. + At that point, a garbage collection can free the objects still referenced by the + JSGlobalContextRef's global object, along with the global object itself. +*/ +JS_EXPORT void JSGarbageCollect(JSContextRef ctx); + +#ifdef __cplusplus +} +#endif + +#endif // JSBase_h diff --git a/API/JSCallbackConstructor.cpp b/API/JSCallbackConstructor.cpp new file mode 100644 index 0000000..46c1823 --- /dev/null +++ b/API/JSCallbackConstructor.cpp @@ -0,0 +1,82 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSCallbackConstructor.h" + +#include "APICast.h" +#include +#include +#include + +namespace KJS { + +const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0}; + +JSCallbackConstructor::JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback) + : JSObject(exec->lexicalGlobalObject()->objectPrototype()) + , m_class(jsClass) + , m_callback(callback) +{ + if (m_class) + JSClassRetain(jsClass); +} + +JSCallbackConstructor::~JSCallbackConstructor() +{ + if (m_class) + JSClassRelease(m_class); +} + +bool JSCallbackConstructor::implementsHasInstance() const +{ + return true; +} + +bool JSCallbackConstructor::implementsConstruct() const +{ + return true; +} + +JSObject* JSCallbackConstructor::construct(ExecState* exec, const List &args) +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + + if (m_callback) { + int argumentCount = static_cast(args.size()); + Vector arguments(argumentCount); + for (int i = 0; i < argumentCount; i++) + arguments[i] = toRef(args[i]); + + JSLock::DropAllLocks dropAllLocks; + return toJS(m_callback(ctx, thisRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + } + + return toJS(JSObjectMake(ctx, m_class, 0)); +} + +} // namespace KJS diff --git a/API/JSCallbackConstructor.h b/API/JSCallbackConstructor.h new file mode 100644 index 0000000..fc45cb5 --- /dev/null +++ b/API/JSCallbackConstructor.h @@ -0,0 +1,59 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSCallbackConstructor_h +#define JSCallbackConstructor_h + +#include "JSObjectRef.h" +#include + +namespace KJS { + +class JSCallbackConstructor : public JSObject +{ +public: + JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback); + virtual ~JSCallbackConstructor(); + + virtual bool implementsHasInstance() const; + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List &args); + + virtual const ClassInfo *classInfo() const { return &info; } + static const ClassInfo info; + +private: + JSCallbackConstructor(); // prevent default construction + JSCallbackConstructor(const JSCallbackConstructor&); + + JSClassRef m_class; + JSObjectCallAsConstructorCallback m_callback; +}; + +} // namespace KJS + +#endif // JSCallbackConstructor_h diff --git a/API/JSCallbackFunction.cpp b/API/JSCallbackFunction.cpp new file mode 100644 index 0000000..fb3937d --- /dev/null +++ b/API/JSCallbackFunction.cpp @@ -0,0 +1,68 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include +#include "JSCallbackFunction.h" + +#include "APICast.h" +#include "function.h" +#include "function_object.h" +#include +#include + +namespace KJS { + +const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunctionImp::info, 0}; + +JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name) + : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name) + , m_callback(callback) +{ +} + +// InternalFunctionImp mish-mashes constructor and function behavior -- we should +// refactor the code so this override isn't necessary +bool JSCallbackFunction::implementsHasInstance() const { + return false; +} + +JSValue* JSCallbackFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef thisRef = toRef(this); + JSObjectRef thisObjRef = toRef(thisObj); + + int argumentCount = static_cast(args.size()); + Vector arguments(argumentCount); + for (int i = 0; i < argumentCount; i++) + arguments[i] = toRef(args[i]); + + JSLock::DropAllLocks dropAllLocks; + return toJS(m_callback(execRef, thisRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); +} + +} // namespace KJS diff --git a/API/JSCallbackFunction.h b/API/JSCallbackFunction.h new file mode 100644 index 0000000..48be3d2 --- /dev/null +++ b/API/JSCallbackFunction.h @@ -0,0 +1,56 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSCallbackFunction_h +#define JSCallbackFunction_h + +#include "JSObjectRef.h" +#include "function.h" +#include "object.h" + +namespace KJS { + +class JSCallbackFunction : public InternalFunctionImp +{ +public: + JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name); + + virtual bool implementsHasInstance() const; + virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List &args); + + virtual const ClassInfo *classInfo() const { return &info; } + static const ClassInfo info; + +private: + JSCallbackFunction(); // prevent default construction + JSCallbackFunction(const JSCallbackFunction&); + + JSObjectCallAsFunctionCallback m_callback; +}; + +} // namespace KJS + +#endif // JSCallbackFunction_h diff --git a/API/JSCallbackObject.cpp b/API/JSCallbackObject.cpp new file mode 100644 index 0000000..129b304 --- /dev/null +++ b/API/JSCallbackObject.cpp @@ -0,0 +1,41 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSCallbackObject.h" + +#include "collector.h" + +namespace KJS { + +// Define the two types of JSCallbackObjects we support. +template <> const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0 }; +template <> const ClassInfo JSCallbackObject::info = { "CallbackGlobalObject", 0, 0 }; + +COMPILE_ASSERT(sizeof(JSCallbackObject) <= CELL_SIZE, global_callback_object_fits_in_cell); + +} // namespace KJS diff --git a/API/JSCallbackObject.h b/API/JSCallbackObject.h new file mode 100644 index 0000000..7eb32a6 --- /dev/null +++ b/API/JSCallbackObject.h @@ -0,0 +1,95 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSCallbackObject_h +#define JSCallbackObject_h + +#include "JSObjectRef.h" +#include "JSValueRef.h" +#include "object.h" + +namespace KJS { + +template +class JSCallbackObject : public Base +{ +public: + JSCallbackObject(ExecState*, JSClassRef, JSValue* prototype, void* data); + JSCallbackObject(JSClassRef); + virtual ~JSCallbackObject(); + + virtual UString className() const; + + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual bool getOwnPropertySlot(ExecState*, unsigned, PropertySlot&); + + virtual void put(ExecState*, const Identifier&, JSValue*, int attr); + virtual void put(ExecState*, unsigned, JSValue*, int attr); + + virtual bool deleteProperty(ExecState*, const Identifier&); + virtual bool deleteProperty(ExecState*, unsigned); + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List& args); + + virtual bool implementsHasInstance() const; + virtual bool hasInstance(ExecState *exec, JSValue *value); + + virtual bool implementsCall() const; + virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List &args); + + virtual void getPropertyNames(ExecState*, PropertyNameArray&); + + virtual double toNumber(ExecState*) const; + virtual UString toString(ExecState*) const; + + void setPrivate(void* data); + void* getPrivate(); + + virtual const ClassInfo *classInfo() const { return &info; } + static const ClassInfo info; + + bool inherits(JSClassRef) const; + +private: + void init(ExecState*); + + static JSValue* cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + static JSValue* staticValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot); + static JSValue* staticFunctionGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot); + static JSValue* callbackGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + + void* m_privateData; + JSClassRef m_class; +}; + +} // namespace KJS + +// include the actual template class implementation +#include "JSCallbackObjectFunctions.h" + +#endif // JSCallbackObject_h diff --git a/API/JSCallbackObjectFunctions.h b/API/JSCallbackObjectFunctions.h new file mode 100644 index 0000000..f987dd8 --- /dev/null +++ b/API/JSCallbackObjectFunctions.h @@ -0,0 +1,495 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "APICast.h" +#include "JSCallbackFunction.h" +#include "JSClassRef.h" +#include "JSObjectRef.h" +#include "JSGlobalObject.h" +#include "JSStringRef.h" +#include "PropertyNameArray.h" +#include "internal.h" +#include + +namespace KJS { + +template +JSCallbackObject::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSValue* prototype, void* data) + : Base(prototype) + , m_privateData(data) + , m_class(JSClassRetain(jsClass)) +{ + init(exec); +} + +// Global object constructor. FIXME: Move this into a JSGlobalCallbackObject subclass. +template +JSCallbackObject::JSCallbackObject(JSClassRef jsClass) + : m_privateData(0) + , m_class(JSClassRetain(jsClass)) +{ + ASSERT(Base::isGlobalObject()); + init(static_cast(this)->globalExec()); +} + +template +void JSCallbackObject::init(ExecState* exec) +{ + ASSERT(exec); + + Vector initRoutines; + JSClassRef jsClass = m_class; + do { + if (JSObjectInitializeCallback initialize = jsClass->initialize) + initRoutines.append(initialize); + } while ((jsClass = jsClass->parentClass)); + + // initialize from base to derived + for (int i = static_cast(initRoutines.size()) - 1; i >= 0; i--) { + JSLock::DropAllLocks dropAllLocks; + JSObjectInitializeCallback initialize = initRoutines[i]; + initialize(toRef(exec), toRef(this)); + } +} + +template +JSCallbackObject::~JSCallbackObject() +{ + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + if (JSObjectFinalizeCallback finalize = jsClass->finalize) { + finalize(thisRef); + } + + JSClassRelease(m_class); +} + +template +UString JSCallbackObject::className() const +{ + if (!m_class->className.isNull()) + return m_class->className; + + return Base::className(); +} + +template +bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + // optional optimization to bypass getProperty in cases when we only need to know if the property exists + if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) { + JSLock::DropAllLocks dropAllLocks; + if (hasProperty(ctx, thisRef, propertyNameRef)) { + slot.setCustom(this, callbackGetter); + return true; + } + } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { + JSLock::DropAllLocks dropAllLocks; + if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) { + // cache the value so we don't have to compute it again + // FIXME: This violates the PropertySlot design a little bit. + // We should either use this optimization everywhere, or nowhere. + slot.setCustom(reinterpret_cast(toJS(value)), cachedValueGetter); + return true; + } + } + + if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) { + if (staticValues->contains(propertyName.ustring().rep())) { + slot.setCustom(this, staticValueGetter); + return true; + } + } + + if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { + if (staticFunctions->contains(propertyName.ustring().rep())) { + slot.setCustom(this, staticFunctionGetter); + return true; + } + } + } + + return Base::getOwnPropertySlot(exec, propertyName, slot); +} + +template +bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + return getOwnPropertySlot(exec, Identifier::from(propertyName), slot); +} + +template +void JSCallbackObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + JSValueRef valueRef = toRef(value); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { + JSLock::DropAllLocks dropAllLocks; + if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()))) + return; + } + + if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) { + if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) { + if (entry->attributes & kJSPropertyAttributeReadOnly) + return; + if (JSObjectSetPropertyCallback setProperty = entry->setProperty) { + JSLock::DropAllLocks dropAllLocks; + if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()))) + return; + } else + throwError(exec, ReferenceError, "Attempt to set a property that is not settable."); + } + } + + if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { + if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { + if (entry->attributes & kJSPropertyAttributeReadOnly) + return; + JSCallbackObject::putDirect(propertyName, value, attr); // put as override property + return; + } + } + } + + return Base::put(exec, propertyName, value, attr); +} + +template +void JSCallbackObject::put(ExecState* exec, unsigned propertyName, JSValue* value, int attr) +{ + return put(exec, Identifier::from(propertyName), value, attr); +} + +template +bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& propertyName) +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { + JSLock::DropAllLocks dropAllLocks; + if (deleteProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) + return true; + } + + if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) { + if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) { + if (entry->attributes & kJSPropertyAttributeDontDelete) + return false; + return true; + } + } + + if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { + if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { + if (entry->attributes & kJSPropertyAttributeDontDelete) + return false; + return true; + } + } + } + + return Base::deleteProperty(exec, propertyName); +} + +template +bool JSCallbackObject::deleteProperty(ExecState* exec, unsigned propertyName) +{ + return deleteProperty(exec, Identifier::from(propertyName)); +} + +template +bool JSCallbackObject::implementsConstruct() const +{ + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + if (jsClass->callAsConstructor) + return true; + + return false; +} + +template +JSObject* JSCallbackObject::construct(ExecState* exec, const List& args) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) { + int argumentCount = static_cast(args.size()); + Vector arguments(argumentCount); + for (int i = 0; i < argumentCount; i++) + arguments[i] = toRef(args[i]); + JSLock::DropAllLocks dropAllLocks; + return toJS(callAsConstructor(execRef, thisRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + } + } + + ASSERT(0); // implementsConstruct should prevent us from reaching here + return 0; +} + +template +bool JSCallbackObject::implementsHasInstance() const +{ + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + if (jsClass->hasInstance) + return true; + + return false; +} + +template +bool JSCallbackObject::hasInstance(ExecState *exec, JSValue *value) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) { + JSLock::DropAllLocks dropAllLocks; + return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot())); + } + + ASSERT_NOT_REACHED(); // implementsHasInstance should prevent us from reaching here + return 0; +} + + +template +bool JSCallbackObject::implementsCall() const +{ + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + if (jsClass->callAsFunction) + return true; + + return false; +} + +template +JSValue* JSCallbackObject::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef thisRef = toRef(this); + JSObjectRef thisObjRef = toRef(thisObj); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) { + int argumentCount = static_cast(args.size()); + Vector arguments(argumentCount); + for (int i = 0; i < argumentCount; i++) + arguments[i] = toRef(args[i]); + JSLock::DropAllLocks dropAllLocks; + return toJS(callAsFunction(execRef, thisRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + } + } + + ASSERT_NOT_REACHED(); // implementsCall should prevent us from reaching here + return 0; +} + +template +void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) { + JSLock::DropAllLocks dropAllLocks; + getPropertyNames(execRef, thisRef, toRef(&propertyNames)); + } + + if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) { + typedef OpaqueJSClass::StaticValuesTable::const_iterator iterator; + iterator end = staticValues->end(); + for (iterator it = staticValues->begin(); it != end; ++it) { + UString::Rep* name = it->first.get(); + StaticValueEntry* entry = it->second; + if (entry->getProperty && !(entry->attributes & kJSPropertyAttributeDontEnum)) + propertyNames.add(Identifier(name)); + } + } + + if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { + typedef OpaqueJSClass::StaticFunctionsTable::const_iterator iterator; + iterator end = staticFunctions->end(); + for (iterator it = staticFunctions->begin(); it != end; ++it) { + UString::Rep* name = it->first.get(); + StaticFunctionEntry* entry = it->second; + if (!(entry->attributes & kJSPropertyAttributeDontEnum)) + propertyNames.add(Identifier(name)); + } + } + } + + Base::getPropertyNames(exec, propertyNames); +} + +template +double JSCallbackObject::toNumber(ExecState* exec) const +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { + JSLock::DropAllLocks dropAllLocks; + if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot()))) + return toJS(value)->getNumber(); + } + + return Base::toNumber(exec); +} + +template +UString JSCallbackObject::toString(ExecState* exec) const +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { + JSLock::DropAllLocks dropAllLocks; + if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot()))) + return toJS(value)->getString(); + } + + return Base::toString(exec); +} + +template +void JSCallbackObject::setPrivate(void* data) +{ + m_privateData = data; +} + +template +void* JSCallbackObject::getPrivate() +{ + return m_privateData; +} + +template +bool JSCallbackObject::inherits(JSClassRef c) const +{ + for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + if (jsClass == c) + return true; + + return false; +} + +template +JSValue* JSCallbackObject::cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) +{ + JSValue* v = slot.slotBase(); + ASSERT(v); + return v; +} + +template +JSValue* JSCallbackObject::staticValueGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) +{ + ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info)); + JSCallbackObject* thisObj = static_cast(slot.slotBase()); + + JSObjectRef thisRef = toRef(thisObj); + JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + + for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) + if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) + if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) + if (JSObjectGetPropertyCallback getProperty = entry->getProperty) { + JSLock::DropAllLocks dropAllLocks; + if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) + return toJS(value); + } + + return throwError(exec, ReferenceError, "Static value property defined with NULL getProperty callback."); +} + +template +JSValue* JSCallbackObject::staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) +{ + ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info)); + JSCallbackObject* thisObj = static_cast(slot.slotBase()); + + // Check for cached or override property. + PropertySlot slot2; + if (thisObj->Base::getOwnPropertySlot(exec, propertyName, slot2)) + return slot2.getValue(exec, thisObj, propertyName); + + for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) { + if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { + if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { + if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) { + JSObject* o = new JSCallbackFunction(exec, callAsFunction, propertyName); + thisObj->putDirect(propertyName, o, entry->attributes); + return o; + } + } + } + } + + return throwError(exec, ReferenceError, "Static function property defined with NULL callAsFunction callback."); +} + +template +JSValue* JSCallbackObject::callbackGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) +{ + ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info)); + JSCallbackObject* thisObj = static_cast(slot.slotBase()); + + JSObjectRef thisRef = toRef(thisObj); + JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + + for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) + if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { + JSLock::DropAllLocks dropAllLocks; + if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) + return toJS(value); + } + + return throwError(exec, ReferenceError, "hasProperty callback returned true for a property that doesn't exist."); +} + +} // namespace KJS diff --git a/API/JSClassRef.cpp b/API/JSClassRef.cpp new file mode 100644 index 0000000..98aaaf5 --- /dev/null +++ b/API/JSClassRef.cpp @@ -0,0 +1,164 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSClassRef.h" + +#include "APICast.h" +#include "JSCallbackObject.h" +#include "JSObjectRef.h" +#include +#include +#include + +using namespace KJS; + +const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* protoClass) + // FIXME: + : className(definition->className) + , parentClass(definition->parentClass) + , prototypeClass(0) + , staticValues(0) + , staticFunctions(0) + , initialize(definition->initialize) + , finalize(definition->finalize) + , hasProperty(definition->hasProperty) + , getProperty(definition->getProperty) + , setProperty(definition->setProperty) + , deleteProperty(definition->deleteProperty) + , getPropertyNames(definition->getPropertyNames) + , callAsFunction(definition->callAsFunction) + , callAsConstructor(definition->callAsConstructor) + , hasInstance(definition->hasInstance) + , convertToType(definition->convertToType) + , cachedPrototype(0) +{ + if (const JSStaticValue* staticValue = definition->staticValues) { + staticValues = new StaticValuesTable(); + while (staticValue->name) { + // FIXME: + staticValues->add(Identifier(staticValue->name).ustring().rep(), + new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes)); + ++staticValue; + } + } + + if (const JSStaticFunction* staticFunction = definition->staticFunctions) { + staticFunctions = new StaticFunctionsTable(); + while (staticFunction->name) { + // FIXME: + staticFunctions->add(Identifier(staticFunction->name).ustring().rep(), + new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes)); + ++staticFunction; + } + } + + if (protoClass) + prototypeClass = JSClassRetain(protoClass); +} + +OpaqueJSClass::~OpaqueJSClass() +{ + if (staticValues) { + deleteAllValues(*staticValues); + delete staticValues; + } + + if (staticFunctions) { + deleteAllValues(*staticFunctions); + delete staticFunctions; + } + + if (prototypeClass) + JSClassRelease(prototypeClass); +} + +JSClassRef OpaqueJSClass::createNoAutomaticPrototype(const JSClassDefinition* definition) +{ + return new OpaqueJSClass(definition, 0); +} + +void clearReferenceToPrototype(JSObjectRef prototype) +{ + OpaqueJSClass* jsClass = static_cast(JSObjectGetPrivate(prototype)); + ASSERT(jsClass); + jsClass->cachedPrototype = 0; +} + +JSClassRef OpaqueJSClass::create(const JSClassDefinition* definition) +{ + if (const JSStaticFunction* staticFunctions = definition->staticFunctions) { + // copy functions into a prototype class + JSClassDefinition protoDefinition = kJSClassDefinitionEmpty; + protoDefinition.staticFunctions = staticFunctions; + protoDefinition.finalize = clearReferenceToPrototype; + OpaqueJSClass* protoClass = new OpaqueJSClass(&protoDefinition, 0); + + // remove functions from the original class + JSClassDefinition objectDefinition = *definition; + objectDefinition.staticFunctions = 0; + return new OpaqueJSClass(&objectDefinition, protoClass); + } + + return new OpaqueJSClass(definition, 0); +} + +/*! +// Doc here in case we make this public. (Hopefully we won't.) +@function + @abstract Returns the prototype that will be used when constructing an object with a given class. + @param ctx The execution context to use. + @param jsClass A JSClass whose prototype you want to get. + @result The JSObject prototype that was automatically generated for jsClass, or NULL if no prototype was automatically generated. This is the prototype that will be used when constructing an object using jsClass. +*/ +JSObject* OpaqueJSClass::prototype(JSContextRef ctx) +{ + /* Class (C++) and prototype (JS) inheritance are parallel, so: + * (C++) | (JS) + * ParentClass | ParentClassPrototype + * ^ | ^ + * | | | + * DerivedClass | DerivedClassPrototype + */ + + if (!prototypeClass) + return 0; + + ExecState* exec = toJS(ctx); + + if (!cachedPrototype) { + // Recursive, but should be good enough for our purposes + JSObject* parentPrototype = 0; + if (parentClass) + parentPrototype = parentClass->prototype(ctx); // can be null + if (!parentPrototype) + parentPrototype = exec->dynamicGlobalObject()->objectPrototype(); + cachedPrototype = new JSCallbackObject(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction + } + return cachedPrototype; +} diff --git a/API/JSClassRef.h b/API/JSClassRef.h new file mode 100644 index 0000000..eb2b35b --- /dev/null +++ b/API/JSClassRef.h @@ -0,0 +1,97 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSClassRef_h +#define JSClassRef_h + +#include "JSObjectRef.h" + +#include +#include +#include +#include +#include + +struct StaticValueEntry { + StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes) + : getProperty(_getProperty), setProperty(_setProperty), attributes(_attributes) + { + } + + JSObjectGetPropertyCallback getProperty; + JSObjectSetPropertyCallback setProperty; + JSPropertyAttributes attributes; +}; + +struct StaticFunctionEntry { + StaticFunctionEntry(JSObjectCallAsFunctionCallback _callAsFunction, JSPropertyAttributes _attributes) + : callAsFunction(_callAsFunction), attributes(_attributes) + { + } + + JSObjectCallAsFunctionCallback callAsFunction; + JSPropertyAttributes attributes; +}; + +struct OpaqueJSClass : public RefCounted { + static OpaqueJSClass* create(const JSClassDefinition*); + static OpaqueJSClass* createNoAutomaticPrototype(const JSClassDefinition*); + ~OpaqueJSClass(); + + KJS::JSObject* prototype(JSContextRef ctx); + + typedef HashMap, StaticValueEntry*> StaticValuesTable; + typedef HashMap, StaticFunctionEntry*> StaticFunctionsTable; + + KJS::UString className; + OpaqueJSClass* parentClass; + OpaqueJSClass* prototypeClass; + + StaticValuesTable* staticValues; + StaticFunctionsTable* staticFunctions; + + JSObjectInitializeCallback initialize; + JSObjectFinalizeCallback finalize; + JSObjectHasPropertyCallback hasProperty; + JSObjectGetPropertyCallback getProperty; + JSObjectSetPropertyCallback setProperty; + JSObjectDeletePropertyCallback deleteProperty; + JSObjectGetPropertyNamesCallback getPropertyNames; + JSObjectCallAsFunctionCallback callAsFunction; + JSObjectCallAsConstructorCallback callAsConstructor; + JSObjectHasInstanceCallback hasInstance; + JSObjectConvertToTypeCallback convertToType; + +private: + OpaqueJSClass(); + OpaqueJSClass(const OpaqueJSClass&); + OpaqueJSClass(const JSClassDefinition*, OpaqueJSClass* protoClass); + + friend void clearReferenceToPrototype(JSObjectRef prototype); + KJS::JSObject* cachedPrototype; +}; + +#endif // JSClassRef_h diff --git a/API/JSContextRef.cpp b/API/JSContextRef.cpp new file mode 100644 index 0000000..203326e --- /dev/null +++ b/API/JSContextRef.cpp @@ -0,0 +1,76 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSContextRef.h" + +#include "APICast.h" +#include "JSCallbackObject.h" +#include "JSClassRef.h" +#include "JSGlobalObject.h" +#include "object.h" +#include + +using namespace KJS; + +JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) +{ + JSLock lock; + + if (!globalObjectClass) { + JSGlobalObject* globalObject = new JSGlobalObject; + return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec())); + } + + JSGlobalObject* globalObject = new JSCallbackObject(globalObjectClass); + JSGlobalContextRef ctx = toGlobalRef(globalObject->globalExec()); + JSValue* prototype = globalObjectClass->prototype(ctx); + if (!prototype) + prototype = jsNull(); + globalObject->reset(prototype); + return JSGlobalContextRetain(ctx); +} + +JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + gcProtect(exec->dynamicGlobalObject()); + return ctx; +} + +void JSGlobalContextRelease(JSGlobalContextRef ctx) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + gcUnprotect(exec->dynamicGlobalObject()); +} + +JSObjectRef JSContextGetGlobalObject(JSContextRef ctx) +{ + ExecState* exec = toJS(ctx); + return toRef(exec->dynamicGlobalObject()); +} diff --git a/API/JSContextRef.h b/API/JSContextRef.h new file mode 100644 index 0000000..df0a397 --- /dev/null +++ b/API/JSContextRef.h @@ -0,0 +1,77 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSContextRef_h +#define JSContextRef_h + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@function +@abstract Creates a global JavaScript execution context. +@discussion JSGlobalContextCreate allocates a global object and populates it with all the + built-in JavaScript objects, such as Object, Function, String, and Array. +@param globalObjectClass The class to use when creating the global object. Pass + NULL to use the default object class. +@result A JSGlobalContext with a global object of class globalObjectClass. +*/ +JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass); + +/*! +@function +@abstract Retains a global JavaScript execution context. +@param ctx The JSGlobalContext to retain. +@result A JSGlobalContext that is the same as ctx. +*/ +JS_EXPORT JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx); + +/*! +@function +@abstract Releases a global JavaScript execution context. +@param ctx The JSGlobalContext to release. +*/ +JS_EXPORT void JSGlobalContextRelease(JSGlobalContextRef ctx); + +/*! +@function +@abstract Gets the global object of a JavaScript execution context. +@param ctx The JSContext whose global object you want to get. +@result ctx's global object. +*/ +JS_EXPORT JSObjectRef JSContextGetGlobalObject(JSContextRef ctx); + +#ifdef __cplusplus +} +#endif + +#endif // JSContextRef_h diff --git a/API/JSNode.c b/API/JSNode.c new file mode 100644 index 0000000..c1f6294 --- /dev/null +++ b/API/JSNode.c @@ -0,0 +1,197 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "JSNode.h" +#include "JSNodeList.h" +#include "JSObjectRef.h" +#include "JSStringRef.h" +#include "JSValueRef.h" +#include "Node.h" +#include "NodeList.h" +#include "UnusedParam.h" +#include + +static JSValueRef JSNode_appendChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + UNUSED_PARAM(function); + + // Example of throwing a type error for invalid values + if (!JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) { + JSStringRef message = JSStringCreateWithUTF8CString("TypeError: appendChild can only be called on nodes"); + *exception = JSValueMakeString(context, message); + JSStringRelease(message); + } else if (argumentCount < 1 || !JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) { + JSStringRef message = JSStringCreateWithUTF8CString("TypeError: first argument to appendChild must be a node"); + *exception = JSValueMakeString(context, message); + JSStringRelease(message); + } else { + Node* node = JSObjectGetPrivate(thisObject); + Node* child = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL)); + + Node_appendChild(node, child); + } + + return JSValueMakeUndefined(context); +} + +static JSValueRef JSNode_removeChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + UNUSED_PARAM(function); + + // Example of ignoring invalid values + if (argumentCount > 0) { + if (JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) { + if (JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) { + Node* node = JSObjectGetPrivate(thisObject); + Node* child = JSObjectGetPrivate(JSValueToObject(context, arguments[0], exception)); + + Node_removeChild(node, child); + } + } + } + + return JSValueMakeUndefined(context); +} + +static JSValueRef JSNode_replaceChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + UNUSED_PARAM(function); + + if (argumentCount > 1) { + if (JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) { + if (JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) { + if (JSValueIsObjectOfClass(context, arguments[1], JSNode_class(context))) { + Node* node = JSObjectGetPrivate(thisObject); + Node* newChild = JSObjectGetPrivate(JSValueToObject(context, arguments[0], exception)); + Node* oldChild = JSObjectGetPrivate(JSValueToObject(context, arguments[1], exception)); + + Node_replaceChild(node, newChild, oldChild); + } + } + } + } + + return JSValueMakeUndefined(context); +} + +static JSStaticFunction JSNode_staticFunctions[] = { + { "appendChild", JSNode_appendChild, kJSPropertyAttributeDontDelete }, + { "removeChild", JSNode_removeChild, kJSPropertyAttributeDontDelete }, + { "replaceChild", JSNode_replaceChild, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +static JSValueRef JSNode_getNodeType(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + UNUSED_PARAM(propertyName); + UNUSED_PARAM(exception); + + Node* node = JSObjectGetPrivate(object); + if (node) { + JSStringRef nodeType = JSStringCreateWithUTF8CString(node->nodeType); + JSValueRef value = JSValueMakeString(context, nodeType); + JSStringRelease(nodeType); + return value; + } + + return NULL; +} + +static JSValueRef JSNode_getChildNodes(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + UNUSED_PARAM(propertyName); + UNUSED_PARAM(exception); + + Node* node = JSObjectGetPrivate(thisObject); + ASSERT(node); + return JSNodeList_new(context, NodeList_new(node)); +} + +static JSValueRef JSNode_getFirstChild(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + UNUSED_PARAM(object); + UNUSED_PARAM(propertyName); + UNUSED_PARAM(exception); + + return JSValueMakeUndefined(context); +} + +static JSStaticValue JSNode_staticValues[] = { + { "nodeType", JSNode_getNodeType, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "childNodes", JSNode_getChildNodes, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "firstChild", JSNode_getFirstChild, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +static void JSNode_initialize(JSContextRef context, JSObjectRef object) +{ + UNUSED_PARAM(context); + + Node* node = JSObjectGetPrivate(object); + ASSERT(node); + + Node_ref(node); +} + +static void JSNode_finalize(JSObjectRef object) +{ + Node* node = JSObjectGetPrivate(object); + ASSERT(node); + + Node_deref(node); +} + +JSClassRef JSNode_class(JSContextRef context) +{ + UNUSED_PARAM(context); + + static JSClassRef jsClass; + if (!jsClass) { + JSClassDefinition definition = kJSClassDefinitionEmpty; + definition.staticValues = JSNode_staticValues; + definition.staticFunctions = JSNode_staticFunctions; + definition.initialize = JSNode_initialize; + definition.finalize = JSNode_finalize; + + jsClass = JSClassCreate(&definition); + } + return jsClass; +} + +JSObjectRef JSNode_new(JSContextRef context, Node* node) +{ + return JSObjectMake(context, JSNode_class(context), node); +} + +JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + UNUSED_PARAM(object); + UNUSED_PARAM(argumentCount); + UNUSED_PARAM(arguments); + UNUSED_PARAM(exception); + + return JSNode_new(context, Node_new()); +} diff --git a/API/JSNode.h b/API/JSNode.h new file mode 100644 index 0000000..cd3a441 --- /dev/null +++ b/API/JSNode.h @@ -0,0 +1,38 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSNode_h +#define JSNode_h + +#include "JSBase.h" +#include "Node.h" +#include + +extern JSObjectRef JSNode_new(JSContextRef context, Node* node); +extern JSClassRef JSNode_class(JSContextRef context); +extern JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +#endif // JSNode_h diff --git a/API/JSNodeList.c b/API/JSNodeList.c new file mode 100644 index 0000000..0da7c8d --- /dev/null +++ b/API/JSNodeList.c @@ -0,0 +1,124 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "JSNode.h" +#include "JSNodeList.h" +#include "JSObjectRef.h" +#include "JSValueRef.h" +#include "UnusedParam.h" +#include + +static JSValueRef JSNodeList_item(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + UNUSED_PARAM(object); + + if (argumentCount > 0) { + NodeList* nodeList = JSObjectGetPrivate(thisObject); + ASSERT(nodeList); + Node* node = NodeList_item(nodeList, (unsigned)JSValueToNumber(context, arguments[0], exception)); + if (node) + return JSNode_new(context, node); + } + + return JSValueMakeUndefined(context); +} + +static JSStaticFunction JSNodeList_staticFunctions[] = { + { "item", JSNodeList_item, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +static JSValueRef JSNodeList_length(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + UNUSED_PARAM(propertyName); + UNUSED_PARAM(exception); + + NodeList* nodeList = JSObjectGetPrivate(thisObject); + ASSERT(nodeList); + return JSValueMakeNumber(context, NodeList_length(nodeList)); +} + +static JSStaticValue JSNodeList_staticValues[] = { + { "length", JSNodeList_length, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { 0, 0, 0, 0 } +}; + +static JSValueRef JSNodeList_getProperty(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + NodeList* nodeList = JSObjectGetPrivate(thisObject); + ASSERT(nodeList); + double index = JSValueToNumber(context, JSValueMakeString(context, propertyName), exception); + unsigned uindex = (unsigned)index; + if (uindex == index) { // false for NaN + Node* node = NodeList_item(nodeList, uindex); + if (node) + return JSNode_new(context, node); + } + + return NULL; +} + +static void JSNodeList_initialize(JSContextRef context, JSObjectRef thisObject) +{ + UNUSED_PARAM(context); + + NodeList* nodeList = JSObjectGetPrivate(thisObject); + ASSERT(nodeList); + + NodeList_ref(nodeList); +} + +static void JSNodeList_finalize(JSObjectRef thisObject) +{ + NodeList* nodeList = JSObjectGetPrivate(thisObject); + ASSERT(nodeList); + + NodeList_deref(nodeList); +} + +static JSClassRef JSNodeList_class(JSContextRef context) +{ + UNUSED_PARAM(context); + + static JSClassRef jsClass; + if (!jsClass) { + JSClassDefinition definition = kJSClassDefinitionEmpty; + definition.staticValues = JSNodeList_staticValues; + definition.staticFunctions = JSNodeList_staticFunctions; + definition.getProperty = JSNodeList_getProperty; + definition.initialize = JSNodeList_initialize; + definition.finalize = JSNodeList_finalize; + + jsClass = JSClassCreate(&definition); + } + + return jsClass; +} + +JSObjectRef JSNodeList_new(JSContextRef context, NodeList* nodeList) +{ + return JSObjectMake(context, JSNodeList_class(context), nodeList); +} diff --git a/API/JSNodeList.h b/API/JSNodeList.h new file mode 100644 index 0000000..0bc5f74 --- /dev/null +++ b/API/JSNodeList.h @@ -0,0 +1,35 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSNodeList_h +#define JSNodeList_h + +#include "JSBase.h" +#include "NodeList.h" + +extern JSObjectRef JSNodeList_new(JSContextRef, NodeList*); + +#endif // JSNodeList_h diff --git a/API/JSObjectRef.cpp b/API/JSObjectRef.cpp new file mode 100644 index 0000000..c6cda25 --- /dev/null +++ b/API/JSObjectRef.cpp @@ -0,0 +1,374 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSObjectRef.h" + +#include +#include "APICast.h" +#include "JSValueRef.h" +#include "JSCallbackConstructor.h" +#include "JSCallbackFunction.h" +#include "JSCallbackObject.h" +#include "JSClassRef.h" +#include "JSGlobalObject.h" + +#include "PropertyNameArray.h" +#include "function.h" +#include "function_object.h" +#include "identifier.h" +#include "internal.h" +#include "object.h" +#include "object_object.h" + +using namespace KJS; + +JSClassRef JSClassCreate(const JSClassDefinition* definition) +{ + JSLock lock; + JSClassRef jsClass = (definition->attributes & kJSClassAttributeNoAutomaticPrototype) + ? OpaqueJSClass::createNoAutomaticPrototype(definition) + : OpaqueJSClass::create(definition); + + return JSClassRetain(jsClass); +} + +JSClassRef JSClassRetain(JSClassRef jsClass) +{ + JSLock lock; + jsClass->ref(); + return jsClass; +} + +void JSClassRelease(JSClassRef jsClass) +{ + JSLock lock; + jsClass->deref(); +} + +JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + + if (!jsClass) + return toRef(new JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient + + JSValue* jsPrototype = jsClass->prototype(ctx); + if (!jsPrototype) + jsPrototype = exec->lexicalGlobalObject()->objectPrototype(); + + return toRef(new JSCallbackObject(exec, jsClass, jsPrototype, data)); +} + +JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + Identifier nameID = name ? Identifier(toJS(name)) : Identifier("anonymous"); + + return toRef(new JSCallbackFunction(exec, callAsFunction, nameID)); +} + +JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + + JSValue* jsPrototype = jsClass + ? jsClass->prototype(ctx) + : exec->dynamicGlobalObject()->objectPrototype(); + + JSCallbackConstructor* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor); + constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly); + return toRef(constructor); +} + +JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) +{ + JSLock lock; + + ExecState* exec = toJS(ctx); + UString::Rep* bodyRep = toJS(body); + UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; + + Identifier nameID = name ? Identifier(toJS(name)) : Identifier("anonymous"); + + List args; + for (unsigned i = 0; i < parameterCount; i++) + args.append(jsString(UString(toJS(parameterNames[i])))); + args.append(jsString(UString(bodyRep))); + + JSObject* result = exec->dynamicGlobalObject()->functionConstructor()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + result = 0; + } + return toRef(result); +} + +JSValueRef JSObjectGetPrototype(JSContextRef, JSObjectRef object) +{ + JSObject* jsObject = toJS(object); + return toRef(jsObject->prototype()); +} + +void JSObjectSetPrototype(JSContextRef, JSObjectRef object, JSValueRef value) +{ + JSObject* jsObject = toJS(object); + JSValue* jsValue = toJS(value); + + jsObject->setPrototype(jsValue); +} + +bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSObject* jsObject = toJS(object); + UString::Rep* nameRep = toJS(propertyName); + + return jsObject->hasProperty(exec, Identifier(nameRep)); +} + +JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSObject* jsObject = toJS(object); + UString::Rep* nameRep = toJS(propertyName); + + JSValue* jsValue = jsObject->get(exec, Identifier(nameRep)); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + } + return toRef(jsValue); +} + +void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSObject* jsObject = toJS(object); + UString::Rep* nameRep = toJS(propertyName); + JSValue* jsValue = toJS(value); + + jsObject->put(exec, Identifier(nameRep), jsValue, attributes); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + } +} + +JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSObject* jsObject = toJS(object); + + JSValue* jsValue = jsObject->get(exec, propertyIndex); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + } + return toRef(jsValue); +} + + +void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSObject* jsObject = toJS(object); + JSValue* jsValue = toJS(value); + + jsObject->put(exec, propertyIndex, jsValue); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + } +} + +bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSObject* jsObject = toJS(object); + UString::Rep* nameRep = toJS(propertyName); + + bool result = jsObject->deleteProperty(exec, Identifier(nameRep)); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + } + return result; +} + +void* JSObjectGetPrivate(JSObjectRef object) +{ + JSObject* jsObject = toJS(object); + + if (jsObject->inherits(&JSCallbackObject::info)) + return static_cast*>(jsObject)->getPrivate(); + else if (jsObject->inherits(&JSCallbackObject::info)) + return static_cast*>(jsObject)->getPrivate(); + + return 0; +} + +bool JSObjectSetPrivate(JSObjectRef object, void* data) +{ + JSObject* jsObject = toJS(object); + + if (jsObject->inherits(&JSCallbackObject::info)) { + static_cast*>(jsObject)->setPrivate(data); + return true; + } else if (jsObject->inherits(&JSCallbackObject::info)) { + static_cast*>(jsObject)->setPrivate(data); + return true; + } + + return false; +} + +bool JSObjectIsFunction(JSContextRef, JSObjectRef object) +{ + JSObject* jsObject = toJS(object); + return jsObject->implementsCall(); +} + +JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSObject* jsObject = toJS(object); + JSObject* jsThisObject = toJS(thisObject); + + if (!jsThisObject) + jsThisObject = exec->dynamicGlobalObject(); + + List argList; + for (size_t i = 0; i < argumentCount; i++) + argList.append(toJS(arguments[i])); + + JSValueRef result = toRef(jsObject->call(exec, jsThisObject, argList)); // returns NULL if object->implementsCall() is false + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + result = 0; + } + return result; +} + +bool JSObjectIsConstructor(JSContextRef, JSObjectRef object) +{ + JSObject* jsObject = toJS(object); + return jsObject->implementsConstruct(); +} + +JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSObject* jsObject = toJS(object); + + List argList; + for (size_t i = 0; i < argumentCount; i++) + argList.append(toJS(arguments[i])); + + JSObjectRef result = toRef(jsObject->construct(exec, argList)); // returns NULL if object->implementsCall() is false + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + result = 0; + } + return result; +} + +struct OpaqueJSPropertyNameArray +{ + OpaqueJSPropertyNameArray() : refCount(0) + { + } + + unsigned refCount; + PropertyNameArray array; +}; + +JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object) +{ + JSLock lock; + JSObject* jsObject = toJS(object); + ExecState* exec = toJS(ctx); + + JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(); + jsObject->getPropertyNames(exec, propertyNames->array); + + return JSPropertyNameArrayRetain(propertyNames); +} + +JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array) +{ + JSLock lock; + ++array->refCount; + return array; +} + +void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array) +{ + JSLock lock; + if (--array->refCount == 0) + delete array; +} + +size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array) +{ + return array->array.size(); +} + +JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index) +{ + return toRef(array->array[static_cast(index)].ustring().rep()); +} + +void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef array, JSStringRef propertyName) +{ + JSLock lock; + PropertyNameArray* propertyNames = toJS(array); + UString::Rep* rep = toJS(propertyName); + + propertyNames->add(Identifier(rep)); +} diff --git a/API/JSObjectRef.h b/API/JSObjectRef.h new file mode 100644 index 0000000..bf4041f --- /dev/null +++ b/API/JSObjectRef.h @@ -0,0 +1,645 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSObjectRef_h +#define JSObjectRef_h + +#include +#include + +#include +#include // for size_t + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@enum JSPropertyAttribute +@constant kJSPropertyAttributeNone Specifies that a property has no special attributes. +@constant kJSPropertyAttributeReadOnly Specifies that a property is read-only. +@constant kJSPropertyAttributeDontEnum Specifies that a property should not be enumerated by JSPropertyEnumerators and JavaScript for...in loops. +@constant kJSPropertyAttributeDontDelete Specifies that the delete operation should fail on a property. +*/ +enum { + kJSPropertyAttributeNone = 0, + kJSPropertyAttributeReadOnly = 1 << 1, + kJSPropertyAttributeDontEnum = 1 << 2, + kJSPropertyAttributeDontDelete = 1 << 3 +}; + +/*! +@typedef JSPropertyAttributes +@abstract A set of JSPropertyAttributes. Combine multiple attributes by logically ORing them together. +*/ +typedef unsigned JSPropertyAttributes; + +/*! +@enum JSClassAttribute +@constant kJSClassAttributeNone Specifies that a class has no special attributes. +@constant kJSClassAttributeNoAutomaticPrototype Specifies that a class should not automatically generate a shared prototype for its instance objects. Use kJSClassAttributeNoAutomaticPrototype in combination with JSObjectSetPrototype to manage prototypes manually. +*/ +enum { + kJSClassAttributeNone = 0, + kJSClassAttributeNoAutomaticPrototype = 1 << 1 +}; + +/*! +@typedef JSClassAttributes +@abstract A set of JSClassAttributes. Combine multiple attributes by logically ORing them together. +*/ +typedef unsigned JSClassAttributes; + +/*! +@typedef JSObjectInitializeCallback +@abstract The callback invoked when an object is first created. +@param ctx The execution context to use. +@param object The JSObject being created. +@discussion If you named your function Initialize, you would declare it like this: + +void Initialize(JSContextRef ctx, JSObjectRef object); + +Unlike the other object callbacks, the initialize callback is called on the least +derived class (the parent class) first, and the most derived class last. +*/ +typedef void +(*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object); + +/*! +@typedef JSObjectFinalizeCallback +@abstract The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread. +@param object The JSObject being finalized. +@discussion If you named your function Finalize, you would declare it like this: + +void Finalize(JSObjectRef object); + +The finalize callback is called on the most derived class first, and the least +derived class (the parent class) last. + +You must not call any function that may cause a garbage collection or an allocation +of a garbage collected object from within a JSObjectFinalizeCallback. This includes +all functions that have a JSContextRef parameter. +*/ +typedef void +(*JSObjectFinalizeCallback) (JSObjectRef object); + +/*! +@typedef JSObjectHasPropertyCallback +@abstract The callback invoked when determining whether an object has a property. +@param ctx The execution context to use. +@param object The JSObject to search for the property. +@param propertyName A JSString containing the name of the property look up. +@result true if object has the property, otherwise false. +@discussion If you named your function HasProperty, you would declare it like this: + +bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + +If this function returns false, the hasProperty request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain. + +This callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value would be expensive. + +If this callback is NULL, the getProperty callback will be used to service hasProperty requests. +*/ +typedef bool +(*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + +/*! +@typedef JSObjectGetPropertyCallback +@abstract The callback invoked when getting a property's value. +@param ctx The execution context to use. +@param object The JSObject to search for the property. +@param propertyName A JSString containing the name of the property to get. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result The property's value if object has the property, otherwise NULL. +@discussion If you named your function GetProperty, you would declare it like this: + +JSValueRef GetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +If this function returns NULL, the get request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain. +*/ +typedef JSValueRef +(*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +/*! +@typedef JSObjectSetPropertyCallback +@abstract The callback invoked when setting a property's value. +@param ctx The execution context to use. +@param object The JSObject on which to set the property's value. +@param propertyName A JSString containing the name of the property to set. +@param value A JSValue to use as the property's value. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result true if the property was set, otherwise false. +@discussion If you named your function SetProperty, you would declare it like this: + +bool SetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + +If this function returns false, the set request forwards to object's statically declared properties, then its parent class chain (which includes the default object class). +*/ +typedef bool +(*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + +/*! +@typedef JSObjectDeletePropertyCallback +@abstract The callback invoked when deleting a property. +@param ctx The execution context to use. +@param object The JSObject in which to delete the property. +@param propertyName A JSString containing the name of the property to delete. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result true if propertyName was successfully deleted, otherwise false. +@discussion If you named your function DeleteProperty, you would declare it like this: + +bool DeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +If this function returns false, the delete request forwards to object's statically declared properties, then its parent class chain (which includes the default object class). +*/ +typedef bool +(*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +/*! +@typedef JSObjectGetPropertyNamesCallback +@abstract The callback invoked when collecting the names of an object's properties. +@param ctx The execution context to use. +@param object The JSObject whose property names are being collected. +@param accumulator A JavaScript property name accumulator in which to accumulate the names of object's properties. +@discussion If you named your function GetPropertyNames, you would declare it like this: + +void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); + +Property name accumulators are used by JSObjectCopyPropertyNames and JavaScript for...in loops. + +Use JSPropertyNameAccumulatorAddName to add property names to accumulator. A class's getPropertyNames callback only needs to provide the names of properties that the class vends through a custom getProperty or setProperty callback. Other properties, including statically declared properties, properties vended by other classes, and properties belonging to object's prototype, are added independently. +*/ +typedef void +(*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); + +/*! +@typedef JSObjectCallAsFunctionCallback +@abstract The callback invoked when an object is called as a function. +@param ctx The execution context to use. +@param function A JSObject that is the function being called. +@param thisObject A JSObject that is the 'this' variable in the function's scope. +@param argumentCount An integer count of the number of arguments in arguments. +@param arguments A JSValue array of the arguments passed to the function. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result A JSValue that is the function's return value. +@discussion If you named your function CallAsFunction, you would declare it like this: + +JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +If your callback were invoked by the JavaScript expression 'myObject.myFunction()', function would be set to myFunction, and thisObject would be set to myObject. + +If this callback is NULL, calling your object as a function will throw an exception. +*/ +typedef JSValueRef +(*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +/*! +@typedef JSObjectCallAsConstructorCallback +@abstract The callback invoked when an object is used as a constructor in a 'new' expression. +@param ctx The execution context to use. +@param constructor A JSObject that is the constructor being called. +@param argumentCount An integer count of the number of arguments in arguments. +@param arguments A JSValue array of the arguments passed to the function. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result A JSObject that is the constructor's return value. +@discussion If you named your function CallAsConstructor, you would declare it like this: + +JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +If your callback were invoked by the JavaScript expression 'new myConstructor()', constructor would be set to myConstructor. + +If this callback is NULL, using your object as a constructor in a 'new' expression will throw an exception. +*/ +typedef JSObjectRef +(*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +/*! +@typedef JSObjectHasInstanceCallback +@abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression. +@param ctx The execution context to use. +@param constructor The JSObject that is the target of the 'instanceof' expression. +@param possibleInstance The JSValue being tested to determine if it is an instance of constructor. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result true if possibleInstance is an instance of constructor, otherwise false. +@discussion If you named your function HasInstance, you would declare it like this: + +bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + +If your callback were invoked by the JavaScript expression 'someValue instanceof myObject', constructor would be set to myObject and possibleInstance would be set to someValue. + +If this callback is NULL, 'instanceof' expressions that target your object will return false. + +Standard JavaScript practice calls for objects that implement the callAsConstructor callback to implement the hasInstance callback as well. +*/ +typedef bool +(*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + +/*! +@typedef JSObjectConvertToTypeCallback +@abstract The callback invoked when converting an object to a particular JavaScript type. +@param ctx The execution context to use. +@param object The JSObject to convert. +@param type A JSType specifying the JavaScript type to convert to. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result The objects's converted value, or NULL if the object was not converted. +@discussion If you named your function ConvertToType, you would declare it like this: + +JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); + +If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class). + +This function is only invoked when converting an object to number or string. An object converted to boolean is 'true.' An object converted to object is itself. +*/ +typedef JSValueRef +(*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); + +/*! +@struct JSStaticValue +@abstract This structure describes a statically declared value property. +@field name A null-terminated UTF8 string containing the property's name. +@field getProperty A JSObjectGetPropertyCallback to invoke when getting the property's value. +@field setProperty A JSObjectSetPropertyCallback to invoke when setting the property's value. May be NULL if the ReadOnly attribute is set. +@field attributes A logically ORed set of JSPropertyAttributes to give to the property. +*/ +typedef struct { + const char* const name; + JSObjectGetPropertyCallback getProperty; + JSObjectSetPropertyCallback setProperty; + JSPropertyAttributes attributes; +} JSStaticValue; + +/*! +@struct JSStaticFunction +@abstract This structure describes a statically declared function property. +@field name A null-terminated UTF8 string containing the property's name. +@field callAsFunction A JSObjectCallAsFunctionCallback to invoke when the property is called as a function. +@field attributes A logically ORed set of JSPropertyAttributes to give to the property. +*/ +typedef struct { + const char* const name; + JSObjectCallAsFunctionCallback callAsFunction; + JSPropertyAttributes attributes; +} JSStaticFunction; + +/*! +@struct JSClassDefinition +@abstract This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL. +@field version The version number of this structure. The current version is 0. +@field attributes A logically ORed set of JSClassAttributes to give to the class. +@field className A null-terminated UTF8 string containing the class's name. +@field parentClass A JSClass to set as the class's parent class. Pass NULL use the default object class. +@field staticValues A JSStaticValue array containing the class's statically declared value properties. Pass NULL to specify no statically declared value properties. The array must be terminated by a JSStaticValue whose name field is NULL. +@field staticFunctions A JSStaticFunction array containing the class's statically declared function properties. Pass NULL to specify no statically declared function properties. The array must be terminated by a JSStaticFunction whose name field is NULL. +@field initialize The callback invoked when an object is first created. Use this callback to initialize the object. +@field finalize The callback invoked when an object is finalized (prepared for garbage collection). Use this callback to release resources allocated for the object, and perform other cleanup. +@field hasProperty The callback invoked when determining whether an object has a property. If this field is NULL, getProperty is called instead. The hasProperty callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value is expensive. +@field getProperty The callback invoked when getting a property's value. +@field setProperty The callback invoked when setting a property's value. +@field deleteProperty The callback invoked when deleting a property. +@field getPropertyNames The callback invoked when collecting the names of an object's properties. +@field callAsFunction The callback invoked when an object is called as a function. +@field hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression. +@field callAsConstructor The callback invoked when an object is used as a constructor in a 'new' expression. +@field convertToType The callback invoked when converting an object to a particular JavaScript type. +@discussion The staticValues and staticFunctions arrays are the simplest and most efficient means for vending custom properties. Statically declared properties autmatically service requests like getProperty, setProperty, and getPropertyNames. Property access callbacks are required only to implement unusual properties, like array indexes, whose names are not known at compile-time. + +If you named your getter function "GetX" and your setter function "SetX", you would declare a JSStaticValue array containing "X" like this: + +JSStaticValue StaticValueArray[] = { + { "X", GetX, SetX, kJSPropertyAttributeNone }, + { 0, 0, 0, 0 } +}; + +Standard JavaScript practice calls for storing function objects in prototypes, so they can be shared. The default JSClass created by JSClassCreate follows this idiom, instantiating objects with a shared, automatically generating prototype containing the class's function objects. The kJSClassAttributeNoAutomaticPrototype attribute specifies that a JSClass should not automatically generate such a prototype. The resulting JSClass instantiates objects with the default object prototype, and gives each instance object its own copy of the class's function objects. + +A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute. +*/ +typedef struct { + int version; // current (and only) version is 0 + JSClassAttributes attributes; + + const char* className; + JSClassRef parentClass; + + const JSStaticValue* staticValues; + const JSStaticFunction* staticFunctions; + + JSObjectInitializeCallback initialize; + JSObjectFinalizeCallback finalize; + JSObjectHasPropertyCallback hasProperty; + JSObjectGetPropertyCallback getProperty; + JSObjectSetPropertyCallback setProperty; + JSObjectDeletePropertyCallback deleteProperty; + JSObjectGetPropertyNamesCallback getPropertyNames; + JSObjectCallAsFunctionCallback callAsFunction; + JSObjectCallAsConstructorCallback callAsConstructor; + JSObjectHasInstanceCallback hasInstance; + JSObjectConvertToTypeCallback convertToType; +} JSClassDefinition; + +/*! +@const kJSClassDefinitionEmpty +@abstract A JSClassDefinition structure of the current version, filled with NULL pointers and having no attributes. +@discussion Use this constant as a convenience when creating class definitions. For example, to create a class definition with only a finalize method: + +JSClassDefinition definition = kJSClassDefinitionEmpty; +definition.finalize = Finalize; +*/ +JS_EXPORT extern const JSClassDefinition kJSClassDefinitionEmpty; + +/*! +@function +@abstract Creates a JavaScript class suitable for use with JSObjectMake. +@param definition A JSClassDefinition that defines the class. +@result A JSClass with the given definition. Ownership follows the Create Rule. +*/ +JS_EXPORT JSClassRef JSClassCreate(const JSClassDefinition* definition); + +/*! +@function +@abstract Retains a JavaScript class. +@param jsClass The JSClass to retain. +@result A JSClass that is the same as jsClass. +*/ +JS_EXPORT JSClassRef JSClassRetain(JSClassRef jsClass); + +/*! +@function +@abstract Releases a JavaScript class. +@param jsClass The JSClass to release. +*/ +JS_EXPORT void JSClassRelease(JSClassRef jsClass); + +/*! +@function +@abstract Creates a JavaScript object. +@param ctx The execution context to use. +@param jsClass The JSClass to assign to the object. Pass NULL to use the default object class. +@param data A void* to set as the object's private data. Pass NULL to specify no private data. +@result A JSObject with the given class and private data. +@discussion The default object class does not allocate storage for private data, so you must provide a non-NULL jsClass to JSObjectMake if you want your object to be able to store private data. + +data is set on the created object before the intialize methods in its class chain are called. This enables the initialize methods to retrieve and manipulate data through JSObjectGetPrivate. +*/ +JS_EXPORT JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data); + +/*! +@function +@abstract Convenience method for creating a JavaScript function with a given callback as its implementation. +@param ctx The execution context to use. +@param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function. +@param callAsFunction The JSObjectCallAsFunctionCallback to invoke when the function is called. +@result A JSObject that is a function. The object's prototype will be the default function prototype. +*/ +JS_EXPORT JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction); + +/*! +@function +@abstract Convenience method for creating a JavaScript constructor. +@param ctx The execution context to use. +@param jsClass A JSClass that is the class your constructor will assign to the objects its constructs. jsClass will be used to set the constructor's .prototype property, and to evaluate 'instanceof' expressions. Pass NULL to use the default object class. +@param callAsConstructor A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a 'new' expression. Pass NULL to use the default object constructor. +@result A JSObject that is a constructor. The object's prototype will be the default object prototype. +@discussion The default object constructor takes no arguments and constructs an object of class jsClass with no private data. +*/ +JS_EXPORT JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor); + +/*! +@function +@abstract Creates a function with a given script as its body. +@param ctx The execution context to use. +@param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function. +@param parameterCount An integer count of the number of parameter names in parameterNames. +@param parameterNames A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0. +@param body A JSString containing the script to use as the function's body. +@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. +@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. +@param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception. +@result A JSObject that is a function, or NULL if either body or parameterNames contains a syntax error. The object's prototype will be the default function prototype. +@discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution. +*/ +JS_EXPORT JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); + +/*! +@function +@abstract Gets an object's prototype. +@param ctx The execution context to use. +@param object A JSObject whose prototype you want to get. +@result A JSValue that is the object's prototype. +*/ +JS_EXPORT JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Sets an object's prototype. +@param ctx The execution context to use. +@param object The JSObject whose prototype you want to set. +@param value A JSValue to set as the object's prototype. +*/ +JS_EXPORT void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value); + +/*! +@function +@abstract Tests whether an object has a given property. +@param object The JSObject to test. +@param propertyName A JSString containing the property's name. +@result true if the object has a property whose name matches propertyName, otherwise false. +*/ +JS_EXPORT bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + +/*! +@function +@abstract Gets a property from an object. +@param ctx The execution context to use. +@param object The JSObject whose property you want to get. +@param propertyName A JSString containing the property's name. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The property's value if object has the property, otherwise the undefined value. +*/ +JS_EXPORT JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +/*! +@function +@abstract Sets a property on an object. +@param ctx The execution context to use. +@param object The JSObject whose property you want to set. +@param propertyName A JSString containing the property's name. +@param value A JSValue to use as the property's value. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@param attributes A logically ORed set of JSPropertyAttributes to give to the property. +*/ +JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception); + +/*! +@function +@abstract Deletes a property from an object. +@param ctx The execution context to use. +@param object The JSObject whose property you want to delete. +@param propertyName A JSString containing the property's name. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set). +*/ +JS_EXPORT bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +/*! +@function +@abstract Gets a property from an object by numeric index. +@param ctx The execution context to use. +@param object The JSObject whose property you want to get. +@param propertyIndex An integer value that is the property's name. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The property's value if object has the property, otherwise the undefined value. +@discussion Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties. +*/ +JS_EXPORT JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception); + +/*! +@function +@abstract Sets a property on an object by numeric index. +@param ctx The execution context to use. +@param object The JSObject whose property you want to set. +@param propertyIndex The property's name as a number. +@param value A JSValue to use as the property's value. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@discussion Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties. +*/ +JS_EXPORT void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception); + +/*! +@function +@abstract Gets an object's private data. +@param object A JSObject whose private data you want to get. +@result A void* that is the object's private data, if the object has private data, otherwise NULL. +*/ +JS_EXPORT void* JSObjectGetPrivate(JSObjectRef object); + +/*! +@function +@abstract Sets a pointer to private data on an object. +@param object The JSObject whose private data you want to set. +@param data A void* to set as the object's private data. +@result true if object can store private data, otherwise false. +@discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data. +*/ +JS_EXPORT bool JSObjectSetPrivate(JSObjectRef object, void* data); + +/*! +@function +@abstract Tests whether an object can be called as a function. +@param ctx The execution context to use. +@param object The JSObject to test. +@result true if the object can be called as a function, otherwise false. +*/ +JS_EXPORT bool JSObjectIsFunction(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Calls an object as a function. +@param ctx The execution context to use. +@param object The JSObject to call as a function. +@param thisObject The object to use as "this," or NULL to use the global object as "this." +@param argumentCount An integer count of the number of arguments in arguments. +@param arguments A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function. +*/ +JS_EXPORT JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +/*! +@function +@abstract Tests whether an object can be called as a constructor. +@param ctx The execution context to use. +@param object The JSObject to test. +@result true if the object can be called as a constructor, otherwise false. +*/ +JS_EXPORT bool JSObjectIsConstructor(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Calls an object as a constructor. +@param ctx The execution context to use. +@param object The JSObject to call as a constructor. +@param argumentCount An integer count of the number of arguments in arguments. +@param arguments A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor. +*/ +JS_EXPORT JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +/*! +@function +@abstract Gets the names of an object's enumerable properties. +@param ctx The execution context to use. +@param object The object whose property names you want to get. +@result A JSPropertyNameArray containing the names object's enumerable properties. Ownership follows the Create Rule. +*/ +JS_EXPORT JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Retains a JavaScript property name array. +@param array The JSPropertyNameArray to retain. +@result A JSPropertyNameArray that is the same as array. +*/ +JS_EXPORT JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array); + +/*! +@function +@abstract Releases a JavaScript property name array. +@param array The JSPropetyNameArray to release. +*/ +JS_EXPORT void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array); + +/*! +@function +@abstract Gets a count of the number of items in a JavaScript property name array. +@param array The array from which to retrieve the count. +@result An integer count of the number of names in array. +*/ +JS_EXPORT size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array); + +/*! +@function +@abstract Gets a property name at a given index in a JavaScript property name array. +@param array The array from which to retrieve the property name. +@param index The index of the property name to retrieve. +@result A JSStringRef containing the property name. +*/ +JS_EXPORT JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index); + +/*! +@function +@abstract Adds a property name to a JavaScript property name accumulator. +@param accumulator The accumulator object to which to add the property name. +@param propertyName The property name to add. +*/ +JS_EXPORT void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef accumulator, JSStringRef propertyName); + +#ifdef __cplusplus +} +#endif + +#endif // JSObjectRef_h diff --git a/API/JSRetainPtr.h b/API/JSRetainPtr.h new file mode 100644 index 0000000..69c6de1 --- /dev/null +++ b/API/JSRetainPtr.h @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSRetainPtr_h +#define JSRetainPtr_h + +#include +#include + +inline void JSRetain(JSStringRef string) { JSStringRetain(string); } +inline void JSRelease(JSStringRef string) { JSStringRelease(string); } + +enum AdoptTag { Adopt }; + +template class JSRetainPtr { +public: + JSRetainPtr() : m_ptr(0) {} + JSRetainPtr(T ptr) : m_ptr(ptr) { if (ptr) JSRetain(ptr); } + + JSRetainPtr(AdoptTag, T ptr) : m_ptr(ptr) { } + + JSRetainPtr(const JSRetainPtr& o) : m_ptr(o.m_ptr) { if (T ptr = m_ptr) JSRetain(ptr); } + + ~JSRetainPtr() { if (T ptr = m_ptr) JSRelease(ptr); } + + template JSRetainPtr(const JSRetainPtr& o) : m_ptr(o.get()) { if (T ptr = m_ptr) JSRetain(ptr); } + + T get() const { return m_ptr; } + + T releaseRef() { T tmp = m_ptr; m_ptr = 0; return tmp; } + + T operator->() const { return m_ptr; } + + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef T JSRetainPtr::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &JSRetainPtr::m_ptr : 0; } + + JSRetainPtr& operator=(const JSRetainPtr&); + template JSRetainPtr& operator=(const JSRetainPtr&); + JSRetainPtr& operator=(T); + template JSRetainPtr& operator=(U*); + + void adopt(T); + + void swap(JSRetainPtr&); + +private: + T m_ptr; +}; + +template inline JSRetainPtr& JSRetainPtr::operator=(const JSRetainPtr& o) +{ + T optr = o.get(); + if (optr) + JSRetain(optr); + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); + return *this; +} + +template template inline JSRetainPtr& JSRetainPtr::operator=(const JSRetainPtr& o) +{ + T optr = o.get(); + if (optr) + JSRetain(optr); + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); + return *this; +} + +template inline JSRetainPtr& JSRetainPtr::operator=(T optr) +{ + if (optr) + JSRetain(optr); + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); + return *this; +} + +template inline void JSRetainPtr::adopt(T optr) +{ + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); +} + +template template inline JSRetainPtr& JSRetainPtr::operator=(U* optr) +{ + if (optr) + JSRetain(optr); + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); + return *this; +} + +template inline void JSRetainPtr::swap(JSRetainPtr& o) +{ + std::swap(m_ptr, o.m_ptr); +} + +template inline void swap(JSRetainPtr& a, JSRetainPtr& b) +{ + a.swap(b); +} + +template inline bool operator==(const JSRetainPtr& a, const JSRetainPtr& b) +{ + return a.get() == b.get(); +} + +template inline bool operator==(const JSRetainPtr& a, U* b) +{ + return a.get() == b; +} + +template inline bool operator==(T* a, const JSRetainPtr& b) +{ + return a == b.get(); +} + +template inline bool operator!=(const JSRetainPtr& a, const JSRetainPtr& b) +{ + return a.get() != b.get(); +} + +template inline bool operator!=(const JSRetainPtr& a, U* b) +{ + return a.get() != b; +} + +template inline bool operator!=(T* a, const JSRetainPtr& b) +{ + return a != b.get(); +} + + +#endif // JSRetainPtr_h diff --git a/API/JSStringRef.cpp b/API/JSStringRef.cpp new file mode 100644 index 0000000..9a307d0 --- /dev/null +++ b/API/JSStringRef.cpp @@ -0,0 +1,125 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSStringRef.h" + +#include + +#include "APICast.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace KJS; +using namespace WTF::Unicode; + +JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars) +{ + JSLock lock; + return toRef(UString(reinterpret_cast(chars), static_cast(numChars)).rep()->ref()); +} + +JSStringRef JSStringCreateWithUTF8CString(const char* string) +{ + JSLock lock; + + size_t length = strlen(string); + Vector< ::UChar, 1024> buffer(length); + ::UChar* p = buffer.data(); + if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length)) + return 0; + + return toRef(UString(reinterpret_cast(buffer.data()), p - buffer.data()).rep()->ref()); +} + +JSStringRef JSStringRetain(JSStringRef string) +{ + JSLock lock; + UString::Rep* rep = toJS(string); + return toRef(rep->ref()); +} + +void JSStringRelease(JSStringRef string) +{ + JSLock lock; + UString::Rep* rep = toJS(string); + rep->deref(); +} + +size_t JSStringGetLength(JSStringRef string) +{ + UString::Rep* rep = toJS(string); + return rep->size(); +} + +const JSChar* JSStringGetCharactersPtr(JSStringRef string) +{ + UString::Rep* rep = toJS(string); + return reinterpret_cast(rep->data()); +} + +size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string) +{ + UString::Rep* rep = toJS(string); + + // Any UTF8 character > 3 bytes encodes as a UTF16 surrogate pair. + return rep->size() * 3 + 1; // + 1 for terminating '\0' +} + +size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize) +{ + JSLock lock; + UString::Rep* rep = toJS(string); + CString cString = UString(rep).UTF8String(); + + size_t length = std::min(bufferSize, cString.size() + 1); // + 1 for terminating '\0' + memcpy(buffer, cString.c_str(), length); + return length; +} + +bool JSStringIsEqual(JSStringRef a, JSStringRef b) +{ + JSLock lock; + + UString::Rep* aRep = toJS(a); + UString::Rep* bRep = toJS(b); + + return UString(aRep) == UString(bRep); +} + +bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b) +{ + JSStringRef bBuf = JSStringCreateWithUTF8CString(b); + bool result = JSStringIsEqual(a, bBuf); + JSStringRelease(bBuf); + + return result; +} diff --git a/API/JSStringRef.h b/API/JSStringRef.h new file mode 100644 index 0000000..fb5649f --- /dev/null +++ b/API/JSStringRef.h @@ -0,0 +1,143 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSStringRef_h +#define JSStringRef_h + +#include + +#include +#include // for size_t + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(WIN32) && !defined(_WIN32) +/*! +@typedef JSChar +@abstract A Unicode character. +*/ + typedef unsigned short JSChar; +#else + typedef wchar_t JSChar; +#endif + +/*! +@function +@abstract Creates a JavaScript string from a buffer of Unicode characters. +@param chars The buffer of Unicode characters to copy into the new JSString. +@param numChars The number of characters to copy from the buffer pointed to by chars. +@result A JSString containing chars. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars); +/*! +@function +@abstract Creates a JavaScript string from a null-terminated UTF8 string. +@param string The null-terminated UTF8 string to copy into the new JSString. +@result A JSString containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSStringCreateWithUTF8CString(const char* string); + +/*! +@function +@abstract Retains a JavaScript string. +@param string The JSString to retain. +@result A JSString that is the same as string. +*/ +JS_EXPORT JSStringRef JSStringRetain(JSStringRef string); +/*! +@function +@abstract Releases a JavaScript string. +@param string The JSString to release. +*/ +JS_EXPORT void JSStringRelease(JSStringRef string); + +/*! +@function +@abstract Returns the number of Unicode characters in a JavaScript string. +@param string The JSString whose length (in Unicode characters) you want to know. +@result The number of Unicode characters stored in string. +*/ +JS_EXPORT size_t JSStringGetLength(JSStringRef string); +/*! +@function +@abstract Returns a pointer to the Unicode character buffer that + serves as the backing store for a JavaScript string. +@param string The JSString whose backing store you want to access. +@result A pointer to the Unicode character buffer that serves as string's + backing store, which will be deallocated when string is deallocated. +*/ +JS_EXPORT const JSChar* JSStringGetCharactersPtr(JSStringRef string); + +/*! +@function +@abstract Returns the maximum number of bytes a JavaScript string will + take up if converted into a null-terminated UTF8 string. +@param string The JSString whose maximum converted size (in bytes) you + want to know. +@result The maximum number of bytes that could be required to convert string into a + null-terminated UTF8 string. The number of bytes that the conversion actually ends + up requiring could be less than this, but never more. +*/ +JS_EXPORT size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string); +/*! +@function +@abstract Converts a JavaScript string into a null-terminated UTF8 string, + and copies the result into an external byte buffer. +@param string The source JSString. +@param buffer The destination byte buffer into which to copy a null-terminated + UTF8 representation of string. On return, buffer contains a UTF8 string + representation of string. If bufferSize is too small, buffer will contain only + partial results. If buffer is not at least bufferSize bytes in size, + behavior is undefined. +@param bufferSize The size of the external buffer in bytes. +@result The number of bytes written into buffer (including the null-terminator byte). +*/ +JS_EXPORT size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize); + +/*! +@function +@abstract Tests whether two JavaScript strings match. +@param a The first JSString to test. +@param b The second JSString to test. +@result true if the two strings match, otherwise false. +*/ +JS_EXPORT bool JSStringIsEqual(JSStringRef a, JSStringRef b); +/*! +@function +@abstract Tests whether a JavaScript string matches a null-terminated UTF8 string. +@param a The JSString to test. +@param b The null-terminated UTF8 string to test. +@result true if the two strings match, otherwise false. +*/ +JS_EXPORT bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b); + +#ifdef __cplusplus +} +#endif + +#endif // JSStringRef_h diff --git a/API/JSStringRefBSTR.cpp b/API/JSStringRefBSTR.cpp new file mode 100644 index 0000000..1a538ab --- /dev/null +++ b/API/JSStringRefBSTR.cpp @@ -0,0 +1,43 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSStringRefBSTR.h" + +#include "JSStringRef.h" + +JSStringRef JSStringCreateWithBSTR(BSTR string) +{ + return JSStringCreateWithCharacters(string ? string : L"", string ? SysStringLen(string) : 0); +} + +BSTR JSStringCopyBSTR(const JSStringRef string) +{ + return SysAllocStringLen(JSStringGetCharactersPtr(string), JSStringGetLength(string)); +} diff --git a/API/JSStringRefBSTR.h b/API/JSStringRefBSTR.h new file mode 100644 index 0000000..4987f83 --- /dev/null +++ b/API/JSStringRefBSTR.h @@ -0,0 +1,63 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSStringRefBSTR_h +#define JSStringRefBSTR_h + +#include "JSBase.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// COM convenience methods + +/*! +@function +@abstract Creates a JavaScript string from a BSTR. +@param string The BSTR to copy into the new JSString. +@result A JSString containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSStringCreateWithBSTR(const BSTR string); + +/*! +@function +@abstract Creates a BSTR from a JavaScript string. +@param string The JSString to copy into the new BSTR. +@result A BSTR containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT BSTR JSStringCopyBSTR(const JSStringRef string); + +#ifdef __cplusplus +} +#endif + +#endif // JSStringRefBSTR_h diff --git a/API/JSStringRefCF.cpp b/API/JSStringRefCF.cpp new file mode 100644 index 0000000..70a5aa7 --- /dev/null +++ b/API/JSStringRefCF.cpp @@ -0,0 +1,57 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSStringRefCF.h" + +#include "APICast.h" +#include "JSStringRef.h" +#include +#include +#include + +using namespace KJS; + +JSStringRef JSStringCreateWithCFString(CFStringRef string) +{ + JSLock lock; + CFIndex length = CFStringGetLength(string); + UString::Rep* rep; + if (!length) + rep = UString("").rep()->ref(); + else { + UniChar* buffer = static_cast(fastMalloc(sizeof(UniChar) * length)); + CFStringGetCharacters(string, CFRangeMake(0, length), buffer); + rep = UString(reinterpret_cast(buffer), length, false).rep()->ref(); + } + return toRef(rep); +} + +CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string) +{ + UString::Rep* rep = toJS(string); + return CFStringCreateWithCharacters(alloc, reinterpret_cast(rep->data()), rep->size()); +} diff --git a/API/JSStringRefCF.h b/API/JSStringRefCF.h new file mode 100644 index 0000000..ef84a9c --- /dev/null +++ b/API/JSStringRefCF.h @@ -0,0 +1,61 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSStringRefCF_h +#define JSStringRefCF_h + +#include "JSBase.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// CFString convenience methods + +/*! +@function +@abstract Creates a JavaScript string from a CFString. +@discussion This function is optimized to take advantage of cases when + CFStringGetCharactersPtr returns a valid pointer. +@param string The CFString to copy into the new JSString. +@result A JSString containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSStringCreateWithCFString(CFStringRef string); +/*! +@function +@abstract Creates a CFString from a JavaScript string. +@param alloc The alloc parameter to pass to CFStringCreate. +@param string The JSString to copy into the new CFString. +@result A CFString containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string); + +#ifdef __cplusplus +} +#endif + +#endif // JSStringRefCF_h diff --git a/API/JSValueRef.cpp b/API/JSValueRef.cpp new file mode 100644 index 0000000..468a2d1 --- /dev/null +++ b/API/JSValueRef.cpp @@ -0,0 +1,259 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSValueRef.h" + +#include +#include "APICast.h" +#include "JSCallbackObject.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include // for std::min + +JSType JSValueGetType(JSContextRef, JSValueRef value) +{ + KJS::JSValue* jsValue = toJS(value); + switch (jsValue->type()) { + case KJS::UndefinedType: + return kJSTypeUndefined; + case KJS::NullType: + return kJSTypeNull; + case KJS::BooleanType: + return kJSTypeBoolean; + case KJS::NumberType: + return kJSTypeNumber; + case KJS::StringType: + return kJSTypeString; + case KJS::ObjectType: + return kJSTypeObject; + default: + ASSERT(!"JSValueGetType: unknown type code.\n"); + return kJSTypeUndefined; + } +} + +using namespace KJS; // placed here to avoid conflict between KJS::JSType and JSType, above. + +bool JSValueIsUndefined(JSContextRef, JSValueRef value) +{ + JSValue* jsValue = toJS(value); + return jsValue->isUndefined(); +} + +bool JSValueIsNull(JSContextRef, JSValueRef value) +{ + JSValue* jsValue = toJS(value); + return jsValue->isNull(); +} + +bool JSValueIsBoolean(JSContextRef, JSValueRef value) +{ + JSValue* jsValue = toJS(value); + return jsValue->isBoolean(); +} + +bool JSValueIsNumber(JSContextRef, JSValueRef value) +{ + JSValue* jsValue = toJS(value); + return jsValue->isNumber(); +} + +bool JSValueIsString(JSContextRef, JSValueRef value) +{ + JSValue* jsValue = toJS(value); + return jsValue->isString(); +} + +bool JSValueIsObject(JSContextRef, JSValueRef value) +{ + JSValue* jsValue = toJS(value); + return jsValue->isObject(); +} + +bool JSValueIsObjectOfClass(JSContextRef, JSValueRef value, JSClassRef jsClass) +{ + JSValue* jsValue = toJS(value); + + if (JSObject* o = jsValue->getObject()) { + if (o->inherits(&JSCallbackObject::info)) + return static_cast*>(o)->inherits(jsClass); + else if (o->inherits(&JSCallbackObject::info)) + return static_cast*>(o)->inherits(jsClass); + } + return false; +} + +bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSValue* jsA = toJS(a); + JSValue* jsB = toJS(b); + + bool result = equal(exec, jsA, jsB); // false if an exception is thrown + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + } + return result; +} + +bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSValue* jsA = toJS(a); + JSValue* jsB = toJS(b); + + bool result = strictEqual(exec, jsA, jsB); // can't throw because it doesn't perform value conversion + ASSERT(!exec->hadException()); + return result; +} + +bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSValue* jsValue = toJS(value); + JSObject* jsConstructor = toJS(constructor); + if (!jsConstructor->implementsHasInstance()) + return false; + bool result = jsConstructor->hasInstance(exec, jsValue); // false if an exception is thrown + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + } + return result; +} + +JSValueRef JSValueMakeUndefined(JSContextRef) +{ + return toRef(jsUndefined()); +} + +JSValueRef JSValueMakeNull(JSContextRef) +{ + return toRef(jsNull()); +} + +JSValueRef JSValueMakeBoolean(JSContextRef, bool value) +{ + return toRef(jsBoolean(value)); +} + +JSValueRef JSValueMakeNumber(JSContextRef, double value) +{ + JSLock lock; + return toRef(jsNumber(value)); +} + +JSValueRef JSValueMakeString(JSContextRef, JSStringRef string) +{ + JSLock lock; + UString::Rep* rep = toJS(string); + return toRef(jsString(UString(rep))); +} + +bool JSValueToBoolean(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + JSValue* jsValue = toJS(value); + return jsValue->toBoolean(exec); +} + +double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception) +{ + JSLock lock; + JSValue* jsValue = toJS(value); + ExecState* exec = toJS(ctx); + + double number = jsValue->toNumber(exec); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + number = NaN; + } + return number; +} + +JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception) +{ + JSLock lock; + JSValue* jsValue = toJS(value); + ExecState* exec = toJS(ctx); + + JSStringRef stringRef = toRef(jsValue->toString(exec).rep()->ref()); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + stringRef = 0; + } + return stringRef; +} + +JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception) +{ + JSLock lock; + ExecState* exec = toJS(ctx); + JSValue* jsValue = toJS(value); + + JSObjectRef objectRef = toRef(jsValue->toObject(exec)); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + objectRef = 0; + } + return objectRef; +} + +void JSValueProtect(JSContextRef, JSValueRef value) +{ + JSLock lock; + JSValue* jsValue = toJS(value); + gcProtect(jsValue); +} + +void JSValueUnprotect(JSContextRef, JSValueRef value) +{ + JSLock lock; + JSValue* jsValue = toJS(value); + gcUnprotect(jsValue); +} diff --git a/API/JSValueRef.h b/API/JSValueRef.h new file mode 100644 index 0000000..6f1ce08 --- /dev/null +++ b/API/JSValueRef.h @@ -0,0 +1,277 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSValueRef_h +#define JSValueRef_h + +#include + +#include + +/*! +@enum JSType +@abstract A constant identifying the type of a JSValue. +@constant kJSTypeUndefined The unique undefined value. +@constant kJSTypeNull The unique null value. +@constant kJSTypeBoolean A primitive boolean value, one of true or false. +@constant kJSTypeNumber A primitive number value. +@constant kJSTypeString A primitive string value. +@constant kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef). +*/ +typedef enum { + kJSTypeUndefined, + kJSTypeNull, + kJSTypeBoolean, + kJSTypeNumber, + kJSTypeString, + kJSTypeObject +} JSType; + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@function +@abstract Returns a JavaScript value's type. +@param ctx The execution context to use. +@param value The JSValue whose type you want to obtain. +@result A value of type JSType that identifies value's type. +*/ +JS_EXPORT JSType JSValueGetType(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the undefined type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the undefined type, otherwise false. +*/ +JS_EXPORT bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the null type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the null type, otherwise false. +*/ +JS_EXPORT bool JSValueIsNull(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the boolean type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the boolean type, otherwise false. +*/ +JS_EXPORT bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the number type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the number type, otherwise false. +*/ +JS_EXPORT bool JSValueIsNumber(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the string type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the string type, otherwise false. +*/ +JS_EXPORT bool JSValueIsString(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the object type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the object type, otherwise false. +*/ +JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value is an object with a given class in its class chain. +@param ctx The execution context to use. +@param value The JSValue to test. +@param jsClass The JSClass to test against. +@result true if value is an object and has jsClass in its class chain, otherwise false. +*/ +JS_EXPORT bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass); + +// Comparing values + +/*! +@function +@abstract Tests whether two JavaScript values are equal, as compared by the JS == operator. +@param ctx The execution context to use. +@param a The first value to test. +@param b The second value to test. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result true if the two values are equal, false if they are not equal or an exception is thrown. +*/ +JS_EXPORT bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception); + +/*! +@function +@abstract Tests whether two JavaScript values are strict equal, as compared by the JS === operator. +@param ctx The execution context to use. +@param a The first value to test. +@param b The second value to test. +@result true if the two values are strict equal, otherwise false. +*/ +JS_EXPORT bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b); + +/*! +@function +@abstract Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator. +@param ctx The execution context to use. +@param value The JSValue to test. +@param constructor The constructor to test against. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false. +*/ +JS_EXPORT bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception); + +// Creating values + +/*! +@function +@abstract Creates a JavaScript value of the undefined type. +@param ctx The execution context to use. +@result The unique undefined value. +*/ +JS_EXPORT JSValueRef JSValueMakeUndefined(JSContextRef ctx); + +/*! +@function +@abstract Creates a JavaScript value of the null type. +@param ctx The execution context to use. +@result The unique null value. +*/ +JS_EXPORT JSValueRef JSValueMakeNull(JSContextRef ctx); + +/*! +@function +@abstract Creates a JavaScript value of the boolean type. +@param ctx The execution context to use. +@param boolean The bool to assign to the newly created JSValue. +@result A JSValue of the boolean type, representing the value of boolean. +*/ +JS_EXPORT JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool boolean); + +/*! +@function +@abstract Creates a JavaScript value of the number type. +@param ctx The execution context to use. +@param number The double to assign to the newly created JSValue. +@result A JSValue of the number type, representing the value of number. +*/ +JS_EXPORT JSValueRef JSValueMakeNumber(JSContextRef ctx, double number); + +/*! +@function +@abstract Creates a JavaScript value of the string type. +@param ctx The execution context to use. +@param string The JSString to assign to the newly created JSValue. The + newly created JSValue retains string, and releases it upon garbage collection. +@result A JSValue of the string type, representing the value of string. +*/ +JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string); + +// Converting to primitive values + +/*! +@function +@abstract Converts a JavaScript value to boolean and returns the resulting boolean. +@param ctx The execution context to use. +@param value The JSValue to convert. +@result The boolean result of conversion. +*/ +JS_EXPORT bool JSValueToBoolean(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Converts a JavaScript value to number and returns the resulting number. +@param ctx The execution context to use. +@param value The JSValue to convert. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The numeric result of conversion, or NaN if an exception is thrown. +*/ +JS_EXPORT double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception); + +/*! +@function +@abstract Converts a JavaScript value to string and copies the result into a JavaScript string. +@param ctx The execution context to use. +@param value The JSValue to convert. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception); + +/*! +@function +@abstract Converts a JavaScript value to object and returns the resulting object. +@param ctx The execution context to use. +@param value The JSValue to convert. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The JSObject result of conversion, or NULL if an exception is thrown. +*/ +JS_EXPORT JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception); + +// Garbage collection +/*! +@function +@abstract Protects a JavaScript value from garbage collection. +@param ctx The execution context to use. +@param value The JSValue to protect. +@discussion Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it. + +A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection. +*/ +JS_EXPORT void JSValueProtect(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Unprotects a JavaScript value from garbage collection. +@param ctx The execution context to use. +@param value The JSValue to unprotect. +@discussion A value may be protected multiple times and must be unprotected an + equal number of times before becoming eligible for garbage collection. +*/ +JS_EXPORT void JSValueUnprotect(JSContextRef ctx, JSValueRef value); + +#ifdef __cplusplus +} +#endif + +#endif // JSValueRef_h diff --git a/API/JavaScript.h b/API/JavaScript.h new file mode 100644 index 0000000..3a6cc38 --- /dev/null +++ b/API/JavaScript.h @@ -0,0 +1,37 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Inc. All rights reserved. + * Copyright (C) 2008 Alp Toker + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JavaScript_h +#define JavaScript_h + +#include +#include +#include +#include +#include + +#endif // JavaScript_h diff --git a/API/JavaScriptCore.h b/API/JavaScriptCore.h new file mode 100644 index 0000000..be6b8b2 --- /dev/null +++ b/API/JavaScriptCore.h @@ -0,0 +1,33 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JavaScriptCore_h +#define JavaScriptCore_h + +#include +#include + +#endif // JavaScriptCore_h diff --git a/API/Node.c b/API/Node.c new file mode 100644 index 0000000..3ff82e2 --- /dev/null +++ b/API/Node.c @@ -0,0 +1,86 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Node.h" +#include +#include + +Node* Node_new(void) +{ + Node* node = (Node*)malloc(sizeof(Node)); + node->refCount = 0; + node->nodeType = "Node"; + node->childNodesTail = NULL; + + return node; +} + +void Node_appendChild(Node* node, Node* child) +{ + Node_ref(child); + NodeLink* nodeLink = (NodeLink*)malloc(sizeof(NodeLink)); + nodeLink->node = child; + nodeLink->prev = node->childNodesTail; + node->childNodesTail = nodeLink; +} + +void Node_removeChild(Node* node, Node* child) +{ + // Linear search from tail -- good enough for our purposes here + NodeLink* current; + NodeLink** currentHandle; + for (currentHandle = &node->childNodesTail, current = *currentHandle; current; currentHandle = ¤t->prev, current = *currentHandle) { + if (current->node == child) { + Node_deref(current->node); + *currentHandle = current->prev; + free(current); + break; + } + } +} + +void Node_replaceChild(Node* node, Node* newChild, Node* oldChild) +{ + // Linear search from tail -- good enough for our purposes here + NodeLink* current; + for (current = node->childNodesTail; current; current = current->prev) { + if (current->node == oldChild) { + Node_deref(current->node); + current->node = newChild; + } + } +} + +void Node_ref(Node* node) +{ + ++node->refCount; +} + +void Node_deref(Node* node) +{ + if (--node->refCount == 0) + free(node); +} diff --git a/API/Node.h b/API/Node.h new file mode 100644 index 0000000..04b2c70 --- /dev/null +++ b/API/Node.h @@ -0,0 +1,51 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef Node_h +#define Node_h + +typedef struct __Node Node; +typedef struct __NodeLink NodeLink; + +struct __NodeLink { + Node* node; + NodeLink* prev; +}; + +struct __Node { + unsigned refCount; + const char* nodeType; + NodeLink* childNodesTail; +}; + +extern Node* Node_new(void); +extern void Node_ref(Node* node); +extern void Node_deref(Node* node); +extern void Node_appendChild(Node* node, Node* child); +extern void Node_removeChild(Node* node, Node* child); +extern void Node_replaceChild(Node* node, Node* newChild, Node* oldChild); + +#endif // Node_h diff --git a/API/NodeList.c b/API/NodeList.c new file mode 100644 index 0000000..21b2c62 --- /dev/null +++ b/API/NodeList.c @@ -0,0 +1,82 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "NodeList.h" + +#include + +extern NodeList* NodeList_new(Node* parentNode) +{ + Node_ref(parentNode); + + NodeList* nodeList = (NodeList*)malloc(sizeof(NodeList)); + nodeList->parentNode = parentNode; + nodeList->refCount = 0; + return nodeList; +} + +extern unsigned NodeList_length(NodeList* nodeList) +{ + // Linear count from tail -- good enough for our purposes here + unsigned i = 0; + NodeLink* n = nodeList->parentNode->childNodesTail; + while (n) { + n = n->prev; + ++i; + } + + return i; +} + +extern Node* NodeList_item(NodeList* nodeList, unsigned index) +{ + unsigned length = NodeList_length(nodeList); + if (index >= length) + return NULL; + + // Linear search from tail -- good enough for our purposes here + NodeLink* n = nodeList->parentNode->childNodesTail; + unsigned i = 0; + unsigned count = length - 1 - index; + while (i < count) { + ++i; + n = n->prev; + } + return n->node; +} + +extern void NodeList_ref(NodeList* nodeList) +{ + ++nodeList->refCount; +} + +extern void NodeList_deref(NodeList* nodeList) +{ + if (--nodeList->refCount == 0) { + Node_deref(nodeList->parentNode); + free(nodeList); + } +} diff --git a/API/NodeList.h b/API/NodeList.h new file mode 100644 index 0000000..289d206 --- /dev/null +++ b/API/NodeList.h @@ -0,0 +1,43 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NodeList_h +#define NodeList_h + +#include "Node.h" + +typedef struct { + unsigned refCount; + Node* parentNode; +} NodeList; + +extern NodeList* NodeList_new(Node* parentNode); +extern unsigned NodeList_length(NodeList*); +extern Node* NodeList_item(NodeList*, unsigned); +extern void NodeList_ref(NodeList*); +extern void NodeList_deref(NodeList*); + +#endif // NodeList_h diff --git a/API/minidom.c b/API/minidom.c new file mode 100644 index 0000000..1537925 --- /dev/null +++ b/API/minidom.c @@ -0,0 +1,128 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2007 Alp Toker + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "JSContextRef.h" +#include "JSNode.h" +#include "JSObjectRef.h" +#include "JSStringRef.h" +#include +#include +#include +#include + +static char* createStringWithContentsOfFile(const char* fileName); +static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +int main(int argc, char* argv[]) +{ + const char *scriptPath = "minidom.js"; + if (argc > 1) { + scriptPath = argv[1]; + } + + JSGlobalContextRef context = JSGlobalContextCreate(NULL); + JSObjectRef globalObject = JSContextGetGlobalObject(context); + + JSStringRef printIString = JSStringCreateWithUTF8CString("print"); + JSObjectSetProperty(context, globalObject, printIString, JSObjectMakeFunctionWithCallback(context, printIString, print), kJSPropertyAttributeNone, NULL); + JSStringRelease(printIString); + + JSStringRef node = JSStringCreateWithUTF8CString("Node"); + JSObjectSetProperty(context, globalObject, node, JSObjectMakeConstructor(context, JSNode_class(context), JSNode_construct), kJSPropertyAttributeNone, NULL); + JSStringRelease(node); + + char* scriptUTF8 = createStringWithContentsOfFile(scriptPath); + JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8); + JSValueRef exception; + JSValueRef result = JSEvaluateScript(context, script, NULL, NULL, 0, &exception); + if (result) + printf("PASS: Test script executed successfully.\n"); + else { + printf("FAIL: Test script threw exception:\n"); + JSStringRef exceptionIString = JSValueToStringCopy(context, exception, NULL); + size_t exceptionUTF8Size = JSStringGetMaximumUTF8CStringSize(exceptionIString); + char* exceptionUTF8 = (char*)malloc(exceptionUTF8Size); + JSStringGetUTF8CString(exceptionIString, exceptionUTF8, exceptionUTF8Size); + printf("%s\n", exceptionUTF8); + free(exceptionUTF8); + JSStringRelease(exceptionIString); + } + JSStringRelease(script); + free(scriptUTF8); + + globalObject = 0; + JSGlobalContextRelease(context); + JSGarbageCollect(context); + printf("PASS: Program exited normally.\n"); + return 0; +} + +static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + UNUSED_PARAM(object); + UNUSED_PARAM(thisObject); + + if (argumentCount > 0) { + JSStringRef string = JSValueToStringCopy(context, arguments[0], exception); + size_t numChars = JSStringGetMaximumUTF8CStringSize(string); + char stringUTF8[numChars]; + JSStringGetUTF8CString(string, stringUTF8, numChars); + printf("%s\n", stringUTF8); + } + + return JSValueMakeUndefined(context); +} + +static char* createStringWithContentsOfFile(const char* fileName) +{ + char* buffer; + + size_t buffer_size = 0; + size_t buffer_capacity = 1024; + buffer = (char*)malloc(buffer_capacity); + + FILE* f = fopen(fileName, "r"); + if (!f) { + fprintf(stderr, "Could not open file: %s\n", fileName); + return 0; + } + + while (!feof(f) && !ferror(f)) { + buffer_size += fread(buffer + buffer_size, 1, buffer_capacity - buffer_size, f); + if (buffer_size == buffer_capacity) { // guarantees space for trailing '\0' + buffer_capacity *= 2; + buffer = (char*)realloc(buffer, buffer_capacity); + ASSERT(buffer); + } + + ASSERT(buffer_size < buffer_capacity); + } + fclose(f); + buffer[buffer_size] = '\0'; + + return buffer; +} diff --git a/API/minidom.html b/API/minidom.html new file mode 100644 index 0000000..7ea4747 --- /dev/null +++ b/API/minidom.html @@ -0,0 +1,9 @@ + + + + + + +

+
+
diff --git a/API/minidom.js b/API/minidom.js
new file mode 100644
index 0000000..7624d39
--- /dev/null
+++ b/API/minidom.js
@@ -0,0 +1,111 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+function shouldBe(a, b)
+{
+    var evalA;
+    try {
+        evalA = eval(a);
+    } catch(e) {
+        evalA = e;
+    }
+    
+    if (evalA == b || isNaN(evalA) && typeof evalA == 'number' && isNaN(b) && typeof b == 'number')
+        print("PASS: " + a + " should be " + b + " and is.", "green");
+    else
+        print("__FAIL__: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
+}
+
+function test()
+{
+    print("Node is " + Node);
+    for (var p in Node)
+        print(p + ": " + Node[p]);
+    
+    node = new Node();
+    print("node is " + node);
+    for (var p in node)
+        print(p + ": " + node[p]);
+
+    child1 = new Node();
+    child2 = new Node();
+    child3 = new Node();
+    
+    node.appendChild(child1);
+    node.appendChild(child2);
+
+    var childNodes = node.childNodes;
+    
+    for (var i = 0; i < childNodes.length + 1; i++) {
+        print("item " + i + ": " + childNodes.item(i));
+    }
+    
+    for (var i = 0; i < childNodes.length + 1; i++) {
+        print(i + ": " + childNodes[i]);
+    }
+
+    node.removeChild(child1);
+    node.replaceChild(child3, child2);
+    
+    for (var i = 0; i < childNodes.length + 1; i++) {
+        print("item " + i + ": " + childNodes.item(i));
+    }
+
+    for (var i = 0; i < childNodes.length + 1; i++) {
+        print(i + ": " + childNodes[i]);
+    }
+
+    try {
+        node.appendChild(null);
+    } catch(e) {
+        print("caught: " + e);
+    }
+    
+    try {
+        var o = new Object();
+        o.appendChild = node.appendChild;
+        o.appendChild(node);
+    } catch(e) {
+        print("caught: " + e);
+    }
+    
+    try {
+        node.appendChild();
+    } catch(e) {
+        print("caught: " + e);
+    }
+    
+    oldNodeType = node.nodeType;
+    node.nodeType = 1;
+    shouldBe("node.nodeType", oldNodeType);
+    
+    shouldBe("node instanceof Node", true);
+    shouldBe("new Object() instanceof Node", false);
+    
+    print(Node);
+}
+
+test();
diff --git a/API/testapi.c b/API/testapi.c
new file mode 100644
index 0000000..5319b89
--- /dev/null
+++ b/API/testapi.c
@@ -0,0 +1,944 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "JavaScriptCore.h"
+#include 
+#include 
+#include 
+
+static JSGlobalContextRef context = 0;
+
+static void assertEqualsAsBoolean(JSValueRef value, bool expectedValue)
+{
+    if (JSValueToBoolean(context, value) != expectedValue)
+        fprintf(stderr, "assertEqualsAsBoolean failed: %p, %d\n", value, expectedValue);
+}
+
+static void assertEqualsAsNumber(JSValueRef value, double expectedValue)
+{
+    double number = JSValueToNumber(context, value, NULL);
+
+    // FIXME  - On i386 the isnan(double) macro tries to map to the isnan(float) function,
+    // causing a build break with -Wshorten-64-to-32 enabled.  The issue is known by the appropriate team.
+    // After that's resolved, we can remove these casts
+    if (number != expectedValue && !(isnan((float)number) && isnan((float)expectedValue)))
+        fprintf(stderr, "assertEqualsAsNumber failed: %p, %lf\n", value, expectedValue);
+}
+
+static void assertEqualsAsUTF8String(JSValueRef value, const char* expectedValue)
+{
+    JSStringRef valueAsString = JSValueToStringCopy(context, value, NULL);
+
+    size_t jsSize = JSStringGetMaximumUTF8CStringSize(valueAsString);
+    char jsBuffer[jsSize];
+    JSStringGetUTF8CString(valueAsString, jsBuffer, jsSize);
+    
+    unsigned i;
+    for (i = 0; jsBuffer[i]; i++)
+        if (jsBuffer[i] != expectedValue[i])
+            fprintf(stderr, "assertEqualsAsUTF8String failed at character %d: %c(%d) != %c(%d)\n", i, jsBuffer[i], jsBuffer[i], expectedValue[i], expectedValue[i]);
+        
+    if (jsSize < strlen(jsBuffer) + 1)
+        fprintf(stderr, "assertEqualsAsUTF8String failed: jsSize was too small\n");
+
+    JSStringRelease(valueAsString);
+}
+
+static void assertEqualsAsCharactersPtr(JSValueRef value, const char* expectedValue)
+{
+    JSStringRef valueAsString = JSValueToStringCopy(context, value, NULL);
+
+    size_t jsLength = JSStringGetLength(valueAsString);
+    const JSChar* jsBuffer = JSStringGetCharactersPtr(valueAsString);
+
+    CFStringRef expectedValueAsCFString = CFStringCreateWithCString(kCFAllocatorDefault, 
+                                                                    expectedValue,
+                                                                    kCFStringEncodingUTF8);    
+    CFIndex cfLength = CFStringGetLength(expectedValueAsCFString);
+    UniChar cfBuffer[cfLength];
+    CFStringGetCharacters(expectedValueAsCFString, CFRangeMake(0, cfLength), cfBuffer);
+    CFRelease(expectedValueAsCFString);
+
+    if (memcmp(jsBuffer, cfBuffer, cfLength * sizeof(UniChar)) != 0)
+        fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsBuffer != cfBuffer\n");
+    
+    if (jsLength != (size_t)cfLength)
+        fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%ld) != cfLength(%ld)\n", jsLength, cfLength);
+    
+    JSStringRelease(valueAsString);
+}
+
+static JSValueRef jsGlobalValue; // non-stack value for testing JSValueProtect()
+
+/* MyObject pseudo-class */
+
+static bool MyObject_hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(object);
+
+    if (JSStringIsEqualToUTF8CString(propertyName, "alwaysOne")
+        || JSStringIsEqualToUTF8CString(propertyName, "cantFind")
+        || JSStringIsEqualToUTF8CString(propertyName, "myPropertyName")
+        || JSStringIsEqualToUTF8CString(propertyName, "hasPropertyLie")
+        || JSStringIsEqualToUTF8CString(propertyName, "0")) {
+        return true;
+    }
+    
+    return false;
+}
+
+static JSValueRef MyObject_getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(object);
+    
+    if (JSStringIsEqualToUTF8CString(propertyName, "alwaysOne")) {
+        return JSValueMakeNumber(context, 1);
+    }
+    
+    if (JSStringIsEqualToUTF8CString(propertyName, "myPropertyName")) {
+        return JSValueMakeNumber(context, 1);
+    }
+
+    if (JSStringIsEqualToUTF8CString(propertyName, "cantFind")) {
+        return JSValueMakeUndefined(context);
+    }
+    
+    if (JSStringIsEqualToUTF8CString(propertyName, "0")) {
+        *exception = JSValueMakeNumber(context, 1);
+        return JSValueMakeNumber(context, 1);
+    }
+    
+    return NULL;
+}
+
+static bool MyObject_setProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(value);
+    UNUSED_PARAM(exception);
+
+    if (JSStringIsEqualToUTF8CString(propertyName, "cantSet"))
+        return true; // pretend we set the property in order to swallow it
+    
+    return false;
+}
+
+static bool MyObject_deleteProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(object);
+    
+    if (JSStringIsEqualToUTF8CString(propertyName, "cantDelete"))
+        return true;
+    
+    if (JSStringIsEqualToUTF8CString(propertyName, "throwOnDelete")) {
+        *exception = JSValueMakeNumber(context, 2);
+        return false;
+    }
+
+    return false;
+}
+
+static void MyObject_getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames)
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(object);
+    
+    JSStringRef propertyName;
+    
+    propertyName = JSStringCreateWithUTF8CString("alwaysOne");
+    JSPropertyNameAccumulatorAddName(propertyNames, propertyName);
+    JSStringRelease(propertyName);
+    
+    propertyName = JSStringCreateWithUTF8CString("myPropertyName");
+    JSPropertyNameAccumulatorAddName(propertyNames, propertyName);
+    JSStringRelease(propertyName);
+}
+
+static JSValueRef MyObject_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(thisObject);
+    UNUSED_PARAM(exception);
+
+    if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(context, 0)))
+        return JSValueMakeNumber(context, 1);
+    
+    return JSValueMakeUndefined(context);
+}
+
+static JSObjectRef MyObject_callAsConstructor(JSContextRef context, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(object);
+
+    if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(context, 0)))
+        return JSValueToObject(context, JSValueMakeNumber(context, 1), exception);
+    
+    return JSValueToObject(context, JSValueMakeNumber(context, 0), exception);
+}
+
+static bool MyObject_hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleValue, JSValueRef* exception)
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(constructor);
+
+    JSStringRef numberString = JSStringCreateWithUTF8CString("Number");
+    JSObjectRef numberConstructor = JSValueToObject(context, JSObjectGetProperty(context, JSContextGetGlobalObject(context), numberString, exception), exception);
+    JSStringRelease(numberString);
+
+    return JSValueIsInstanceOfConstructor(context, possibleValue, numberConstructor, exception);
+}
+
+static JSValueRef MyObject_convertToType(JSContextRef context, JSObjectRef object, JSType type, JSValueRef* exception)
+{
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(exception);
+    
+    switch (type) {
+    case kJSTypeNumber:
+        return JSValueMakeNumber(context, 1);
+    default:
+        break;
+    }
+
+    // string conversion -- forward to default object class
+    return NULL;
+}
+
+static JSStaticValue evilStaticValues[] = {
+    { "nullGetSet", 0, 0, kJSPropertyAttributeNone },
+    { 0, 0, 0, 0 }
+};
+
+static JSStaticFunction evilStaticFunctions[] = {
+    { "nullCall", 0, kJSPropertyAttributeNone },
+    { 0, 0, 0 }
+};
+
+JSClassDefinition MyObject_definition = {
+    0,
+    kJSClassAttributeNone,
+    
+    "MyObject",
+    NULL,
+    
+    evilStaticValues,
+    evilStaticFunctions,
+    
+    NULL,
+    NULL,
+    MyObject_hasProperty,
+    MyObject_getProperty,
+    MyObject_setProperty,
+    MyObject_deleteProperty,
+    MyObject_getPropertyNames,
+    MyObject_callAsFunction,
+    MyObject_callAsConstructor,
+    MyObject_hasInstance,
+    MyObject_convertToType,
+};
+
+static JSClassRef MyObject_class(JSContextRef context)
+{
+    UNUSED_PARAM(context);
+
+    static JSClassRef jsClass;
+    if (!jsClass)
+        jsClass = JSClassCreate(&MyObject_definition);
+    
+    return jsClass;
+}
+
+static JSValueRef Base_get(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(propertyName);
+    UNUSED_PARAM(exception);
+
+    return JSValueMakeNumber(ctx, 1); // distinguish base get form derived get
+}
+
+static bool Base_set(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(propertyName);
+    UNUSED_PARAM(value);
+
+    *exception = JSValueMakeNumber(ctx, 1); // distinguish base set from derived set
+    return true;
+}
+
+static JSValueRef Base_callAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    UNUSED_PARAM(function);
+    UNUSED_PARAM(thisObject);
+    UNUSED_PARAM(argumentCount);
+    UNUSED_PARAM(arguments);
+    UNUSED_PARAM(exception);
+    
+    return JSValueMakeNumber(ctx, 1); // distinguish base call from derived call
+}
+
+static JSStaticFunction Base_staticFunctions[] = {
+    { "baseProtoDup", NULL, kJSPropertyAttributeNone },
+    { "baseProto", Base_callAsFunction, kJSPropertyAttributeNone },
+    { 0, 0, 0 }
+};
+
+static JSStaticValue Base_staticValues[] = {
+    { "baseDup", Base_get, Base_set, kJSPropertyAttributeNone },
+    { "baseOnly", Base_get, Base_set, kJSPropertyAttributeNone },
+    { 0, 0, 0, 0 }
+};
+
+static bool TestInitializeFinalize;
+static void Base_initialize(JSContextRef context, JSObjectRef object)
+{
+    UNUSED_PARAM(context);
+
+    if (TestInitializeFinalize) {
+        ASSERT((void*)1 == JSObjectGetPrivate(object));
+        JSObjectSetPrivate(object, (void*)2);
+    }
+}
+
+static unsigned Base_didFinalize;
+static void Base_finalize(JSObjectRef object)
+{
+    UNUSED_PARAM(object);
+    if (TestInitializeFinalize) {
+        ASSERT((void*)4 == JSObjectGetPrivate(object));
+        Base_didFinalize = true;
+    }
+}
+
+static JSClassRef Base_class(JSContextRef context)
+{
+    UNUSED_PARAM(context);
+
+    static JSClassRef jsClass;
+    if (!jsClass) {
+        JSClassDefinition definition = kJSClassDefinitionEmpty;
+        definition.staticValues = Base_staticValues;
+        definition.staticFunctions = Base_staticFunctions;
+        definition.initialize = Base_initialize;
+        definition.finalize = Base_finalize;
+        jsClass = JSClassCreate(&definition);
+    }
+    return jsClass;
+}
+
+static JSValueRef Derived_get(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(propertyName);
+    UNUSED_PARAM(exception);
+
+    return JSValueMakeNumber(ctx, 2); // distinguish base get form derived get
+}
+
+static bool Derived_set(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+    UNUSED_PARAM(ctx);
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(propertyName);
+    UNUSED_PARAM(value);
+
+    *exception = JSValueMakeNumber(ctx, 2); // distinguish base set from derived set
+    return true;
+}
+
+static JSValueRef Derived_callAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    UNUSED_PARAM(function);
+    UNUSED_PARAM(thisObject);
+    UNUSED_PARAM(argumentCount);
+    UNUSED_PARAM(arguments);
+    UNUSED_PARAM(exception);
+    
+    return JSValueMakeNumber(ctx, 2); // distinguish base call from derived call
+}
+
+static JSStaticFunction Derived_staticFunctions[] = {
+    { "protoOnly", Derived_callAsFunction, kJSPropertyAttributeNone },
+    { "protoDup", NULL, kJSPropertyAttributeNone },
+    { "baseProtoDup", Derived_callAsFunction, kJSPropertyAttributeNone },
+    { 0, 0, 0 }
+};
+
+static JSStaticValue Derived_staticValues[] = {
+    { "derivedOnly", Derived_get, Derived_set, kJSPropertyAttributeNone },
+    { "protoDup", Derived_get, Derived_set, kJSPropertyAttributeNone },
+    { "baseDup", Derived_get, Derived_set, kJSPropertyAttributeNone },
+    { 0, 0, 0, 0 }
+};
+
+static void Derived_initialize(JSContextRef context, JSObjectRef object)
+{
+    UNUSED_PARAM(context);
+
+    if (TestInitializeFinalize) {
+        ASSERT((void*)2 == JSObjectGetPrivate(object));
+        JSObjectSetPrivate(object, (void*)3);
+    }
+}
+
+static void Derived_finalize(JSObjectRef object)
+{
+    if (TestInitializeFinalize) {
+        ASSERT((void*)3 == JSObjectGetPrivate(object));
+        JSObjectSetPrivate(object, (void*)4);
+    }
+}
+
+static JSClassRef Derived_class(JSContextRef context)
+{
+    static JSClassRef jsClass;
+    if (!jsClass) {
+        JSClassDefinition definition = kJSClassDefinitionEmpty;
+        definition.parentClass = Base_class(context);
+        definition.staticValues = Derived_staticValues;
+        definition.staticFunctions = Derived_staticFunctions;
+        definition.initialize = Derived_initialize;
+        definition.finalize = Derived_finalize;
+        jsClass = JSClassCreate(&definition);
+    }
+    return jsClass;
+}
+
+static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functionObject, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    UNUSED_PARAM(functionObject);
+    UNUSED_PARAM(thisObject);
+    UNUSED_PARAM(exception);
+    
+    if (argumentCount > 0) {
+        JSStringRef string = JSValueToStringCopy(context, arguments[0], NULL);
+        size_t sizeUTF8 = JSStringGetMaximumUTF8CStringSize(string);
+        char stringUTF8[sizeUTF8];
+        JSStringGetUTF8CString(string, stringUTF8, sizeUTF8);
+        printf("%s\n", stringUTF8);
+        JSStringRelease(string);
+    }
+    
+    return JSValueMakeUndefined(context);
+}
+
+static JSObjectRef myConstructor_callAsConstructor(JSContextRef context, JSObjectRef constructorObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    UNUSED_PARAM(constructorObject);
+    UNUSED_PARAM(exception);
+    
+    JSObjectRef result = JSObjectMake(context, NULL, NULL);
+    if (argumentCount > 0) {
+        JSStringRef value = JSStringCreateWithUTF8CString("value");
+        JSObjectSetProperty(context, result, value, arguments[0], kJSPropertyAttributeNone, NULL);
+        JSStringRelease(value);
+    }
+    
+    return result;
+}
+
+
+static void globalObject_initialize(JSContextRef context, JSObjectRef object)
+{
+    UNUSED_PARAM(object);
+    // Ensure that an execution context is passed in
+    ASSERT(context);
+
+    // Ensure that the global object is set to the object that we were passed
+    JSObjectRef globalObject = JSContextGetGlobalObject(context);
+    ASSERT(globalObject);
+    ASSERT(object == globalObject);
+
+    // Ensure that the standard global properties have been set on the global object
+    JSStringRef array = JSStringCreateWithUTF8CString("Array");
+    JSObjectRef arrayConstructor = JSValueToObject(context, JSObjectGetProperty(context, globalObject, array, NULL), NULL);
+    JSStringRelease(array);
+
+    UNUSED_PARAM(arrayConstructor);
+    ASSERT(arrayConstructor);
+}
+
+static JSValueRef globalObject_get(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(propertyName);
+    UNUSED_PARAM(exception);
+
+    return JSValueMakeNumber(ctx, 3);
+}
+
+static bool globalObject_set(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+    UNUSED_PARAM(object);
+    UNUSED_PARAM(propertyName);
+    UNUSED_PARAM(value);
+
+    *exception = JSValueMakeNumber(ctx, 3);
+    return true;
+}
+
+static JSValueRef globalObject_call(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    UNUSED_PARAM(function);
+    UNUSED_PARAM(thisObject);
+    UNUSED_PARAM(argumentCount);
+    UNUSED_PARAM(arguments);
+    UNUSED_PARAM(exception);
+
+    return JSValueMakeNumber(ctx, 3);
+}
+
+static JSStaticValue globalObject_staticValues[] = {
+    { "globalStaticValue", globalObject_get, globalObject_set, kJSPropertyAttributeNone },
+    { 0, 0, 0, 0 }
+};
+
+static JSStaticFunction globalObject_staticFunctions[] = {
+    { "globalStaticFunction", globalObject_call, kJSPropertyAttributeNone },
+    { 0, 0, 0 }
+};
+
+static char* createStringWithContentsOfFile(const char* fileName);
+
+static void testInitializeFinalize()
+{
+    JSObjectRef o = JSObjectMake(context, Derived_class(context), (void*)1);
+    UNUSED_PARAM(o);
+    ASSERT(JSObjectGetPrivate(o) == (void*)3);
+}
+
+int main(int argc, char* argv[])
+{
+    const char *scriptPath = "testapi.js";
+    if (argc > 1) {
+        scriptPath = argv[1];
+    }
+    
+    // Test garbage collection with a fresh context
+    context = JSGlobalContextCreate(NULL);
+    TestInitializeFinalize = true;
+    testInitializeFinalize();
+    JSGlobalContextRelease(context);
+    JSGarbageCollect(context);
+    TestInitializeFinalize = false;
+
+    ASSERT(Base_didFinalize);
+
+    JSClassDefinition globalObjectClassDefinition = kJSClassDefinitionEmpty;
+    globalObjectClassDefinition.initialize = globalObject_initialize;
+    globalObjectClassDefinition.staticValues = globalObject_staticValues;
+    globalObjectClassDefinition.staticFunctions = globalObject_staticFunctions;
+    globalObjectClassDefinition.attributes = kJSClassAttributeNoAutomaticPrototype;
+    JSClassRef globalObjectClass = JSClassCreate(&globalObjectClassDefinition);
+    context = JSGlobalContextCreate(globalObjectClass);
+    
+    JSObjectRef globalObject = JSContextGetGlobalObject(context);
+    ASSERT(JSValueIsObject(context, globalObject));
+    
+    JSValueRef jsUndefined = JSValueMakeUndefined(context);
+    JSValueRef jsNull = JSValueMakeNull(context);
+    JSValueRef jsTrue = JSValueMakeBoolean(context, true);
+    JSValueRef jsFalse = JSValueMakeBoolean(context, false);
+    JSValueRef jsZero = JSValueMakeNumber(context, 0);
+    JSValueRef jsOne = JSValueMakeNumber(context, 1);
+    JSValueRef jsOneThird = JSValueMakeNumber(context, 1.0 / 3.0);
+    JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, NULL);
+    JSObjectSetPrototype(context, jsObjectNoProto, JSValueMakeNull(context));
+
+    // FIXME: test funny utf8 characters
+    JSStringRef jsEmptyIString = JSStringCreateWithUTF8CString("");
+    JSValueRef jsEmptyString = JSValueMakeString(context, jsEmptyIString);
+    
+    JSStringRef jsOneIString = JSStringCreateWithUTF8CString("1");
+    JSValueRef jsOneString = JSValueMakeString(context, jsOneIString);
+
+    UniChar singleUniChar = 65; // Capital A
+    CFMutableStringRef cfString = 
+        CFStringCreateMutableWithExternalCharactersNoCopy(kCFAllocatorDefault,
+                                                          &singleUniChar,
+                                                          1,
+                                                          1,
+                                                          kCFAllocatorNull);
+
+    JSStringRef jsCFIString = JSStringCreateWithCFString(cfString);
+    JSValueRef jsCFString = JSValueMakeString(context, jsCFIString);
+    
+    CFStringRef cfEmptyString = CFStringCreateWithCString(kCFAllocatorDefault, "", kCFStringEncodingUTF8);
+    
+    JSStringRef jsCFEmptyIString = JSStringCreateWithCFString(cfEmptyString);
+    JSValueRef jsCFEmptyString = JSValueMakeString(context, jsCFEmptyIString);
+
+    CFIndex cfStringLength = CFStringGetLength(cfString);
+    UniChar buffer[cfStringLength];
+    CFStringGetCharacters(cfString, 
+                          CFRangeMake(0, cfStringLength), 
+                          buffer);
+    JSStringRef jsCFIStringWithCharacters = JSStringCreateWithCharacters(buffer, cfStringLength);
+    JSValueRef jsCFStringWithCharacters = JSValueMakeString(context, jsCFIStringWithCharacters);
+    
+    JSStringRef jsCFEmptyIStringWithCharacters = JSStringCreateWithCharacters(buffer, CFStringGetLength(cfEmptyString));
+    JSValueRef jsCFEmptyStringWithCharacters = JSValueMakeString(context, jsCFEmptyIStringWithCharacters);
+
+    ASSERT(JSValueGetType(context, jsUndefined) == kJSTypeUndefined);
+    ASSERT(JSValueGetType(context, jsNull) == kJSTypeNull);
+    ASSERT(JSValueGetType(context, jsTrue) == kJSTypeBoolean);
+    ASSERT(JSValueGetType(context, jsFalse) == kJSTypeBoolean);
+    ASSERT(JSValueGetType(context, jsZero) == kJSTypeNumber);
+    ASSERT(JSValueGetType(context, jsOne) == kJSTypeNumber);
+    ASSERT(JSValueGetType(context, jsOneThird) == kJSTypeNumber);
+    ASSERT(JSValueGetType(context, jsEmptyString) == kJSTypeString);
+    ASSERT(JSValueGetType(context, jsOneString) == kJSTypeString);
+    ASSERT(JSValueGetType(context, jsCFString) == kJSTypeString);
+    ASSERT(JSValueGetType(context, jsCFStringWithCharacters) == kJSTypeString);
+    ASSERT(JSValueGetType(context, jsCFEmptyString) == kJSTypeString);
+    ASSERT(JSValueGetType(context, jsCFEmptyStringWithCharacters) == kJSTypeString);
+
+    JSObjectRef myObject = JSObjectMake(context, MyObject_class(context), NULL);
+    JSStringRef myObjectIString = JSStringCreateWithUTF8CString("MyObject");
+    JSObjectSetProperty(context, globalObject, myObjectIString, myObject, kJSPropertyAttributeNone, NULL);
+    JSStringRelease(myObjectIString);
+    
+    JSValueRef exception;
+
+    // Conversions that throw exceptions
+    exception = NULL;
+    ASSERT(NULL == JSValueToObject(context, jsNull, &exception));
+    ASSERT(exception);
+    
+    exception = NULL;
+    // FIXME  - On i386 the isnan(double) macro tries to map to the isnan(float) function,
+    // causing a build break with -Wshorten-64-to-32 enabled.  The issue is known by the appropriate team.
+    // After that's resolved, we can remove these casts
+    ASSERT(isnan((float)JSValueToNumber(context, jsObjectNoProto, &exception)));
+    ASSERT(exception);
+
+    exception = NULL;
+    ASSERT(!JSValueToStringCopy(context, jsObjectNoProto, &exception));
+    ASSERT(exception);
+    
+    ASSERT(JSValueToBoolean(context, myObject));
+    
+    exception = NULL;
+    ASSERT(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber(context, 1), &exception));
+    ASSERT(exception);
+    
+    exception = NULL;
+    JSObjectGetPropertyAtIndex(context, myObject, 0, &exception);
+    ASSERT(1 == JSValueToNumber(context, exception, NULL));
+
+    assertEqualsAsBoolean(jsUndefined, false);
+    assertEqualsAsBoolean(jsNull, false);
+    assertEqualsAsBoolean(jsTrue, true);
+    assertEqualsAsBoolean(jsFalse, false);
+    assertEqualsAsBoolean(jsZero, false);
+    assertEqualsAsBoolean(jsOne, true);
+    assertEqualsAsBoolean(jsOneThird, true);
+    assertEqualsAsBoolean(jsEmptyString, false);
+    assertEqualsAsBoolean(jsOneString, true);
+    assertEqualsAsBoolean(jsCFString, true);
+    assertEqualsAsBoolean(jsCFStringWithCharacters, true);
+    assertEqualsAsBoolean(jsCFEmptyString, false);
+    assertEqualsAsBoolean(jsCFEmptyStringWithCharacters, false);
+    
+    assertEqualsAsNumber(jsUndefined, nan(""));
+    assertEqualsAsNumber(jsNull, 0);
+    assertEqualsAsNumber(jsTrue, 1);
+    assertEqualsAsNumber(jsFalse, 0);
+    assertEqualsAsNumber(jsZero, 0);
+    assertEqualsAsNumber(jsOne, 1);
+    assertEqualsAsNumber(jsOneThird, 1.0 / 3.0);
+    assertEqualsAsNumber(jsEmptyString, 0);
+    assertEqualsAsNumber(jsOneString, 1);
+    assertEqualsAsNumber(jsCFString, nan(""));
+    assertEqualsAsNumber(jsCFStringWithCharacters, nan(""));
+    assertEqualsAsNumber(jsCFEmptyString, 0);
+    assertEqualsAsNumber(jsCFEmptyStringWithCharacters, 0);
+    ASSERT(sizeof(JSChar) == sizeof(UniChar));
+    
+    assertEqualsAsCharactersPtr(jsUndefined, "undefined");
+    assertEqualsAsCharactersPtr(jsNull, "null");
+    assertEqualsAsCharactersPtr(jsTrue, "true");
+    assertEqualsAsCharactersPtr(jsFalse, "false");
+    assertEqualsAsCharactersPtr(jsZero, "0");
+    assertEqualsAsCharactersPtr(jsOne, "1");
+    assertEqualsAsCharactersPtr(jsOneThird, "0.3333333333333333");
+    assertEqualsAsCharactersPtr(jsEmptyString, "");
+    assertEqualsAsCharactersPtr(jsOneString, "1");
+    assertEqualsAsCharactersPtr(jsCFString, "A");
+    assertEqualsAsCharactersPtr(jsCFStringWithCharacters, "A");
+    assertEqualsAsCharactersPtr(jsCFEmptyString, "");
+    assertEqualsAsCharactersPtr(jsCFEmptyStringWithCharacters, "");
+    
+    assertEqualsAsUTF8String(jsUndefined, "undefined");
+    assertEqualsAsUTF8String(jsNull, "null");
+    assertEqualsAsUTF8String(jsTrue, "true");
+    assertEqualsAsUTF8String(jsFalse, "false");
+    assertEqualsAsUTF8String(jsZero, "0");
+    assertEqualsAsUTF8String(jsOne, "1");
+    assertEqualsAsUTF8String(jsOneThird, "0.3333333333333333");
+    assertEqualsAsUTF8String(jsEmptyString, "");
+    assertEqualsAsUTF8String(jsOneString, "1");
+    assertEqualsAsUTF8String(jsCFString, "A");
+    assertEqualsAsUTF8String(jsCFStringWithCharacters, "A");
+    assertEqualsAsUTF8String(jsCFEmptyString, "");
+    assertEqualsAsUTF8String(jsCFEmptyStringWithCharacters, "");
+    
+    ASSERT(JSValueIsStrictEqual(context, jsTrue, jsTrue));
+    ASSERT(!JSValueIsStrictEqual(context, jsOne, jsOneString));
+
+    ASSERT(JSValueIsEqual(context, jsOne, jsOneString, NULL));
+    ASSERT(!JSValueIsEqual(context, jsTrue, jsFalse, NULL));
+    
+    CFStringRef cfJSString = JSStringCopyCFString(kCFAllocatorDefault, jsCFIString);
+    CFStringRef cfJSEmptyString = JSStringCopyCFString(kCFAllocatorDefault, jsCFEmptyIString);
+    ASSERT(CFEqual(cfJSString, cfString));
+    ASSERT(CFEqual(cfJSEmptyString, cfEmptyString));
+    CFRelease(cfJSString);
+    CFRelease(cfJSEmptyString);
+
+    CFRelease(cfString);
+    CFRelease(cfEmptyString);
+    
+    jsGlobalValue = JSObjectMake(context, NULL, NULL);
+    JSValueProtect(context, jsGlobalValue);
+    JSGarbageCollect(context);
+    ASSERT(JSValueIsObject(context, jsGlobalValue));
+    JSValueUnprotect(context, jsGlobalValue);
+
+    JSStringRef goodSyntax = JSStringCreateWithUTF8CString("x = 1;");
+    JSStringRef badSyntax = JSStringCreateWithUTF8CString("x := 1;");
+    ASSERT(JSCheckScriptSyntax(context, goodSyntax, NULL, 0, NULL));
+    ASSERT(!JSCheckScriptSyntax(context, badSyntax, NULL, 0, NULL));
+
+    JSValueRef result;
+    JSValueRef v;
+    JSObjectRef o;
+    JSStringRef string;
+
+    result = JSEvaluateScript(context, goodSyntax, NULL, NULL, 1, NULL);
+    ASSERT(result);
+    ASSERT(JSValueIsEqual(context, result, jsOne, NULL));
+
+    exception = NULL;
+    result = JSEvaluateScript(context, badSyntax, NULL, NULL, 1, &exception);
+    ASSERT(!result);
+    ASSERT(JSValueIsObject(context, exception));
+    
+    JSStringRef array = JSStringCreateWithUTF8CString("Array");
+    JSObjectRef arrayConstructor = JSValueToObject(context, JSObjectGetProperty(context, globalObject, array, NULL), NULL);
+    JSStringRelease(array);
+    result = JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, NULL);
+    ASSERT(result);
+    ASSERT(JSValueIsObject(context, result));
+    ASSERT(JSValueIsInstanceOfConstructor(context, result, arrayConstructor, NULL));
+    ASSERT(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull(context), arrayConstructor, NULL));
+
+    o = JSValueToObject(context, result, NULL);
+    exception = NULL;
+    ASSERT(JSValueIsUndefined(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception)));
+    ASSERT(!exception);
+    
+    JSObjectSetPropertyAtIndex(context, o, 0, JSValueMakeNumber(context, 1), &exception);
+    ASSERT(!exception);
+    
+    exception = NULL;
+    ASSERT(1 == JSValueToNumber(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception), &exception));
+    ASSERT(!exception);
+
+    JSStringRef functionBody;
+    JSObjectRef function;
+    
+    exception = NULL;
+    functionBody = JSStringCreateWithUTF8CString("rreturn Array;");
+    JSStringRef line = JSStringCreateWithUTF8CString("line");
+    ASSERT(!JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception));
+    ASSERT(JSValueIsObject(context, exception));
+    v = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), line, NULL);
+    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)
+    JSStringRelease(functionBody);
+    JSStringRelease(line);
+
+    exception = NULL;
+    functionBody = JSStringCreateWithUTF8CString("return Array;");
+    function = JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception);
+    JSStringRelease(functionBody);
+    ASSERT(!exception);
+    ASSERT(JSObjectIsFunction(context, function));
+    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
+    ASSERT(v);
+    ASSERT(JSValueIsEqual(context, v, arrayConstructor, NULL));
+    
+    exception = NULL;
+    function = JSObjectMakeFunction(context, NULL, 0, NULL, jsEmptyIString, NULL, 0, &exception);
+    ASSERT(!exception);
+    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, &exception);
+    ASSERT(v && !exception);
+    ASSERT(JSValueIsUndefined(context, v));
+    
+    exception = NULL;
+    v = NULL;
+    JSStringRef foo = JSStringCreateWithUTF8CString("foo");
+    JSStringRef argumentNames[] = { foo };
+    functionBody = JSStringCreateWithUTF8CString("return foo;");
+    function = JSObjectMakeFunction(context, foo, 1, argumentNames, functionBody, NULL, 1, &exception);
+    ASSERT(function && !exception);
+    JSValueRef arguments[] = { JSValueMakeNumber(context, 2) };
+    v = JSObjectCallAsFunction(context, function, NULL, 1, arguments, &exception);
+    JSStringRelease(foo);
+    JSStringRelease(functionBody);
+    
+    string = JSValueToStringCopy(context, function, NULL);
+    assertEqualsAsUTF8String(JSValueMakeString(context, string), "function foo(foo) \n{\n  return foo;\n}");
+    JSStringRelease(string);
+
+    JSStringRef print = JSStringCreateWithUTF8CString("print");
+    JSObjectRef printFunction = JSObjectMakeFunctionWithCallback(context, print, print_callAsFunction);
+    JSObjectSetProperty(context, globalObject, print, printFunction, kJSPropertyAttributeNone, NULL); 
+    JSStringRelease(print);
+    
+    ASSERT(!JSObjectSetPrivate(printFunction, (void*)1));
+    ASSERT(!JSObjectGetPrivate(printFunction));
+
+    JSStringRef myConstructorIString = JSStringCreateWithUTF8CString("MyConstructor");
+    JSObjectRef myConstructor = JSObjectMakeConstructor(context, NULL, myConstructor_callAsConstructor);
+    JSObjectSetProperty(context, globalObject, myConstructorIString, myConstructor, kJSPropertyAttributeNone, NULL);
+    JSStringRelease(myConstructorIString);
+    
+    ASSERT(!JSObjectSetPrivate(myConstructor, (void*)1));
+    ASSERT(!JSObjectGetPrivate(myConstructor));
+    
+    string = JSStringCreateWithUTF8CString("Derived");
+    JSObjectRef derivedConstructor = JSObjectMakeConstructor(context, Derived_class(context), NULL);
+    JSObjectSetProperty(context, globalObject, string, derivedConstructor, kJSPropertyAttributeNone, NULL);
+    JSStringRelease(string);
+    
+    o = JSObjectMake(context, NULL, NULL);
+    JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber(context, 1), kJSPropertyAttributeNone, NULL);
+    JSObjectSetProperty(context, o, jsCFIString,  JSValueMakeNumber(context, 1), kJSPropertyAttributeDontEnum, NULL);
+    JSPropertyNameArrayRef nameArray = JSObjectCopyPropertyNames(context, o);
+    size_t expectedCount = JSPropertyNameArrayGetCount(nameArray);
+    size_t count;
+    for (count = 0; count < expectedCount; ++count)
+        JSPropertyNameArrayGetNameAtIndex(nameArray, count);
+    JSPropertyNameArrayRelease(nameArray);
+    ASSERT(count == 1); // jsCFString should not be enumerated
+
+    JSClassDefinition nullDefinition = kJSClassDefinitionEmpty;
+    nullDefinition.attributes = kJSClassAttributeNoAutomaticPrototype;
+    JSClassRef nullClass = JSClassCreate(&nullDefinition);
+    JSClassRelease(nullClass);
+    
+    nullDefinition = kJSClassDefinitionEmpty;
+    nullClass = JSClassCreate(&nullDefinition);
+    JSClassRelease(nullClass);
+
+    functionBody = JSStringCreateWithUTF8CString("return this;");
+    function = JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, NULL);
+    JSStringRelease(functionBody);
+    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
+    ASSERT(JSValueIsEqual(context, v, globalObject, NULL));
+    v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL);
+    ASSERT(JSValueIsEqual(context, v, o, NULL));
+    
+    char* scriptUTF8 = createStringWithContentsOfFile(scriptPath);	
+    if (!scriptUTF8)
+        printf("FAIL: Test script could not be loaded.\n");
+    else {
+        JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8);
+        result = JSEvaluateScript(context, script, NULL, NULL, 1, &exception);
+        if (JSValueIsUndefined(context, result))
+            printf("PASS: Test script executed successfully.\n");
+        else {
+            printf("FAIL: Test script returned unexpected value:\n");
+            JSStringRef exceptionIString = JSValueToStringCopy(context, exception, NULL);
+            CFStringRef exceptionCF = JSStringCopyCFString(kCFAllocatorDefault, exceptionIString);
+            CFShow(exceptionCF);
+            CFRelease(exceptionCF);
+            JSStringRelease(exceptionIString);
+        }
+        JSStringRelease(script);
+        free(scriptUTF8);
+    }
+
+    // Clear out local variables pointing at JSObjectRefs to allow their values to be collected
+    function = NULL;
+    v = NULL;
+    o = NULL;
+    globalObject = NULL;
+
+    JSStringRelease(jsEmptyIString);
+    JSStringRelease(jsOneIString);
+    JSStringRelease(jsCFIString);
+    JSStringRelease(jsCFEmptyIString);
+    JSStringRelease(jsCFIStringWithCharacters);
+    JSStringRelease(jsCFEmptyIStringWithCharacters);
+    JSStringRelease(goodSyntax);
+    JSStringRelease(badSyntax);
+
+    JSGlobalContextRelease(context);
+    JSGarbageCollect(context);
+    JSClassRelease(globalObjectClass);
+
+    printf("PASS: Program exited normally.\n");
+    return 0;
+}
+
+static char* createStringWithContentsOfFile(const char* fileName)
+{
+    char* buffer;
+    
+    size_t buffer_size = 0;
+    size_t buffer_capacity = 1024;
+    buffer = (char*)malloc(buffer_capacity);
+    
+    FILE* f = fopen(fileName, "r");
+    if (!f) {
+        fprintf(stderr, "Could not open file: %s\n", fileName);
+        return 0;
+    }
+    
+    while (!feof(f) && !ferror(f)) {
+        buffer_size += fread(buffer + buffer_size, 1, buffer_capacity - buffer_size, f);
+        if (buffer_size == buffer_capacity) { // guarantees space for trailing '\0'
+            buffer_capacity *= 2;
+            buffer = (char*)realloc(buffer, buffer_capacity);
+            ASSERT(buffer);
+        }
+        
+        ASSERT(buffer_size < buffer_capacity);
+    }
+    fclose(f);
+    buffer[buffer_size] = '\0';
+    
+    return buffer;
+}
diff --git a/API/testapi.js b/API/testapi.js
new file mode 100644
index 0000000..52bcb71
--- /dev/null
+++ b/API/testapi.js
@@ -0,0 +1,132 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+function shouldBe(a, b)
+{
+    var evalA;
+    try {
+        evalA = eval(a);
+    } catch(e) {
+        evalA = e;
+    }
+    
+    if (evalA == b || isNaN(evalA) && typeof evalA == 'number' && isNaN(b) && typeof b == 'number')
+        print("PASS: " + a + " should be " + b + " and is.", "green");
+    else
+        print("__FAIL__: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
+}
+
+function shouldThrow(a)
+{
+    var result = "__FAIL__: " + a + " did not throw an exception.";
+    
+    var evalA;
+    try {
+        eval(a);
+    } catch(e) {
+        result = "PASS: " + a + " threw: " + e;
+    }
+    
+    print(result);
+}
+
+function globalStaticFunction()
+{
+    return 4;
+}
+
+shouldBe("globalStaticValue", 3);
+shouldBe("globalStaticFunction()", 4);
+
+shouldBe("typeof MyObject", "function"); // our object implements 'call'
+MyObject.cantFind = 1;
+shouldBe("MyObject.cantFind", undefined);
+MyObject.regularType = 1;
+shouldBe("MyObject.regularType", 1);
+MyObject.alwaysOne = 2;
+shouldBe("MyObject.alwaysOne", 1);
+MyObject.cantDelete = 1;
+delete MyObject.cantDelete;
+shouldBe("MyObject.cantDelete", 1);
+shouldBe("delete MyObject.throwOnDelete", 2); // deleteProperty -- should throw 2
+MyObject.cantSet = 1;
+shouldBe("MyObject.cantSet", undefined);
+
+var foundMyPropertyName = false;
+var foundRegularType = false;
+for (var p in MyObject) {
+    if (p == "myPropertyName")
+        foundMyPropertyName = true;
+    if (p == "regularType")
+        foundRegularType = true;
+}
+print(foundMyPropertyName
+      ? "PASS: MyObject.myPropertyName was enumerated"
+      : "__FAIL__: MyObject.myPropertyName was not enumerated");
+print(foundRegularType
+      ? "PASS: MyObject.regularType was enumerated"
+      : "__FAIL__: MyObject.regularType was not enumerated");
+
+myObject = new MyObject();
+
+shouldBe("delete MyObject.regularType", true);
+shouldBe("MyObject.regularType", undefined);
+shouldBe("MyObject(0)", 1);
+shouldBe("MyObject()", undefined);
+shouldBe("typeof myObject", "object");
+shouldBe("MyObject ? 1 : 0", true); // toBoolean
+shouldBe("+MyObject", 1); // toNumber
+shouldBe("(MyObject.toString())", "[object MyObject]"); // toString
+shouldBe("MyObject - 0", NaN); // toPrimitive
+
+shouldBe("typeof MyConstructor", "object");
+constructedObject = new MyConstructor(1);
+shouldBe("typeof constructedObject", "object");
+shouldBe("constructedObject.value", 1);
+shouldBe("myObject instanceof MyObject", true);
+shouldBe("(new Object()) instanceof MyObject", false);
+
+shouldThrow("MyObject.nullGetSet = 1");
+shouldThrow("MyObject.nullGetSet");
+shouldThrow("MyObject.nullCall()");
+shouldThrow("MyObject.hasPropertyLie");
+
+derived = new Derived();
+
+// base properties and functions return 1 when called/gotten; derived, 2
+shouldBe("derived.baseProtoDup()", 2);
+shouldBe("derived.baseProto()", 1);
+shouldBe("derived.baseDup", 2);
+shouldBe("derived.baseOnly", 1);
+shouldBe("derived.protoOnly()", 2);
+shouldBe("derived.protoDup", 2);
+shouldBe("derived.derivedOnly", 2)
+
+// base properties throw 1 when set; derived, 2
+shouldBe("derived.baseDup = 0", 2);
+shouldBe("derived.baseOnly = 0", 1);
+shouldBe("derived.derivedOnly = 0", 2)
+shouldBe("derived.protoDup = 0", 2);
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e50da8c
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Harri Porten (porten@kde.org)
+Peter Kelly (pmk@post.com)
diff --git a/COPYING.LIB b/COPYING.LIB
new file mode 100644
index 0000000..87c4a33
--- /dev/null
+++ b/COPYING.LIB
@@ -0,0 +1,488 @@
+
+
+NOTE! The LGPL below is copyrighted by the Free Software Foundation, but 
+the instance of code that it refers to (the kde libraries) are copyrighted 
+by the authors who actually wrote it.
+				   
+---------------------------------------------------------------------------
+		  GNU LIBRARY GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+                    51 Franklin Street, Fifth Floor
+                    Boston, MA 02110-1301, USA.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL.  It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it.  You can use it for
+your libraries, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library.  If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software.  To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+  Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs.  This
+license, the GNU Library General Public License, applies to certain
+designated libraries.  This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+  The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it.  Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program.  However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+  Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries.  We
+concluded that weaker conditions might promote sharing better.
+
+  However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves.  This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them.  (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.)  The hope is that this
+will lead to faster development of free libraries.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+  Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+		  GNU LIBRARY GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License").  Each licensee is
+addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    c) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    d) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    
+    Copyright (C)   
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  , 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/DerivedSources.make b/DerivedSources.make
new file mode 100644
index 0000000..4f89a6f
--- /dev/null
+++ b/DerivedSources.make
@@ -0,0 +1,65 @@
+# Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer. 
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution. 
+# 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+#     its contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission. 
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+VPATH = \
+    $(JavaScriptCore)/kjs \
+    $(JavaScriptCore)/pcre \
+#
+
+.PHONY : all
+all : \
+    array_object.lut.h \
+    chartables.c \
+    date_object.lut.h \
+    grammar.cpp \
+    lexer.lut.h \
+    math_object.lut.h \
+    number_object.lut.h \
+    regexp_object.lut.h \
+    string_object.lut.h \
+#
+
+# lookup tables for classes
+
+%.lut.h: create_hash_table %.cpp
+	$^ -i > $@
+lexer.lut.h: create_hash_table keywords.table
+	$^ > $@
+
+# JavaScript language grammar
+
+grammar.cpp: grammar.y
+	bison -d -p kjsyy $< -o $@ > bison_out.txt 2>&1
+	perl -p -e 'END { if ($$conflict) { unlink "grammar.cpp"; die; } } $$conflict ||= /conflict/' < bison_out.txt
+	touch grammar.cpp.h
+	touch grammar.hpp
+	cat grammar.cpp.h grammar.hpp > grammar.h
+	rm -f grammar.cpp.h grammar.hpp bison_out.txt
+
+# character tables for PCRE
+
+chartables.c : dftables
+	$^ $@
diff --git a/ForwardingHeaders/JavaScriptCore/APICast.h b/ForwardingHeaders/JavaScriptCore/APICast.h
new file mode 100644
index 0000000..06b566b
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/APICast.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JSBase.h b/ForwardingHeaders/JavaScriptCore/JSBase.h
new file mode 100644
index 0000000..25b2aa4
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JSBase.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JSContextRef.h b/ForwardingHeaders/JavaScriptCore/JSContextRef.h
new file mode 100644
index 0000000..f7e57be
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JSContextRef.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JSLock.h b/ForwardingHeaders/JavaScriptCore/JSLock.h
new file mode 100644
index 0000000..8519612
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JSLock.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JSObjectRef.h b/ForwardingHeaders/JavaScriptCore/JSObjectRef.h
new file mode 100644
index 0000000..7713722
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JSObjectRef.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JSRetainPtr.h b/ForwardingHeaders/JavaScriptCore/JSRetainPtr.h
new file mode 100644
index 0000000..e048d34
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JSRetainPtr.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JSStringRef.h b/ForwardingHeaders/JavaScriptCore/JSStringRef.h
new file mode 100644
index 0000000..d32e0c7
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JSStringRef.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JSStringRefCF.h b/ForwardingHeaders/JavaScriptCore/JSStringRefCF.h
new file mode 100644
index 0000000..11ae723
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JSStringRefCF.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JSValueRef.h b/ForwardingHeaders/JavaScriptCore/JSValueRef.h
new file mode 100644
index 0000000..7186287
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JSValueRef.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JavaScript.h b/ForwardingHeaders/JavaScriptCore/JavaScript.h
new file mode 100644
index 0000000..ab90c6d
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JavaScript.h
@@ -0,0 +1 @@
+#include 
diff --git a/ForwardingHeaders/JavaScriptCore/JavaScriptCore.h b/ForwardingHeaders/JavaScriptCore/JavaScriptCore.h
new file mode 100644
index 0000000..7dc8e08
--- /dev/null
+++ b/ForwardingHeaders/JavaScriptCore/JavaScriptCore.h
@@ -0,0 +1 @@
+#include 
diff --git a/GNUmakefile.am b/GNUmakefile.am
new file mode 100644
index 0000000..b1f0274
--- /dev/null
+++ b/GNUmakefile.am
@@ -0,0 +1,171 @@
+# tell automake to create gensources/ for us
+nodist_EXTRA_libJavaScriptCore_la_SOURCES = \
+	DerivedSources/dummy.cxx
+
+javascriptcore_cppflags += \
+	-I$(srcdir)/JavaScriptCore/ForwardingHeaders \
+	-I$(srcdir)/JavaScriptCore/bindings \
+	-I$(srcdir)/JavaScriptCore/bindings/c \
+	-I$(top_builddir)/JavaScriptCore/pcre \
+	-I$(top_builddir)/JavaScriptCore/kjs
+
+javascriptcore_h_api += \
+	JavaScriptCore/API/JavaScript.h \
+	JavaScriptCore/API/JavaScriptCore.h \
+	JavaScriptCore/API/JSBase.h \
+	JavaScriptCore/API/JSContextRef.h \
+	JavaScriptCore/API/JSObjectRef.h \
+	JavaScriptCore/API/JSStringRefBSTR.h \
+	JavaScriptCore/API/JSStringRefCF.h \
+	JavaScriptCore/API/JSStringRef.h \
+	JavaScriptCore/API/JSValueRef.h
+
+javascriptcore_built_nosources += \
+	JavaScriptCore/kjs/array_object.lut.h \
+	JavaScriptCore/kjs/date_object.lut.h \
+	JavaScriptCore/kjs/math_object.lut.h \
+	JavaScriptCore/kjs/number_object.lut.h \
+	JavaScriptCore/kjs/regexp_object.lut.h \
+	JavaScriptCore/kjs/string_object.lut.h \
+	JavaScriptCore/pcre/chartables.c \
+	DerivedSources/lexer.lut.h
+
+javascriptcore_sources += \
+	JavaScriptCore/API/JSBase.cpp \
+	JavaScriptCore/API/JSCallbackConstructor.cpp \
+	JavaScriptCore/API/JSCallbackFunction.cpp \
+	JavaScriptCore/API/JSCallbackObject.cpp \
+	JavaScriptCore/API/JSClassRef.cpp \
+	JavaScriptCore/API/JSContextRef.cpp \
+	JavaScriptCore/API/JSObjectRef.cpp \
+	JavaScriptCore/API/JSStringRef.cpp \
+	JavaScriptCore/API/JSValueRef.cpp \
+	JavaScriptCore/bindings/NP_jsobject.cpp \
+	JavaScriptCore/bindings/c/c_class.cpp \
+	JavaScriptCore/bindings/c/c_instance.cpp \
+	JavaScriptCore/bindings/c/c_runtime.cpp \
+	JavaScriptCore/bindings/c/c_utility.cpp \
+	JavaScriptCore/bindings/npruntime.cpp \
+	JavaScriptCore/bindings/runtime.cpp \
+	JavaScriptCore/bindings/runtime_array.cpp \
+	JavaScriptCore/bindings/runtime_method.cpp \
+	JavaScriptCore/bindings/runtime_object.cpp \
+	JavaScriptCore/bindings/runtime_root.cpp \
+	JavaScriptCore/kjs/JSGlobalObject.cpp \
+	JavaScriptCore/kjs/JSVariableObject.cpp \
+	JavaScriptCore/pcre/pcre_compile.cpp \
+	JavaScriptCore/pcre/pcre_exec.cpp \
+	JavaScriptCore/pcre/pcre_tables.cpp \
+	JavaScriptCore/pcre/pcre_ucp_searchfuncs.cpp \
+	JavaScriptCore/pcre/pcre_xclass.cpp \
+	JavaScriptCore/wtf/Assertions.cpp \
+	JavaScriptCore/wtf/HashTable.cpp \
+	JavaScriptCore/wtf/unicode/UTF8.cpp
+
+# Debug build
+if ENABLE_DEBUG
+javascriptcore_built_sources += \
+	DerivedSources/grammar.h \
+	DerivedSources/grammar.cpp
+
+javascriptcore_sources += \
+	JavaScriptCore/kjs/CommonIdentifiers.cpp \
+	JavaScriptCore/kjs/DateMath.cpp \
+	JavaScriptCore/kjs/ExecState.cpp \
+	JavaScriptCore/kjs/JSImmediate.cpp \
+	JavaScriptCore/kjs/JSLock.cpp \
+	JavaScriptCore/kjs/JSWrapperObject.cpp \
+	JavaScriptCore/kjs/Parser.cpp \
+	JavaScriptCore/kjs/PropertyNameArray.cpp \
+	JavaScriptCore/kjs/array_instance.cpp \
+	JavaScriptCore/kjs/array_object.cpp \
+	JavaScriptCore/kjs/bool_object.cpp \
+	JavaScriptCore/kjs/collector.cpp \
+	JavaScriptCore/kjs/date_object.cpp \
+	JavaScriptCore/kjs/debugger.cpp \
+	JavaScriptCore/kjs/dtoa.cpp \
+	JavaScriptCore/kjs/error_object.cpp \
+	JavaScriptCore/kjs/function.cpp \
+	JavaScriptCore/kjs/function_object.cpp \
+	JavaScriptCore/kjs/identifier.cpp \
+	JavaScriptCore/kjs/internal.cpp \
+	JavaScriptCore/kjs/interpreter.cpp \
+	JavaScriptCore/kjs/lexer.cpp \
+	JavaScriptCore/kjs/list.cpp \
+	JavaScriptCore/kjs/lookup.cpp \
+	JavaScriptCore/kjs/math_object.cpp \
+	JavaScriptCore/kjs/nodes.cpp \
+	JavaScriptCore/kjs/nodes2string.cpp \
+	JavaScriptCore/kjs/number_object.cpp \
+	JavaScriptCore/kjs/object.cpp \
+	JavaScriptCore/kjs/object_object.cpp \
+	JavaScriptCore/kjs/operations.cpp \
+	JavaScriptCore/kjs/property_map.cpp \
+	JavaScriptCore/kjs/property_slot.cpp \
+	JavaScriptCore/kjs/regexp.cpp \
+	JavaScriptCore/kjs/regexp_object.cpp \
+	JavaScriptCore/kjs/scope_chain.cpp \
+	JavaScriptCore/kjs/string_object.cpp \
+	JavaScriptCore/kjs/ustring.cpp \
+	JavaScriptCore/kjs/value.cpp \
+	JavaScriptCore/wtf/FastMalloc.cpp \
+	JavaScriptCore/wtf/TCSystemAlloc.cpp
+
+else
+javascriptcore_built_nosources += \
+	DerivedSources/grammar.h \
+	DerivedSources/grammar.cpp
+
+javascriptcore_sources += \
+	JavaScriptCore/kjs/AllInOneFile.cpp
+endif # END ENABLE_DEBUG
+
+DerivedSources/grammar.h: DerivedSources/grammar.cpp;
+
+DerivedSources/grammar.cpp: $(srcdir)/JavaScriptCore/kjs/grammar.y
+	$(BISON) -d -p kjsyy $(srcdir)/JavaScriptCore/kjs/grammar.y -o $@ > bison_out.txt 2>&1
+	$(PERL) -p -e 'END { if ($$conflict) { unlink "grammar.cpp"; die; } } $$conflict ||= /conflict/' < bison_out.txt
+	cat $(GENSOURCES)/grammar.hpp > $(GENSOURCES)/grammar.h
+	rm -f $(GENSOURCES)/grammar.hpp bison_out.txt
+
+DerivedSources/lexer.lut.h: $(CREATE_HASH_TABLE) $(srcdir)/JavaScriptCore/kjs/keywords.table
+	$(PERL) $^ > $@
+
+%_object.lut.h: $(CREATE_HASH_TABLE) %_object.cpp
+	$^ -i > $@
+
+JavaScriptCore/pcre/chartables.c: $(srcdir)/JavaScriptCore/pcre/dftables
+	$^ $@
+
+noinst_PROGRAMS += \
+	Programs/minidom \
+	Programs/testkjs
+
+# minidom
+Programs_minidom_SOURCES = \
+	JavaScriptCore/API/JSNode.c \
+	JavaScriptCore/API/JSNodeList.c \
+	JavaScriptCore/API/Node.c \
+	JavaScriptCore/API/NodeList.c \
+	JavaScriptCore/API/minidom.c
+Programs_minidom_CPPFLAGS = $(global_cppflags)
+Programs_minidom_CXXFLAGS = $(global_cxxflags) $(global_cflags)
+Programs_minidom_LDADD = libJavaScriptCore.la
+Programs_minidom_LDFLAGS = -rpath $(CURDIR)/.libs
+
+# testkjs
+Programs_testkjs_SOURCES = JavaScriptCore/kjs/testkjs.cpp
+Programs_testkjs_CPPFLAGS = $(global_cppflags)
+Programs_testkjs_CXXFLAGS = $(global_cxxflags) $(global_cflags)
+Programs_testkjs_LDADD = libJavaScriptCore.la
+Programs_testkjs_LDFLAGS = -rpath $(CURDIR)/.libs
+
+# Clean rules for JavaScriptCore
+CLEANFILES += \
+	JavaScriptCore/kjs/array_object.lut.h \
+	JavaScriptCore/kjs/date_object.lut.h \
+	JavaScriptCore/kjs/math_object.lut.h \
+	JavaScriptCore/kjs/number_object.lut.h \
+	JavaScriptCore/kjs/regexp_object.lut.h \
+	JavaScriptCore/kjs/string_object.lut.h \
+	JavaScriptCore/pcre/chartables.c
diff --git a/Info.plist b/Info.plist
new file mode 100644
index 0000000..1bb58dc
--- /dev/null
+++ b/Info.plist
@@ -0,0 +1,24 @@
+
+
+
+
+	CFBundleDevelopmentRegion
+	English
+	CFBundleExecutable
+	${PRODUCT_NAME}
+	CFBundleGetInfoString
+	${BUNDLE_VERSION}, Copyright 2003-2007 Apple Inc.; Copyright 1999-2001 Harri Porten <porten@kde.org>; Copyright 2001 Peter Kelly <pmk@post.com>; Copyright 1997-2005 University of Cambridge; Copyright 1991, 2000, 2001 by Lucent Technologies.
+	CFBundleIdentifier
+	com.apple.${PRODUCT_NAME}
+	CFBundleInfoDictionaryVersion
+	6.0
+	CFBundleName
+	${PRODUCT_NAME}
+	CFBundlePackageType
+	FMWK
+	CFBundleShortVersionString
+	${BUNDLE_VERSION}
+	CFBundleVersion
+	${BUNDLE_VERSION}
+
+
diff --git a/JavaScriptCore.exp b/JavaScriptCore.exp
new file mode 100644
index 0000000..9a5750a
--- /dev/null
+++ b/JavaScriptCore.exp
@@ -0,0 +1,294 @@
+_JSCheckScriptSyntax
+_JSClassCreate
+_JSClassRelease
+_JSClassRetain
+_JSContextGetGlobalObject
+_JSEvaluateScript
+_JSGarbageCollect
+_JSGlobalContextCreate
+_JSGlobalContextRelease
+_JSGlobalContextRetain
+_JSObjectCallAsConstructor
+_JSObjectCallAsFunction
+_JSObjectCopyPropertyNames
+_JSObjectDeleteProperty
+_JSObjectGetPrivate
+_JSObjectGetProperty
+_JSObjectGetPropertyAtIndex
+_JSObjectGetPrototype
+_JSObjectHasProperty
+_JSObjectIsConstructor
+_JSObjectIsFunction
+_JSObjectMake
+_JSObjectMakeConstructor
+_JSObjectMakeFunction
+_JSObjectMakeFunctionWithCallback
+_JSObjectSetPrivate
+_JSObjectSetProperty
+_JSObjectSetPropertyAtIndex
+_JSObjectSetPrototype
+_JSPropertyNameAccumulatorAddName
+_JSPropertyNameArrayGetCount
+_JSPropertyNameArrayGetNameAtIndex
+_JSPropertyNameArrayRelease
+_JSPropertyNameArrayRetain
+_JSStringCopyCFString
+_JSStringCreateWithCFString
+_JSStringCreateWithCharacters
+_JSStringCreateWithUTF8CString
+_JSStringGetCharactersPtr
+_JSStringGetLength
+_JSStringGetMaximumUTF8CStringSize
+_JSStringGetUTF8CString
+_JSStringIsEqual
+_JSStringIsEqualToUTF8CString
+_JSStringRelease
+_JSStringRetain
+_JSValueGetType
+_JSValueIsBoolean
+_JSValueIsEqual
+_JSValueIsInstanceOfConstructor
+_JSValueIsNull
+_JSValueIsNumber
+_JSValueIsObject
+_JSValueIsObjectOfClass
+_JSValueIsStrictEqual
+_JSValueIsString
+_JSValueIsUndefined
+_JSValueMakeBoolean
+_JSValueMakeNull
+_JSValueMakeNumber
+_JSValueMakeString
+_JSValueMakeUndefined
+_JSValueProtect
+_JSValueToBoolean
+_JSValueToNumber
+_JSValueToObject
+_JSValueToStringCopy
+_JSValueUnprotect
+_WTFLog
+_WTFLogVerbose
+_WTFReportArgumentAssertionFailure
+_WTFReportAssertionFailure
+_WTFReportAssertionFailureWithMessage
+_WTFReportError
+_WTFReportFatalError
+#__NPN_CreateObject
+#__NPN_DeallocateObject
+#__NPN_Enumerate
+#__NPN_Evaluate
+#__NPN_GetIntIdentifier
+#__NPN_GetProperty
+#__NPN_GetStringIdentifier
+#__NPN_GetStringIdentifiers
+#__NPN_IdentifierIsString
+#__NPN_Invoke
+#__NPN_InvokeDefault
+#__NPN_ReleaseObject
+#__NPN_ReleaseVariantValue
+#__NPN_RemoveProperty
+#__NPN_RetainObject
+#__NPN_SetException
+#__NPN_SetProperty
+#__NPN_UTF8FromIdentifier
+__Z12jsRegExpFreeP8JSRegExp
+__Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc
+__Z15jsRegExpExecutePK8JSRegExpPKtiiPii
+#__Z23_NPN_CreateScriptObjectP4_NPPPN3KJS8JSObjectEN3WTF10PassRefPtrINS1_8Bindings10RootObjectEEE
+#__Z25_NPN_CreateNoScriptObjectv
+__ZN3KJS10Identifier11addSlowCaseEPNS_7UString3RepE
+__ZN3KJS10Identifier3addEPKNS_5UCharEi
+__ZN3KJS10Identifier3addEPKc
+__ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc
+__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
+__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
+__ZN3KJS11Interpreter11checkSyntaxEPNS_9ExecStateERKNS_7UStringEiPKNS_5UCharEi
+__ZN3KJS11Interpreter21shouldPrintExceptionsEv
+__ZN3KJS11Interpreter24setShouldPrintExceptionsEb
+__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE
+__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiS5_PNS_7JSValueE
+__ZN3KJS11JSImmediate4typeEPKNS_7JSValueE
+__ZN3KJS11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE
+__ZN3KJS11JSImmediate8toStringEPKNS_7JSValueE
+__ZN3KJS11ProgramNode6createEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE
+__ZN3KJS11PropertyMap11getLocationERKNS_10IdentifierE
+__ZN3KJS11PropertyMap5clearEv
+__ZN3KJS11PropertyMap7restoreERKNS_15SavedPropertiesE
+__ZN3KJS11PropertyMapD1Ev
+__ZN3KJS12DateInstance4infoE
+__ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_
+__ZN3KJS12jsNumberCellEd
+__ZN3KJS13ArrayInstance4infoE
+__ZN3KJS13StatementNode6setLocEii
+__ZN3KJS13jsOwnedStringERKNS_7UStringE
+__ZN3KJS14JSGlobalObject10globalExecEv
+__ZN3KJS14JSGlobalObject15restoreBuiltinsERKNS_13SavedBuiltinsE
+__ZN3KJS14JSGlobalObject16stopTimeoutCheckEv
+__ZN3KJS14JSGlobalObject17startTimeoutCheckEv
+__ZN3KJS14JSGlobalObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS14JSGlobalObject4initEv
+__ZN3KJS14JSGlobalObject4markEv
+__ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE
+__ZN3KJS14JSGlobalObject6s_headE
+__ZN3KJS14JSGlobalObjectD2Ev
+__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
+__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
+__ZN3KJS14StringInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS14StringInstance4infoE
+__ZN3KJS14StringInstanceC1EPNS_8JSObjectERKNS_7UStringE
+__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE
+__ZN3KJS15GlobalExecStateC1EPNS_14JSGlobalObjectE
+__ZN3KJS15JSWrapperObject4markEv
+__ZN3KJS15SavedPropertiesC1Ev
+__ZN3KJS15SavedPropertiesD1Ev
+__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
+__ZN3KJS16JSVariableObject19restoreLocalStorageERKNS_15SavedPropertiesE
+__ZN3KJS16ParserRefCounted3refEv
+__ZN3KJS16ParserRefCounted5derefEv
+__ZN3KJS16RuntimeObjectImp4infoE
+__ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE
+__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectERKNS_4ListEE
+__ZN3KJS19InternalFunctionImp4infoE
+__ZN3KJS19InternalFunctionImpC2EPNS_17FunctionPrototypeERKNS_10IdentifierE
+__ZN3KJS23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS4List15expandAndAppendEPNS_7JSValueE
+__ZN3KJS4List7markSetEv
+__ZN3KJS6JSCell9getObjectEv
+__ZN3KJS6JSCellnwEm
+__ZN3KJS6JSLock12DropAllLocksC1Ev
+__ZN3KJS6JSLock12DropAllLocksD1Ev
+__ZN3KJS6JSLock14registerThreadEv
+__ZN3KJS6JSLock4lockEv
+__ZN3KJS6JSLock6unlockEv
+__ZN3KJS6JSLock9lockCountEv
+__ZN3KJS6Lookup9findEntryEPKNS_9HashTableERKNS_10IdentifierE
+__ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE
+__ZN3KJS6parserEv
+__ZN3KJS7CStringD1Ev
+__ZN3KJS7UString3Rep4nullE
+__ZN3KJS7UString3Rep7destroyEv
+__ZN3KJS7UString4fromEj
+__ZN3KJS7UString6appendERKS0_
+__ZN3KJS7UStringC1EPKNS_5UCharEi
+__ZN3KJS7UStringC1EPKc
+__ZN3KJS7UStringC1ERKS0_S2_
+__ZN3KJS7UStringaSEPKc
+__ZN3KJS8Bindings10RootObject10invalidateEv
+__ZN3KJS8Bindings10RootObject11gcUnprotectEPNS_8JSObjectE
+__ZN3KJS8Bindings10RootObject17_createRootObjectE
+__ZN3KJS8Bindings10RootObject19setCreateRootObjectEPFN3WTF10PassRefPtrIS1_EEPvE
+__ZN3KJS8Bindings10RootObject6createEPKvPNS_14JSGlobalObjectE
+__ZN3KJS8Bindings10RootObject9gcProtectEPNS_8JSObjectE
+__ZN3KJS8Bindings10RootObjectD1Ev
+__ZN3KJS8Bindings10throwErrorEPNS_9ExecStateENS_9ErrorTypeEP8NSString
+__ZN3KJS8Bindings23convertObjcValueToValueEPNS_9ExecStateEPvNS0_13ObjcValueTypeEPNS0_10RootObjectE
+__ZN3KJS8Bindings23convertValueToObjcValueEPNS_9ExecStateEPNS_7JSValueENS0_13ObjcValueTypeE
+__ZN3KJS8Bindings24findProtectingRootObjectEPNS_8JSObjectE
+__ZN3KJS8Bindings8Instance18didExecuteFunctionEv
+__ZN3KJS8Bindings8Instance19createRuntimeObjectEPS1_
+__ZN3KJS8Bindings8Instance21setDidExecuteFunctionEPFvPNS_9ExecStateEPNS_8JSObjectEE
+__ZN3KJS8Bindings8Instance32createBindingForLanguageInstanceENS1_15BindingLanguageEPvN3WTF10PassRefPtrINS0_10RootObjectEEE
+__ZN3KJS8Debugger12sourceUnusedEPNS_9ExecStateEi
+__ZN3KJS8Debugger6attachEPNS_14JSGlobalObjectE
+__ZN3KJS8Debugger9exceptionEPNS_9ExecStateEiiPNS_7JSValueE
+__ZN3KJS8DebuggerC2Ev
+__ZN3KJS8DebuggerD2Ev
+__ZN3KJS8JSObject11hasInstanceEPNS_9ExecStateEPNS_7JSValueE
+__ZN3KJS8JSObject12removeDirectERKNS_10IdentifierE
+__ZN3KJS8JSObject14callAsFunctionEPNS_9ExecStateEPS0_RKNS_4ListE
+__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj
+__ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
+__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
+__ZN3KJS8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRPNS_7JSValueE
+__ZN3KJS8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPPNS_7JSValueE
+__ZN3KJS8JSObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS8JSObject3putEPNS_9ExecStateEjPNS_7JSValueEi
+__ZN3KJS8JSObject4callEPNS_9ExecStateEPS0_RKNS_4ListE
+__ZN3KJS8JSObject4markEv
+__ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_4ListERKNS_10IdentifierERKNS_7UStringEi
+__ZN3KJS8JSObject9putDirectERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS8JSObject9putDirectERKNS_10IdentifierEii
+__ZN3KJS8jsStringEPKc
+__ZN3KJS8jsStringERKNS_7UStringE
+__ZN3KJS9Collector15recordExtraCostEm
+__ZN3KJS9Collector17globalObjectCountEv
+__ZN3KJS9Collector20protectedObjectCountEv
+__ZN3KJS9Collector23collectOnMainThreadOnlyEPNS_7JSValueE
+__ZN3KJS9Collector25protectedObjectTypeCountsEv
+__ZN3KJS9Collector26protectedGlobalObjectCountEv
+__ZN3KJS9Collector4sizeEv
+__ZN3KJS9Collector7collectEv
+__ZN3KJS9Collector7protectEPNS_7JSValueE
+__ZN3KJS9Collector9unprotectEPNS_7JSValueE
+__ZN3KJS9ExecState16activeExecStatesEv
+__ZN3KJSeqERKNS_7UStringEPKc
+__ZN3WTF10fastCallocEmm
+__ZN3WTF10fastMallocEm
+__ZN3WTF11fastReallocEPvm
+__ZN3WTF16fastZeroedMallocEm
+__ZN3WTF8fastFreeEPv
+__ZNK3KJS11PropertyMap3getERKNS_10IdentifierE
+__ZNK3KJS11PropertyMap4saveERNS_15SavedPropertiesE
+__ZNK3KJS12DateInstance7getTimeERdRi
+__ZNK3KJS13ArrayInstance7getItemEj
+__ZNK3KJS14JSGlobalObject12saveBuiltinsERNS_13SavedBuiltinsE
+__ZNK3KJS16JSVariableObject16saveLocalStorageERNS_15SavedPropertiesE
+__ZNK3KJS19InternalFunctionImp14implementsCallEv
+__ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv
+__ZNK3KJS4List8getSliceEiRS0_
+__ZNK3KJS4Node8toStringEv
+__ZNK3KJS6JSCell17getTruncatedInt32ERi
+__ZNK3KJS6JSCell18getTruncatedUInt32ERj
+__ZNK3KJS6JSCell9getNumberERd
+__ZNK3KJS6JSCell9getNumberEv
+__ZNK3KJS6JSCell9getStringERNS_7UStringE
+__ZNK3KJS6JSCell9getStringEv
+__ZNK3KJS6JSCell9getUInt32ERj
+__ZNK3KJS7JSValue15toInt32SlowCaseEPNS_9ExecStateERb
+__ZNK3KJS7JSValue16toUInt32SlowCaseEPNS_9ExecStateERb
+__ZNK3KJS7JSValue7toFloatEPNS_9ExecStateE
+__ZNK3KJS7JSValue9toIntegerEPNS_9ExecStateE
+__ZNK3KJS7UString10UTF8StringEb
+__ZNK3KJS7UString14toStrictUInt32EPb
+__ZNK3KJS7UString5asciiEv
+__ZNK3KJS7UString6is8BitEv
+__ZNK3KJS7UString8toUInt32EPb
+__ZNK3KJS7UString8toUInt32EPbb
+__ZNK3KJS8Bindings10RootObject12globalObjectEv
+__ZNK3KJS8Bindings8Instance10rootObjectEv
+__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE
+__ZNK3KJS8JSObject14implementsCallEv
+__ZNK3KJS8JSObject19implementsConstructEv
+__ZNK3KJS8JSObject21implementsHasInstanceEv
+__ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE
+__ZNK3KJS8JSObject3getEPNS_9ExecStateEj
+__ZNK3KJS8JSObject4typeEv
+__ZNK3KJS8JSObject6canPutEPNS_9ExecStateERKNS_10IdentifierE
+__ZNK3KJS8JSObject8toNumberEPNS_9ExecStateE
+__ZNK3KJS8JSObject8toObjectEPNS_9ExecStateE
+__ZNK3KJS8JSObject8toStringEPNS_9ExecStateE
+__ZNK3KJS8JSObject9classInfoEv
+__ZNK3KJS8JSObject9classNameEv
+__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
+__ZNK3KJS9ExecState19lexicalGlobalObjectEv
+__ZTVN3KJS14JSGlobalObjectE
+__ZTVN3KJS14StringInstanceE
+__ZTVN3KJS15JSWrapperObjectE
+__ZTVN3KJS16JSVariableObjectE
+__ZTVN3KJS19InternalFunctionImpE
+__ZTVN3KJS8JSObjectE
+_jscore_collector_introspection
+_jscore_fastmalloc_introspection
+_kJSClassDefinitionEmpty
+_kjs_strtod
+_JSLockDropAllLocks
+_JSLockRecoverAllLocks
+_JSSetJavaScriptCollectionThread
+_releaseFastMallocFreeMemory
diff --git a/JavaScriptCore.order b/JavaScriptCore.order
new file mode 100644
index 0000000..f9f8238
--- /dev/null
+++ b/JavaScriptCore.order
@@ -0,0 +1,1532 @@
+__ZN3WTF10fastMallocEm
+__ZN3WTF20TCMalloc_ThreadCache10InitModuleEv
+__ZN3WTF15InitSizeClassesEv
+__Z20TCMalloc_SystemAllocmPmm
+__ZN3WTF17TCMalloc_PageHeap4initEv
+__ZN3WTF20TCMalloc_ThreadCache22CreateCacheIfNecessaryEv
+__ZN3WTF25TCMalloc_Central_FreeList11RemoveRangeEPPvS2_Pi
+__ZN3WTF25TCMalloc_Central_FreeList18FetchFromSpansSafeEv
+__ZN3WTF17TCMalloc_PageHeap10AllocLargeEm
+__ZN3WTF17TCMalloc_PageHeap8GrowHeapEm
+__ZN3WTF13MetaDataAllocEm
+__ZN3WTF17TCMalloc_PageHeap19IncrementalScavengeEm
+__ZN3WTF8fastFreeEPv
+__ZN3WTF16fastZeroedMallocEm
+__ZN3WTF14FastMallocZone4sizeEP14_malloc_zone_tPKv
+__ZN3KJS8Bindings10RootObject19setCreateRootObjectEPFN3WTF10PassRefPtrIS1_EEPvE
+__ZN3KJS8Bindings8Instance21setDidExecuteFunctionEPFvPNS_9ExecStateEPNS_8JSObjectEE
+_kjs_strtod
+__Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc
+__Z30calculateCompiledPatternLengthPKti24JSRegExpIgnoreCaseOptionR11CompileDataR9ErrorCode
+__Z11checkEscapePPKtS0_P9ErrorCodeib
+__Z13compileBranchiPiPPhPPKtS3_P9ErrorCodeS_S_R11CompileData
+__Z15jsRegExpExecutePK8JSRegExpPKtiiPii
+__ZN3WTF11fastReallocEPvm
+__ZN3KJS6JSLock4lockEv
+__ZN3KJS20createDidLockJSMutexEv
+__ZN3KJS6JSLock14registerThreadEv
+__ZN3KJS9Collector14registerThreadEv
+__ZN3KJS29initializeRegisteredThreadKeyEv
+__ZN3KJS6JSLock6unlockEv
+__ZN3KJS15SavedPropertiesC1Ev
+__ZN3KJS6JSCellnwEm
+__ZN3KJS9Collector12heapAllocateILNS0_8HeapTypeE0EEEPvm
+__ZN3KJS15GlobalExecStateC1EPNS_14JSGlobalObjectE
+__ZN3KJS17CommonIdentifiers6sharedEv
+__ZN3KJS17CommonIdentifiersC2Ev
+__ZN3KJS10IdentifierC1EPKc
+__ZN3KJS10Identifier3addEPKc
+__ZN3WTF7HashSetIPN3KJS7UString3RepENS_7StrHashIS4_EENS_10HashTraitsIS4_EEE3addINS1_11UCharBufferENS1_21UCharBufferTranslatorEEESt4pairINS_24HashTableIteratorAdapterINS_9HashTableIS4_S4_NS_17IdentityExtractorIS4_EES6_S8_S8_EES4_EEbERKT_
+__ZN3WTF9HashTableIPN3KJS7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7StrHashIS4_EENS_10HashTraitsIS4_EESA_E6rehashEi
+__ZN3KJS14JSGlobalObject4initEv
+__ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE
+__ZN3KJS11PropertyMap5clearEv
+__ZN3KJS17FunctionPrototypeC2EPNS_9ExecStateE
+__ZN3KJS11PropertyMap3putERKNS_10IdentifierEPNS_7JSValueEjb
+__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEPNS_17FunctionPrototypeEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectERKNS_4ListEE
+__ZN3KJS19InternalFunctionImpC2EPNS_17FunctionPrototypeERKNS_10IdentifierE
+__ZN3KJS11PropertyMap11createTableEv
+__ZN3KJS15ObjectPrototypeC2EPNS_9ExecStateEPNS_17FunctionPrototypeE
+__ZN3KJS11PropertyMap6rehashEj
+__ZN3KJS14ArrayPrototypeC1EPNS_9ExecStateEPNS_15ObjectPrototypeE
+__ZN3KJS13ArrayInstanceC2EPNS_8JSObjectEj
+__ZN3KJS15StringPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeE
+__ZN3KJS8jsStringEPKc
+__ZN3KJS16BooleanPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE
+__ZN3KJS15NumberPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE
+__ZN3KJS13DatePrototypeC1EPNS_9ExecStateEPNS_15ObjectPrototypeE
+__ZN3KJS12jsNumberCellEd
+__ZN3KJS9Collector12heapAllocateILNS0_8HeapTypeE1EEEPvm
+__ZN3KJS15RegExpPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE
+__ZN3WTF9HashTableIPN3KJS7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7StrHashIS4_EENS_10HashTraitsIS4_EESA_E4findIS4_NS_22IdentityHashTranslatorIS4_S4_S8_EEEENS_17HashTableIteratorIS4_S4_S6_S8_SA_SA_EERKT_
+__ZN3KJS14ErrorPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE
+__ZN3KJS7UStringC1EPKc
+__ZN3KJS20NativeErrorPrototypeC1EPNS_9ExecStateEPNS_14ErrorPrototypeERKNS_7UStringES7_
+__ZN3KJS8jsStringERKNS_7UStringE
+__ZN3KJS15ObjectObjectImpC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE
+__ZN3KJS17FunctionObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeE
+__ZNK3KJS19InternalFunctionImp9classInfoEv
+__ZN3KJS14ArrayObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_14ArrayPrototypeE
+__ZNK3KJS14ArrayPrototype9classInfoEv
+__ZN3KJS15StringObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_15StringPrototypeE
+__ZNK3KJS15StringPrototype9classInfoEv
+__ZN3KJS19StringObjectFuncImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeERKNS_10IdentifierE
+__ZN3KJS16BooleanObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_16BooleanPrototypeE
+__ZNK3KJS15BooleanInstance9classInfoEv
+__ZN3KJS15NumberObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_15NumberPrototypeE
+__ZNK3KJS14NumberInstance9classInfoEv
+__ZN3KJS13DateObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_13DatePrototypeE
+__ZNK3KJS13DatePrototype9classInfoEv
+__ZN3KJS15RegExpObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_15RegExpPrototypeE
+__ZN3KJS14ErrorObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_14ErrorPrototypeE
+__ZNK3KJS13ErrorInstance9classInfoEv
+__ZN3KJS14NativeErrorImpC1EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_20NativeErrorPrototypeE
+__ZNK3KJS11PropertyMap3getERKNS_10IdentifierE
+__ZNK3KJS9StringImp4typeEv
+__ZN3KJS10Identifier11addSlowCaseEPNS_7UString3RepE
+__ZN3WTF9HashTableIPN3KJS7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7StrHashIS4_EENS_10HashTraitsIS4_EESA_E3addIS4_S4_NS_17HashSetTranslatorILb1ES4_SA_SA_S8_EEEESt4pairINS_17HashTableIteratorIS4_S4_S6_S8_SA_SA_EEbERKT_RKT0_
+__ZN3KJS8JSObject9putDirectERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS13MathObjectImpC1EPNS_9ExecStateEPNS_15ObjectPrototypeE
+__ZN3KJS8JSObject17putDirectFunctionEPNS_19InternalFunctionImpEi
+__ZNK3KJS8JSObject4typeEv
+__ZN3KJS9Collector23collectOnMainThreadOnlyEPNS_7JSValueE
+__ZN3KJS9Collector7protectEPNS_7JSValueE
+__ZN3WTF9HashTableIiSt4pairIiiENS_18PairFirstExtractorIS2_EENS_7IntHashIiEENS_14PairHashTraitsINS_10HashTraitsIiEES9_EES9_E3addIPN3KJS8JSObjectEjNS_17HashMapTranslatorILb1ES1_ISF_jENS_18PairBaseHashTraitsINS8_ISF_EENS8_IjEEEESA_NS_7PtrHashISF_EEEEEES1_INS_17HashTableIteratorIiS2_S4_S6_SA_S9_EEbERKT_RKT0_
+__ZN3WTF9HashTableIiSt4pairIiiENS_18PairFirstExtractorIS2_EENS_7IntHashIiEENS_14PairHashTraitsINS_10HashTraitsIiEES9_EES9_E6rehashEi
+__ZN3KJS6JSCell9getObjectEv
+__ZN3KJS8Bindings10RootObject6createEPKvPNS_14JSGlobalObjectE
+__ZN3KJS8Bindings10RootObjectC2EPKvPNS_14JSGlobalObjectE
+__ZN3WTF9HashTableIiiNS_17IdentityExtractorIiEENS_7IntHashIiEENS_10HashTraitsIiEES6_E6rehashEi
+__ZN3KJS8Bindings10RootObject9gcProtectEPNS_8JSObjectE
+__ZNK3KJS14JSGlobalObject12saveBuiltinsERNS_13SavedBuiltinsE
+__ZN3KJS21SavedBuiltinsInternalC2Ev
+__ZNK3KJS11PropertyMap4saveERNS_15SavedPropertiesE
+__ZN3KJS30comparePropertyMapEntryIndicesEPKvS1_
+__ZN3WTF9HashTableIiSt4pairIiiENS_18PairFirstExtractorIS2_EENS_7IntHashIiEENS_14PairHashTraitsINS_10HashTraitsIiEES9_EES9_E4findIiNS_22IdentityHashTranslatorIiS2_S6_EEEENS_17HashTableIteratorIiS2_S4_S6_SA_S9_EERKT_
+__ZNK3KJS16JSVariableObject16saveLocalStorageERNS_15SavedPropertiesE
+__ZN3KJS13ActivationImpD0Ev
+__ZN3KJS8JSObject12removeDirectERKNS_10IdentifierE
+__ZN3KJS11PropertyMap6removeERKNS_10IdentifierE
+__ZN3KJS7UString3Rep7destroyEv
+__ZN3KJS10Identifier6removeEPNS_7UString3RepE
+__ZN3KJS8Bindings10RootObject10invalidateEv
+__ZN3KJS9Collector9unprotectEPNS_7JSValueE
+__ZN3WTF9HashTableIiiNS_17IdentityExtractorIiEENS_7IntHashIiEENS_10HashTraitsIiEES6_E4findIiNS_22IdentityHashTranslatorIiiS4_EEEENS_17HashTableIteratorIiiS2_S4_S6_S6_EERKT_
+__ZN3KJS8Bindings10RootObjectD1Ev
+__ZN3KJS14JSGlobalObject10globalExecEv
+__ZN3KJS14JSGlobalObject17startTimeoutCheckEv
+__ZN3KJS7UStringC1EPKNS_5UCharEi
+__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE
+__ZN3KJS6ParserC2Ev
+__ZN3KJS6Parser5parseINS_11ProgramNodeEEEN3WTF10PassRefPtrIT_EERKNS_7UStringEiPKNS_5UCharEjPiSD_PS7_
+__ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE
+__ZN3KJS7UStringaSEPKc
+__ZN3KJS5LexerC2Ev
+__ZN3WTF6VectorIcLm0EE15reserveCapacityEm
+__ZN3WTF6VectorIN3KJS5UCharELm0EE15reserveCapacityEm
+__ZN3WTF6VectorIPN3KJS7UStringELm0EE15reserveCapacityEm
+__ZN3WTF6VectorIPN3KJS10IdentifierELm0EE15reserveCapacityEm
+__Z10kjsyyparsev
+__Z8kjsyylexv
+__ZN3KJS5Lexer3lexEv
+__ZN3KJS5Lexer14makeIdentifierERKN3WTF6VectorINS_5UCharELm0EEE
+__ZN3KJS10Identifier3addEPKNS_5UCharEi
+__ZN3KJS5Lexer15matchPunctuatorEiiii
+__ZN3KJS7UStringC2ERKN3WTF6VectorINS_5UCharELm0EEE
+__ZN3KJS14ExpressionNodeC2ENS_6JSTypeE
+__ZN3KJS16ParserRefCountedC2Ev
+__ZN3KJS7UStringC1ERKS0_
+__ZN3KJS4NodeC2Ev
+__ZN3KJS10IdentifierC1ERKS0_
+__ZN3WTF6RefPtrIN3KJS14ExpressionNodeEEC1EPS2_
+__ZN3KJS16ParserRefCounted3refEv
+__ZN3WTF6RefPtrIN3KJS12PropertyNodeEEC1EPS2_
+__ZN3WTF10ListRefPtrIN3KJS16PropertyListNodeEEC1Ev
+__ZN3KJS11ResolveNodeC1ERKNS_10IdentifierE
+__ZN3KJS14ExpressionNodeC2Ev
+__ZN3WTF10ListRefPtrIN3KJS16ArgumentListNodeEEC1Ev
+__Z20makeFunctionCallNodePN3KJS14ExpressionNodeEPNS_13ArgumentsNodeE
+__ZNK3KJS15DotAccessorNode10isLocationEv
+__ZNK3KJS14ExpressionNode13isResolveNodeEv
+__ZNK3KJS14ExpressionNode21isBracketAccessorNodeEv
+__Z14makeNumberNoded
+__Z14makeNegateNodePN3KJS14ExpressionNodeE
+__ZNK3KJS10NumberNode8isNumberEv
+__ZN3KJS19ImmediateNumberNode8setValueEd
+__ZN3KJS5lexerEv
+__ZN3KJS5Lexer10scanRegExpEv
+__ZN3KJS6RegExp6createERKNS_7UStringES3_
+__ZNK3KJS7UString4findENS_5UCharEi
+__ZN3KJS17ObjectLiteralNodeC1EPNS_16PropertyListNodeE
+__Z14compileBracketiPiPPhPPKtS3_P9ErrorCodeiS_S_R11CompileData
+__ZN3KJS16FunctionBodyNode6createEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE
+__ZN3KJS16FunctionBodyNodeC2EPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE
+__ZN3KJS9ScopeNodeC2EPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE
+__ZN3KJS9BlockNodeC1EPNS_14SourceElementsE
+__ZN3KJS13StatementNodeC2Ev
+__ZN3WTF6RefPtrIN3KJS13ParameterNodeEEC1EPS2_
+__ZN3WTF6RefPtrIN3KJS16FunctionBodyNodeEEC1EPS2_
+__ZN3KJS12FuncExprNode9addParamsEv
+__ZN3WTF10ListRefPtrIN3KJS13ParameterNodeEEC1Ev
+__ZN3KJS10ReturnNodeC1EPNS_14ExpressionNodeE
+__Z23allowAutomaticSemicolonv
+__ZN3KJS14SourceElementsC1Ev
+__ZN3WTF10PassRefPtrIN3KJS13StatementNodeEEC1EPS2_
+__ZN3KJS14SourceElements6appendEN3WTF10PassRefPtrINS_13StatementNodeEEE
+__ZNK3KJS13StatementNode16isEmptyStatementEv
+__ZN3WTF6VectorINS_6RefPtrIN3KJS13StatementNodeEEELm0EE14expandCapacityEm
+__ZN3WTF6VectorINS_6RefPtrIN3KJS13StatementNodeEEELm0EE15reserveCapacityEm
+__ZN3WTF6VectorIN3KJS10IdentifierELm0EE14expandCapacityEmPKS2_
+__ZN3WTF6VectorIN3KJS10IdentifierELm0EE14expandCapacityEm
+__ZN3WTF6VectorIN3KJS10IdentifierELm0EE15reserveCapacityEm
+__ZN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEEC1Ev
+__Z26appendToVarDeclarationListRPN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEEERKS4_j
+__Z20makeVarStatementNodePN3KJS14ExpressionNodeE
+__Z14makeAssignNodePN3KJS14ExpressionNodeENS_8OperatorES1_
+__ZN3KJS17ExprStatementNodeC1EPNS_14ExpressionNodeE
+__ZN3KJS6IfNodeC2EPNS_14ExpressionNodeEPNS_13StatementNodeE
+__Z21mergeDeclarationListsIPN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS0_10IdentifierEjELm16EEEEEET_SA_SA_
+__Z21mergeDeclarationListsIPN3KJS20ParserRefCountedDataIN3WTF6VectorIPNS0_12FuncDeclNodeELm16EEEEEET_S9_S9_
+__ZNK3KJS11ResolveNode10isLocationEv
+__ZNK3KJS11ResolveNode13isResolveNodeEv
+__Z22combineVarInitializersPN3KJS14ExpressionNodeEPNS_17AssignResolveNodeE
+__ZN3KJS14ExpressionNode28optimizeForUnnecessaryResultEv
+__ZN3WTF6VectorIPN3KJS10IdentifierELm0EE14expandCapacityEmPKS3_
+__ZN3WTF6VectorIPN3KJS10IdentifierELm0EE14expandCapacityEm
+__ZN3KJS12FuncDeclNode9addParamsEv
+__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EEC1Ev
+__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EE6appendIS4_EEvPKT_m
+__ZN3KJS16ParserRefCounted5derefEv
+__ZN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEED1Ev
+__Z12makeLessNodePN3KJS14ExpressionNodeES1_
+__Z15makePostfixNodePN3KJS14ExpressionNodeENS_8OperatorE
+__ZN3WTF6RefPtrIN3KJS13StatementNodeEEC1EPS2_
+__ZN3KJS18PostIncResolveNode28optimizeForUnnecessaryResultEv
+__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EEaSERKS5_
+__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EEaSERKS4_
+__ZNK3KJS14ExpressionNode10isLocationEv
+__ZNK3KJS19BracketAccessorNode10isLocationEv
+__ZNK3KJS19BracketAccessorNode21isBracketAccessorNodeEv
+__ZN3KJS9ForInNodeC1ERKNS_10IdentifierEPNS_14ExpressionNodeES5_PNS_13StatementNodeE
+__ZN3KJS9ThrowNodeC1EPNS_14ExpressionNodeE
+__Z14makeTypeOfNodePN3KJS14ExpressionNodeE
+__ZN3WTF6VectorINS_6RefPtrIN3KJS13StatementNodeEEELm0EEC1Ev
+__ZN3WTF6RefPtrIN3KJS14CaseClauseNodeEEC1EPS2_
+__ZN3WTF10ListRefPtrIN3KJS14ClauseListNodeEEC1Ev
+__ZN3KJS13CaseBlockNodeC2EPNS_14ClauseListNodeEPNS_14CaseClauseNodeES2_
+__Z11makeAddNodePN3KJS14ExpressionNodeES1_
+__ZN3WTF10ListRefPtrIN3KJS11ElementNodeEEC1Ev
+__ZN3WTF6RefPtrIN3KJS11ElementNodeEEC1EPS2_
+__ZNK3KJS18EmptyStatementNode16isEmptyStatementEv
+__ZN3KJS9BreakNodeC1Ev
+__Z32branchFindFirstAssertedCharacterPKhb
+__Z20branchNeedsLineStartPKhjj
+__ZN3KJS10IdentifierC1ERKNS_7UStringE
+__ZN3WTF6RefPtrIN3KJS7UString3RepEED1Ev
+__ZN3KJS9CommaNodeC2EPNS_14ExpressionNodeES2_
+__Z14makePrefixNodePN3KJS14ExpressionNodeENS_8OperatorE
+__ZN3WTF6RefPtrIN3KJS13ArgumentsNodeEEC1EPS2_
+__ZN3WTF6VectorIPN3KJS7UStringELm0EE14expandCapacityEmPKS3_
+__ZN3WTF6VectorIPN3KJS7UStringELm0EE14expandCapacityEm
+__ZN3WTF6VectorIN3KJS5UCharELm0EE14expandCapacityEmPKS2_
+__ZN3WTF6VectorIN3KJS5UCharELm0EE14expandCapacityEm
+__ZNK3KJS14ExpressionNode8isNumberEv
+__ZN3KJS19PlaceholderTrueNodeC1Ev
+__ZN3KJS18EmptyStatementNodeC1Ev
+__Z14makeDeleteNodePN3KJS14ExpressionNodeE
+__Z15isCountedRepeatPKtS0_
+__ZN3KJS12ContinueNodeC1Ev
+__ZN3KJS9ForInNodeC1EPNS_14ExpressionNodeES2_PNS_13StatementNodeE
+__ZN3KJS18PostDecResolveNode28optimizeForUnnecessaryResultEv
+__Z17bracketIsAnchoredPKh
+__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EE14expandCapacityEmPKS4_
+__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EE14expandCapacityEm
+__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EE15reserveCapacityEm
+__ZN3KJS7UString4fromEd
+_kjs_dtoa
+_d2b
+_Balloc
+__ZN3KJS6parserEv
+__ZN3KJS6Parser16didFinishParsingEPNS_14SourceElementsEPNS_20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEEEPNS3_INS5_IPNS_12FuncDeclNodeELm16EEEEEi
+__ZN3KJS5Lexer5clearEv
+__ZN3WTF25TCMalloc_Central_FreeList11InsertRangeEPvS1_i
+__ZN3WTF25TCMalloc_Central_FreeList11ShrinkCacheEib
+__ZN3WTF25TCMalloc_Central_FreeList18ReleaseListToSpansEPv
+__ZN3WTF15deleteAllValuesIPN3KJS16ParserRefCountedEKNS_9HashTableIiiNS_17IdentityExtractorIiEENS_7IntHashIiEENS_10HashTraitsIiEESA_EEEEvRT0_
+__ZN3KJS19BracketAccessorNodeD1Ev
+__ZN3KJS11ProgramNodeC2EPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE
+__ZNK3KJS8JSObject8toObjectEPNS_9ExecStateE
+__ZN3KJS11ProgramNode7executeEPNS_9ExecStateE
+__ZN3KJS11ProgramNode21initializeSymbolTableEPNS_9ExecStateE
+__ZN3WTF6VectorImLm0EE6resizeEm
+__ZN3WTF6VectorImLm0EE14expandCapacityEm
+__ZN3WTF6VectorImLm0EE15reserveCapacityEm
+__ZN3WTF9HashTableINS_6RefPtrIN3KJS7UString3RepEEESt4pairIS5_mENS_18PairFirstExtractorIS7_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS2_23IdentifierRepHashTraitsENS2_26SymbolTableIndexHashTraitsEEESC_E3addIS5_mNS_17HashMapTranslatorILb1ES7_NS_18PairBaseHashTraitsISC_SD_EESE_SA_EEEES6_INS_17HashTableIteratorIS5_S7_S9_SA_SE_SC_EEbERKT_RKT0_
+__ZN3WTF9HashTableINS_6RefPtrIN3KJS7UString3RepEEESt4pairIS5_mENS_18PairFirstExtractorIS7_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS2_23IdentifierRepHashTraitsENS2_26SymbolTableIndexHashTraitsEEESC_E6rehashEi
+__ZN3KJS14JSGlobalObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZNK3WTF7HashMapINS_6RefPtrIN3KJS7UString3RepEEEmNS2_17IdentifierRepHashENS2_23IdentifierRepHashTraitsENS2_26SymbolTableIndexHashTraitsEE3getEPS4_
+__ZN3KJS11PropertyMap11getLocationERKNS_10IdentifierE
+__ZN3KJS6Lookup9findEntryEPKNS_9HashTableERKNS_10IdentifierE
+__ZNK3KJS7UString14toStrictUInt32EPb
+__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3WTF6VectorIN3KJS17LocalStorageEntryELm32EE15reserveCapacityEm
+__ZN3KJS11FunctionImpC2EPNS_9ExecStateERKNS_10IdentifierEPNS_16FunctionBodyNodeERKNS_10ScopeChainE
+__ZN3KJS15ObjectObjectImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS9ScopeNode22optimizeVariableAccessEPNS_9ExecStateE
+__ZN3WTF6VectorIPN3KJS4NodeELm16EE14expandCapacityEm
+__ZN3WTF6VectorIPN3KJS4NodeELm16EE15reserveCapacityEm
+__ZN3KJS16VarStatementNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS17AssignResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS17ObjectLiteralNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS16PropertyListNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS12PropertyNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS4Node22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPS0_Lm16EEE
+__ZN3KJS14LogicalNotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS14LogicalAndNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS15DotAccessorNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS11ResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS11GreaterNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS19FunctionCallDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS13ArgumentsNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS16ArgumentListNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS9EqualNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS18NotStrictEqualNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS6IfNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS17ExprStatementNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS13AssignDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS13LogicalOrNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS8WithNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS9BlockNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS23FunctionCallResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS21FunctionCallValueNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS9ArrayNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS11ElementNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS10IfElseNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS7AddNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS6InNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS11NewExprNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS16VarStatementNode7executeEPNS_9ExecStateE
+__ZN3KJS18AssignLocalVarNode8evaluateEPNS_9ExecStateE
+__ZN3KJS17ObjectLiteralNode8evaluateEPNS_9ExecStateE
+__ZN3KJS16PropertyListNode8evaluateEPNS_9ExecStateE
+__ZN3KJS10StringNode8evaluateEPNS_9ExecStateE
+__ZN3KJS13jsOwnedStringERKNS_7UStringE
+__ZN3KJS8JSObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS14LogicalNotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS14LogicalNotNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS14LogicalAndNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS15DotAccessorNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS11ResolveNode8evaluateEPNS_9ExecStateE
+__ZN3KJS11GreaterNode8evaluateEPNS_9ExecStateE
+__ZN3KJS19FunctionCallDotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15DotAccessorNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS9ExecState19lexicalGlobalObjectEv
+__ZNK3KJS9StringImp8toObjectEPNS_9ExecStateE
+__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS15StringPrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS20staticFunctionGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectERKNS_4ListEE
+__ZNK3KJS19InternalFunctionImp14implementsCallEv
+__ZN3KJS16ArgumentListNode12evaluateListEPNS_9ExecStateERNS_4ListE
+__ZN3KJS17PrototypeFunction14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS22stringProtoFuncIndexOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS14StringInstance9classInfoEv
+__ZNK3KJS9StringImp8toStringEPNS_9ExecStateE
+__ZNK3KJS7JSValue9toIntegerEPNS_9ExecStateE
+__ZNK3KJS7UString4findERKS0_i
+__ZN3KJS19ImmediateNumberNode8evaluateEPNS_9ExecStateE
+__ZN3KJS14LogicalAndNode8evaluateEPNS_9ExecStateE
+__ZN3KJS9EqualNode8evaluateEPNS_9ExecStateE
+__ZN3KJS5equalEPNS_9ExecStateEPNS_7JSValueES3_
+__ZN3KJS19FunctionCallDotNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS10RegExpNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15RegExpObjectImp15createRegExpImpEPNS_9ExecStateEN3WTF10PassRefPtrINS_6RegExpEEE
+__ZN3KJS20stringProtoFuncMatchEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS9RegExpImp9classInfoEv
+__ZN3KJS15RegExpObjectImp12performMatchEPNS_6RegExpERKNS_7UStringEiRiS6_PPi
+__ZN3KJS6RegExp5matchERKNS_7UStringEiPN3WTF11OwnArrayPtrIiEE
+__Z5matchPKtPKhiR9MatchData
+__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
+__ZN3KJS18NotStrictEqualNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS7UString8toUInt32EPbb
+__ZNK3KJS7UString8toDoubleEbb
+__ZN3KJS11strictEqualEPNS_9ExecStateEPNS_7JSValueES3_
+__ZN3KJS12FuncExprNode8evaluateEPNS_9ExecStateE
+__ZN3KJS14JSGlobalObject17tearOffActivationEPNS_9ExecStateEb
+__ZN3KJS6IfNode7executeEPNS_9ExecStateE
+__ZN3KJS18LocalVarAccessNode8evaluateEPNS_9ExecStateE
+__ZN3KJS17ExprStatementNode7executeEPNS_9ExecStateE
+__ZN3KJS13AssignDotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS11FunctionImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17FunctionExecStateC1EPNS_14JSGlobalObjectEPNS_8JSObjectEPNS_16FunctionBodyNodeEPNS_9ExecStateEPNS_11FunctionImpERKNS_4ListE
+__ZN3KJS14JSGlobalObject14pushActivationEPNS_9ExecStateE
+__ZN3KJS13ActivationImp4initEPNS_9ExecStateE
+__ZN3KJS16FunctionBodyNode7executeEPNS_9ExecStateE
+__ZN3KJS16FunctionBodyNode21initializeSymbolTableEPNS_9ExecStateE
+__ZN3KJS9ForInNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS17AssignBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS19BracketAccessorNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS10ReturnNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS9ForInNode7executeEPNS_9ExecStateE
+__ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
+__ZNK3KJS11PropertyMap26getEnumerablePropertyNamesERNS_17PropertyNameArrayE
+__ZNK3KJS8JSObject9classInfoEv
+__ZN3KJS13ActivationImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS13ActivationImp3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS17AssignBracketNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS6JSCell9getUInt32ERj
+__ZN3KJS19BracketAccessorNode8evaluateEPNS_9ExecStateE
+__ZN3KJS10ReturnNode7executeEPNS_9ExecStateE
+__ZN3KJS14JSGlobalObject13popActivationEv
+__ZN3KJS11FunctionImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS10NumberNode8evaluateEPNS_9ExecStateE
+__ZN3KJS9CommaNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS13ActivationImpC1ERKNS0_14ActivationDataEb
+__ZN3WTF6VectorIN3KJS17LocalStorageEntryELm32EEC2ERKS3_
+__ZN3KJS13ActivationImp15argumentsGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS13ActivationImp21createArgumentsObjectEPNS_9ExecStateE
+__ZN3KJS9ArgumentsC2EPNS_9ExecStateEPNS_11FunctionImpERKNS_4ListEPNS_13ActivationImpE
+__ZN3KJS14IndexToNameMapC2EPNS_11FunctionImpERKNS_4ListE
+__ZN3KJS11FunctionImp16getParameterNameEi
+__ZN3KJS7UString4fromEj
+__ZN3KJS9Arguments18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS9CommaNode8evaluateEPNS_9ExecStateE
+__ZN3KJS8ThisNode8evaluateEPNS_9ExecStateE
+__ZN3KJS23FunctionCallResolveNode8evaluateEPNS_9ExecStateE
+__ZN3KJS9WhileNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS18PostDecResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS18LocalVarAccessNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS13LogicalOrNode8evaluateEPNS_9ExecStateE
+__ZN3KJS11NewExprNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS14ArrayObjectImp19implementsConstructEv
+__ZN3KJS14ArrayObjectImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS9WhileNode7executeEPNS_9ExecStateE
+__ZN3KJS19PostDecLocalVarNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
+__ZN3KJS13ArrayInstance3putEPNS_9ExecStateEjPNS_7JSValueEi
+__ZN3KJS15RegExpObjectImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS15RegExpObjectImp3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS7ForNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS8LessNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS17PreIncResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS8NullNode8evaluateEPNS_9ExecStateE
+__ZN3KJS13ArrayInstance18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
+__ZN3KJS17TypeOfResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS18LocalVarTypeOfNode8evaluateEPNS_9ExecStateE
+__ZN3KJS18typeStringForValueEPNS_7JSValueE
+__ZNK3KJS8JSObject21masqueradeAsUndefinedEv
+__ZNK3KJS8JSObject14implementsCallEv
+__ZN3KJS12FuncDeclNode7executeEPNS_9ExecStateE
+__ZN3KJS11FunctionImp3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS9ArrayNode8evaluateEPNS_9ExecStateE
+__ZN3KJS13ArrayInstanceC2EPNS_8JSObjectERKNS_4ListE
+__ZN3KJS13ArrayInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS13ArrayInstance9setLengthEj
+__ZN3KJS7ForNode7executeEPNS_9ExecStateE
+__ZN3KJS8LessNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS13ArrayInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS13ArrayInstance12lengthGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS14ArrayPrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS18arrayProtoFuncPushEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS8TrueNode8evaluateEPNS_9ExecStateE
+__ZN3KJS9BlockNode7executeEPNS_9ExecStateE
+__ZN3KJS18PreIncLocalVarNode8evaluateEPNS_9ExecStateE
+__ZN3KJS14StringInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS13LogicalOrNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS8WithNode7executeEPNS_9ExecStateE
+__ZN3KJS15NumberObjectImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS24LocalVarFunctionCallNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15ConditionalNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS22stringProtoFuncReplaceEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS7replaceEPNS_9ExecStateEPNS_9StringImpEPNS_7JSValueES5_
+__ZNK3KJS7UString30spliceSubstringsWithSeparatorsEPKNS0_5RangeEiPKS0_i
+__ZN3KJS15ConditionalNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS9StringImp9toBooleanEPNS_9ExecStateE
+__ZN3KJS20stringProtoFuncSplitEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS7UString6substrEii
+__ZN3KJS7UString3Rep6createEN3WTF10PassRefPtrIS1_EEii
+__ZN3KJS7TryNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS15LessNumbersNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS15DotAccessorNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS10NumberNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS7TryNode7executeEPNS_9ExecStateE
+__ZN3KJS21arrayProtoFuncForEachEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS18PostIncResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS18PostIncResolveNode8evaluateEPNS_9ExecStateE
+__ZN3KJS13ActivationImp18isActivationObjectEv
+__ZN3KJS13MathObjectImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS21FunctionCallValueNode8evaluateEPNS_9ExecStateE
+__ZN3KJS12NotEqualNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS9FalseNode8evaluateEPNS_9ExecStateE
+__ZN3KJS19arrayProtoFuncShiftEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS13ArrayInstance14deletePropertyEPNS_9ExecStateEj
+__ZNK3KJS11FunctionImp19implementsConstructEv
+__ZN3KJS11FunctionImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS9EqualNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS25functionProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS11FunctionImp9classInfoEv
+__ZNK3KJS4Node8toStringEv
+__ZNK3KJS9ScopeNode8streamToERNS_12SourceStreamE
+__ZN3KJS7UString6appendEt
+__ZN3KJS7UString6appendERKS0_
+__ZN3KJS7UString6appendEPKc
+__ZN3KJS7UString14expandCapacityEi
+__ZN3KJS12SourceStreamlsEPKNS_4NodeE
+__ZNK3KJS17ExprStatementNode8streamToERNS_12SourceStreamE
+__ZNK3KJS4Node21needsParensIfLeftmostEv
+__ZNK3KJS23FunctionCallResolveNode8streamToERNS_12SourceStreamE
+__ZNK3KJS13ArgumentsNode8streamToERNS_12SourceStreamE
+__ZNK3KJS16ArgumentListNode8streamToERNS_12SourceStreamE
+__ZNK3KJS11ResolveNode10precedenceEv
+__ZNK3KJS11ResolveNode8streamToERNS_12SourceStreamE
+__ZNK3KJS13AssignDotNode8streamToERNS_12SourceStreamE
+__ZNK3KJS8ThisNode10precedenceEv
+__ZNK3KJS8ThisNode8streamToERNS_12SourceStreamE
+__ZNK3KJS19FunctionCallDotNode10precedenceEv
+__ZNK3KJS19FunctionCallDotNode8streamToERNS_12SourceStreamE
+__ZNK3KJS16FunctionBodyNode11paramStringEv
+__ZNK3KJS15RegExpObjectImp14arrayOfMatchesEPNS_9ExecStateE
+__ZN3KJS9Arguments17mappedIndexGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS19arrayProtoFuncSliceEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS22functionProtoFuncApplyEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS13ArrayInstance9classInfoEv
+__ZN3KJS24substituteBackreferencesERKNS_7UStringES2_PiPNS_6RegExpE
+__ZNK3KJS15DotAccessorNode10precedenceEv
+__ZNK3KJS15DotAccessorNode8streamToERNS_12SourceStreamE
+__ZNK3KJS16VarStatementNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17AssignResolveNode8streamToERNS_12SourceStreamE
+__ZNK3KJS6IfNode8streamToERNS_12SourceStreamE
+__ZNK3KJS14LogicalNotNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9ArrayNode10precedenceEv
+__ZNK3KJS9ArrayNode8streamToERNS_12SourceStreamE
+__ZNK3KJS11ElementNode8streamToERNS_12SourceStreamE
+__ZNK3KJS10StringNode10precedenceEv
+__ZNK3KJS10StringNode8streamToERNS_12SourceStreamE
+__ZN3KJS29escapeStringForPrettyPrintingERKNS_7UStringE
+__ZNK3KJS9BlockNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17AssignBracketNode8streamToERNS_12SourceStreamE
+__ZNK3KJS10IfElseNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9EqualNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9EqualNode10precedenceEv
+__ZN3KJS35streamLeftAssociativeBinaryOperatorERNS_12SourceStreamENS_10PrecedenceEPKcPKNS_4NodeES7_
+__ZNK3KJS17ReadModifyDotNode8streamToERNS_12SourceStreamE
+__ZNK3KJS7AddNode10precedenceEv
+__ZNK3KJS7AddNode8streamToERNS_12SourceStreamE
+__ZNK3KJS15ConditionalNode10precedenceEv
+__ZNK3KJS15ConditionalNode8streamToERNS_12SourceStreamE
+__ZNK3KJS10RegExpNode10precedenceEv
+__ZNK3KJS10RegExpNode8streamToERNS_12SourceStreamE
+__ZNK3KJS21ReadModifyResolveNode8streamToERNS_12SourceStreamE
+__ZNK3KJS7TryNode8streamToERNS_12SourceStreamE
+__ZNK3KJS11NewExprNode10precedenceEv
+__ZNK3KJS11NewExprNode8streamToERNS_12SourceStreamE
+__ZNK3KJS10NumberNode10precedenceEv
+__ZNK3KJS10NumberNode8streamToERNS_12SourceStreamE
+__ZN3KJS12SourceStreamlsEd
+__ZNK3KJS13LogicalOrNode10precedenceEv
+__ZNK3KJS13LogicalOrNode8streamToERNS_12SourceStreamE
+__ZNK3KJS8NullNode10precedenceEv
+__ZNK3KJS8NullNode8streamToERNS_12SourceStreamE
+__ZNK3KJS14LogicalAndNode8streamToERNS_12SourceStreamE
+__ZNK3KJS14LogicalAndNode10precedenceEv
+__ZNK3KJS14LogicalNotNode10precedenceEv
+__ZN3KJS7UString17expandPreCapacityEi
+__ZN3KJS19BracketAccessorNode17evaluateToBooleanEPNS_9ExecStateE
+__ZNK3KJS11GreaterNode10precedenceEv
+__ZNK3KJS11GreaterNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17ObjectLiteralNode10precedenceEv
+__ZNK3KJS17ObjectLiteralNode8streamToERNS_12SourceStreamE
+__ZNK3KJS16PropertyListNode8streamToERNS_12SourceStreamE
+__ZNK3KJS12PropertyNode8streamToERNS_12SourceStreamE
+__ZNK3KJS8LessNode10precedenceEv
+__ZNK3KJS8LessNode8streamToERNS_12SourceStreamE
+__ZNK3KJS19BracketAccessorNode10precedenceEv
+__ZNK3KJS19BracketAccessorNode8streamToERNS_12SourceStreamE
+__ZNK3KJS15TypeOfValueNode10precedenceEv
+__ZNK3KJS15TypeOfValueNode8streamToERNS_12SourceStreamE
+__ZNK3KJS7ForNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9CommaNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17AssignResolveNode10precedenceEv
+__ZNK3KJS23FunctionCallResolveNode10precedenceEv
+__ZNK3KJS12FuncExprNode10precedenceEv
+__ZNK3KJS12FuncExprNode8streamToERNS_12SourceStreamE
+__ZNK3KJS13ParameterNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9ForInNode8streamToERNS_12SourceStreamE
+__ZNK3KJS10ReturnNode8streamToERNS_12SourceStreamE
+__ZNK3KJS13GreaterEqNode10precedenceEv
+__ZNK3KJS13GreaterEqNode8streamToERNS_12SourceStreamE
+__ZNK3KJS8TrueNode10precedenceEv
+__ZNK3KJS8TrueNode8streamToERNS_12SourceStreamE
+__ZNK3KJS21FunctionCallValueNode8streamToERNS_12SourceStreamE
+__ZN3KJS11ElementNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS8MultNode10precedenceEv
+__ZNK3KJS8MultNode8streamToERNS_12SourceStreamE
+__ZN3KJS21functionProtoFuncCallEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS4List8getSliceEiRS0_
+__ZN3KJS10IfElseNode7executeEPNS_9ExecStateE
+__ZN3KJS6InNode17evaluateToBooleanEPNS_9ExecStateE
+__ZNK3KJS12NotEqualNode10precedenceEv
+__ZNK3KJS12NotEqualNode8streamToERNS_12SourceStreamE
+__ZN3KJS17AssignResolveNode8evaluateEPNS_9ExecStateE
+__ZN3KJS13DeleteDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS12ContinueNode7executeEPNS_9ExecStateE
+__ZN3KJS13DeleteDotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS11FunctionImp14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZNK3KJS11PropertyMap3getERKNS_10IdentifierERj
+__ZN3KJS11GreaterNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS13PrefixDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS13PreIncDotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZNK3KJS8JSObject8toStringEPNS_9ExecStateE
+__ZNK3KJS8JSObject11toPrimitiveEPNS_9ExecStateENS_6JSTypeE
+__ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE
+__ZN3KJS22arrayProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3WTF9HashTableIiiNS_17IdentityExtractorIiEENS_7IntHashIiEENS_10HashTraitsIiEES6_E3addIPN3KJS16RuntimeObjectImpESB_NS_17HashSetTranslatorILb1ESB_NS5_ISB_EES6_NS_7PtrHashISB_EEEEEESt4pairINS_17HashTableIteratorIiiS2_S4_S6_S6_EEbERKT_RKT0_
+__ZN3KJS11JSImmediate8toStringEPKNS_7JSValueE
+__ZN3KJS12NotEqualNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS21arrayProtoFuncIndexOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS14ErrorObjectImp19implementsConstructEv
+__ZN3KJS14ErrorObjectImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS9Collector7collectEv
+__ZN3KJS9Collector31markCurrentThreadConservativelyEv
+__ZN3KJS9Collector30markStackObjectsConservativelyEPvS1_
+__ZN3KJS6JSCell4markEv
+__ZN3KJS8JSObject4markEv
+__ZNK3KJS11PropertyMap4markEv
+__ZN3KJS11FunctionImp4markEv
+__ZN3KJS14JSGlobalObject4markEv
+__ZN3KJS16JSVariableObject4markEv
+__ZN3KJS13ArrayInstance4markEv
+__ZN3KJS15JSWrapperObject4markEv
+__ZN3KJS13ActivationImp4markEv
+__ZN3KJS13ActivationImp12markChildrenEv
+__ZN3KJS14NativeErrorImp4markEv
+__ZN3KJS9Arguments4markEv
+__ZN3KJS9Collector20markProtectedObjectsEv
+__ZN3KJS9Collector5sweepILNS0_8HeapTypeE0EEEmb
+__ZN3KJS11PropertyMapD1Ev
+__ZN3KJS11FunctionImpD0Ev
+__ZN3KJS9StringImpD0Ev
+__ZN3KJS9RegExpImpD0Ev
+__ZN3KJS13ArrayInstanceD0Ev
+__ZN3KJS9ArgumentsD0Ev
+__ZN3KJS9Collector5sweepILNS0_8HeapTypeE1EEEmb
+__ZN3KJS14AddStringsNode8evaluateEPNS_9ExecStateE
+__ZN3KJS17AddStringLeftNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS9StringImp11toPrimitiveEPNS_9ExecStateENS_6JSTypeE
+__ZN3KJS7AddNode8evaluateEPNS_9ExecStateE
+__ZN3KJS21stringProtoFuncCharAtEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS26stringProtoFuncToUpperCaseEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS24stringProtoFuncSubstringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS26stringProtoFuncToLowerCaseEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS7UString8toUInt32EPb
+__ZN3KJS22ReadModifyLocalVarNode8evaluateEPNS_9ExecStateE
+__ZN3KJS19PostIncLocalVarNode8evaluateEPNS_9ExecStateE
+__ZN3KJS17PreDecResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS18PreDecLocalVarNode8evaluateEPNS_9ExecStateE
+__ZN3KJS8MultNode16evaluateToNumberEPNS_9ExecStateE
+__ZNK3KJS9NumberImp4typeEv
+__ZN3KJS20dateProtoFuncSetTimeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS7SubNode16evaluateToNumberEPNS_9ExecStateE
+__ZNK3KJS9StringImp8toNumberEPNS_9ExecStateE
+__ZN3KJS18globalFuncParseIntEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS7JSValue15toInt32SlowCaseEPNS_9ExecStateERb
+__ZN3KJS24dateProtoFuncToGMTStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS10formatTimeERKNS_17GregorianDateTimeEb
+__ZNK3KJS15RegExpObjectImp19implementsConstructEv
+__ZN3KJS15RegExpObjectImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS19regExpProtoFuncExecEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
+__ZN3KJS35stringInstanceNumericPropertyGetterEPNS_9ExecStateEPNS_8JSObjectEjRKNS_12PropertySlotE
+__ZN3KJS23FunctionCallResolveNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS15globalFuncIsNaNEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS20dateProtoFuncSetYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS21gregorianDateTimeToMSERKNS_17GregorianDateTimeEdb
+__ZN3KJS15dateToDayInYearEiii
+__ZN3KJS21ReadModifyBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZNK3KJS15ObjectObjectImp19implementsConstructEv
+__ZN3KJS21ReadModifyBracketNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS9ExecState12hadExceptionEv
+__ZNK3KJS7JSValue8toObjectEPNS_9ExecStateE
+__ZNK3KJS7JSValue8toStringEPNS_9ExecStateE
+__ZN3KJS7UStringD1Ev
+__ZN3KJS8JSObject15getPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZNK3KJS12PropertySlot8getValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierE
+__ZNK3WTF6RefPtrIN3KJS14ExpressionNodeEE3getEv
+__ZN3KJS3addEPNS_9ExecStateEPNS_7JSValueES3_
+__ZN3KJS10IdentifierD1Ev
+__ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS20arrayProtoFuncConcatEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS14ExpressionNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS9BreakNode7executeEPNS_9ExecStateE
+__ZN3KJS18arrayProtoFuncJoinEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE
+__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
+__ZN3KJS5Error6createEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringEiiS6_
+__ZN3KJS14NativeErrorImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZNK3KJS6JSCell17getTruncatedInt32ERi
+__ZN3KJS15StringObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS9Collector15recordExtraCostEm
+__ZN3KJS22objectProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS8JSObject9classNameEv
+__ZN3KJS14PostDecDotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS9CommaNodeD1Ev
+__ZN3KJS28globalFuncDecodeURIComponentEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS6decodeEPNS_9ExecStateERKNS_4ListEPKcb
+__ZN3KJS19BracketAccessorNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS15TypeOfValueNodeD1Ev
+__ZN3KJS17PrototypeFunctionD0Ev
+__ZN3KJS13ErrorInstanceD0Ev
+__ZN3KJS18mathProtoFuncRoundEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23FunctionCallResolveNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS13GreaterEqNodeD1Ev
+__ZN3KJS7ModNodeD1Ev
+__ZN3KJS24LocalVarFunctionCallNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS4List15expandAndAppendEPNS_7JSValueE
+__ZN3WTF6VectorIPN3KJS7JSValueELm8EE15reserveCapacityEm
+__ZN3KJS10SwitchNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS13CaseBlockNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS14ClauseListNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS14CaseClauseNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS10SwitchNode7executeEPNS_9ExecStateE
+__ZN3KJS13CaseBlockNode12executeBlockEPNS_9ExecStateEPNS_7JSValueE
+__ZN3KJS18NotStrictEqualNode17evaluateToBooleanEPNS_9ExecStateE
+__Z23_NPN_CreateScriptObjectP4_NPPPN3KJS8JSObjectEN3WTF10PassRefPtrINS1_8Bindings10RootObjectEEE
+__NPN_CreateObject
+__Z10jsAllocateP4_NPPP7NPClass
+__NPN_RetainObject
+__NPN_Evaluate
+__ZNK3KJS8Bindings10RootObject12globalObjectEv
+__ZN3KJS8Bindings22convertNPStringToUTF16EPK9_NPStringPPtPj
+__ZN3KJS8Bindings36convertUTF8ToUTF16WithLatin1FallbackEPKciPPtPj
+__ZN3WTF7Unicode18convertUTF8ToUTF16EPPKcS2_PPtS4_b
+__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiS5_PNS_7JSValueE
+__ZN3KJS8Bindings23convertValueToNPVariantEPNS_9ExecStateEPNS_7JSValueEP10_NPVariant
+__ZN3KJS11JSImmediate4typeEPKNS_7JSValueE
+__NPN_GetStringIdentifier
+__ZN3KJS8Bindings26identifierFromNPIdentifierEPKc
+__NPN_Invoke
+__ZN3KJS8Bindings14findRootObjectEPNS_14JSGlobalObjectE
+__NPN_ReleaseVariantValue
+__ZNK3KJS7UString10UTF8StringEb
+__ZN3WTF7Unicode18convertUTF16ToUTF8EPPKtS2_PPcS4_b
+__Z35NPN_InitializeVariantWithStringCopyP10_NPVariantPK9_NPString
+__ZN3KJS7CStringD1Ev
+__NPN_ReleaseObject
+__Z12jsDeallocateP8NPObject
+__ZN3KJS8Bindings10RootObject11gcUnprotectEPNS_8JSObjectE
+__ZN3KJS6JSLock12DropAllLocksC1Ev
+__ZN3KJS6JSLock12DropAllLocksD1Ev
+_pow5mult
+_quorem
+_diff
+__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EE14expandCapacityEmPKS3_
+__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EE14expandCapacityEm
+__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EE15reserveCapacityEm
+__ZN3KJS10NumberNode8setValueEd
+__ZN3KJS11ResolveNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS21dateProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS24dateProtoFuncGetFullYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS12NotEqualNode8evaluateEPNS_9ExecStateE
+__ZN3KJS14InstanceOfNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS17PreIncResolveNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS9NumberImp9toBooleanEPNS_9ExecStateE
+__ZN3KJS10LessEqNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS29objectProtoFuncHasOwnPropertyEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS10LessEqNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS13UnaryPlusNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS17DeleteBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS17DeleteBracketNode8evaluateEPNS_9ExecStateE
+__ZN3KJS20arrayProtoFuncSpliceEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17staticValueGetterINS_13MathObjectImpEEEPNS_7JSValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZNK3KJS13MathObjectImp16getValuePropertyEPNS_9ExecStateEi
+__NPN_DeallocateObject
+__ZN3KJS14PostIncDotNodeD1Ev
+__ZN3KJS22ReadModifyLocalVarNodeD1Ev
+__ZN3KJS10LessEqNodeD1Ev
+__ZN3KJS18PostDecResolveNodeD1Ev
+__ZN3KJS17DeleteBracketNodeD1Ev
+__ZN3KJS18PostIncResolveNodeD1Ev
+__ZN3KJS14InstanceOfNodeD1Ev
+__ZN3KJS10NegateNodeD1Ev
+__ZN3KJS17PreDecResolveNodeD1Ev
+__ZN3KJS21ReadModifyBracketNodeD1Ev
+__ZN3KJS10BitAndNodeD1Ev
+__ZN3KJS9BitOrNodeD1Ev
+__ZN3KJS14RightShiftNodeD1Ev
+__ZN3KJS13LeftShiftNodeD1Ev
+__ZN3KJS13UnaryPlusNodeD1Ev
+__ZN3KJS13MathObjectImpD0Ev
+__ZN3KJS14NativeErrorImpD0Ev
+__ZN3KJS14ErrorObjectImpD0Ev
+__ZN3KJS15RegExpObjectImpD0Ev
+__ZN3KJS17DateObjectFuncImpD0Ev
+__ZN3KJS13DateObjectImpD0Ev
+__ZN3KJS15NumberObjectImpD0Ev
+__ZN3KJS16BooleanObjectImpD0Ev
+__ZN3KJS19StringObjectFuncImpD0Ev
+__ZN3KJS15StringObjectImpD0Ev
+__ZN3KJS14ArrayObjectImpD0Ev
+__ZN3KJS17FunctionObjectImpD0Ev
+__ZN3KJS15ObjectObjectImpD0Ev
+__ZN3KJS20NativeErrorPrototypeD0Ev
+__ZN3KJS15RegExpPrototypeD0Ev
+__ZN3KJS15NumberPrototypeD0Ev
+__ZN3KJS16BooleanPrototypeD0Ev
+__ZN3KJS15StringPrototypeD0Ev
+__ZN3KJS15ObjectPrototypeD0Ev
+__ZN3KJS17FunctionPrototypeD0Ev
+__ZN3KJS13PreIncDotNodeD1Ev
+__ZN3KJS17staticValueGetterINS_15RegExpObjectImpEEEPNS_7JSValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZNK3KJS15RegExpObjectImp16getValuePropertyEPNS_9ExecStateEi
+__ZNK3KJS15RegExpObjectImp10getBackrefEj
+__ZN3KJS16mathProtoFuncMaxEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17staticValueGetterINS_15NumberObjectImpEEEPNS_7JSValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZNK3KJS15NumberObjectImp16getValuePropertyEPNS_9ExecStateEi
+__ZN3KJS10NegateNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS10NegateNode8evaluateEPNS_9ExecStateE
+__ZN3KJS25stringProtoFuncCharCodeAtEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS21arrayProtoFuncUnShiftEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS10LessEqNode8evaluateEPNS_9ExecStateE
+__ZN3KJS8JSObject15getPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
+__ZNK3KJS12PropertySlot8getValueEPNS_9ExecStateEPNS_8JSObjectEj
+__ZN3KJS16mathProtoFuncMinEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc
+__ZN3KJS11addSlowCaseEPNS_9ExecStateEPNS_7JSValueES3_
+__ZN3KJS8LessNode8evaluateEPNS_9ExecStateE
+__ZN3KJS7DivNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS10NegateNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS7AddNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS16mathProtoFuncSinEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS16mathProtoFuncLogEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS16mathProtoFuncAbsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3WTF6VectorIPN3KJS9ExecStateELm16EE14expandCapacityEm
+__ZN3WTF6VectorIPN3KJS9ExecStateELm16EE15reserveCapacityEm
+__ZN3KJS17arrayProtoFuncPopEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS21stringProtoFuncSubstrEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS28globalFuncEncodeURIComponentEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS6encodeEPNS_9ExecStateERKNS_4ListEPKc
+__ZN3KJS17PrefixBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS17PreIncBracketNode8evaluateEPNS_9ExecStateE
+__ZN3KJS16mathProtoFuncExpEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17mathProtoFuncATanEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17mathProtoFuncCeilEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS14AddNumbersNode8evaluateEPNS_9ExecStateE
+__ZN3KJS18arrayProtoFuncSortEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS13ArrayInstance4sortEPNS_9ExecStateEPNS_8JSObjectE
+__ZN3KJS13ArrayInstance17compactForSortingEv
+__ZN3KJS34compareWithCompareFunctionForQSortEPKvS1_
+__ZN3KJS13ArrayInstance4sortEPNS_9ExecStateE
+__ZN3KJS16mathProtoFuncPowEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS15NumberObjectImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS23numberProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS9NumberImp8toObjectEPNS_9ExecStateE
+__ZN3KJS16mathProtoFuncCosEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17mathProtoFuncSqrtEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17mathProtoFuncASinEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS14ExpressionNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS11DoWhileNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS21stringProtoFuncSearchEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS13PreDecDotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS18PostfixBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS18PostIncBracketNode8evaluateEPNS_9ExecStateE
+__ZN3KJS13LeftShiftNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3WTF7Unicode18UTF8SequenceLengthEc
+__ZN3WTF7Unicode18decodeUTF8SequenceEPKc
+__ZN3KJS9StringImp18getPrimitiveNumberEPNS_9ExecStateERdRPNS_7JSValueE
+__ZN3KJSltERKNS_7UStringES2_
+__ZN3KJS15ConditionalNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS10BitAndNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS10BitAndNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS15DotAccessorNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS19ImmediateNumberNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS13ArrayInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
+__ZN3KJS18LocalVarAccessNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS13LeftShiftNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS19BracketAccessorNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS14RightShiftNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS14RightShiftNode8evaluateEPNS_9ExecStateE
+__ZN3KJS7AddNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS19ImmediateNumberNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS13LeftShiftNode8evaluateEPNS_9ExecStateE
+__ZN3KJS18LocalVarAccessNode16evaluateToUInt32EPNS_9ExecStateE
+__ZNK3KJS9NumberImp17getTruncatedInt32ERi
+__ZN3KJS19BracketAccessorNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS16BooleanObjectImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS24booleanProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS14BitwiseNotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS9BitOrNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS9BitOrNode8evaluateEPNS_9ExecStateE
+__ZN3KJS10BitAndNode8evaluateEPNS_9ExecStateE
+__ZN3KJS14BitwiseNotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15NumberObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS8Bindings8Instance32createBindingForLanguageInstanceENS1_15BindingLanguageEPvN3WTF10PassRefPtrINS0_10RootObjectEEE
+__ZN3KJS8Bindings9CInstanceC2EP8NPObjectN3WTF10PassRefPtrINS0_10RootObjectEEE
+__ZN3KJS8Bindings8InstanceC2EN3WTF10PassRefPtrINS0_10RootObjectEEE
+__ZNK3KJS8Bindings8Instance10rootObjectEv
+__ZN3KJS8Bindings8Instance19createRuntimeObjectEPS1_
+__ZN3KJS16RuntimeObjectImpC2EPNS_8Bindings8InstanceE
+__ZN3KJS8Bindings10RootObject16addRuntimeObjectEPNS_16RuntimeObjectImpE
+__ZN3KJS16RuntimeObjectImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS8Bindings9CInstance5beginEv
+__ZNK3KJS8Bindings9CInstance8getClassEv
+__ZN3KJS8Bindings6CClass11classForIsAEP7NPClass
+__ZN3KJS8Bindings6CClassC2EP7NPClass
+__ZNK3KJS8Bindings6CClass10fieldNamedERKNS_10IdentifierEPNS0_8InstanceE
+__ZNK3KJS7UString5asciiEv
+__ZNK3KJS8Bindings6CClass12methodsNamedERKNS_10IdentifierEPNS0_8InstanceE
+__NPN_UTF8FromIdentifier
+__ZN3KJS8Bindings5Class14fallbackObjectEPNS_9ExecStateEPNS0_8InstanceERKNS_10IdentifierE
+__ZN3KJS8Bindings9CInstance3endEv
+__ZN3WTF6VectorIPN3KJS8Bindings6MethodELm0EE14expandCapacityEmPKS4_
+__ZN3WTF6VectorIPN3KJS8Bindings6MethodELm0EE14expandCapacityEm
+__ZN3WTF6VectorIPN3KJS8Bindings6MethodELm0EE15reserveCapacityEm
+__ZN3KJS16RuntimeObjectImp12methodGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS13RuntimeMethodC2EPNS_9ExecStateERKNS_10IdentifierERN3WTF6VectorIPNS_8Bindings6MethodELm0EEE
+__ZN3WTF6VectorIPN3KJS8Bindings6MethodELm0EEC2ERKS5_
+__ZN3KJS13RuntimeMethod14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS16RuntimeObjectImp9classInfoEv
+__ZN3KJS8Bindings9CInstance12invokeMethodEPNS_9ExecStateERKN3WTF6VectorIPNS0_6MethodELm0EEERKNS_4ListE
+__ZNK3KJS8Bindings7CMethod4nameEv
+__ZN3KJS8Bindings23convertNPVariantToValueEPNS_9ExecStateEPK10_NPVariantPNS0_10RootObjectE
+__ZN3KJS16RuntimeObjectImpD2Ev
+__ZN3KJS8Bindings10RootObject19removeRuntimeObjectEPNS_16RuntimeObjectImpE
+__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcPNS_7JSValueEPS0_RKNS_10IdentifierE
+__ZN3KJS10substituteERNS_7UStringERKS0_
+__ZN3KJS4Node16rethrowExceptionEPNS_9ExecStateE
+__ZN3KJS4Node15handleExceptionEPNS_9ExecStateEPNS_7JSValueE
+__ZN3KJS16RuntimeObjectImp10invalidateEv
+__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS14JSGlobalObjectD2Ev
+__ZN3KJS15GlobalExecStateD1Ev
+__ZN3KJS14BitwiseNotNodeD1Ev
+__ZN3KJSplERKNS_7UStringES2_
+__ZN3KJS5Lexer14convertUnicodeEiiii
+__ZN3KJS14ArrayObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS9Arguments3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3WTF9HashTableIjSt4pairIjiENS_18PairFirstExtractorIS2_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENS8_IiEEEES9_E3addIjS2_NS_22IdentityHashTranslatorIjS2_S6_EEEES1_INS_17HashTableIteratorIjS2_S4_S6_SB_S9_EEbERKT_RKT0_
+__ZN3WTF9HashTableIjSt4pairIjiENS_18PairFirstExtractorIS2_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENS8_IiEEEES9_EC2ERKSC_
+__ZN3KJS23stringProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3WTF9HashTableIjSt4pairIjiENS_18PairFirstExtractorIS2_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENS8_IiEEEES9_E4findIjNS_22IdentityHashTranslatorIjS2_S6_EEEENS_17HashTableIteratorIjS2_S4_S6_SB_S9_EERKT_
+__ZN3KJS10BitXOrNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS10BitXOrNode8evaluateEPNS_9ExecStateE
+__ZN3KJS14RightShiftNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS10BitXOrNodeD1Ev
+__ZN3KJS17DateObjectFuncImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS9parseDateERKNS_7UStringE
+__ZN3KJS6RegExp6createERKNS_7UStringE
+__ZN3KJS7ModNode16evaluateToNumberEPNS_9ExecStateE
+__ZNK3KJS16RuntimeObjectImp14implementsCallEv
+__ZNK3KJS8Bindings9CInstance14implementsCallEv
+__ZN3KJS11Interpreter21shouldPrintExceptionsEv
+__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcRKNS_10IdentifierE
+__ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_
+__ZN3KJS15SavedPropertiesD1Ev
+__ZN3KJS8JSObject18isActivationObjectEv
+__ZN3KJS19globalFuncDecodeURIEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS14JSGlobalObject15restoreBuiltinsERKNS_13SavedBuiltinsE
+__ZN3KJS11PropertyMap7restoreERKNS_15SavedPropertiesE
+__ZN3KJS16JSVariableObject19restoreLocalStorageERKNS_15SavedPropertiesE
+__ZN3WTF6VectorIN3KJS17LocalStorageEntryELm32EE6resizeEm
+__ZNK3KJS23FunctionCallBracketNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17TypeOfResolveNode10precedenceEv
+__ZNK3KJS17TypeOfResolveNode8streamToERNS_12SourceStreamE
+__ZNK3KJS13AssignDotNode10precedenceEv
+__ZNK3KJS12ContinueNode8streamToERNS_12SourceStreamE
+__ZN3KJS11FunctionImp12callerGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS9BreakNodeC1ERKNS_10IdentifierE
+__ZN3KJS13StatementNode9pushLabelERKNS_10IdentifierE
+__ZN3KJS10LabelStack4pushERKNS_10IdentifierE
+__ZN3KJS9ThrowNode7executeEPNS_9ExecStateE
+__ZNK3KJS15NumberObjectImp19implementsConstructEv
+__ZN3KJS22numberProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS8VoidNodeD1Ev
+__ZN3KJS14ErrorObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS18globalFuncIsFiniteEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS21ReadModifyResolveNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15StrictEqualNode8evaluateEPNS_9ExecStateE
+__ZN3KJS27compareByStringPairForQSortEPKvS1_
+__ZN3KJS7compareERKNS_7UStringES2_
+__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcPNS_7JSValueEPS0_S8_
+__ZN3KJS21arrayProtoFuncReverseEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS20stringProtoFuncSliceEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS15StringObjectImp19implementsConstructEv
+__ZN3KJS15StringObjectImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS18PostDecResolveNode8evaluateEPNS_9ExecStateE
+__ZN3KJS21dateProtoFuncSetMonthEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23setNewValueFromDateArgsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListEib
+__ZN3KJS20dateProtoFuncSetDateEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS21dateProtoFuncSetHoursEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23setNewValueFromTimeArgsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListEib
+__ZN3KJS23dateProtoFuncSetMinutesEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS24dateProtoFuncSetFullYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRPNS_7JSValueE
+__ZN3KJS20dateProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS27dateProtoFuncGetUTCFullYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS27dateProtoFuncSetUTCFullYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS24dateProtoFuncGetUTCMonthEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS24dateProtoFuncSetUTCMonthEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23dateProtoFuncGetUTCDateEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23dateProtoFuncSetUTCDateEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS24dateProtoFuncGetUTCHoursEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS24dateProtoFuncSetUTCHoursEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS26dateProtoFuncGetUTCMinutesEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS26dateProtoFuncSetUTCMinutesEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS26dateProtoFuncGetUTCSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS26dateProtoFuncSetUTCSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS22numberProtoFuncToFixedEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS18integer_part_noexpEd
+__ZN3KJS14AddNumbersNode16evaluateToNumberEPNS_9ExecStateE
+__ZNK3KJS14InstanceOfNode10precedenceEv
+__ZNK3KJS14InstanceOfNode8streamToERNS_12SourceStreamE
+__ZNK3KJS8JSObject8toNumberEPNS_9ExecStateE
+__Z15kjs_pcre_xclassiPKh
+__ZN3KJS10NumberNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS18PostDecBracketNodeD1Ev
+__ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE
+__ZN3KJS22errorProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS13LeftShiftNode15evaluateToInt32EPNS_9ExecStateE
+__ZNK3KJS9RegExpImp14implementsCallEv
+__ZN3KJS22stringProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS15ConditionalNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
+__ZN3KJS11DoWhileNode7executeEPNS_9ExecStateE
+__ZN3KJS8Bindings23convertObjcValueToValueEPNS_9ExecStateEPvNS0_13ObjcValueTypeEPNS0_10RootObjectE
+__ZN3KJS8Bindings17webUndefinedClassEv
+__ZN3KJS8Bindings20webScriptObjectClassEv
+__ZN3KJS8Bindings8Instance19createRuntimeObjectENS1_15BindingLanguageEPvN3WTF10PassRefPtrINS0_10RootObjectEEE
+__ZN3KJS8Bindings12ObjcInstanceC2EP11objc_objectN3WTF10PassRefPtrINS0_10RootObjectEEE
+__ZN3KJS8Bindings8Instance18didExecuteFunctionEv
+__ZN3KJS8Bindings12ObjcInstance5beginEv
+__ZNK3KJS8Bindings12ObjcInstance8getClassEv
+__ZN3KJS8Bindings9ObjcClass11classForIsAEP10objc_class
+__ZN3KJS8Bindings9ObjcClassC2EP10objc_class
+__ZNK3KJS8Bindings9ObjcClass10fieldNamedERKNS_10IdentifierEPNS0_8InstanceE
+__ZNK3KJS8Bindings9ObjcClass12methodsNamedERKNS_10IdentifierEPNS0_8InstanceE
+__ZN3KJS8Bindings25convertJSMethodNameToObjcEPKcPcm
+__ZN3KJS8Bindings10ObjcMethodC2EP10objc_classPKc
+__ZN3KJS8Bindings12ObjcInstance3endEv
+__ZN3KJS8Bindings12ObjcInstance12invokeMethodEPNS_9ExecStateERKN3WTF6VectorIPNS0_6MethodELm0EEERKNS_4ListE
+__ZNK3KJS8Bindings10ObjcMethod18getMethodSignatureEv
+__ZNK3KJS8Bindings10ObjcMethod4nameEv
+__ZN3KJS8Bindings20objcValueTypeForTypeEPKc
+__ZN3KJS8Bindings23convertValueToObjcValueEPNS_9ExecStateEPNS_7JSValueENS0_13ObjcValueTypeE
+__ZNK3KJS6JSCell9getStringEv
+__ZN3KJS8Bindings23convertNSStringToStringEP8NSString
+__ZN3KJS8Bindings12ObjcInstanceD1Ev
+__ZN3KJS9LabelNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS9LabelNode7executeEPNS_9ExecStateE
+__ZN3KJS12ContinueNodeC1ERKNS_10IdentifierE
+__ZN3KJS11FunctionImp12lengthGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS9BitOrNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS18EmptyStatementNode7executeEPNS_9ExecStateE
+__ZN3KJS22UnsignedRightShiftNodeD1Ev
+__ZN3KJS7ModNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS20arrayProtoFuncFilterEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS6InNode8evaluateEPNS_9ExecStateE
+__ZN3KJS17arrayProtoFuncMapEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS10LessEqNode10precedenceEv
+__ZNK3KJS10LessEqNode8streamToERNS_12SourceStreamE
+__ZNK3KJS18NotStrictEqualNode10precedenceEv
+__ZNK3KJS18NotStrictEqualNode8streamToERNS_12SourceStreamE
+__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
+__ZN3KJS7UString4fromEi
+__ZN3KJS14StringInstance11indexGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS21stringProtoFuncConcatEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS22UnsignedRightShiftNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS11ResolveNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS19FunctionCallDotNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS22UnsignedRightShiftNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS11ResolveNode16evaluateToUInt32EPNS_9ExecStateE
+__ZNK3KJS9NumberImp18getTruncatedUInt32ERj
+__ZN3KJS10NumberNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS7SubNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS14BitwiseNotNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS10BitAndNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS7AddNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS7SubNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS8VoidNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS8VoidNode8evaluateEPNS_9ExecStateE
+__ZN3KJS17DeleteResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS18LocalVarDeleteNodeD1Ev
+__ZN3KJS11FunctionImp15argumentsGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS18LocalVarDeleteNode8evaluateEPNS_9ExecStateE
+__ZN3KJS17DeleteResolveNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS16RuntimeObjectImp6canPutEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS13UnaryPlusNode8evaluateEPNS_9ExecStateE
+__ZN3KJS24dateProtoFuncToUTCStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23booleanProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS11NewExprNode16evaluateToNumberEPNS_9ExecStateE
+__Z22kjs_pcre_ucp_othercasej
+__ZN3KJS17PreDecResolveNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS7JSValue7toFloatEPNS_9ExecStateE
+__ZN3KJS14ExpressionNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS4List26markProtectedListsSlowCaseEv
+__ZNK3KJS6JSCell9getStringERNS_7UStringE
+__ZN3KJS8TrueNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS9RegExpImp3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZNK3KJS9NumberImp9getUInt32ERj
+__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcPNS_7JSValueEPS0_
+__ZN3KJS23FunctionCallResolveNode15evaluateToInt32EPNS_9ExecStateE
+__ZNK3KJS6JSCell18getTruncatedUInt32ERj
+__ZNK3KJS9LabelNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17ObjectLiteralNode21needsParensIfLeftmostEv
+__ZNK3KJS11DoWhileNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17PreDecResolveNode8streamToERNS_12SourceStreamE
+__ZNK3KJS13PreIncDotNode8streamToERNS_12SourceStreamE
+__ZNK3KJS13PreDecDotNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17DeleteResolveNode8streamToERNS_12SourceStreamE
+__ZN3KJS9FalseNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS23dateProtoFuncSetSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS14PostIncDotNode8streamToERNS_12SourceStreamE
+__ZNK3KJS8Bindings12ObjcInstance14implementsCallEv
+__ZN3KJS8Bindings9ObjcClass14fallbackObjectEPNS_9ExecStateEPNS0_8InstanceERKNS_10IdentifierE
+__ZN3KJS16BooleanObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS11jsUndefinedEv
+___tcf_2
+___tcf_6
+___tcf_0
+___tcf_5
+___tcf_3
+___tcf_4
+__Z12jsRegExpFreeP8JSRegExp
+__ZN3KJS25CollectorHeapIntrospector4sizeEP14_malloc_zone_tPKv
+__ZN3WTF9HashTableINS_6RefPtrIN3KJS7UString3RepEEESt4pairIS5_mENS_18PairFirstExtractorIS7_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS2_23IdentifierRepHashTraitsENS2_26SymbolTableIndexHashTraitsEEESC_E4findIS5_NS_22IdentityHashTranslatorIS5_S7_SA_EEEENS_17HashTableIteratorIS5_S7_S9_SA_SE_SC_EERKT_
+__ZN3KJS18AssignLocalVarNodeD1Ev
+__ZN3KJS8TrueNodeD1Ev
+__ZN3KJS11NewExprNodeD1Ev
+__ZN3KJS19ImmediateNumberNodeD1Ev
+__ZN3KJS17AssignBracketNodeD1Ev
+__ZN3KJS18LocalVarAccessNodeD1Ev
+__ZN3KJS16ParserRefCounted8refcountEv
+__ZN3KJS14JSGlobalObject16stopTimeoutCheckEv
+__ZN3KJS11GreaterNodeD1Ev
+__ZN3KJS16ArgumentListNodeD1Ev
+__ZN3KJS17FunctionObjectImp9constructEPNS_9ExecStateERKNS_4ListERKNS_10IdentifierERKNS_7UStringEi
+__ZN3KJS6Parser5parseINS_16FunctionBodyNodeEEEN3WTF10PassRefPtrIT_EERKNS_7UStringEiPKNS_5UCharEjPiSD_PS7_
+__ZN3KJS8JSObject4callEPNS_9ExecStateEPS0_RKNS_4ListE
+__ZN3KJS18AddStringRightNode8evaluateEPNS_9ExecStateE
+__ZN3KJS16globalFuncEscapeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS13DateObjectImp19implementsConstructEv
+__ZN3KJS13DateObjectImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS13DatePrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS20dateProtoFuncGetTimeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS12DateInstance9classInfoEv
+__ZNK3KJS9NumberImp8toNumberEPNS_9ExecStateE
+__ZNK3KJS9NumberImp8toStringEPNS_9ExecStateE
+__ZN3KJS9BlockNodeD1Ev
+__ZN3KJS21dateProtoFuncGetMonthEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS21msToGregorianDateTimeEdbRNS_17GregorianDateTimeE
+__ZN3KJS12getUTCOffsetEv
+__ZN3KJS12getDSTOffsetEdd
+__ZN3KJS15ConditionalNodeD1Ev
+__ZN3KJS7DivNodeD1Ev
+__ZN3KJS9EqualNodeD1Ev
+__ZN3KJS8NullNodeD1Ev
+__ZN3KJS9FalseNodeD1Ev
+__ZN3KJS12NotEqualNodeD1Ev
+__ZN3KJS7SubNodeD1Ev
+__ZN3KJS7SubNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS24LocalVarFunctionCallNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS21ReadModifyResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS14StringInstance12lengthGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS18globalFuncUnescapeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS7DivNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS7DivNode8evaluateEPNS_9ExecStateE
+__ZN3KJS18LocalVarAccessNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS8MultNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS8MultNode8evaluateEPNS_9ExecStateE
+__ZN3KJS19FunctionCallDotNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS7SubNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS9NumberImp11toPrimitiveEPNS_9ExecStateENS_6JSTypeE
+__ZN3KJS18AddStringRightNodeD1Ev
+__ZN3KJS7AddNodeD1Ev
+__ZN3KJS13LogicalOrNodeD1Ev
+__ZN3KJS17PreIncResolveNodeD1Ev
+__ZN3KJS8MultNodeD1Ev
+__ZN3KJS8LessNodeD1Ev
+__ZN3KJS14LogicalAndNodeD1Ev
+__ZN3KJS10NumberNodeD1Ev
+__ZN3KJS13GreaterEqNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS14LogicalNotNodeD1Ev
+__ZN3KJS7ModNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS14JSGlobalObject12checkTimeoutEv
+__ZN3KJS7ModNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15LessNumbersNode8evaluateEPNS_9ExecStateE
+__ZN3KJS20dateProtoFuncGetYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS8ThisNodeD1Ev
+__ZN3KJS19mathProtoFuncRandomEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS20globalFuncParseFloatEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS13GreaterEqNode8evaluateEPNS_9ExecStateE
+__ZN3KJS20dateProtoFuncGetDateEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS18mathProtoFuncFloorEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23stringProtoFuncFontsizeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS11ResolveNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS13GreaterEqNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS9NumberImp18getPrimitiveNumberEPNS_9ExecStateERdRPNS_7JSValueE
+__ZN3KJS19stringProtoFuncLinkEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS19dateProtoFuncGetDayEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS21dateProtoFuncGetHoursEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23dateProtoFuncGetMinutesEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS23dateProtoFuncGetSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS9ArrayNodeD1Ev
+__ZN3KJS11ElementNodeD1Ev
+__ZN3KJS17ObjectLiteralNodeD1Ev
+__ZN3KJS14PostfixDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS14PostIncDotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS19PlaceholderTrueNodeD1Ev
+__ZN3KJS19PostDecLocalVarNode8evaluateEPNS_9ExecStateE
+__ZN3KJS17ReadModifyDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS17ReadModifyDotNode8evaluateEPNS_9ExecStateE
+__ZN3KJS21FunctionCallValueNodeD1Ev
+__ZN3KJS10BitAndNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS14AddNumbersNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS10BitXOrNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS22UnsignedRightShiftNode8evaluateEPNS_9ExecStateE
+__ZN3KJS8MultNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS7DivNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS19StringObjectFuncImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS7ModNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS10BitAndNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS14RightShiftNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS14AddNumbersNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS14globalFuncEvalEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS6Parser5parseINS_8EvalNodeEEEN3WTF10PassRefPtrIT_EERKNS_7UStringEiPKNS_5UCharEjPiSD_PS7_
+__ZN3KJS13EvalExecStateC1EPNS_14JSGlobalObjectEPNS_8EvalNodeEPNS_9ExecStateE
+__ZN3KJS8EvalNode7executeEPNS_9ExecStateE
+__ZN3KJS8EvalNodeD1Ev
+__ZN3KJS23FunctionCallBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS23FunctionCallBracketNode8evaluateEPNS_9ExecStateE
+__ZN3KJS16PropertyListNodeD1Ev
+__ZN3KJS12PropertyNodeD1Ev
+__ZN3KJS13CaseBlockNodeD1Ev
+__ZN3KJS14CaseClauseNodeD1Ev
+__ZN3KJS14ClauseListNodeD1Ev
+__ZN3KJS9RegExpImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS17staticValueGetterINS_9RegExpImpEEEPNS_7JSValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE
+__ZNK3KJS9RegExpImp16getValuePropertyEPNS_9ExecStateEi
+__ZN3KJS9ThrowNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS15StrictEqualNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS19regExpProtoFuncTestEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS9RegExpImp5matchEPNS_9ExecStateERKNS_4ListE
+__ZN3KJS15StrictEqualNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS18NotStrictEqualNodeD1Ev
+__ZN3KJS15StrictEqualNodeD1Ev
+__ZN3KJS18LocalVarTypeOfNodeD1Ev
+__ZN3KJS19globalFuncEncodeURIEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17TypeOfResolveNode8evaluateEPNS_9ExecStateE
+__ZN3KJS26stringProtoFuncLastIndexOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS7JSValue20toIntegerPreserveNaNEPNS_9ExecStateE
+__ZNK3KJS7UString5rfindERKS0_i
+__ZN3KJS15TypeOfValueNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS15TypeOfValueNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS17FunctionObjectImp19implementsConstructEv
+__ZN3KJS17FunctionObjectImp9constructEPNS_9ExecStateERKNS_4ListE
+__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS30dateProtoFuncGetTimezoneOffsetEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS8JSObject3putEPNS_9ExecStateEjPNS_7JSValueEi
+__ZN3KJS6InNodeD1Ev
+__ZNK3KJS9Arguments9classInfoEv
+__ZN3KJS10BitXOrNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS19addSlowCaseToNumberEPNS_9ExecStateEPNS_7JSValueES3_
+__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj
+__ZNK3KJS9WhileNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9FalseNode8streamToERNS_12SourceStreamE
+__ZNK3KJS7DivNode8streamToERNS_12SourceStreamE
+__ZNK3KJS7DivNode10precedenceEv
+__ZNK3KJS15StrictEqualNode8streamToERNS_12SourceStreamE
+__ZNK3KJS15StrictEqualNode10precedenceEv
+__ZNK3KJS16VarDeclCommaNode10precedenceEv
+__ZNK3KJS17PreIncResolveNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9FalseNode10precedenceEv
+__ZN3KJS14InstanceOfNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv
+__ZN3KJS8JSObject11hasInstanceEPNS_9ExecStateEPNS_7JSValueE
+__ZN3WTF14FastMallocZone9forceLockEP14_malloc_zone_t
+__ZN3KJS25CollectorHeapIntrospector9forceLockEP14_malloc_zone_t
+__ZN3WTF14FastMallocZone11forceUnlockEP14_malloc_zone_t
+__ZN3KJS25CollectorHeapIntrospector11forceUnlockEP14_malloc_zone_t
+__ZNK3KJS23FunctionCallBracketNode10precedenceEv
+__ZN3KJS14InstanceOfNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS9ThrowNode8streamToERNS_12SourceStreamE
+__ZNK3KJS7SubNode10precedenceEv
+__ZNK3KJS7SubNode8streamToERNS_12SourceStreamE
+__ZNK3KJS10NegateNode10precedenceEv
+__ZNK3KJS10NegateNode8streamToERNS_12SourceStreamE
+__ZNK3KJS12FuncDeclNode8streamToERNS_12SourceStreamE
+__ZNK3KJS18PostDecResolveNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9BreakNode8streamToERNS_12SourceStreamE
+__ZNK3KJS6InNode10precedenceEv
+__ZNK3KJS6InNode8streamToERNS_12SourceStreamE
+__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE
+__ZN3KJS18PostDecBracketNode8evaluateEPNS_9ExecStateE
+__ZN3KJS28dateProtoFuncGetMilliSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS18PostIncResolveNode8streamToERNS_12SourceStreamE
+__ZN3KJS13ArrayInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS15AssignErrorNodeD1Ev
+__ZN3WTF6VectorIcLm0EE14expandCapacityEmPKc
+__ZN3WTF6VectorIcLm0EE14expandCapacityEm
+_JSContextGetGlobalObject
+_JSClassCreate
+__ZN13OpaqueJSClass6createEPK17JSClassDefinition
+__ZN13OpaqueJSClassC2EPK17JSClassDefinitionPS_
+_JSClassRetain
+_JSObjectMake
+__ZN13OpaqueJSClass9prototypeEPK15OpaqueJSContext
+__ZN3KJS16JSCallbackObjectINS_8JSObjectEE4initEPNS_9ExecStateE
+_JSStringCreateWithUTF8CString
+_JSObjectSetProperty
+_JSStringRelease
+__Z30makeGetterOrSetterPropertyNodeRKN3KJS10IdentifierES2_PNS_13ParameterNodeEPNS_16FunctionBodyNodeE
+__ZN3KJS8JSObject12defineGetterEPNS_9ExecStateERKNS_10IdentifierEPS0_
+__ZN3KJS8JSObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPS0_
+__ZNK3KJS15GetterSetterImp4typeEv
+__ZNK3KJS8JSObject6canPutEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS13ConstDeclNodeC1ERKNS_10IdentifierEPNS_14ExpressionNodeE
+__Z26appendToVarDeclarationListRPN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEEEPNS_13ConstDeclNodeE
+__ZN3KJS18ConstStatementNodeC1EPNS_13ConstDeclNodeE
+__ZN3KJS16JSCallbackObjectINS_8JSObjectEE18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS16JSCallbackObjectINS_8JSObjectEE20staticFunctionGetterEPNS_9ExecStateEPS1_RKNS_10IdentifierERKNS_12PropertySlotE
+__ZN3KJS18JSCallbackFunctionC1EPNS_9ExecStateEPFPK13OpaqueJSValuePK15OpaqueJSContextPS3_S9_mPKS5_PS5_ERKNS_10IdentifierE
+__ZN3KJS18JSCallbackFunction14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+_JSObjectGetPrivate
+__ZNK3KJS16JSCallbackObjectINS_8JSObjectEE9classInfoEv
+_JSStringCreateWithCharacters
+_JSValueMakeString
+__ZN3KJS12PropertySlot14functionGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_
+__ZN3WTF10fastCallocEmm
+_JSObjectGetProperty
+_JSValueToObject
+_JSValueProtect
+_JSObjectCallAsFunction
+_JSValueMakeNumber
+_JSValueMakeBoolean
+_JSObjectCallAsConstructor
+__ZN3KJS15GetterSetterImp4markEv
+_JSValueMakeUndefined
+_JSValueUnprotect
+_JSValueIsNumber
+_JSValueToNumber
+__ZN3KJS16JSCallbackObjectINS_8JSObjectEED0Ev
+__Z25clearReferenceToPrototypeP13OpaqueJSValue
+_JSClassRelease
+_JSStringIsEqualToUTF8CString
+_JSStringIsEqual
+__ZN3KJSeqERKNS_7UStringES2_
+__ZN3KJS16JSCallbackObjectINS_8JSObjectEE14callbackGetterEPNS_9ExecStateEPS1_RKNS_10IdentifierERKNS_12PropertySlotE
+_JSStringCreateWithCFString
+__ZN3KJS7UStringC2EPNS_5UCharEib
+__ZN3KJS16JSCallbackObjectINS_8JSObjectEE3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+_JSObjectSetPrivate
+__ZN3KJS15GetterSetterImpD0Ev
+__ZN3KJS27objectProtoFuncLookupGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS17PreIncResolveNode10precedenceEv
+__ZNK3KJS10SwitchNode8streamToERNS_12SourceStreamE
+__ZNK3KJS13CaseBlockNode8streamToERNS_12SourceStreamE
+__ZNK3KJS14CaseClauseNode8streamToERNS_12SourceStreamE
+__ZN3KJS18ConstStatementNodeD1Ev
+__ZN3KJS17PreDecBracketNodeD1Ev
+__ZN3KJS11Interpreter24setShouldPrintExceptionsEb
+__ZN3KJS9Collector26protectedGlobalObjectCountEv
+__ZN3KJS9Collector4sizeEv
+__ZN3KJS9Collector17globalObjectCountEv
+__ZN3KJS9Collector20protectedObjectCountEv
+__ZN3KJS9Collector25protectedObjectTypeCountsEv
+__ZNK3KJS15NumberObjectImp9classInfoEv
+__ZNK3KJS15RegExpPrototype9classInfoEv
+__ZNK3KJS15RegExpObjectImp9classInfoEv
+__ZNK3KJS14NativeErrorImp9classInfoEv
+__ZNK3KJS13MathObjectImp9classInfoEv
+__ZN3WTF6VectorIPN3KJS7JSValueELm8EE14expandCapacityEmPKS3_
+__ZN3WTF6VectorIPN3KJS7JSValueELm8EE14expandCapacityEm
+__ZN3KJS15ConditionalNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS9Arguments14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZNK3KJS17DeleteBracketNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9BitOrNode10precedenceEv
+__ZNK3KJS9BitOrNode8streamToERNS_12SourceStreamE
+__ZNK3KJS7ModNode10precedenceEv
+__ZNK3KJS7ModNode8streamToERNS_12SourceStreamE
+__ZN3KJS31dateProtoFuncToLocaleTimeStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS16formatLocaleDateEPNS_9ExecStateEdbbRKNS_4ListE
+__ZN3KJS31dateProtoFuncToLocaleDateStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS9BitOrNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS7DivNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS14BitwiseNotNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS13ActivationImp14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS27objectProtoFuncDefineGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17PreDecBracketNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS16BooleanObjectImp19implementsConstructEv
+__ZN3KJS27objectProtoFuncDefineSetterEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPPNS_7JSValueE
+__ZN3KJS10StringNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS13UnaryPlusNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS31dateProtoFuncGetUTCMillisecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS17FunctionObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS15DeleteValueNodeD1Ev
+__ZN3KJS15RegExpObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS22dateProtoFuncGetUTCDayEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS8MultNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS4Node18setErrorCompletionEPNS_9ExecStateENS_9ErrorTypeEPKc
+__ZN3KJS10StringNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS27dateProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS22UnsignedRightShiftNode16evaluateToNumberEPNS_9ExecStateE
+__ZNK3KJS18PostIncResolveNode10precedenceEv
+__ZNK3KJS21ReadModifyResolveNode10precedenceEv
+__ZNK3KJS21FunctionCallValueNode10precedenceEv
+__ZN3KJS4Node15handleExceptionEPNS_9ExecStateE
+__ZNK3KJS13UnaryPlusNode10precedenceEv
+__ZNK3KJS13UnaryPlusNode8streamToERNS_12SourceStreamE
+__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcPNS_7JSValueERKNS_10IdentifierE
+__ZNK3KJS15DotAccessorNode17isDotAccessorNodeEv
+__ZNK3KJS14PostfixDotNode10precedenceEv
+__ZN3KJS23regExpProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS14PostDecDotNode8streamToERNS_12SourceStreamE
+__ZNK3KJS9CommaNode10precedenceEv
+__ZNK3KJS17ReadModifyDotNode10precedenceEv
+__ZNK3KJS13DeleteDotNode8streamToERNS_12SourceStreamE
+__ZNK3KJS19PlaceholderTrueNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17AssignBracketNode10precedenceEv
+__ZNK3KJS8WithNode8streamToERNS_12SourceStreamE
+__ZNK3KJS17DeleteBracketNode10precedenceEv
+__ZN3KJS15ObjectObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+_KJS_JSCreateNativeJSObject
+__ZN3KJS8Bindings12JavaJSObject6invokeEPNS0_19JSObjectCallContextE
+__ZN3KJS8Bindings12JavaJSObject12createNativeEx
+__ZN3KJS8Bindings24findProtectingRootObjectEPNS_8JSObjectE
+_KJS_JSObject_JSObjectEval
+__ZN3KJS8Bindings12JavaJSObjectC1Ex
+__ZNK3KJS8Bindings12JavaJSObject4evalEP8_jstring
+__ZN3KJS8Bindings9getJNIEnvEv
+__ZN3KJS8Bindings9getJavaVMEv
+__ZN3KJS8Bindings30getUCharactersFromJStringInEnvEP7JNIEnv_P8_jstring
+__ZN3KJS8Bindings33releaseUCharactersForJStringInEnvEP7JNIEnv_P8_jstringPKt
+__ZNK3KJS8Bindings12JavaJSObject21convertValueToJObjectEPNS_7JSValueE
+__ZN7JNIEnv_9NewObjectEP7_jclassP10_jmethodIDz
+_KJS_JSObject_JSFinalize
+__ZN3KJS19stringProtoFuncBoldEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS15RegExpObjectImp15getRightContextEv
+__ZNK3KJS15RegExpObjectImp14getLeftContextEv
+__ZN3KJS13LeftShiftNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS7ModNode15evaluateToInt32EPNS_9ExecStateE
+__ZNK3KJS18PostDecResolveNode10precedenceEv
+__ZN3KJS28dateProtoFuncSetMilliSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS32stringProtoFuncToLocaleLowerCaseEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__NPN_SetException
+__ZN3KJS18mathProtoFuncATan2EPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS8Bindings12JavaInstanceC2EP8_jobjectN3WTF10PassRefPtrINS0_10RootObjectEEE
+__ZN3KJS8Bindings12JavaInstance5beginEv
+__ZNK3KJS8Bindings12JavaInstance8getClassEv
+__ZN3KJS8Bindings9JavaClassC2EP8_jobject
+__ZN3KJS8Bindings19callJNIObjectMethodEP8_jobjectPKcS4_z
+__ZN3KJS8Bindings13callJNIMethodE7JNITypeP8_jobjectPKcS5_Pc
+__ZN3KJS8Bindings24getCharactersFromJStringEP8_jstring
+__ZN3KJS8Bindings27releaseCharactersForJStringEP8_jstringPKc
+__ZN3KJS8Bindings9JavaFieldC2EP7JNIEnv_P8_jobject
+__ZN3KJS7CStringaSERKS0_
+__ZN3KJS8Bindings20JNITypeFromClassNameEPKc
+__ZN3KJS8Bindings14JObjectWrapperC1EP8_jobject
+__ZNK3KJS8Bindings9JavaField4nameEv
+__ZN3KJS8Bindings10JavaMethodC2EP7JNIEnv_P8_jobject
+__ZN3KJS8Bindings16callJNIIntMethodEP8_jobjectPKcS4_z
+__ZN3KJS8Bindings26callJNIStaticBooleanMethodEP7_jclassPKcS4_z
+__ZN3KJS8Bindings19callJNIStaticMethodE7JNITypeP7_jclassPKcS5_Pc
+__ZNK3KJS8Bindings10JavaMethod4nameEv
+__ZN3KJS8Bindings13JavaParameterC2EP7JNIEnv_P8_jstring
+__ZNK3KJS8Bindings9JavaClass10fieldNamedERKNS_10IdentifierEPNS0_8InstanceE
+__ZNK3KJS8Bindings9JavaClass12methodsNamedERKNS_10IdentifierEPNS0_8InstanceE
+__ZN3KJS8Bindings12JavaInstance3endEv
+__ZN3KJS8Bindings12JavaInstanceD1Ev
+__ZN3KJS8Bindings9JavaClassD1Ev
+__ZN3WTF20deleteAllPairSecondsIPN3KJS8Bindings5FieldEKNS_7HashMapINS_6RefPtrINS1_7UString3RepEEES4_NS_7PtrHashIS9_EENS_10HashTraitsIS9_EENSC_IS4_EEEEEEvRT0_
+__ZN3KJS8Bindings14JObjectWrapperD1Ev
+__ZN3KJS35objectProtoFuncPropertyIsEnumerableEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS31dateProtoFuncSetUTCMillisecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS12FuncExprNode21needsParensIfLeftmostEv
+__ZN3KJS13DateObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS11NewExprNode17evaluateToBooleanEPNS_9ExecStateE
+__ZN3KJS29numberProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS25dateProtoFuncToDateStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS9BitOrNode16evaluateToNumberEPNS_9ExecStateE
+__ZNK3KJS7JSValue8toUInt32EPNS_9ExecStateE
+__ZNK3KJS8JSObject3getEPNS_9ExecStateEj
+__ZNK3KJS7JSValue16toUInt32SlowCaseEPNS_9ExecStateERb
+__ZN3KJS9Collector29markOtherThreadConservativelyEPNS0_6ThreadE
+__ZN3WTF20TCMalloc_ThreadCache18DestroyThreadCacheEPv
+__ZN3WTF20TCMalloc_ThreadCache11DeleteCacheEPS0_
+__ZN3KJS23destroyRegisteredThreadEPv
+__ZN3KJS28numberProtoFuncToExponentialEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS26numberProtoFuncToPrecisionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS15RegExpObjectImp16putValuePropertyEPNS_9ExecStateEiPNS_7JSValueEi
+__ZNK3KJS15RegExpObjectImp12getLastParenEv
+__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
+__ZN3KJS18arrayProtoFuncSomeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS9LabelNode9pushLabelERKNS_10IdentifierE
+__ZN3KJS9Collector32reportOutOfMemoryToAllExecStatesEv
+__ZN3KJS5Error6createEPNS_9ExecStateENS_9ErrorTypeEPKc
+__ZNK3KJS17PreDecResolveNode10precedenceEv
+__ZN3KJS17mathProtoFuncACosEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS16mathProtoFuncTanEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS16PostfixErrorNode8streamToERNS_12SourceStreamE
+__ZNK3KJS15PrefixErrorNode8streamToERNS_12SourceStreamE
+__ZNK3KJS15AssignErrorNode8streamToERNS_12SourceStreamE
+__ZN3KJS16PostfixErrorNode8evaluateEPNS_9ExecStateE
+__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcS5_
+__ZN3KJS16PostfixErrorNodeD1Ev
+__ZNK3KJS13LeftShiftNode8streamToERNS_12SourceStreamE
+__ZNK3KJS13LeftShiftNode10precedenceEv
+__ZNK3KJS14RightShiftNode8streamToERNS_12SourceStreamE
+__ZNK3KJS14RightShiftNode10precedenceEv
+__ZNK3KJS22UnsignedRightShiftNode8streamToERNS_12SourceStreamE
+__ZNK3KJS22UnsignedRightShiftNode10precedenceEv
+__ZNK3KJS10BitAndNode8streamToERNS_12SourceStreamE
+__ZNK3KJS10BitAndNode10precedenceEv
+__ZNK3KJS10BitXOrNode8streamToERNS_12SourceStreamE
+__ZNK3KJS10BitXOrNode10precedenceEv
+__ZN3KJS15AssignErrorNode8evaluateEPNS_9ExecStateE
+__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
+__ZN3KJS13char_sequenceEci
+__ZN3KJS15LessStringsNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15LessStringsNodeD1Ev
+__ZN3KJS15DeleteValueNode8evaluateEPNS_9ExecStateE
+__ZN3KJS22regExpProtoFuncCompileEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS15PrefixErrorNode8evaluateEPNS_9ExecStateE
+__ZN3KJS28objectProtoFuncIsPrototypeOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS15PrefixErrorNodeD1Ev
+__ZN3KJS19arrayProtoFuncEveryEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS29objectProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS25arrayProtoFuncLastIndexOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3WTF6VectorItLm0EE6resizeEm
+__ZN3WTF6VectorItLm0EE14expandCapacityEm
+__ZN3WTF6VectorItLm0EE15reserveCapacityEm
+__ZN3KJS28arrayProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS18ConstStatementNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS13ConstDeclNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE
+__ZN3KJS18ConstStatementNode7executeEPNS_9ExecStateE
+__ZN3KJS13ConstDeclNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15AssignConstNode8evaluateEPNS_9ExecStateE
+__ZN3KJS16PostIncConstNode8evaluateEPNS_9ExecStateE
+__ZN3KJS16PostDecConstNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15PreIncConstNode8evaluateEPNS_9ExecStateE
+__ZN3KJS15PreDecConstNode8evaluateEPNS_9ExecStateE
+__ZN3KJS19ReadModifyConstNode8evaluateEPNS_9ExecStateE
+__ZNK3KJS13ActivationImp9classInfoEv
+__ZN3KJS16PostIncConstNodeD1Ev
+__ZN3KJS15PreIncConstNodeD1Ev
+__ZN3KJS15PreDecConstNodeD1Ev
+__ZNK3KJS13DeleteDotNode10precedenceEv
+__ZN3KJS28stringProtoFuncLocaleCompareEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZN3KJS10NumberNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS19FunctionCallDotNode16evaluateToUInt32EPNS_9ExecStateE
+__ZNK3KJS21ReadModifyBracketNode8streamToERNS_12SourceStreamE
+__ZN3KJS10BitXOrNode16evaluateToNumberEPNS_9ExecStateE
+___tcf_1
+__ZNK3KJS7UString6is8BitEv
+__ZN3KJS15DotAccessorNode16evaluateToUInt32EPNS_9ExecStateE
+__ZN3KJS24stringProtoFuncFontcolorEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE
+__ZNK3KJS14NativeErrorImp19implementsConstructEv
+__ZN3KJS19PostDecLocalVarNode16evaluateToNumberEPNS_9ExecStateE
+__ZN3KJS19PostDecLocalVarNode15evaluateToInt32EPNS_9ExecStateE
+__ZN3KJS13UnaryPlusNode17evaluateToBooleanEPNS_9ExecStateE
diff --git a/JavaScriptCore.pri b/JavaScriptCore.pri
new file mode 100644
index 0000000..d7cbc6a
--- /dev/null
+++ b/JavaScriptCore.pri
@@ -0,0 +1,155 @@
+# JavaScriptCore - Qt4 build info
+VPATH += $$PWD
+
+INCLUDEPATH += tmp
+INCLUDEPATH += $$PWD $$PWD/kjs $$PWD/bindings $$PWD/bindings/c $$PWD/wtf
+DEPENDPATH += $$PWD $$PWD/kjs $$PWD/bindings $$PWD/bindings/c $$PWD/wtf
+DEFINES -= KJS_IDENTIFIER_HIDE_GLOBALS 
+qt-port:INCLUDEPATH += $$PWD/bindings/qt
+qt-port:DEFINES += BUILDING_QT__
+gtk-port:DEFINES += BUILDING_GTK__
+
+# http://bugs.webkit.org/show_bug.cgi?id=16406
+# [Gtk] JavaScriptCore needs -lpthread
+gtk-port:!win32-*:LIBS += -lpthread
+
+win32-msvc*: INCLUDEPATH += $$PWD/os-win32
+
+isEmpty(GENERATED_SOURCES_DIR):GENERATED_SOURCES_DIR = tmp
+
+include(pcre/pcre.pri)
+
+LUT_FILES += \
+    kjs/date_object.cpp \
+    kjs/number_object.cpp \
+    kjs/string_object.cpp \
+    kjs/array_object.cpp \
+    kjs/math_object.cpp \
+    kjs/regexp_object.cpp
+
+KEYWORDLUT_FILES += \
+    kjs/keywords.table
+
+KJSBISON += \
+    kjs/grammar.y
+
+SOURCES += \
+    wtf/Assertions.cpp \
+    wtf/HashTable.cpp \
+    wtf/unicode/UTF8.cpp \
+    bindings/NP_jsobject.cpp \
+    bindings/npruntime.cpp \
+    bindings/runtime_array.cpp \
+    bindings/runtime.cpp \
+    bindings/runtime_method.cpp \
+    bindings/runtime_object.cpp \
+    bindings/runtime_root.cpp \
+    bindings/c/c_class.cpp \
+    bindings/c/c_instance.cpp \
+    bindings/c/c_runtime.cpp \
+    bindings/c/c_utility.cpp \
+    API/JSBase.cpp \
+    API/JSCallbackConstructor.cpp \
+    API/JSCallbackFunction.cpp \
+    API/JSCallbackObject.cpp \
+    API/JSClassRef.cpp \
+    API/JSContextRef.cpp \
+    API/JSObjectRef.cpp \
+    API/JSStringRef.cpp \
+    API/JSValueRef.cpp \
+    kjs/JSGlobalObject.cpp \
+    kjs/JSVariableObject.cpp
+
+# AllInOneFile.cpp helps gcc analize and optimize code
+# Other compilers may be able to do this at link time
+gtk-port:CONFIG(release) {
+SOURCES += \
+    kjs/AllInOneFile.cpp
+} else {
+SOURCES += \
+    kjs/function.cpp \
+    kjs/debugger.cpp \
+    kjs/array_instance.cpp \
+    kjs/array_object.cpp \
+    kjs/bool_object.cpp \
+    kjs/collector.cpp \
+    kjs/CommonIdentifiers.cpp \
+    kjs/date_object.cpp \
+    kjs/DateMath.cpp \
+    kjs/dtoa.cpp \
+    kjs/error_object.cpp \
+    kjs/ExecState.cpp \
+    kjs/function_object.cpp \
+    kjs/identifier.cpp \
+    kjs/internal.cpp \
+    kjs/interpreter.cpp \
+    kjs/JSImmediate.cpp \
+    kjs/JSLock.cpp \
+    kjs/JSWrapperObject.cpp \
+    kjs/lexer.cpp \
+    kjs/list.cpp \
+    kjs/lookup.cpp \
+    kjs/math_object.cpp \
+    kjs/nodes.cpp \
+    kjs/nodes2string.cpp \
+    kjs/number_object.cpp \
+    kjs/object.cpp \
+    kjs/object_object.cpp \
+    kjs/operations.cpp \
+    kjs/Parser.cpp \
+    kjs/property_map.cpp \
+    kjs/property_slot.cpp \
+    kjs/PropertyNameArray.cpp \
+    kjs/regexp.cpp \
+    kjs/regexp_object.cpp \
+    kjs/scope_chain.cpp \
+    kjs/string_object.cpp \
+    kjs/ustring.cpp \
+    kjs/value.cpp \
+    wtf/FastMalloc.cpp
+
+!qt-port:SOURCES += \
+    wtf/TCSystemAlloc.cpp
+}
+
+qt-port:SOURCES += \
+    bindings/qt/qt_class.cpp \
+    bindings/qt/qt_instance.cpp \
+    bindings/qt/qt_runtime.cpp
+
+!CONFIG(QTDIR_build) {
+    defineTest(addExtraCompiler) {
+        QMAKE_EXTRA_COMPILERS += $$1
+        generated_files.depends += compiler_$${1}_make_all
+        export(QMAKE_EXTRA_COMPILERS)
+        export(generated_files.depends)
+        return(true)
+    }
+}
+
+# GENERATOR 1-A: LUT creator
+lut.output = $$GENERATED_SOURCES_DIR/${QMAKE_FILE_BASE}.lut.h
+lut.commands = perl $$PWD/kjs/create_hash_table ${QMAKE_FILE_NAME} -i > ${QMAKE_FILE_OUT}
+lut.depend = ${QMAKE_FILE_NAME}
+lut.input = LUT_FILES
+lut.CONFIG += no_link
+addExtraCompiler(lut)
+
+# GENERATOR 1-B: particular LUT creator (for 1 file only)
+keywordlut.output = $$GENERATED_SOURCES_DIR/lexer.lut.h
+keywordlut.commands = perl $$PWD/kjs/create_hash_table ${QMAKE_FILE_NAME} -i > ${QMAKE_FILE_OUT}
+keywordlut.depend = ${QMAKE_FILE_NAME}
+keywordlut.input = KEYWORDLUT_FILES
+keywordlut.CONFIG += no_link
+addExtraCompiler(keywordlut)
+
+# GENERATOR 2: bison grammar
+kjsbison.output = $$GENERATED_SOURCES_DIR/${QMAKE_FILE_BASE}.cpp
+kjsbison.commands = bison -d -p kjsyy ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_BASE}.tab.c && $(MOVE) ${QMAKE_FILE_BASE}.tab.c ${QMAKE_FILE_OUT} && $(MOVE) ${QMAKE_FILE_BASE}.tab.h $$GENERATED_SOURCES_DIR/${QMAKE_FILE_BASE}.h
+kjsbison.depend = ${QMAKE_FILE_NAME}
+kjsbison.input = KJSBISON
+kjsbison.variable_out = GENERATED_SOURCES
+kjsbison.dependency_type = TYPE_C
+kjsbison.CONFIG = target_predeps
+kjsbison.clean = ${QMAKE_FILE_OUT} ${QMAKE_VAR_GENERATED_SOURCES_DIR}${QMAKE_FILE_BASE}.h
+addExtraCompiler(kjsbison)
diff --git a/JavaScriptCorePrefix.h b/JavaScriptCorePrefix.h
new file mode 100644
index 0000000..13b21bb
--- /dev/null
+++ b/JavaScriptCorePrefix.h
@@ -0,0 +1,35 @@
+#ifdef __cplusplus
+#define NULL __null
+#else
+#define NULL ((void *)0)
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef __cplusplus
+
+#include 
+#include 
+
+#endif
+
+#ifdef __cplusplus
+#define new ("if you use new/delete make sure to include config.h at the top of the file"()) 
+#define delete ("if you use new/delete make sure to include config.h at the top of the file"()) 
+#endif
+
+/* Work around bug with C++ library that screws up Objective-C++ when exception support is disabled. */
+#undef try
+#undef catch
diff --git a/JavaScriptCoreSources.bkl b/JavaScriptCoreSources.bkl
new file mode 100644
index 0000000..2a1312b
--- /dev/null
+++ b/JavaScriptCoreSources.bkl
@@ -0,0 +1,119 @@
+
+
+
+    
+        API/JSBase.cpp
+        API/JSCallbackConstructor.cpp
+        API/JSCallbackFunction.cpp
+        API/JSCallbackObject.cpp
+        API/JSClassRef.cpp
+        API/JSContextRef.cpp
+        API/JSObjectRef.cpp
+        API/JSStringRef.cpp
+        API/JSValueRef.cpp
+    
+
+    
+        bindings/c/c_class.cpp
+        bindings/c/c_instance.cpp
+        bindings/c/c_runtime.cpp
+        bindings/c/c_utility.cpp
+        bindings/NP_jsobject.cpp
+        bindings/npruntime.cpp
+        bindings/runtime.cpp
+        bindings/runtime_array.cpp
+        bindings/runtime_method.cpp
+        bindings/runtime_object.cpp
+        bindings/runtime_root.cpp
+    
+    
+    
+        DerivedSources/JavaScriptCore/grammar.cpp
+        kjs/array_instance.cpp
+        kjs/array_object.cpp
+        kjs/bool_object.cpp
+        kjs/collector.cpp
+        kjs/CommonIdentifiers.cpp
+        kjs/date_object.cpp
+        kjs/DateMath.cpp
+        kjs/debugger.cpp
+        kjs/dtoa.cpp
+        kjs/error_object.cpp
+        kjs/ExecState.cpp
+        kjs/function.cpp
+        kjs/function_object.cpp
+        kjs/identifier.cpp
+        kjs/internal.cpp
+        kjs/interpreter.cpp
+        kjs/JSGlobalObject.cpp
+        kjs/JSVariableObject.cpp
+        kjs/JSImmediate.cpp
+        kjs/JSLock.cpp
+        kjs/JSWrapperObject.cpp
+        kjs/lexer.cpp
+        kjs/list.cpp
+        kjs/lookup.cpp
+        kjs/math_object.cpp
+        kjs/nodes.cpp
+        kjs/nodes2string.cpp
+        kjs/number_object.cpp
+        kjs/object.cpp
+        kjs/object_object.cpp
+        kjs/operations.cpp
+        kjs/Parser.cpp
+        kjs/property_map.cpp
+        kjs/property_slot.cpp
+        kjs/PropertyNameArray.cpp
+        kjs/regexp.cpp
+        kjs/regexp_object.cpp
+        kjs/scope_chain.cpp
+        kjs/string_object.cpp
+        kjs/ustring.cpp
+        kjs/value.cpp
+
+    
+    
+        pcre/pcre_compile.cpp
+        pcre/pcre_exec.cpp
+        pcre/pcre_tables.cpp
+        pcre/pcre_ucp_searchfuncs.cpp
+        pcre/pcre_xclass.cpp
+    
+    
+    
+        wtf/Assertions.cpp
+        wtf/FastMalloc.cpp
+        wtf/HashTable.cpp
+        wtf/TCSystemAlloc.cpp
+        wtf/unicode/UTF8.cpp
+    
+
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b9e2a72
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,2 @@
+OTHER_OPTIONS = -target All
+include ../Makefile.shared
diff --git a/THANKS b/THANKS
new file mode 100644
index 0000000..b9a9649
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,8 @@
+
+I would like to thank the following people for their help:
+
+Richard Moore  - for filling the Math object with some life
+Daegeun Lee  - for pointing out some bugs and providing
+                                  much code for the String and Date object.
+Marco Pinelli  - for his patches
+Christian Kirsch  - for his contribution to the Date object
diff --git a/bindings/NP_jsobject.cpp b/bindings/NP_jsobject.cpp
new file mode 100644
index 0000000..d68a8e6
--- /dev/null
+++ b/bindings/NP_jsobject.cpp
@@ -0,0 +1,406 @@
+/*
+ * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(NETSCAPE_API)
+
+#include "NP_jsobject.h"
+
+#include "JSGlobalObject.h"
+#include "PropertyNameArray.h"
+#include "c_utility.h"
+#include "interpreter.h"
+#include "npruntime_impl.h"
+#include "npruntime_priv.h"
+#include "object.h"
+#include "runtime_root.h"
+
+using namespace KJS;
+using namespace KJS::Bindings;
+
+static void getListFromVariantArgs(ExecState* exec, const NPVariant* args, unsigned argCount, RootObject* rootObject, List& aList)
+{
+    for (unsigned i = 0; i < argCount; i++)
+        aList.append(convertNPVariantToValue(exec, &args[i], rootObject));
+}
+
+static NPObject* jsAllocate(NPP, NPClass*)
+{
+    return (NPObject*)malloc(sizeof(JavaScriptObject));
+}
+
+static void jsDeallocate(NPObject* npObj)
+{
+    JavaScriptObject* obj = (JavaScriptObject*)npObj;
+
+    if (obj->rootObject && obj->rootObject->isValid())
+        obj->rootObject->gcUnprotect(obj->imp);
+
+    if (obj->rootObject)
+        obj->rootObject->deref();
+
+    free(obj);
+}
+
+static NPClass javascriptClass = { 1, jsAllocate, jsDeallocate, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static NPClass noScriptClass = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+NPClass* NPScriptObjectClass = &javascriptClass;
+static NPClass* NPNoScriptObjectClass = &noScriptClass;
+
+NPObject* _NPN_CreateScriptObject(NPP npp, JSObject* imp, PassRefPtr rootObject)
+{
+    JavaScriptObject* obj = (JavaScriptObject*)_NPN_CreateObject(npp, NPScriptObjectClass);
+
+    obj->rootObject = rootObject.releaseRef();
+
+    if (obj->rootObject)
+        obj->rootObject->gcProtect(imp);
+    obj->imp = imp;
+
+    return (NPObject*)obj;
+}
+
+NPObject *_NPN_CreateNoScriptObject(void)
+{
+    return _NPN_CreateObject(0, NPNoScriptObjectClass);
+}
+
+bool _NPN_InvokeDefault(NPP, NPObject* o, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+        
+        VOID_TO_NPVARIANT(*result);
+        
+        // Lookup the function object.
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return false;
+        
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        JSLock lock;
+        
+        // Call the function object.
+        JSObject *funcImp = static_cast(obj->imp);
+        if (!funcImp->implementsCall())
+            return false;
+        
+        List argList;
+        getListFromVariantArgs(exec, args, argCount, rootObject, argList);
+        rootObject->globalObject()->startTimeoutCheck();
+        JSValue *resultV = funcImp->call (exec, funcImp, argList);
+        rootObject->globalObject()->stopTimeoutCheck();
+
+        // Convert and return the result of the function call.
+        convertValueToNPVariant(exec, resultV, result);
+        return true;        
+    }
+
+    if (o->_class->invokeDefault)
+        return o->_class->invokeDefault(o, args, argCount, result);    
+    VOID_TO_NPVARIANT(*result);
+    return true;
+}
+
+bool _NPN_Invoke(NPP npp, NPObject* o, NPIdentifier methodName, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+
+        PrivateIdentifier* i = (PrivateIdentifier*)methodName;
+        if (!i->isString)
+            return false;
+
+        // Special case the "eval" method.
+        if (methodName == _NPN_GetStringIdentifier("eval")) {
+            if (argCount != 1)
+                return false;
+            if (args[0].type != NPVariantType_String)
+                return false;
+            return _NPN_Evaluate(npp, o, (NPString *)&args[0].value.stringValue, result);
+        }
+
+        // Lookup the function object.
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return false;
+
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        JSLock lock;
+        JSValue* func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
+        if (func->isNull()) {
+            NULL_TO_NPVARIANT(*result);
+            return false;
+        } 
+        if (func->isUndefined()) {
+            VOID_TO_NPVARIANT(*result);
+            return false;
+        }
+        // Call the function object.
+        JSObject *funcImp = static_cast(func);
+        JSObject *thisObj = const_cast(obj->imp);
+        List argList;
+        getListFromVariantArgs(exec, args, argCount, rootObject, argList);
+        rootObject->globalObject()->startTimeoutCheck();
+        JSValue *resultV = funcImp->call (exec, thisObj, argList);
+        rootObject->globalObject()->stopTimeoutCheck();
+
+        // Convert and return the result of the function call.
+        convertValueToNPVariant(exec, resultV, result);
+        return true;
+    }
+
+    if (o->_class->invoke)
+        return o->_class->invoke(o, methodName, args, argCount, result);
+    
+    VOID_TO_NPVARIANT(*result);
+    return true;
+}
+
+bool _NPN_Evaluate(NPP, NPObject* o, NPString* s, NPVariant* variant)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return false;
+
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        
+        JSLock lock;
+        NPUTF16* scriptString;
+        unsigned int UTF16Length;
+        convertNPStringToUTF16(s, &scriptString, &UTF16Length); // requires free() of returned memory
+        rootObject->globalObject()->startTimeoutCheck();
+        Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), UString(), 0, UString(reinterpret_cast(scriptString), UTF16Length));
+        rootObject->globalObject()->stopTimeoutCheck();
+        ComplType type = completion.complType();
+        
+        JSValue* result;
+        if (type == Normal) {
+            result = completion.value();
+            if (!result)
+                result = jsUndefined();
+        } else
+            result = jsUndefined();
+
+        free(scriptString);
+
+        convertValueToNPVariant(exec, result, variant);
+    
+        return true;
+    }
+
+    VOID_TO_NPVARIANT(*variant);
+    return false;
+}
+
+bool _NPN_GetProperty(NPP, NPObject* o, NPIdentifier propertyName, NPVariant* variant)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return false;
+
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
+        
+        JSLock lock;
+        JSValue *result;
+        if (i->isString)
+            result = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
+        else
+            result = obj->imp->get(exec, i->value.number);
+
+        convertValueToNPVariant(exec, result, variant);
+        return true;
+    }
+
+    if (o->_class->hasProperty && o->_class->getProperty) {
+        if (o->_class->hasProperty(o, propertyName))
+            return o->_class->getProperty(o, propertyName, variant);
+        return false;
+    }
+
+    VOID_TO_NPVARIANT(*variant);
+    return false;
+}
+
+bool _NPN_SetProperty(NPP, NPObject* o, NPIdentifier propertyName, const NPVariant* variant)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return false;
+
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        JSLock lock;
+        PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
+        if (i->isString)
+            obj->imp->put(exec, identifierFromNPIdentifier(i->value.string), convertNPVariantToValue(exec, variant, rootObject));
+        else
+            obj->imp->put(exec, i->value.number, convertNPVariantToValue(exec, variant, rootObject));
+        return true;
+    }
+
+    if (o->_class->setProperty)
+        return o->_class->setProperty(o, propertyName, variant);
+
+    return false;
+}
+
+bool _NPN_RemoveProperty(NPP, NPObject* o, NPIdentifier propertyName)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return false;
+
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
+        if (i->isString) {
+            if (!obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->value.string)))
+                return false;
+        } else {
+            if (!obj->imp->hasProperty(exec, i->value.number))
+                return false;
+        }
+
+        JSLock lock;
+        if (i->isString)
+            obj->imp->deleteProperty(exec, identifierFromNPIdentifier(i->value.string));
+        else
+            obj->imp->deleteProperty(exec, i->value.number);
+        
+        return true;
+    }
+    return false;
+}
+
+bool _NPN_HasProperty(NPP, NPObject* o, NPIdentifier propertyName)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return false;
+
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
+        JSLock lock;
+        if (i->isString)
+            return obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->value.string));
+        return obj->imp->hasProperty(exec, i->value.number);
+    }
+
+    if (o->_class->hasProperty)
+        return o->_class->hasProperty(o, propertyName);
+
+    return false;
+}
+
+bool _NPN_HasMethod(NPP, NPObject* o, NPIdentifier methodName)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+
+        PrivateIdentifier* i = (PrivateIdentifier*)methodName;
+        if (!i->isString)
+            return false;
+
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return false;
+
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        JSLock lock;
+        JSValue* func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
+        return !func->isUndefined();
+    }
+    
+    if (o->_class->hasMethod)
+        return o->_class->hasMethod(o, methodName);
+    
+    return false;
+}
+
+void _NPN_SetException(NPObject* o, const NPUTF8* message)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return;
+
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        JSLock lock;
+        throwError(exec, GeneralError, message);
+    }
+}
+
+bool _NPN_Enumerate(NPP, NPObject *o, NPIdentifier **identifier, uint32_t *count)
+{
+    if (o->_class == NPScriptObjectClass) {
+        JavaScriptObject* obj = (JavaScriptObject*)o; 
+        
+        RootObject* rootObject = obj->rootObject;
+        if (!rootObject || !rootObject->isValid())
+            return false;
+        
+        ExecState* exec = rootObject->globalObject()->globalExec();
+        JSLock lock;
+        PropertyNameArray propertyNames;
+
+        obj->imp->getPropertyNames(exec, propertyNames);
+        unsigned size = static_cast(propertyNames.size());
+        // FIXME: This should really call NPN_MemAlloc but that's in WebKit
+        NPIdentifier *identifiers = static_cast(malloc(sizeof(NPIdentifier) * size));
+        
+        for (unsigned i = 0; i < size; i++)
+            identifiers[i] = _NPN_GetStringIdentifier(propertyNames[i].ustring().UTF8String().c_str());
+
+        *identifier = identifiers;
+        *count = size;
+        
+        return true;
+    }
+    
+    if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(o->_class) && o->_class->enumerate)
+        return o->_class->enumerate(o, identifier, count);
+    
+    return false;
+}
+
+#endif // ENABLE(NETSCAPE_API)
diff --git a/bindings/NP_jsobject.h b/bindings/NP_jsobject.h
new file mode 100644
index 0000000..62ab813
--- /dev/null
+++ b/bindings/NP_jsobject.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef NP_JSOBJECT_H
+#define NP_JSOBJECT_H
+
+#if ENABLE(NETSCAPE_API)
+
+#include "npruntime_internal.h"
+#include 
+
+namespace KJS {
+    class JSObject;
+    namespace Bindings {
+        class RootObject;
+    }
+}
+
+extern NPClass* NPScriptObjectClass;
+
+struct JavaScriptObject
+{
+    NPObject object;
+    KJS::JSObject* imp;
+    KJS::Bindings::RootObject* rootObject;
+};
+
+NPObject* _NPN_CreateScriptObject(NPP npp, KJS::JSObject*, PassRefPtr rootObject);
+NPObject* _NPN_CreateNoScriptObject(void);
+
+#endif // ENABLE(NETSCAPE_API)
+
+#endif
diff --git a/bindings/c/c_class.cpp b/bindings/c/c_class.cpp
new file mode 100644
index 0000000..af8a36b
--- /dev/null
+++ b/bindings/c/c_class.cpp
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(NETSCAPE_API)
+
+#include "c_class.h"
+
+#include "c_instance.h"
+#include "c_runtime.h"
+#include "identifier.h"
+#include "npruntime_impl.h"
+
+namespace KJS { namespace Bindings {
+
+CClass::CClass(NPClass* aClass)
+{
+    _isa = aClass;
+}
+
+CClass::~CClass()
+{
+    JSLock lock;
+
+    deleteAllValues(_methods);
+    _methods.clear();
+
+    deleteAllValues(_fields);
+    _fields.clear();
+}
+
+typedef HashMap ClassesByIsAMap;
+static ClassesByIsAMap* classesByIsA = 0;
+
+CClass* CClass::classForIsA(NPClass* isa)
+{
+    if (!classesByIsA)
+        classesByIsA = new ClassesByIsAMap;
+
+    CClass* aClass = classesByIsA->get(isa);
+    if (!aClass) {
+        aClass = new CClass(isa);
+        classesByIsA->set(isa, aClass);
+    }
+
+    return aClass;
+}
+
+const char* CClass::name() const
+{
+    return "";
+}
+
+MethodList CClass::methodsNamed(const Identifier& identifier, Instance* instance) const
+{
+    MethodList methodList;
+
+    Method* method = _methods.get(identifier.ustring().rep());
+    if (method) {
+        methodList.append(method);
+        return methodList;
+    }
+
+    NPIdentifier ident = _NPN_GetStringIdentifier(identifier.ascii());
+    const CInstance* inst = static_cast(instance);
+    NPObject* obj = inst->getObject();
+    if (_isa->hasMethod && _isa->hasMethod(obj, ident)){
+        Method* aMethod = new CMethod(ident); // deleted in the CClass destructor
+        {
+            JSLock lock;
+            _methods.set(identifier.ustring().rep(), aMethod);
+        }
+        methodList.append(aMethod);
+    }
+    
+    return methodList;
+}
+
+Field* CClass::fieldNamed(const Identifier& identifier, Instance* instance) const
+{
+    Field* aField = _fields.get(identifier.ustring().rep());
+    if (aField)
+        return aField;
+    
+    NPIdentifier ident = _NPN_GetStringIdentifier(identifier.ascii());
+    const CInstance* inst = static_cast(instance);
+    NPObject* obj = inst->getObject();
+    if (_isa->hasProperty && _isa->hasProperty(obj, ident)){
+        aField = new CField(ident); // deleted in the CClass destructor
+        {
+            JSLock lock;
+            _fields.set(identifier.ustring().rep(), aField);
+        }
+    }
+    return aField;
+}
+
+} } // namespace KJS::Bindings
+
+#endif // ENABLE(NETSCAPE_API)
diff --git a/bindings/c/c_class.h b/bindings/c/c_class.h
new file mode 100644
index 0000000..68a81fb
--- /dev/null
+++ b/bindings/c/c_class.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef BINDINGS_C_CLASS_H_
+#define BINDINGS_C_CLASS_H_
+
+#if ENABLE(NETSCAPE_API)
+
+#include "npruntime_internal.h"
+#include "runtime.h"
+#include 
+
+namespace KJS {
+namespace Bindings {
+
+class CClass : public Class {
+protected:
+    CClass(NPClass*); // Use classForIsA to create a CClass.
+    
+public:
+    static CClass* classForIsA(NPClass*);
+    virtual ~CClass();
+
+    virtual const char* name() const;    
+    virtual MethodList methodsNamed(const Identifier&, Instance*) const;
+    virtual Field* fieldNamed(const Identifier&, Instance*) const;
+
+private:
+    NPClass* _isa;
+    mutable MethodMap _methods;
+    mutable FieldMap _fields;
+};
+
+} // namespace Bindings
+} // namespace KJS
+
+#endif // ENABLE(NETSCAPE_API)
+
+#endif
diff --git a/bindings/c/c_instance.cpp b/bindings/c/c_instance.cpp
new file mode 100644
index 0000000..dd33253
--- /dev/null
+++ b/bindings/c/c_instance.cpp
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(NETSCAPE_API)
+
+#include "c_instance.h"
+
+#include "c_class.h"
+#include "c_runtime.h"
+#include "c_utility.h"
+#include "list.h"
+#include "npruntime_impl.h"
+#include "PropertyNameArray.h"
+#include "runtime_root.h"
+#include 
+#include 
+#include 
+
+namespace KJS {
+namespace Bindings {
+
+CInstance::CInstance(NPObject* o, PassRefPtr rootObject)
+    : Instance(rootObject)
+{
+    _object = _NPN_RetainObject(o);
+    _class = 0;
+}
+
+CInstance::~CInstance() 
+{
+    _NPN_ReleaseObject(_object);
+}
+
+Class *CInstance::getClass() const
+{
+    if (!_class)
+        _class = CClass::classForIsA(_object->_class);
+    return _class;
+}
+
+void CInstance::begin()
+{
+    // Do nothing.
+}
+
+void CInstance::end()
+{
+    // Do nothing.
+}
+
+bool CInstance::implementsCall() const
+{
+    return (_object->_class->invokeDefault != 0);
+}
+
+JSValue* CInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const List& args)
+{
+    // Overloading methods are not allowed by NPObjects.  Should only be one
+    // name match for a particular method.
+    ASSERT(methodList.size() == 1);
+
+    CMethod* method = static_cast(methodList[0]);
+
+    NPIdentifier ident = _NPN_GetStringIdentifier(method->name());
+    if (!_object->_class->hasMethod(_object, ident))
+        return jsUndefined();
+
+    unsigned count = args.size();
+    Vector cArgs(count);
+
+    unsigned i;
+    for (i = 0; i < count; i++)
+        convertValueToNPVariant(exec, args.at(i), &cArgs[i]);
+
+    // Invoke the 'C' method.
+    NPVariant resultVariant;
+    VOID_TO_NPVARIANT(resultVariant);
+
+    {
+       JSLock::DropAllLocks dropAllLocks;
+        _object->_class->invoke(_object, ident, cArgs.data(), count, &resultVariant);
+    }
+
+    for (i = 0; i < count; i++)
+        _NPN_ReleaseVariantValue(&cArgs[i]);
+
+    JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get());
+    _NPN_ReleaseVariantValue(&resultVariant);
+    return resultValue;
+}
+
+
+JSValue* CInstance::invokeDefaultMethod(ExecState* exec, const List& args)
+{
+    if (!_object->_class->invokeDefault)
+        return jsUndefined();
+
+    unsigned count = args.size();
+    Vector cArgs(count);
+
+    unsigned i;
+    for (i = 0; i < count; i++)
+        convertValueToNPVariant(exec, args.at(i), &cArgs[i]);
+
+    // Invoke the 'C' method.
+    NPVariant resultVariant;
+    VOID_TO_NPVARIANT(resultVariant);
+    {
+       JSLock::DropAllLocks dropAllLocks;
+        _object->_class->invokeDefault(_object, cArgs.data(), count, &resultVariant);
+    }
+    
+    for (i = 0; i < count; i++)
+        _NPN_ReleaseVariantValue(&cArgs[i]);
+
+    JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get());
+    _NPN_ReleaseVariantValue(&resultVariant);
+    return resultValue;
+}
+
+
+JSValue* CInstance::defaultValue(JSType hint) const
+{
+    if (hint == StringType)
+        return stringValue();
+    if (hint == NumberType)
+        return numberValue();
+   if (hint == BooleanType)
+        return booleanValue();
+    return valueOf();
+}
+
+JSValue* CInstance::stringValue() const
+{
+    char buf[1024];
+    snprintf(buf, sizeof(buf), "NPObject %p, NPClass %p", _object, _object->_class);
+    return jsString(buf);
+}
+
+JSValue* CInstance::numberValue() const
+{
+    // FIXME: Implement something sensible.
+    return jsNumber(0);
+}
+
+JSValue* CInstance::booleanValue() const
+{
+    // FIXME: Implement something sensible.
+    return jsBoolean(false);
+}
+
+JSValue* CInstance::valueOf() const 
+{
+    return stringValue();
+}
+
+void CInstance::getPropertyNames(ExecState*, PropertyNameArray& nameArray) 
+{
+    if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(_object->_class) ||
+        !_object->_class->enumerate)
+        return;
+
+    unsigned count;
+    NPIdentifier* identifiers;
+    
+    {
+        JSLock::DropAllLocks dropAllLocks;
+        if (!_object->_class->enumerate(_object, &identifiers, &count))
+            return;
+    }
+    
+    for (unsigned i = 0; i < count; i++) {
+        PrivateIdentifier* identifier = static_cast(identifiers[i]);
+        
+        if (identifier->isString)
+            nameArray.add(identifierFromNPIdentifier(identifier->value.string));
+        else
+            nameArray.add(Identifier::from(identifier->value.number));
+    }
+         
+    // FIXME: This should really call NPN_MemFree but that's in WebKit
+    free(identifiers);
+}
+
+}
+}
+
+#endif // ENABLE(NETSCAPE_API)
diff --git a/bindings/c/c_instance.h b/bindings/c/c_instance.h
new file mode 100644
index 0000000..7d779ba
--- /dev/null
+++ b/bindings/c/c_instance.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef BINDINGS_C_INSTANCE_H_
+#define BINDINGS_C_INSTANCE_H_
+
+#if ENABLE(NETSCAPE_API)
+
+#include "runtime.h"
+#include 
+
+typedef struct NPObject NPObject;
+
+namespace KJS {
+
+namespace Bindings {
+
+class CClass;
+
+class CInstance : public Instance {
+public:
+    CInstance (NPObject*, PassRefPtr);
+    ~CInstance ();
+    
+    virtual Class *getClass() const;
+    
+    virtual void begin();
+    virtual void end();
+    
+    virtual JSValue *valueOf() const;
+    virtual JSValue *defaultValue (JSType hint) const;
+
+    virtual bool implementsCall() const;
+    
+    virtual JSValue *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
+    virtual JSValue *invokeDefaultMethod (ExecState *exec, const List &args);
+    virtual void getPropertyNames(ExecState*, PropertyNameArray&);
+
+    JSValue *stringValue() const;
+    JSValue *numberValue() const;
+    JSValue *booleanValue() const;
+    
+    NPObject *getObject() const { return _object; }
+
+    virtual BindingLanguage getBindingLanguage() const { return CLanguage; }
+
+private:
+    mutable CClass *_class;
+    NPObject *_object;
+};
+
+} // namespace Bindings
+
+} // namespace KJS
+
+#endif // ENABLE(NETSCAPE_API)
+
+#endif
diff --git a/bindings/c/c_runtime.cpp b/bindings/c/c_runtime.cpp
new file mode 100644
index 0000000..cf98019
--- /dev/null
+++ b/bindings/c/c_runtime.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(NETSCAPE_API)
+
+#include "c_runtime.h"
+
+#include "c_instance.h"
+#include "c_utility.h"
+#include "npruntime_impl.h"
+
+namespace KJS {
+namespace Bindings {
+
+// ---------------------- CMethod ----------------------
+
+const char* CMethod::name() const
+{
+    PrivateIdentifier *i = (PrivateIdentifier *)_methodIdentifier;
+    return i->isString ? i->value.string : 0;
+}
+
+// ---------------------- CField ----------------------
+
+const char* CField::name() const
+{
+    PrivateIdentifier *i = (PrivateIdentifier *)_fieldIdentifier;
+    return i->isString ? i->value.string : 0;
+}
+
+JSValue* CField::valueFromInstance(ExecState* exec, const Instance* inst) const
+{
+    const CInstance* instance = static_cast(inst);
+    NPObject* obj = instance->getObject();
+    if (obj->_class->getProperty) {
+        NPVariant property;
+        VOID_TO_NPVARIANT(property);
+
+        bool result;
+        {
+           JSLock::DropAllLocks dropAllLocks;
+            result = obj->_class->getProperty(obj, _fieldIdentifier, &property);
+        }
+        if (result) {
+            JSValue* result = convertNPVariantToValue(exec, &property, instance->rootObject());
+            _NPN_ReleaseVariantValue(&property);
+            return result;
+        }
+    }
+    return jsUndefined();
+}
+
+void CField::setValueToInstance(ExecState *exec, const Instance *inst, JSValue *aValue) const
+{
+    const CInstance* instance = static_cast(inst);
+    NPObject* obj = instance->getObject();
+    if (obj->_class->setProperty) {
+        NPVariant variant;
+        convertValueToNPVariant(exec, aValue, &variant);
+
+        {
+           JSLock::DropAllLocks dropAllLocks;
+            obj->_class->setProperty(obj, _fieldIdentifier, &variant);
+        }
+
+        _NPN_ReleaseVariantValue(&variant);
+    }
+}
+
+} }
+
+#endif // ENABLE(NETSCAPE_API)
diff --git a/bindings/c/c_runtime.h b/bindings/c/c_runtime.h
new file mode 100644
index 0000000..7502166
--- /dev/null
+++ b/bindings/c/c_runtime.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef BINDINGS_C_RUNTIME_H_
+#define BINDINGS_C_RUNTIME_H_
+
+#if ENABLE(NETSCAPE_API)
+
+#include "npruntime_internal.h"
+#include "runtime.h"
+
+namespace KJS {
+namespace Bindings {
+
+class CField : public Field {
+public:
+    CField(NPIdentifier ident) : _fieldIdentifier(ident) { }
+
+    virtual JSValue* valueFromInstance(ExecState*, const Instance*) const;
+    virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const;
+    virtual const char* name() const;
+
+private:
+    NPIdentifier _fieldIdentifier;
+};
+
+
+class CMethod : public Method
+{
+public:
+    CMethod(NPIdentifier ident) : _methodIdentifier(ident) { }
+
+    virtual const char* name() const;
+    virtual int numParameters() const { return 0; }
+
+private:
+    NPIdentifier _methodIdentifier;
+};
+
+} // namespace Bindings
+} // namespace KJS
+
+#endif // ENABLE(NETSCAPE_API)
+
+#endif
diff --git a/bindings/c/c_utility.cpp b/bindings/c/c_utility.cpp
new file mode 100644
index 0000000..7951482
--- /dev/null
+++ b/bindings/c/c_utility.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(NETSCAPE_API)
+
+#include "c_utility.h"
+
+#include "NP_jsobject.h"
+#include "c_instance.h"
+#include "JSGlobalObject.h"
+#include "npruntime_impl.h"
+#include "npruntime_priv.h"
+#include "runtime_object.h"
+#include "runtime_root.h"
+#include "Platform.h"
+#include 
+#include 
+
+using namespace WTF::Unicode;
+
+namespace KJS { namespace Bindings {
+
+// Requires free() of returned UTF16Chars.
+static void convertUTF8ToUTF16WithLatin1Fallback(const NPUTF8* UTF8Chars, int UTF8Length, NPUTF16** UTF16Chars, unsigned int* UTF16Length)
+{
+    ASSERT(UTF8Chars || UTF8Length == 0);
+    ASSERT(UTF16Chars);
+    
+    if (UTF8Length == -1)
+        UTF8Length = static_cast(strlen(UTF8Chars));
+
+    *UTF16Length = UTF8Length; 
+    *UTF16Chars = static_cast(malloc(sizeof(NPUTF16) * (*UTF16Length)));
+    
+    const char* sourcestart = UTF8Chars;
+    const char* sourceend = sourcestart + UTF8Length;
+
+    ::UChar* targetstart = reinterpret_cast< ::UChar*>(*UTF16Chars);
+    ::UChar* targetend = targetstart + UTF8Length;
+    
+    ConversionResult result = convertUTF8ToUTF16(&sourcestart, sourceend, &targetstart, targetend);
+    
+    *UTF16Length = targetstart - reinterpret_cast< ::UChar*>(*UTF16Chars);
+
+    // Check to see if the conversion was successful
+    // Some plugins return invalid UTF-8 in NPVariantType_String, see 
+    // There is no "bad data" for latin1. It is unlikely that the plugin was really sending text in this encoding,
+    // but it should have used UTF-8, and now we are simply avoiding a crash.
+    if (result != conversionOK) {
+        *UTF16Length = UTF8Length;
+        
+        if (!*UTF16Chars)   // If the memory wasn't allocated, allocate it.
+            *UTF16Chars = (NPUTF16*)malloc(sizeof(NPUTF16) * (*UTF16Length));
+ 
+        for (unsigned i = 0; i < *UTF16Length; i++)
+            (*UTF16Chars)[i] = UTF8Chars[i] & 0xFF;
+    }
+}
+
+// Variant value must be released with NPReleaseVariantValue()
+void convertValueToNPVariant(ExecState *exec, JSValue *value, NPVariant *result)
+{
+    JSLock lock;
+    
+    JSType type = value->type();
+    
+    VOID_TO_NPVARIANT(*result);
+
+    if (type == StringType) {
+        UString ustring = value->toString(exec);
+        CString cstring = ustring.UTF8String();
+        NPString string = { (const NPUTF8 *)cstring.c_str(), static_cast(cstring.size()) };
+        NPN_InitializeVariantWithStringCopy(result, &string);
+    } else if (type == NumberType) {
+        DOUBLE_TO_NPVARIANT(value->toNumber(exec), *result);
+    } else if (type == BooleanType) {
+        BOOLEAN_TO_NPVARIANT(value->toBoolean(exec), *result);
+    } else if (type == UnspecifiedType) {
+        VOID_TO_NPVARIANT(*result);
+    } else if (type == NullType) {
+        NULL_TO_NPVARIANT(*result);
+    } else if (type == ObjectType) {
+        JSObject* object = static_cast(value);
+        if (object->classInfo() == &RuntimeObjectImp::info) {
+            RuntimeObjectImp* imp = static_cast(value);
+            CInstance* instance = static_cast(imp->getInternalInstance());
+            if (instance) {
+                NPObject* obj = instance->getObject();
+                _NPN_RetainObject(obj);
+                OBJECT_TO_NPVARIANT(obj, *result);
+            }
+        } else {
+            JSGlobalObject* globalObject = exec->dynamicGlobalObject();
+
+            RootObject* rootObject = findRootObject(globalObject);
+            if (rootObject) {
+                NPObject* npObject = _NPN_CreateScriptObject(0, object, rootObject);
+                OBJECT_TO_NPVARIANT(npObject, *result);
+            }
+        }
+    }
+}
+
+JSValue *convertNPVariantToValue(ExecState*, const NPVariant* variant, RootObject* rootObject)
+{
+    JSLock lock;
+    
+    NPVariantType type = variant->type;
+
+    if (type == NPVariantType_Bool)
+        return jsBoolean(NPVARIANT_TO_BOOLEAN(*variant));
+    if (type == NPVariantType_Null)
+        return jsNull();
+    if (type == NPVariantType_Void)
+        return jsUndefined();
+    if (type == NPVariantType_Int32)
+        return jsNumber(NPVARIANT_TO_INT32(*variant));
+    if (type == NPVariantType_Double)
+        return jsNumber(NPVARIANT_TO_DOUBLE(*variant));
+    if (type == NPVariantType_String) {
+        NPUTF16 *stringValue;
+        unsigned int UTF16Length;
+        convertNPStringToUTF16(&variant->value.stringValue, &stringValue, &UTF16Length); // requires free() of returned memory
+        UString resultString((const UChar *)stringValue,UTF16Length);
+        free(stringValue);
+        return jsString(resultString);
+    }
+    if (type == NPVariantType_Object) {
+        NPObject *obj = variant->value.objectValue;
+        
+        if (obj->_class == NPScriptObjectClass)
+            // Get JSObject from NP_JavaScriptObject.
+            return ((JavaScriptObject *)obj)->imp;
+
+        // Wrap NPObject in a CInstance.
+        return Instance::createRuntimeObject(Instance::CLanguage, obj, rootObject);
+    }
+    
+    return jsUndefined();
+}
+
+// Requires free() of returned UTF16Chars.
+void convertNPStringToUTF16(const NPString *string, NPUTF16 **UTF16Chars, unsigned int *UTF16Length)
+{
+    convertUTF8ToUTF16WithLatin1Fallback(string->UTF8Characters, string->UTF8Length, UTF16Chars, UTF16Length);
+}
+
+Identifier identifierFromNPIdentifier(const NPUTF8* name)
+{
+    NPUTF16 *methodName;
+    unsigned UTF16Length;
+    convertUTF8ToUTF16WithLatin1Fallback(name, -1, &methodName, &UTF16Length); // requires free() of returned memory.
+    Identifier identifier((const KJS::UChar*)methodName, UTF16Length);
+    free(methodName);
+    return identifier;
+}
+
+} }
+
+#endif // ENABLE(NETSCAPE_API)
diff --git a/bindings/c/c_utility.h b/bindings/c/c_utility.h
new file mode 100644
index 0000000..bc4383f
--- /dev/null
+++ b/bindings/c/c_utility.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef C_UTILITY_H_
+#define C_UTILITY_H_
+
+#if ENABLE(NETSCAPE_API)
+
+#include "npruntime_internal.h"
+
+namespace KJS {
+
+class ExecState;
+class Identifier;
+class JSValue;
+
+namespace Bindings {
+
+class RootObject;
+    
+typedef uint16_t NPUTF16;
+
+enum NP_ValueType {
+    NP_NumberValueType,
+    NP_StringValueType,
+    NP_BooleanValueType,
+    NP_NullValueType,
+    NP_UndefinedValueType,
+    NP_ObjectValueType,
+    NP_InvalidValueType
+};
+
+void convertNPStringToUTF16(const NPString*, NPUTF16** UTF16Chars, unsigned int* UTF16Length);
+void convertValueToNPVariant(ExecState*, JSValue*, NPVariant* result);
+JSValue* convertNPVariantToValue(ExecState*, const NPVariant*, RootObject*);
+Identifier identifierFromNPIdentifier(const NPUTF8* name);
+
+struct PrivateIdentifier {
+    union {
+        const NPUTF8* string;
+        int32_t number;
+    } value;
+    bool isString;
+};
+
+} }
+
+#endif // ENABLE(NETSCAPE_API)
+
+#endif
diff --git a/bindings/jni/jni_class.cpp b/bindings/jni/jni_class.cpp
new file mode 100644
index 0000000..38606b9
--- /dev/null
+++ b/bindings/jni/jni_class.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(JAVA_BINDINGS)
+
+#include 
+
+#include "identifier.h"
+#include 
+#include 
+
+using namespace KJS::Bindings;
+
+JavaClass::JavaClass(jobject anInstance)
+{
+    jobject aClass = callJNIObjectMethod(anInstance, "getClass", "()Ljava/lang/Class;");
+    
+    if (!aClass) {
+        fprintf(stderr, "%s:  unable to call getClass on instance %p\n", __PRETTY_FUNCTION__, anInstance);
+        return;
+    }
+    
+    jstring className = (jstring)callJNIObjectMethod(aClass, "getName", "()Ljava/lang/String;");
+    const char *classNameC = getCharactersFromJString(className);
+    _name = strdup(classNameC);
+    releaseCharactersForJString(className, classNameC);
+
+    int i;
+    JNIEnv *env = getJNIEnv();
+    
+    // Get the fields
+    jarray fields = (jarray)callJNIObjectMethod(aClass, "getFields", "()[Ljava/lang/reflect/Field;");
+    int numFields = env->GetArrayLength(fields);    
+    for (i = 0; i < numFields; i++) {
+        jobject aJField = env->GetObjectArrayElement((jobjectArray)fields, i);
+        Field *aField = new JavaField(env, aJField); // deleted in the JavaClass destructor
+        {
+            JSLock lock;
+            _fields.set(Identifier(aField->name()).ustring().rep(), aField);
+        }
+        env->DeleteLocalRef(aJField);
+    }
+    
+    // Get the methods
+    jarray methods = (jarray)callJNIObjectMethod(aClass, "getMethods", "()[Ljava/lang/reflect/Method;");
+    int numMethods = env->GetArrayLength(methods);
+    for (i = 0; i < numMethods; i++) {
+        jobject aJMethod = env->GetObjectArrayElement((jobjectArray)methods, i);
+        Method *aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor
+        MethodList* methodList;
+        {
+            JSLock lock;
+
+            methodList = _methods.get(Identifier(aMethod->name()).ustring().rep());
+            if (!methodList) {
+                methodList = new MethodList();
+                _methods.set(Identifier(aMethod->name()).ustring().rep(), methodList);
+            }
+        }
+        methodList->append(aMethod);
+        env->DeleteLocalRef(aJMethod);
+    }    
+}
+
+JavaClass::~JavaClass() {
+    free((void *)_name);
+
+    JSLock lock;
+
+    deleteAllValues(_fields);
+    _fields.clear();
+
+    MethodListMap::const_iterator end = _methods.end();
+    for (MethodListMap::const_iterator it = _methods.begin(); it != end; ++it) {
+        const MethodList* methodList = it->second;
+        deleteAllValues(*methodList);
+        delete methodList;
+    }
+    _methods.clear();
+}
+
+MethodList JavaClass::methodsNamed(const Identifier& identifier, Instance*) const
+{
+    MethodList *methodList = _methods.get(identifier.ustring().rep());
+    
+    if (methodList)
+        return *methodList;
+    return MethodList();
+}
+
+Field *JavaClass::fieldNamed(const Identifier& identifier, Instance*) const
+{
+    return _fields.get(identifier.ustring().rep());
+}
+
+bool JavaClass::isNumberClass() const
+{
+    return ((strcmp(_name, "java.lang.Byte") == 0 ||
+             strcmp(_name, "java.lang.Short") == 0 ||
+             strcmp(_name, "java.lang.Integer") == 0 ||
+             strcmp(_name, "java.lang.Long") == 0 ||
+             strcmp(_name, "java.lang.Float") == 0 ||
+             strcmp(_name, "java.lang.Double") == 0) );
+}
+
+bool JavaClass::isBooleanClass() const
+{
+    return strcmp(_name, "java.lang.Boolean") == 0;
+}
+
+bool JavaClass::isStringClass() const
+{
+    return strcmp(_name, "java.lang.String") == 0;
+}
+
+#endif // ENABLE(JAVA_BINDINGS)
diff --git a/bindings/jni/jni_class.h b/bindings/jni/jni_class.h
new file mode 100644
index 0000000..b2a211a
--- /dev/null
+++ b/bindings/jni/jni_class.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef JNI_CLASS_H_
+#define JNI_CLASS_H_
+
+#if ENABLE(JAVA_BINDINGS)
+
+#include 
+#include 
+
+namespace KJS {
+
+namespace Bindings {
+
+class JavaClass : public Class {
+public:
+    JavaClass (jobject anInstance);
+    ~JavaClass ();
+
+    virtual const char *name() const { return _name; };
+    
+    virtual MethodList methodsNamed(const Identifier&, Instance* instance) const;    
+    virtual Field *fieldNamed(const Identifier&, Instance* instance) const;
+    
+    bool isNumberClass() const;
+    bool isBooleanClass() const;
+    bool isStringClass() const;
+    
+private:
+    JavaClass ();                                 // prevent default construction
+    
+    const char *_name;
+    FieldMap _fields;
+    MethodListMap _methods;
+};
+
+} // namespace Bindings
+
+} // namespace KJS
+
+#endif // ENABLE(JAVA_BINDINGS)
+
+#endif // JNI_CLASS_H_
diff --git a/bindings/jni/jni_instance.cpp b/bindings/jni/jni_instance.cpp
new file mode 100644
index 0000000..f97da15
--- /dev/null
+++ b/bindings/jni/jni_instance.cpp
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(JAVA_BINDINGS)
+
+#include "jni_class.h"
+#include "jni_instance.h"
+#include "jni_runtime.h"
+#include "jni_utility.h"
+#include "runtime_object.h"
+#include "runtime_root.h"
+
+#ifdef NDEBUG
+#define JS_LOG(formatAndArgs...) ((void)0)
+#else
+#define JS_LOG(formatAndArgs...) { \
+    fprintf (stderr, "%s:%d -- %s:  ", __FILE__, __LINE__, __FUNCTION__); \
+    fprintf(stderr, formatAndArgs); \
+}
+#endif
+ 
+using namespace KJS::Bindings;
+using namespace KJS;
+
+JavaInstance::JavaInstance (jobject instance, PassRefPtr rootObject)
+    : Instance(rootObject)
+{
+    _instance = new JObjectWrapper (instance);
+    _class = 0;
+}
+
+JavaInstance::~JavaInstance () 
+{
+    delete _class; 
+}
+
+#define NUM_LOCAL_REFS 64
+
+void JavaInstance::begin()
+{
+    getJNIEnv()->PushLocalFrame (NUM_LOCAL_REFS);
+}
+
+void JavaInstance::end()
+{
+    getJNIEnv()->PopLocalFrame (NULL);
+}
+
+Class *JavaInstance::getClass() const 
+{
+    if (_class == 0)
+        _class = new JavaClass (_instance->_instance);
+    return _class;
+}
+
+JSValue *JavaInstance::stringValue() const
+{
+    JSLock lock;
+    
+    jstring stringValue = (jstring)callJNIObjectMethod (_instance->_instance, "toString", "()Ljava/lang/String;");
+    JNIEnv *env = getJNIEnv();
+    const jchar *c = getUCharactersFromJStringInEnv(env, stringValue);
+    UString u((const UChar *)c, (int)env->GetStringLength(stringValue));
+    releaseUCharactersForJStringInEnv(env, stringValue, c);
+    return jsString(u);
+}
+
+JSValue *JavaInstance::numberValue() const
+{
+    jdouble doubleValue = callJNIDoubleMethod (_instance->_instance, "doubleValue", "()D");
+    return jsNumber(doubleValue);
+}
+
+JSValue *JavaInstance::booleanValue() const
+{
+    jboolean booleanValue = callJNIBooleanMethod (_instance->_instance, "booleanValue", "()Z");
+    return jsBoolean(booleanValue);
+}
+
+JSValue *JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
+{
+    int i, count = args.size();
+    jvalue *jArgs;
+    JSValue *resultValue;
+    Method *method = 0;
+    size_t numMethods = methodList.size();
+    
+    // Try to find a good match for the overloaded method.  The 
+    // fundamental problem is that JavaScript doesn have the
+    // notion of method overloading and Java does.  We could 
+    // get a bit more sophisticated and attempt to does some
+    // type checking as we as checking the number of parameters.
+    Method *aMethod;
+    for (size_t methodIndex = 0; methodIndex < numMethods; methodIndex++) {
+        aMethod = methodList[methodIndex];
+        if (aMethod->numParameters() == count) {
+            method = aMethod;
+            break;
+        }
+    }
+    if (method == 0) {
+        JS_LOG ("unable to find an appropiate method\n");
+        return jsUndefined();
+    }
+    
+    const JavaMethod *jMethod = static_cast(method);
+    JS_LOG ("call %s %s on %p\n", method->name(), jMethod->signature(), _instance->_instance);
+    
+    if (count > 0) {
+        jArgs = (jvalue *)malloc (count * sizeof(jvalue));
+    }
+    else
+        jArgs = 0;
+        
+    for (i = 0; i < count; i++) {
+        JavaParameter* aParameter = jMethod->parameterAt(i);
+        jArgs[i] = convertValueToJValue (exec, args.at(i), aParameter->getJNIType(), aParameter->type());
+        JS_LOG("arg[%d] = %s\n", i, args.at(i)->toString(exec).ascii());
+    }
+        
+    jvalue result;
+
+    // Try to use the JNI abstraction first, otherwise fall back to
+    // nornmal JNI.  The JNI dispatch abstraction allows the Java plugin
+    // to dispatch the call on the appropriate internal VM thread.
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return jsUndefined();
+
+    bool handled = false;
+    if (rootObject->nativeHandle()) {
+        jobject obj = _instance->_instance;
+        JSValue *exceptionDescription = NULL;
+        const char *callingURL = 0;  // FIXME, need to propagate calling URL to Java
+        handled = dispatchJNICall(rootObject->nativeHandle(), obj, jMethod->isStatic(), jMethod->JNIReturnType(), jMethod->methodID(obj), jArgs, result, callingURL, exceptionDescription);
+        if (exceptionDescription) {
+            throwError(exec, GeneralError, exceptionDescription->toString(exec));
+            free (jArgs);
+            return jsUndefined();
+        }
+    }
+    
+    // The following code can be conditionally removed once we have a Tiger update that
+    // contains the new Java plugin.  It is needed for builds prior to Tiger.
+    if (!handled) {    
+        jobject obj = _instance->_instance;
+        switch (jMethod->JNIReturnType()){
+            case void_type: {
+                callJNIVoidMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+            
+            case object_type: {
+                result.l = callJNIObjectMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+            
+            case boolean_type: {
+                result.z = callJNIBooleanMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+            
+            case byte_type: {
+                result.b = callJNIByteMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+            
+            case char_type: {
+                result.c = callJNICharMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+            
+            case short_type: {
+                result.s = callJNIShortMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+            
+            case int_type: {
+                result.i = callJNIIntMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+            
+            case long_type: {
+                result.j = callJNILongMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+            
+            case float_type: {
+                result.f = callJNIFloatMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+            
+            case double_type: {
+                result.d = callJNIDoubleMethodIDA (obj, jMethod->methodID(obj), jArgs);
+            }
+            break;
+
+            case invalid_type:
+            default: {
+            }
+            break;
+        }
+    }
+        
+    switch (jMethod->JNIReturnType()){
+        case void_type: {
+            resultValue = jsUndefined();
+        }
+        break;
+        
+        case object_type: {
+            if (result.l != 0) {
+                const char *arrayType = jMethod->returnType();
+                if (arrayType[0] == '[') {
+                    resultValue = JavaArray::convertJObjectToArray(exec, result.l, arrayType, rootObject);
+                }
+                else {
+                    resultValue = Instance::createRuntimeObject(Instance::JavaLanguage, result.l, rootObject);
+                }
+            }
+            else {
+                resultValue = jsUndefined();
+            }
+        }
+        break;
+        
+        case boolean_type: {
+            resultValue = jsBoolean(result.z);
+        }
+        break;
+        
+        case byte_type: {
+            resultValue = jsNumber(result.b);
+        }
+        break;
+        
+        case char_type: {
+            resultValue = jsNumber(result.c);
+        }
+        break;
+        
+        case short_type: {
+            resultValue = jsNumber(result.s);
+        }
+        break;
+        
+        case int_type: {
+            resultValue = jsNumber(result.i);
+        }
+        break;
+        
+        case long_type: {
+            resultValue = jsNumber(result.j);
+        }
+        break;
+        
+        case float_type: {
+            resultValue = jsNumber(result.f);
+        }
+        break;
+        
+        case double_type: {
+            resultValue = jsNumber(result.d);
+        }
+        break;
+
+        case invalid_type:
+        default: {
+            resultValue = jsUndefined();
+        }
+        break;
+    }
+
+    free (jArgs);
+
+    return resultValue;
+}
+
+JSValue *JavaInstance::defaultValue (JSType hint) const
+{
+    if (hint == StringType) {
+        return stringValue();
+    }
+    else if (hint == NumberType) {
+        return numberValue();
+    }
+    else if (hint == BooleanType) {
+        return booleanValue();
+    }
+    else if (hint == UnspecifiedType) {
+        JavaClass *aClass = static_cast(getClass());
+        if (aClass->isStringClass()) {
+            return stringValue();
+        }
+        else if (aClass->isNumberClass()) {
+            return numberValue();
+        }
+        else if (aClass->isBooleanClass()) {
+            return booleanValue();
+        }
+    }
+    
+    return valueOf();
+}
+
+JSValue *JavaInstance::valueOf() const 
+{
+    return stringValue();
+}
+
+JObjectWrapper::JObjectWrapper(jobject instance)
+: _refCount(0)
+{
+    assert (instance != 0);
+
+    // Cache the JNIEnv used to get the global ref for this java instanace.
+    // It'll be used to delete the reference.
+    _env = getJNIEnv();
+        
+    _instance = _env->NewGlobalRef (instance);
+    
+    JS_LOG ("new global ref %p for %p\n", _instance, instance);
+
+    if  (_instance == NULL) {
+        fprintf (stderr, "%s:  could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance);
+    }
+}
+
+JObjectWrapper::~JObjectWrapper() {
+    JS_LOG ("deleting global ref %p\n", _instance);
+    _env->DeleteGlobalRef (_instance);
+}
+
+#endif // ENABLE(JAVA_BINDINGS)
diff --git a/bindings/jni/jni_instance.h b/bindings/jni/jni_instance.h
new file mode 100644
index 0000000..b00e7f1
--- /dev/null
+++ b/bindings/jni/jni_instance.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef _JNI_INSTANCE_H_
+#define _JNI_INSTANCE_H_
+
+#if ENABLE(JAVA_BINDINGS)
+
+#include "runtime.h"
+
+#include 
+
+
+namespace KJS {
+
+namespace Bindings {
+
+class JavaClass;
+
+class JObjectWrapper
+{
+friend class RefPtr;
+friend class JavaArray;
+friend class JavaField;
+friend class JavaInstance;
+friend class JavaMethod;
+
+protected:
+    JObjectWrapper(jobject instance);    
+    ~JObjectWrapper();
+    
+    void ref() { _refCount++; }
+    void deref() 
+    { 
+        if (--_refCount == 0) 
+            delete this; 
+    }
+
+    jobject _instance;
+
+private:
+    JNIEnv *_env;
+    unsigned int _refCount;
+};
+
+class JavaInstance : public Instance
+{
+public:
+    JavaInstance(jobject instance, PassRefPtr);
+    ~JavaInstance();
+    
+    virtual Class *getClass() const;
+    
+    virtual void begin();
+    virtual void end();
+    
+    virtual JSValue *valueOf() const;
+    virtual JSValue *defaultValue (JSType hint) const;
+
+    virtual JSValue *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
+
+    jobject javaInstance() const { return _instance->_instance; }
+    
+    JSValue *stringValue() const;
+    JSValue *numberValue() const;
+    JSValue *booleanValue() const;
+
+    virtual BindingLanguage getBindingLanguage() const { return JavaLanguage; }
+
+private:
+    RefPtr _instance;
+    mutable JavaClass *_class;
+};
+
+} // namespace Bindings
+
+} // namespace KJS
+
+#endif // ENABLE(JAVA_BINDINGS)
+
+#endif // _JNI_INSTANCE_H_
diff --git a/bindings/jni/jni_jsobject.cpp b/bindings/jni/jni_jsobject.cpp
new file mode 100644
index 0000000..fe2e9e3
--- /dev/null
+++ b/bindings/jni/jni_jsobject.cpp
@@ -0,0 +1,590 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(JAVA_BINDINGS)
+
+#include "identifier.h"
+#include "internal.h"
+#include "interpreter.h"
+#include "jni_jsobject.h"
+#include "jni_runtime.h"
+#include "jni_utility.h"
+#include "JSGlobalObject.h"
+#include "list.h"
+#include "runtime_object.h"
+#include "runtime_root.h"
+#include 
+#include 
+
+using namespace KJS::Bindings;
+using namespace KJS;
+
+#ifdef NDEBUG
+#define JS_LOG(formatAndArgs...) ((void)0)
+#else
+#define JS_LOG(formatAndArgs...) { \
+    fprintf (stderr, "%s(%p,%p):  ", __PRETTY_FUNCTION__, RootObject::runLoop(), CFRunLoopGetCurrent()); \
+    fprintf(stderr, formatAndArgs); \
+}
+#endif
+
+#define UndefinedHandle 1
+
+static bool isJavaScriptThread()
+{
+    return (RootObject::runLoop() == CFRunLoopGetCurrent());
+}
+
+jvalue JavaJSObject::invoke (JSObjectCallContext *context)
+{
+    jvalue result;
+
+    bzero ((void *)&result, sizeof(jvalue));
+    
+    if (!isJavaScriptThread()) {        
+        // Send the call context to the thread that is allowed to
+        // call JavaScript.
+        RootObject::dispatchToJavaScriptThread(context);
+        result = context->result;
+    }
+    else {
+        jlong nativeHandle = context->nativeHandle;
+        if (nativeHandle == UndefinedHandle || nativeHandle == 0) {
+            return result;
+        }
+
+        if (context->type == CreateNative) {
+            result.j = JavaJSObject::createNative(nativeHandle);
+        }
+        else {
+            JSObject *imp = jlong_to_impptr(nativeHandle);
+            if (!findProtectingRootObject(imp)) {
+                fprintf (stderr, "%s:%d:  Attempt to access JavaScript from destroyed applet, type %d.\n", __FILE__, __LINE__, context->type);
+                return result;
+            }
+
+            switch (context->type){            
+                case Call: {
+                    result.l = JavaJSObject(nativeHandle).call(context->string, context->args);
+                    break;
+                }
+                
+                case Eval: {
+                    result.l = JavaJSObject(nativeHandle).eval(context->string);
+                    break;
+                }
+            
+                case GetMember: {
+                    result.l = JavaJSObject(nativeHandle).getMember(context->string);
+                    break;
+                }
+                
+                case SetMember: {
+                    JavaJSObject(nativeHandle).setMember(context->string, context->value);
+                    break;
+                }
+                
+                case RemoveMember: {
+                    JavaJSObject(nativeHandle).removeMember(context->string);
+                    break;
+                }
+            
+                case GetSlot: {
+                    result.l = JavaJSObject(nativeHandle).getSlot(context->index);
+                    break;
+                }
+                
+                case SetSlot: {
+                    JavaJSObject(nativeHandle).setSlot(context->index, context->value);
+                    break;
+                }
+            
+                case ToString: {
+                    result.l = (jobject) JavaJSObject(nativeHandle).toString();
+                    break;
+                }
+    
+                case Finalize: {
+                    JavaJSObject(nativeHandle).finalize();
+                    break;
+                }
+                
+                default: {
+                    fprintf (stderr, "%s:  invalid JavaScript call\n", __PRETTY_FUNCTION__);
+                }
+            }
+        }
+        context->result = result;
+    }
+
+    return result;
+}
+
+
+JavaJSObject::JavaJSObject(jlong nativeJSObject)
+{
+    _imp = jlong_to_impptr(nativeJSObject);
+    
+    ASSERT(_imp);
+    _rootObject = findProtectingRootObject(_imp);
+    ASSERT(_rootObject);
+}
+
+RootObject* JavaJSObject::rootObject() const
+{ 
+    return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0; 
+}
+
+jobject JavaJSObject::call(jstring methodName, jobjectArray args) const
+{
+    JS_LOG ("methodName = %s\n", JavaString(methodName).UTF8String());
+
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return 0;
+    
+    // Lookup the function object.
+    ExecState* exec = rootObject->globalObject()->globalExec();
+    JSLock lock;
+    
+    Identifier identifier(JavaString(methodName).ustring());
+    JSValue *func = _imp->get (exec, identifier);
+    if (func->isUndefinedOrNull())
+        return 0;
+
+    // Call the function object.
+    JSObject *funcImp = static_cast(func);
+    JSObject *thisObj = const_cast(_imp);
+    List argList;
+    getListFromJArray(args, argList);
+    rootObject->globalObject()->startTimeoutCheck();
+    JSValue *result = funcImp->call(exec, thisObj, argList);
+    rootObject->globalObject()->stopTimeoutCheck();
+
+    return convertValueToJObject(result);
+}
+
+jobject JavaJSObject::eval(jstring script) const
+{
+    JS_LOG ("script = %s\n", JavaString(script).UTF8String());
+    
+    JSObject *thisObj = const_cast(_imp);
+    JSValue *result;
+    
+    JSLock lock;
+    
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return 0;
+
+    rootObject->globalObject()->startTimeoutCheck();
+    Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), UString(), 0, JavaString(script).ustring(),thisObj);
+    rootObject->globalObject()->stopTimeoutCheck();
+    ComplType type = completion.complType();
+    
+    if (type == Normal) {
+        result = completion.value();
+        if (!result)
+            result = jsUndefined();
+    } else
+        result = jsUndefined();
+    
+    return convertValueToJObject (result);
+}
+
+jobject JavaJSObject::getMember(jstring memberName) const
+{
+    JS_LOG ("(%p) memberName = %s\n", _imp, JavaString(memberName).UTF8String());
+
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return 0;
+
+    ExecState* exec = rootObject->globalObject()->globalExec();
+    
+    JSLock lock;
+    JSValue *result = _imp->get (exec, Identifier (JavaString(memberName).ustring()));
+
+    return convertValueToJObject(result);
+}
+
+void JavaJSObject::setMember(jstring memberName, jobject value) const
+{
+    JS_LOG ("memberName = %s, value = %p\n", JavaString(memberName).UTF8String(), value);
+
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return;
+
+    ExecState* exec = rootObject->globalObject()->globalExec();
+    JSLock lock;
+    _imp->put(exec, Identifier (JavaString(memberName).ustring()), convertJObjectToValue(value));
+}
+
+
+void JavaJSObject::removeMember(jstring memberName) const
+{
+    JS_LOG ("memberName = %s\n", JavaString(memberName).UTF8String());
+
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return;
+
+    ExecState* exec = rootObject->globalObject()->globalExec();
+    JSLock lock;
+    _imp->deleteProperty(exec, Identifier (JavaString(memberName).ustring()));
+}
+
+
+jobject JavaJSObject::getSlot(jint index) const
+{
+#ifdef __LP64__
+    JS_LOG ("index = %d\n", index);
+#else
+    JS_LOG ("index = %ld\n", index);
+#endif
+
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return 0;
+
+    ExecState* exec = rootObject->globalObject()->globalExec();
+
+    JSLock lock;
+    JSValue *result = _imp->get (exec, (unsigned)index);
+
+    return convertValueToJObject(result);
+}
+
+
+void JavaJSObject::setSlot(jint index, jobject value) const
+{
+#ifdef __LP64__
+    JS_LOG ("index = %d, value = %p\n", index, value);
+#else
+    JS_LOG ("index = %ld, value = %p\n", index, value);
+#endif
+
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return;
+
+    ExecState* exec = rootObject->globalObject()->globalExec();
+    JSLock lock;
+    _imp->put(exec, (unsigned)index, convertJObjectToValue(value));
+}
+
+
+jstring JavaJSObject::toString() const
+{
+    JS_LOG ("\n");
+    
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return 0;
+
+    JSLock lock;
+    JSObject *thisObj = const_cast(_imp);
+    ExecState* exec = rootObject->globalObject()->globalExec();
+    
+    return (jstring)convertValueToJValue (exec, thisObj, object_type, "java.lang.String").l;
+}
+
+void JavaJSObject::finalize() const
+{
+    if (RootObject* rootObject = this->rootObject())
+        rootObject->gcUnprotect(_imp);
+}
+
+// We're either creating a 'Root' object (via a call to JavaJSObject.getWindow()), or
+// another JavaJSObject.
+jlong JavaJSObject::createNative(jlong nativeHandle)
+{
+    JS_LOG ("nativeHandle = %d\n", (int)nativeHandle);
+
+    if (nativeHandle == UndefinedHandle)
+        return nativeHandle;
+
+    if (findProtectingRootObject(jlong_to_impptr(nativeHandle)))
+        return nativeHandle;
+
+    CreateRootObjectFunction createRootObject = RootObject::createRootObject();
+    if (!createRootObject)
+        return ptr_to_jlong(0);
+
+    RefPtr rootObject = createRootObject(jlong_to_ptr(nativeHandle));
+
+    // If rootObject is !NULL We must have been called via netscape.javascript.JavaJSObject.getWindow(),
+    // otherwise we are being called after creating a JavaJSObject in
+    // JavaJSObject::convertValueToJObject().
+    if (rootObject) {
+        JSObject* globalObject = rootObject->globalObject();
+        // We call gcProtect here to get the object into the root object's "protect set" which
+        // is used to test if a native handle is valid as well as getting the root object given the handle.
+        rootObject->gcProtect(globalObject);
+        return ptr_to_jlong(globalObject);
+    }
+    
+    return nativeHandle;
+}
+
+jobject JavaJSObject::convertValueToJObject (JSValue *value) const
+{
+    JSLock lock;
+    
+    RootObject* rootObject = this->rootObject();
+    if (!rootObject)
+        return 0;
+
+    ExecState* exec = rootObject->globalObject()->globalExec();
+    JNIEnv *env = getJNIEnv();
+    jobject result = 0;
+    
+    // See section 22.7 of 'JavaScript:  The Definitive Guide, 4th Edition',
+    // figure 22-5.
+    // number -> java.lang.Double
+    // string -> java.lang.String
+    // boolean -> java.lang.Boolean
+    // Java instance -> Java instance
+    // Everything else -> JavaJSObject
+    
+    JSType type = value->type();
+    if (type == NumberType) {
+        jclass JSObjectClass = env->FindClass ("java/lang/Double");
+        jmethodID constructorID = env->GetMethodID (JSObjectClass, "", "(D)V");
+        if (constructorID != NULL) {
+            result = env->NewObject (JSObjectClass, constructorID, (jdouble)value->toNumber(exec));
+        }
+    }
+    else if (type == StringType) {
+        UString stringValue = value->toString(exec);
+        JNIEnv *env = getJNIEnv();
+        result = env->NewString ((const jchar *)stringValue.data(), stringValue.size());
+    }
+    else if (type == BooleanType) {
+        jclass JSObjectClass = env->FindClass ("java/lang/Boolean");
+        jmethodID constructorID = env->GetMethodID (JSObjectClass, "", "(Z)V");
+        if (constructorID != NULL) {
+            result = env->NewObject (JSObjectClass, constructorID, (jboolean)value->toBoolean(exec));
+        }
+    }
+    else {
+        // Create a JavaJSObject.
+        jlong nativeHandle;
+        
+        if (type == ObjectType){
+            JSObject *imp = static_cast(value);
+            
+            // We either have a wrapper around a Java instance or a JavaScript
+            // object.  If we have a wrapper around a Java instance, return that
+            // instance, otherwise create a new Java JavaJSObject with the JSObject*
+            // as it's nativeHandle.
+            if (imp->classInfo() && strcmp(imp->classInfo()->className, "RuntimeObject") == 0) {
+                RuntimeObjectImp *runtimeImp = static_cast(value);
+                JavaInstance *runtimeInstance = static_cast(runtimeImp->getInternalInstance());
+                if (!runtimeInstance)
+                    return 0;
+                
+                return runtimeInstance->javaInstance();
+            }
+            else {
+                nativeHandle = ptr_to_jlong(imp);
+                rootObject->gcProtect(imp);
+            }
+        }
+        // All other types will result in an undefined object.
+        else {
+            nativeHandle = UndefinedHandle;
+        }
+        
+        // Now create the Java JavaJSObject.  Look for the JavaJSObject in it's new (Tiger)
+        // location and in the original Java 1.4.2 location.
+        jclass JSObjectClass;
+        
+        JSObjectClass = env->FindClass ("sun/plugin/javascript/webkit/JSObject");
+        if (!JSObjectClass) {
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+            JSObjectClass = env->FindClass ("apple/applet/JSObject");
+        }
+            
+        jmethodID constructorID = env->GetMethodID (JSObjectClass, "", "(J)V");
+        if (constructorID != NULL) {
+            result = env->NewObject (JSObjectClass, constructorID, nativeHandle);
+        }
+    }
+    
+    return result;
+}
+
+JSValue *JavaJSObject::convertJObjectToValue (jobject theObject) const
+{
+    // Instances of netscape.javascript.JSObject get converted back to
+    // JavaScript objects.  All other objects are wrapped.  It's not
+    // possible to pass primitive types from the Java to JavaScript.
+    // See section 22.7 of 'JavaScript:  The Definitive Guide, 4th Edition',
+    // figure 22-4.
+    jobject classOfInstance = callJNIObjectMethod(theObject, "getClass", "()Ljava/lang/Class;");
+    jstring className = (jstring)callJNIObjectMethod(classOfInstance, "getName", "()Ljava/lang/String;");
+    
+    // Only the sun.plugin.javascript.webkit.JSObject has a member called nativeJSObject. This class is
+    // created above to wrap internal browser objects. The constructor of this class takes the native
+    // pointer and stores it in this object, so that it can be retrieved below.
+    if (strcmp(JavaString(className).UTF8String(), "sun.plugin.javascript.webkit.JSObject") == 0) {
+        // Pull the nativeJSObject value from the Java instance.  This is a
+        // pointer to the JSObject.
+        JNIEnv *env = getJNIEnv();
+        jfieldID fieldID = env->GetFieldID((jclass)classOfInstance, "nativeJSObject", "J");
+        if (fieldID == NULL) {
+            return jsUndefined();
+        }
+        jlong nativeHandle = env->GetLongField(theObject, fieldID);
+        if (nativeHandle == UndefinedHandle) {
+            return jsUndefined();
+        }
+        JSObject *imp = static_cast(jlong_to_impptr(nativeHandle));
+        return imp;
+    }
+
+    JSLock lock;
+    JavaInstance* javaInstance = new JavaInstance(theObject, _rootObject);
+    return KJS::Bindings::Instance::createRuntimeObject(javaInstance);
+}
+
+void JavaJSObject::getListFromJArray(jobjectArray jArray, List& list) const
+{
+    JNIEnv *env = getJNIEnv();
+    int i, numObjects = jArray ? env->GetArrayLength (jArray) : 0;
+    
+    for (i = 0; i < numObjects; i++) {
+        jobject anObject = env->GetObjectArrayElement ((jobjectArray)jArray, i);
+        if (anObject) {
+            list.append(convertJObjectToValue(anObject));
+            env->DeleteLocalRef (anObject);
+        }
+        else {
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+        }
+    }
+}
+
+extern "C" {
+
+jlong KJS_JSCreateNativeJSObject (JNIEnv*, jclass, jstring, jlong nativeHandle, jboolean)
+{
+    JSObjectCallContext context;
+    context.type = CreateNative;
+    context.nativeHandle = nativeHandle;
+    return JavaJSObject::invoke (&context).j;
+}
+
+void KJS_JSObject_JSFinalize (JNIEnv*, jclass, jlong nativeHandle)
+{
+    JSObjectCallContext context;
+    context.type = Finalize;
+    context.nativeHandle = nativeHandle;
+    JavaJSObject::invoke (&context);
+}
+
+jobject KJS_JSObject_JSObjectCall (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring methodName, jobjectArray args, jboolean)
+{
+    JSObjectCallContext context;
+    context.type = Call;
+    context.nativeHandle = nativeHandle;
+    context.string = methodName;
+    context.args = args;
+    return JavaJSObject::invoke (&context).l;
+}
+
+jobject KJS_JSObject_JSObjectEval (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring jscript, jboolean)
+{
+    JSObjectCallContext context;
+    context.type = Eval;
+    context.nativeHandle = nativeHandle;
+    context.string = jscript;
+    return JavaJSObject::invoke (&context).l;
+}
+
+jobject KJS_JSObject_JSObjectGetMember (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring jname, jboolean)
+{
+    JSObjectCallContext context;
+    context.type = GetMember;
+    context.nativeHandle = nativeHandle;
+    context.string = jname;
+    return JavaJSObject::invoke (&context).l;
+}
+
+void KJS_JSObject_JSObjectSetMember (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring jname, jobject value, jboolean)
+{
+    JSObjectCallContext context;
+    context.type = SetMember;
+    context.nativeHandle = nativeHandle;
+    context.string = jname;
+    context.value = value;
+    JavaJSObject::invoke (&context);
+}
+
+void KJS_JSObject_JSObjectRemoveMember (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring jname, jboolean)
+{
+    JSObjectCallContext context;
+    context.type = RemoveMember;
+    context.nativeHandle = nativeHandle;
+    context.string = jname;
+    JavaJSObject::invoke (&context);
+}
+
+jobject KJS_JSObject_JSObjectGetSlot (JNIEnv*, jclass, jlong nativeHandle, jstring, jint jindex, jboolean)
+{
+    JSObjectCallContext context;
+    context.type = GetSlot;
+    context.nativeHandle = nativeHandle;
+    context.index = jindex;
+    return JavaJSObject::invoke (&context).l;
+}
+
+void KJS_JSObject_JSObjectSetSlot (JNIEnv*, jclass, jlong nativeHandle, jstring, jint jindex, jobject value, jboolean)
+{
+    JSObjectCallContext context;
+    context.type = SetSlot;
+    context.nativeHandle = nativeHandle;
+    context.index = jindex;
+    context.value = value;
+    JavaJSObject::invoke (&context);
+}
+
+jstring KJS_JSObject_JSObjectToString (JNIEnv*, jclass, jlong nativeHandle)
+{
+    JSObjectCallContext context;
+    context.type = ToString;
+    context.nativeHandle = nativeHandle;
+    return (jstring)JavaJSObject::invoke (&context).l;
+}
+
+}
+
+#endif // ENABLE(JAVA_BINDINGS)
diff --git a/bindings/jni/jni_jsobject.h b/bindings/jni/jni_jsobject.h
new file mode 100644
index 0000000..d559fa1
--- /dev/null
+++ b/bindings/jni/jni_jsobject.h
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef JAVASCRIPTCORE_BINDINGS_JNI_JSOBJECT_H
+#define JAVASCRIPTCORE_BINDINGS_JNI_JSOBJECT_H
+
+#if ENABLE(JAVA_BINDINGS)
+
+#if PLATFORM(MAC)
+#include 
+#endif
+
+#include 
+#include 
+
+#define jlong_to_ptr(a) ((void*)(uintptr_t)(a))
+#define jlong_to_impptr(a) (static_cast(((void*)(uintptr_t)(a))))
+#define ptr_to_jlong(a) ((jlong)(uintptr_t)(a))
+
+namespace KJS {
+
+class List;
+class JSObject;
+class JSValue;
+
+namespace Bindings {
+
+class RootObject;
+
+enum JSObjectCallType {
+    CreateNative,
+    Call,
+    Eval,
+    GetMember,
+    SetMember,
+    RemoveMember,
+    GetSlot,
+    SetSlot,
+    ToString,
+    Finalize
+};
+
+struct JSObjectCallContext
+{
+    JSObjectCallType type;
+    jlong nativeHandle;
+    jstring string;
+    jobjectArray args;
+    jint index;
+    jobject value;
+    CFRunLoopRef originatingLoop;
+    jvalue result;
+};
+
+class JavaJSObject
+{
+public:
+    JavaJSObject(jlong nativeHandle);
+    
+    static jlong createNative(jlong nativeHandle);
+    jobject call(jstring methodName, jobjectArray args) const;
+    jobject eval(jstring script) const;
+    jobject getMember(jstring memberName) const;
+    void setMember(jstring memberName, jobject value) const;
+    void removeMember(jstring memberName) const;
+    jobject getSlot(jint index) const;
+    void setSlot(jint index, jobject value) const;
+    jstring toString() const;
+    void finalize() const;
+    
+    static jvalue invoke(JSObjectCallContext*);
+
+    jobject convertValueToJObject(JSValue*) const;
+    JSValue* convertJObjectToValue(jobject) const;
+    void getListFromJArray(jobjectArray, List&) const;
+    
+    RootObject* rootObject() const;
+    
+private:
+    RefPtr _rootObject;
+    JSObject* _imp;
+};
+
+
+} // namespace Bindings
+
+} // namespace KJS
+
+extern "C" {
+
+// The Java VM calls these functions to handle calls to methods in Java's JSObject class.
+jlong KJS_JSCreateNativeJSObject(JNIEnv*, jclass, jstring jurl, jlong nativeHandle, jboolean ctx);
+void KJS_JSObject_JSFinalize(JNIEnv*, jclass, jlong nativeJSObject);
+jobject KJS_JSObject_JSObjectCall(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring methodName, jobjectArray args, jboolean ctx);
+jobject KJS_JSObject_JSObjectEval(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring jscript, jboolean ctx);
+jobject KJS_JSObject_JSObjectGetMember(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring jname, jboolean ctx);
+void KJS_JSObject_JSObjectSetMember(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring jname, jobject value, jboolean ctx);
+void KJS_JSObject_JSObjectRemoveMember(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring jname, jboolean ctx);
+jobject KJS_JSObject_JSObjectGetSlot(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jint jindex, jboolean ctx);
+void KJS_JSObject_JSObjectSetSlot(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jint jindex, jobject value, jboolean ctx);
+jstring KJS_JSObject_JSObjectToString(JNIEnv*, jclass, jlong nativeJSObject);
+
+}
+
+#endif // ENABLE(JAVA_BINDINGS)
+
+#endif // JAVASCRIPTCORE_BINDINGS_JNI_JSOBJECT_H
diff --git a/bindings/jni/jni_objc.mm b/bindings/jni/jni_objc.mm
new file mode 100644
index 0000000..c5ba0af
--- /dev/null
+++ b/bindings/jni/jni_objc.mm
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(JAVA_BINDINGS)
+
+#import 
+#import 
+#import 
+
+using namespace KJS::Bindings;
+
+@interface NSObject (WebScriptingPrivate)
+- (jvalue)webPlugInCallJava:(jobject)object method:(jmethodID)method returnType:(JNIType)returnType arguments:(jvalue*)args;
+- (jvalue)webPlugInCallJava:(jobject)object
+                   isStatic:(BOOL)isStatic
+                 returnType:(JNIType)returnType
+                     method:(jmethodID)method
+                  arguments:(jvalue*)args
+                 callingURL:(NSURL *)url
+       exceptionDescription:(NSString **)exceptionString;
+@end
+
+bool KJS::Bindings::dispatchJNICall (const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char*, JSValue *&exceptionDescription)
+{
+    id view = (id)targetAppletView;
+    
+    // As array_type is not known by the Mac JVM, change it to a compatible type.
+    if (returnType == array_type)
+        returnType = object_type;
+    
+    if ([view respondsToSelector:@selector(webPlugInCallJava:isStatic:returnType:method:arguments:callingURL:exceptionDescription:)]) {
+        NSString *_exceptionDescription = 0;
+
+        // Passing nil as the calling URL will cause the Java plugin to use the URL
+        // of the page that contains the applet. The execution restrictions 
+        // implemented in WebCore will guarantee that only appropriate JavaScript
+        // can reference the applet.
+        {
+           JSLock::DropAllLocks dropAllLocks;
+            result = [view webPlugInCallJava:obj isStatic:isStatic returnType:returnType method:methodID arguments:args callingURL:nil exceptionDescription:&_exceptionDescription];
+        }
+
+        if (_exceptionDescription != 0) {
+            exceptionDescription = convertNSStringToString(_exceptionDescription);
+        }
+        return true;
+    }
+    else if ([view respondsToSelector:@selector(webPlugInCallJava:method:returnType:arguments:)]) {
+       JSLock::DropAllLocks dropAllLocks;
+        result = [view webPlugInCallJava:obj method:methodID returnType:returnType arguments:args];
+        return true;
+    }
+
+    bzero (&result, sizeof(jvalue));
+    return false;
+}
+
+#endif // ENABLE(JAVA_BINDINGS)
diff --git a/bindings/jni/jni_runtime.cpp b/bindings/jni/jni_runtime.cpp
new file mode 100644
index 0000000..e42ac82
--- /dev/null
+++ b/bindings/jni/jni_runtime.cpp
@@ -0,0 +1,549 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(JAVA_BINDINGS)
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#ifdef NDEBUG
+#define JS_LOG(formatAndArgs...) ((void)0)
+#else
+#define JS_LOG(formatAndArgs...) { \
+    fprintf (stderr, "%s:%d -- %s:  ", __FILE__, __LINE__, __FUNCTION__); \
+    fprintf(stderr, formatAndArgs); \
+}
+#endif
+
+using namespace KJS;
+using namespace KJS::Bindings;
+
+
+JavaParameter::JavaParameter (JNIEnv *env, jstring type)
+{
+    _type = JavaString (env, type);
+    _JNIType = JNITypeFromClassName (_type.UTF8String());
+}
+
+JavaField::JavaField (JNIEnv *env, jobject aField)
+{
+    // Get field type
+    jobject fieldType = callJNIObjectMethod (aField, "getType", "()Ljava/lang/Class;");
+    jstring fieldTypeName = (jstring)callJNIObjectMethod (fieldType, "getName", "()Ljava/lang/String;");
+    _type = JavaString(env, fieldTypeName);
+    _JNIType = JNITypeFromClassName (_type.UTF8String());
+
+    // Get field name
+    jstring fieldName = (jstring)callJNIObjectMethod (aField, "getName", "()Ljava/lang/String;");
+    _name = JavaString(env, fieldName);
+
+    _field = new JObjectWrapper(aField);
+}
+
+JSValue* JavaArray::convertJObjectToArray(ExecState* exec, jobject anObject, const char* type, PassRefPtr rootObject)
+{
+    if (type[0] != '[')
+        return jsUndefined();
+
+    return new RuntimeArray(exec, new JavaArray((jobject)anObject, type, rootObject));
+}
+
+jvalue JavaField::dispatchValueFromInstance(ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const
+{
+    jobject jinstance = instance->javaInstance();
+    jobject fieldJInstance = _field->_instance;
+    JNIEnv *env = getJNIEnv();
+    jvalue result;
+
+    bzero (&result, sizeof(jvalue));
+    jclass cls = env->GetObjectClass(fieldJInstance);
+    if ( cls != NULL ) {
+        jmethodID mid = env->GetMethodID(cls, name, sig);
+        if ( mid != NULL )
+        {
+            RootObject* rootObject = instance->rootObject();
+            if (rootObject && rootObject->nativeHandle()) {
+                JSValue *exceptionDescription = NULL;
+                jvalue args[1];
+                
+                args[0].l = jinstance;
+                dispatchJNICall(rootObject->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription);
+                if (exceptionDescription)
+                    throwError(exec, GeneralError, exceptionDescription->toString(exec));
+            }
+        }
+    }
+    return result;
+}
+
+JSValue *JavaField::valueFromInstance(ExecState *exec, const Instance *i) const 
+{
+    const JavaInstance *instance = static_cast(i);
+
+    JSValue *jsresult = jsUndefined();
+    
+    switch (_JNIType) {
+        case array_type:
+        case object_type: {
+            jvalue result = dispatchValueFromInstance (exec, instance, "get", "(Ljava/lang/Object;)Ljava/lang/Object;", object_type);
+            jobject anObject = result.l;
+
+            const char *arrayType = type();
+            if (arrayType[0] == '[') {
+                jsresult = JavaArray::convertJObjectToArray(exec, anObject, arrayType, instance->rootObject());
+            }
+            else if (anObject != 0){
+                jsresult = Instance::createRuntimeObject(Instance::JavaLanguage, anObject, instance->rootObject());
+            }
+        }
+        break;
+            
+        case boolean_type:
+            jsresult = jsBoolean(dispatchValueFromInstance(exec, instance, "getBoolean", "(Ljava/lang/Object;)Z", boolean_type).z);
+            break;
+            
+        case byte_type:
+        case char_type:
+        case short_type:
+        
+        case int_type: {
+            jint value;
+            jvalue result = dispatchValueFromInstance (exec, instance, "getInt", "(Ljava/lang/Object;)I", int_type);
+            value = result.i;
+            jsresult = jsNumber((int)value);
+        }
+        break;
+
+        case long_type:
+        case float_type:
+        case double_type: {
+            jdouble value;
+            jvalue result = dispatchValueFromInstance (exec, instance, "getDouble", "(Ljava/lang/Object;)D", double_type);
+            value = result.i;
+            jsresult = jsNumber((double)value);
+        }
+        break;
+        default:
+        break;
+    }
+
+    JS_LOG ("getting %s = %s\n", name(), jsresult->toString(exec).ascii());
+    
+    return jsresult;
+}
+
+void JavaField::dispatchSetValueToInstance(ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const
+{
+    jobject jinstance = instance->javaInstance();
+    jobject fieldJInstance = _field->_instance;
+    JNIEnv *env = getJNIEnv();
+
+    jclass cls = env->GetObjectClass(fieldJInstance);
+    if ( cls != NULL ) {
+        jmethodID mid = env->GetMethodID(cls, name, sig);
+        if ( mid != NULL )
+        {
+            RootObject* rootObject = instance->rootObject();
+            if (rootObject && rootObject->nativeHandle()) {
+                JSValue *exceptionDescription = NULL;
+                jvalue args[2];
+                jvalue result;
+                
+                args[0].l = jinstance;
+                args[1] = javaValue;
+                dispatchJNICall(rootObject->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription);
+                if (exceptionDescription)
+                    throwError(exec, GeneralError, exceptionDescription->toString(exec));
+            }
+        }
+    }
+}
+
+void JavaField::setValueToInstance(ExecState *exec, const Instance *i, JSValue *aValue) const
+{
+    const JavaInstance *instance = static_cast(i);
+    jvalue javaValue = convertValueToJValue (exec, aValue, _JNIType, type());
+
+    JS_LOG ("setting value %s to %s\n", name(), aValue->toString(exec).ascii());
+
+    switch (_JNIType) {
+        case array_type:
+        case object_type: {
+            dispatchSetValueToInstance (exec, instance, javaValue, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V");
+        }
+        break;
+            
+        case boolean_type: {
+            dispatchSetValueToInstance (exec, instance, javaValue, "setBoolean", "(Ljava/lang/Object;Z)V");
+        }
+        break;
+            
+        case byte_type: {
+            dispatchSetValueToInstance (exec, instance, javaValue, "setByte", "(Ljava/lang/Object;B)V");
+        }
+        break;
+
+        case char_type: {
+            dispatchSetValueToInstance (exec, instance, javaValue, "setChar", "(Ljava/lang/Object;C)V");
+        }
+        break;
+
+        case short_type: {
+            dispatchSetValueToInstance (exec, instance, javaValue, "setShort", "(Ljava/lang/Object;S)V");
+        }
+        break;
+
+        case int_type: {
+            dispatchSetValueToInstance (exec, instance, javaValue, "setInt", "(Ljava/lang/Object;I)V");
+        }
+        break;
+
+        case long_type: {
+            dispatchSetValueToInstance (exec, instance, javaValue, "setLong", "(Ljava/lang/Object;J)V");
+        }
+        break;
+
+        case float_type: {
+            dispatchSetValueToInstance (exec, instance, javaValue, "setFloat", "(Ljava/lang/Object;F)V");
+        }
+        break;
+
+        case double_type: {
+            dispatchSetValueToInstance (exec, instance, javaValue, "setDouble", "(Ljava/lang/Object;D)V");
+        }
+        break;
+        default:
+        break;
+    }
+}
+
+JavaMethod::JavaMethod (JNIEnv *env, jobject aMethod)
+{
+    // Get return type
+    jobject returnType = callJNIObjectMethod (aMethod, "getReturnType", "()Ljava/lang/Class;");
+    jstring returnTypeName = (jstring)callJNIObjectMethod (returnType, "getName", "()Ljava/lang/String;");
+    _returnType =JavaString (env, returnTypeName);
+    _JNIReturnType = JNITypeFromClassName (_returnType.UTF8String());
+    env->DeleteLocalRef (returnType);
+    env->DeleteLocalRef (returnTypeName);
+
+    // Get method name
+    jstring methodName = (jstring)callJNIObjectMethod (aMethod, "getName", "()Ljava/lang/String;");
+    _name = JavaString (env, methodName);
+    env->DeleteLocalRef (methodName);
+
+    // Get parameters
+    jarray jparameters = (jarray)callJNIObjectMethod (aMethod, "getParameterTypes", "()[Ljava/lang/Class;");
+    _numParameters = env->GetArrayLength (jparameters);
+    _parameters = new JavaParameter[_numParameters];
+    
+    int i;
+    for (i = 0; i < _numParameters; i++) {
+        jobject aParameter = env->GetObjectArrayElement ((jobjectArray)jparameters, i);
+        jstring parameterName = (jstring)callJNIObjectMethod (aParameter, "getName", "()Ljava/lang/String;");
+        _parameters[i] = JavaParameter(env, parameterName);
+        env->DeleteLocalRef (aParameter);
+        env->DeleteLocalRef (parameterName);
+    }
+    env->DeleteLocalRef (jparameters);
+
+    // Created lazily.
+    _signature = 0;
+    _methodID = 0;
+    
+    jclass modifierClass = env->FindClass("java/lang/reflect/Modifier");
+    int modifiers = callJNIIntMethod (aMethod, "getModifiers", "()I");
+    _isStatic = (bool)callJNIStaticBooleanMethod (modifierClass, "isStatic", "(I)Z", modifiers);
+}
+
+JavaMethod::~JavaMethod() 
+{
+    if (_signature)
+        free(_signature);
+    delete [] _parameters;
+};
+
+// JNI method signatures use '/' between components of a class name, but
+// we get '.' between components from the reflection API.
+static void appendClassName(UString& aString, const char* className)
+{
+    ASSERT(JSLock::lockCount() > 0);
+    
+    char *result, *cp = strdup(className);
+    
+    result = cp;
+    while (*cp) {
+        if (*cp == '.')
+            *cp = '/';
+        cp++;
+    }
+        
+    aString.append(result);
+
+    free (result);
+}
+
+const char *JavaMethod::signature() const 
+{
+    if (!_signature) {
+        JSLock lock;
+
+        UString signatureBuilder("(");
+        for (int i = 0; i < _numParameters; i++) {
+            JavaParameter* aParameter = parameterAt(i);
+            JNIType _JNIType = aParameter->getJNIType();
+            if (_JNIType == array_type)
+                appendClassName(signatureBuilder, aParameter->type());
+            else {
+                signatureBuilder.append(signatureFromPrimitiveType(_JNIType));
+                if (_JNIType == object_type) {
+                    appendClassName(signatureBuilder, aParameter->type());
+                    signatureBuilder.append(";");
+                }
+            }
+        }
+        signatureBuilder.append(")");
+        
+        const char *returnType = _returnType.UTF8String();
+        if (_JNIReturnType == array_type) {
+            appendClassName(signatureBuilder, returnType);
+        } else {
+            signatureBuilder.append(signatureFromPrimitiveType(_JNIReturnType));
+            if (_JNIReturnType == object_type) {
+                appendClassName(signatureBuilder, returnType);
+                signatureBuilder.append(";");
+            }
+        }
+        
+        _signature = strdup(signatureBuilder.ascii());
+    }
+    
+    return _signature;
+}
+
+JNIType JavaMethod::JNIReturnType() const
+{
+    return _JNIReturnType;
+}
+
+jmethodID JavaMethod::methodID (jobject obj) const
+{
+    if (_methodID == 0) {
+        _methodID = getMethodID (obj, name(), signature());
+    }
+    return _methodID;
+}
+
+
+JavaArray::JavaArray(jobject array, const char* type, PassRefPtr rootObject)
+    : Array(rootObject)
+{
+    _array = new JObjectWrapper(array);
+    // Java array are fixed length, so we can cache length.
+    JNIEnv *env = getJNIEnv();
+    _length = env->GetArrayLength((jarray)_array->_instance);
+    _type = strdup(type);
+    _rootObject = rootObject;
+}
+
+JavaArray::~JavaArray () 
+{
+    free ((void *)_type);
+}
+
+RootObject* JavaArray::rootObject() const 
+{ 
+    return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0;
+}
+
+void JavaArray::setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const
+{
+    JNIEnv *env = getJNIEnv();
+    char *javaClassName = 0;
+    
+    JNIType arrayType = JNITypeFromPrimitiveType(_type[1]);
+    if (_type[1] == 'L'){
+        // The type of the array will be something like:
+        // "[Ljava.lang.string;".  This is guaranteed, so no need
+        // for extra sanity checks.
+        javaClassName = strdup(&_type[2]);
+        javaClassName[strchr(javaClassName, ';')-javaClassName] = 0;
+    }
+    jvalue aJValue = convertValueToJValue (exec, aValue, arrayType, javaClassName);
+    
+    switch (arrayType) {
+        case object_type: {
+            env->SetObjectArrayElement((jobjectArray)javaArray(), index, aJValue.l);
+            break;
+        }
+            
+        case boolean_type: {
+            env->SetBooleanArrayRegion((jbooleanArray)javaArray(), index, 1, &aJValue.z);
+            break;
+        }
+            
+        case byte_type: {
+            env->SetByteArrayRegion((jbyteArray)javaArray(), index, 1, &aJValue.b);
+            break;
+        }
+            
+        case char_type: {
+            env->SetCharArrayRegion((jcharArray)javaArray(), index, 1, &aJValue.c);
+            break;
+        }
+            
+        case short_type: {
+            env->SetShortArrayRegion((jshortArray)javaArray(), index, 1, &aJValue.s);
+            break;
+        }
+            
+        case int_type: {
+            env->SetIntArrayRegion((jintArray)javaArray(), index, 1, &aJValue.i);
+            break;
+        }
+            
+        case long_type: {
+            env->SetLongArrayRegion((jlongArray)javaArray(), index, 1, &aJValue.j);
+        }
+            
+        case float_type: {
+            env->SetFloatArrayRegion((jfloatArray)javaArray(), index, 1, &aJValue.f);
+            break;
+        }
+            
+        case double_type: {
+            env->SetDoubleArrayRegion((jdoubleArray)javaArray(), index, 1, &aJValue.d);
+            break;
+        }
+        default:
+        break;
+    }
+    
+    if (javaClassName)
+        free ((void *)javaClassName);
+}
+
+
+JSValue *JavaArray::valueAt(ExecState *exec, unsigned int index) const
+{
+    JNIEnv *env = getJNIEnv();
+    JNIType arrayType = JNITypeFromPrimitiveType(_type[1]);
+    switch (arrayType) {
+        case object_type: {
+            jobjectArray objectArray = (jobjectArray)javaArray();
+            jobject anObject;
+            anObject = env->GetObjectArrayElement(objectArray, index);
+
+            // No object?
+            if (!anObject) {
+                return jsNull();
+            }
+            
+            // Nested array?
+            if (_type[1] == '[') {
+                return JavaArray::convertJObjectToArray(exec, anObject, _type+1, rootObject());
+            }
+            // or array of other object type?
+            return Instance::createRuntimeObject(Instance::JavaLanguage, anObject, rootObject());
+        }
+            
+        case boolean_type: {
+            jbooleanArray booleanArray = (jbooleanArray)javaArray();
+            jboolean aBoolean;
+            env->GetBooleanArrayRegion(booleanArray, index, 1, &aBoolean);
+            return jsBoolean(aBoolean);
+        }
+            
+        case byte_type: {
+            jbyteArray byteArray = (jbyteArray)javaArray();
+            jbyte aByte;
+            env->GetByteArrayRegion(byteArray, index, 1, &aByte);
+            return jsNumber(aByte);
+        }
+            
+        case char_type: {
+            jcharArray charArray = (jcharArray)javaArray();
+            jchar aChar;
+            env->GetCharArrayRegion(charArray, index, 1, &aChar);
+            return jsNumber(aChar);
+            break;
+        }
+            
+        case short_type: {
+            jshortArray shortArray = (jshortArray)javaArray();
+            jshort aShort;
+            env->GetShortArrayRegion(shortArray, index, 1, &aShort);
+            return jsNumber(aShort);
+        }
+            
+        case int_type: {
+            jintArray intArray = (jintArray)javaArray();
+            jint anInt;
+            env->GetIntArrayRegion(intArray, index, 1, &anInt);
+            return jsNumber(anInt);
+        }
+            
+        case long_type: {
+            jlongArray longArray = (jlongArray)javaArray();
+            jlong aLong;
+            env->GetLongArrayRegion(longArray, index, 1, &aLong);
+            return jsNumber(aLong);
+        }
+            
+        case float_type: {
+            jfloatArray floatArray = (jfloatArray)javaArray();
+            jfloat aFloat;
+            env->GetFloatArrayRegion(floatArray, index, 1, &aFloat);
+            return jsNumber(aFloat);
+        }
+            
+        case double_type: {
+            jdoubleArray doubleArray = (jdoubleArray)javaArray();
+            jdouble aDouble;
+            env->GetDoubleArrayRegion(doubleArray, index, 1, &aDouble);
+            return jsNumber(aDouble);
+        }
+        default:
+        break;
+    }
+    return jsUndefined();
+}
+
+unsigned int JavaArray::getLength() const
+{
+    return _length;
+}
+
+#endif // ENABLE(JAVA_BINDINGS)
diff --git a/bindings/jni/jni_runtime.h b/bindings/jni/jni_runtime.h
new file mode 100644
index 0000000..eb6d273
--- /dev/null
+++ b/bindings/jni/jni_runtime.h
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef _JNI_RUNTIME_H_
+#define _JNI_RUNTIME_H_
+
+#if ENABLE(JAVA_BINDINGS)
+
+#include 
+#include 
+
+
+namespace KJS
+{
+
+namespace Bindings
+{
+
+typedef const char* RuntimeType;
+
+class JavaString
+{
+public:
+    JavaString()
+    {
+        JSLock lock;
+        _rep = UString().rep();
+    }
+
+    void _commonInit (JNIEnv *e, jstring s)
+    {
+        int _size = e->GetStringLength (s);
+        const jchar *uc = getUCharactersFromJStringInEnv (e, s);
+        {
+            JSLock lock;
+            _rep = UString((UChar *)uc,_size).rep();
+        }
+        releaseUCharactersForJStringInEnv (e, s, uc);
+    }
+    
+    JavaString (JNIEnv *e, jstring s) {
+        _commonInit (e, s);
+    }
+    
+    JavaString (jstring s) {
+        _commonInit (getJNIEnv(), s);
+    }
+    
+    ~JavaString()
+    {
+        JSLock lock;
+        _rep = 0;
+    }
+    
+    const char *UTF8String() const { 
+        if (_utf8String.c_str() == 0) {
+            JSLock lock;
+            _utf8String = UString(_rep).UTF8String();
+        }
+        return _utf8String.c_str();
+    }
+    const jchar *uchars() const { return (const jchar *)_rep->data(); }
+    int length() const { return _rep->size(); }
+    UString ustring() const { return UString(_rep); }
+
+private:
+    RefPtr _rep;
+    mutable CString _utf8String;
+};
+
+class JavaParameter
+{
+public:
+    JavaParameter () : _JNIType(invalid_type) {};
+    JavaParameter (JNIEnv *env, jstring type);
+    virtual ~JavaParameter() { }
+
+    RuntimeType type() const { return _type.UTF8String(); }
+    JNIType getJNIType() const { return _JNIType; }
+    
+private:
+    JavaString _type;
+    JNIType _JNIType;
+};
+
+
+class JavaField : public Field
+{
+public:
+    JavaField (JNIEnv *env, jobject aField);
+
+    virtual JSValue *valueFromInstance(ExecState *exec, const Instance *instance) const;
+    virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const;
+    
+    virtual const char *name() const { return _name.UTF8String(); }
+    virtual RuntimeType type() const { return _type.UTF8String(); }
+
+    JNIType getJNIType() const { return _JNIType; }
+    
+private:
+    void dispatchSetValueToInstance(ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const;
+    jvalue dispatchValueFromInstance(ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const;
+
+    JavaString _name;
+    JavaString _type;
+    JNIType _JNIType;
+    RefPtr _field;
+};
+
+
+class JavaMethod : public Method
+{
+public:
+    JavaMethod(JNIEnv* env, jobject aMethod);
+    ~JavaMethod();
+
+    virtual const char *name() const { return _name.UTF8String(); };
+    RuntimeType returnType() const { return _returnType.UTF8String(); };
+    JavaParameter* parameterAt(int i) const { return &_parameters[i]; };
+    int numParameters() const { return _numParameters; };
+    
+    const char *signature() const;
+    JNIType JNIReturnType() const;
+
+    jmethodID methodID (jobject obj) const;
+    
+    bool isStatic() const { return _isStatic; }
+
+private:
+    JavaParameter* _parameters;
+    int _numParameters;
+    JavaString _name;
+    mutable char* _signature;
+    JavaString _returnType;
+    JNIType _JNIReturnType;
+    mutable jmethodID _methodID;
+    bool _isStatic;
+};
+
+class JavaArray : public Array
+{
+public:
+    JavaArray(jobject array, const char* type, PassRefPtr);
+    virtual ~JavaArray();
+
+    RootObject* rootObject() const;
+
+    virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const;
+    virtual JSValue *valueAt(ExecState *exec, unsigned int index) const;
+    virtual unsigned int getLength() const;
+    
+    jobject javaArray() const { return _array->_instance; }
+
+    static JSValue* convertJObjectToArray (ExecState* exec, jobject anObject, const char* type, PassRefPtr);
+
+private:
+    RefPtr _array;
+    unsigned int _length;
+    const char *_type;
+};
+
+} // namespace Bindings
+
+} // namespace KJS
+
+#endif // ENABLE(JAVA_BINDINGS)
+
+#endif // _JNI_RUNTIME_H_
diff --git a/bindings/jni/jni_utility.cpp b/bindings/jni/jni_utility.cpp
new file mode 100644
index 0000000..967aa54
--- /dev/null
+++ b/bindings/jni/jni_utility.cpp
@@ -0,0 +1,992 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(JAVA_BINDINGS)
+
+#include "jni_utility.h"
+
+#include "list.h"
+#include "jni_runtime.h"
+#include "runtime_array.h"
+#include "runtime_object.h"
+#include 
+
+namespace KJS {
+
+namespace Bindings {
+
+static jint KJS_GetCreatedJavaVMs(JavaVM** vmBuf, jsize bufLen, jsize* nVMs)
+{
+    static void* javaVMFramework = 0;
+    if (!javaVMFramework)
+        javaVMFramework = dlopen("/System/Library/Frameworks/JavaVM.framework/JavaVM", RTLD_LAZY);
+    if (!javaVMFramework)
+        return JNI_ERR;
+
+    static jint(*functionPointer)(JavaVM**, jsize, jsize *) = 0;
+    if (!functionPointer)
+        functionPointer = (jint(*)(JavaVM**, jsize, jsize *))dlsym(javaVMFramework, "JNI_GetCreatedJavaVMs");
+    if (!functionPointer)
+        return JNI_ERR;
+    return functionPointer(vmBuf, bufLen, nVMs);
+}
+
+static JavaVM *jvm = 0;
+
+// Provide the ability for an outside component to specify the JavaVM to use
+// If the jvm value is set, the getJavaVM function below will just return. 
+// In getJNIEnv(), if AttachCurrentThread is called to a VM that is already
+// attached, the result is a no-op.
+void setJavaVM(JavaVM *javaVM)
+{
+    jvm = javaVM;
+}
+
+JavaVM *getJavaVM()
+{
+    if (jvm)
+        return jvm;
+
+    JavaVM *jvmArray[1];
+    jsize bufLen = 1;
+    jsize nJVMs = 0;
+    jint jniError = 0;
+
+    // Assumes JVM is already running ..., one per process
+    jniError = KJS_GetCreatedJavaVMs(jvmArray, bufLen, &nJVMs);
+    if ( jniError == JNI_OK && nJVMs > 0 ) {
+        jvm = jvmArray[0];
+    }
+    else 
+        fprintf(stderr, "%s: JNI_GetCreatedJavaVMs failed, returned %ld\n", __PRETTY_FUNCTION__, (long)jniError);
+        
+    return jvm;
+}
+
+JNIEnv* getJNIEnv()
+{
+    union {
+        JNIEnv* env;
+        void* dummy;
+    } u;
+    jint jniError = 0;
+
+    jniError = (getJavaVM())->AttachCurrentThread(&u.dummy, NULL);
+    if (jniError == JNI_OK)
+        return u.env;
+    else
+        fprintf(stderr, "%s: AttachCurrentThread failed, returned %ld\n", __PRETTY_FUNCTION__, (long)jniError);
+    return NULL;
+}
+
+static jvalue callJNIMethod (JNIType type, jobject obj, const char *name, const char *sig, va_list args)
+{
+    JavaVM *jvm = getJavaVM();
+    JNIEnv *env = getJNIEnv();
+    jvalue result;
+
+    bzero (&result, sizeof(jvalue));
+    if ( obj != NULL && jvm != NULL && env != NULL) {
+        jclass cls = env->GetObjectClass(obj);
+        if ( cls != NULL ) {
+            jmethodID mid = env->GetMethodID(cls, name, sig);
+            if ( mid != NULL )
+            {
+                switch (type) {
+                case void_type:
+                    env->functions->CallVoidMethodV(env, obj, mid, args);
+                    break;
+                case array_type:
+                case object_type:
+                    result.l = env->functions->CallObjectMethodV(env, obj, mid, args);
+                    break;
+                case boolean_type:
+                    result.z = env->functions->CallBooleanMethodV(env, obj, mid, args);
+                    break;
+                case byte_type:
+                    result.b = env->functions->CallByteMethodV(env, obj, mid, args);
+                    break;
+                case char_type:
+                    result.c = env->functions->CallCharMethodV(env, obj, mid, args);
+                    break;
+                case short_type:
+                    result.s = env->functions->CallShortMethodV(env, obj, mid, args);
+                    break;
+                case int_type:
+                    result.i = env->functions->CallIntMethodV(env, obj, mid, args);
+                    break;
+                case long_type:
+                    result.j = env->functions->CallLongMethodV(env, obj, mid, args);
+                    break;
+                case float_type:
+                    result.f = env->functions->CallFloatMethodV(env, obj, mid, args);
+                    break;
+                case double_type:
+                    result.d = env->functions->CallDoubleMethodV(env, obj, mid, args);
+                    break;
+                default:
+                    fprintf(stderr, "%s: invalid function type (%d)\n", __PRETTY_FUNCTION__, (int)type);
+                }
+            }
+            else
+            {
+                fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, name, obj);
+                env->ExceptionDescribe();
+                env->ExceptionClear();
+                fprintf (stderr, "\n");
+            }
+
+            env->DeleteLocalRef(cls);
+        }
+        else {
+            fprintf(stderr, "%s: Could not find class for %p\n", __PRETTY_FUNCTION__, obj);
+        }
+    }
+
+    return result;
+}
+
+static jvalue callJNIStaticMethod (JNIType type, jclass cls, const char *name, const char *sig, va_list args)
+{
+    JavaVM *jvm = getJavaVM();
+    JNIEnv *env = getJNIEnv();
+    jvalue result;
+
+    bzero (&result, sizeof(jvalue));
+    if ( cls != NULL && jvm != NULL && env != NULL) {
+        jmethodID mid = env->GetStaticMethodID(cls, name, sig);
+        if ( mid != NULL )
+        {
+            switch (type) {
+            case void_type:
+                env->functions->CallStaticVoidMethodV(env, cls, mid, args);
+                break;
+            case array_type:
+            case object_type:
+                result.l = env->functions->CallStaticObjectMethodV(env, cls, mid, args);
+                break;
+            case boolean_type:
+                result.z = env->functions->CallStaticBooleanMethodV(env, cls, mid, args);
+                break;
+            case byte_type:
+                result.b = env->functions->CallStaticByteMethodV(env, cls, mid, args);
+                break;
+            case char_type:
+                result.c = env->functions->CallStaticCharMethodV(env, cls, mid, args);
+                break;
+            case short_type:
+                result.s = env->functions->CallStaticShortMethodV(env, cls, mid, args);
+                break;
+            case int_type:
+                result.i = env->functions->CallStaticIntMethodV(env, cls, mid, args);
+                break;
+            case long_type:
+                result.j = env->functions->CallStaticLongMethodV(env, cls, mid, args);
+                break;
+            case float_type:
+                result.f = env->functions->CallStaticFloatMethodV(env, cls, mid, args);
+                break;
+            case double_type:
+                result.d = env->functions->CallStaticDoubleMethodV(env, cls, mid, args);
+                break;
+            default:
+                fprintf(stderr, "%s: invalid function type (%d)\n", __PRETTY_FUNCTION__, (int)type);
+            }
+        }
+        else
+        {
+            fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, name, cls);
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+            fprintf (stderr, "\n");
+        }
+    }
+
+    return result;
+}
+
+static jvalue callJNIMethodIDA (JNIType type, jobject obj, jmethodID mid, jvalue *args)
+{
+    JNIEnv *env = getJNIEnv();
+    jvalue result;
+    
+    bzero (&result, sizeof(jvalue));
+    if ( obj != NULL && mid != NULL )
+    {
+        switch (type) {
+        case void_type:
+            env->functions->CallVoidMethodA(env, obj, mid, args);
+            break;
+        case array_type:
+        case object_type:
+            result.l = env->functions->CallObjectMethodA(env, obj, mid, args);
+            break;
+        case boolean_type:
+            result.z = env->functions->CallBooleanMethodA(env, obj, mid, args);
+            break;
+        case byte_type:
+            result.b = env->functions->CallByteMethodA(env, obj, mid, args);
+            break;
+        case char_type:
+            result.c = env->functions->CallCharMethodA(env, obj, mid, args);
+            break;
+        case short_type:
+            result.s = env->functions->CallShortMethodA(env, obj, mid, args);
+            break;
+        case int_type:
+            result.i = env->functions->CallIntMethodA(env, obj, mid, args);
+            break;
+        case long_type:
+            result.j = env->functions->CallLongMethodA(env, obj, mid, args);
+            break;
+        case float_type:
+            result.f = env->functions->CallFloatMethodA(env, obj, mid, args);
+            break;
+        case double_type:
+            result.d = env->functions->CallDoubleMethodA(env, obj, mid, args);
+            break;
+        default:
+            fprintf(stderr, "%s: invalid function type (%d)\n", __PRETTY_FUNCTION__, (int)type);
+        }
+    }
+
+    return result;
+}
+
+static jvalue callJNIMethodA (JNIType type, jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    JavaVM *jvm = getJavaVM();
+    JNIEnv *env = getJNIEnv();
+    jvalue result;
+    
+    bzero (&result, sizeof(jvalue));
+    if ( obj != NULL && jvm != NULL && env != NULL) {
+        jclass cls = env->GetObjectClass(obj);
+        if ( cls != NULL ) {
+            jmethodID mid = env->GetMethodID(cls, name, sig);
+            if ( mid != NULL ) {
+                result = callJNIMethodIDA (type, obj, mid, args);
+            }
+            else {
+                fprintf(stderr, "%s: Could not find method: %s\n", __PRETTY_FUNCTION__, name);
+                env->ExceptionDescribe();
+                env->ExceptionClear();
+                fprintf (stderr, "\n");
+            }
+
+            env->DeleteLocalRef(cls);
+        }
+        else {
+            fprintf(stderr, "%s: Could not find class for object\n", __PRETTY_FUNCTION__);
+        }
+    }
+
+    return result;
+}
+
+jmethodID getMethodID (jobject obj, const char *name, const char *sig)
+{
+    JNIEnv *env = getJNIEnv();
+    jmethodID mid = 0;
+        
+    if ( env != NULL) {
+    jclass cls = env->GetObjectClass(obj);
+    if ( cls != NULL ) {
+            mid = env->GetMethodID(cls, name, sig);
+            if (!mid) {
+                env->ExceptionClear();
+                mid = env->GetStaticMethodID(cls, name, sig);
+                if (!mid) {
+                    env->ExceptionClear();
+                }
+            }
+        }
+        env->DeleteLocalRef(cls);
+    }
+    return mid;
+}
+
+
+#define CALL_JNI_METHOD(function_type,obj,name,sig) \
+    va_list args;\
+    va_start (args, sig);\
+    \
+    jvalue result = callJNIMethod(function_type, obj, name, sig, args);\
+    \
+    va_end (args);
+
+#define CALL_JNI_STATIC_METHOD(function_type,cls,name,sig) \
+    va_list args;\
+    va_start (args, sig);\
+    \
+    jvalue result = callJNIStaticMethod(function_type, cls, name, sig, args);\
+    \
+    va_end (args);
+
+void callJNIVoidMethod (jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (void_type, obj, name, sig);
+}
+
+jobject callJNIObjectMethod (jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (object_type, obj, name, sig);
+    return result.l;
+}
+
+jboolean callJNIBooleanMethod( jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (boolean_type, obj, name, sig);
+    return result.z;
+}
+
+jboolean callJNIStaticBooleanMethod (jclass cls, const char *name, const char *sig, ... )
+{
+    CALL_JNI_STATIC_METHOD (boolean_type, cls, name, sig);
+    return result.z;
+}
+
+jbyte callJNIByteMethod( jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (byte_type, obj, name, sig);
+    return result.b;
+}
+
+jchar callJNICharMethod (jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (char_type, obj, name, sig);
+    return result.c;
+}
+
+jshort callJNIShortMethod (jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (short_type, obj, name, sig);
+    return result.s;
+}
+
+jint callJNIIntMethod (jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (int_type, obj, name, sig);
+    return result.i;
+}
+
+jlong callJNILongMethod (jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (long_type, obj, name, sig);
+    return result.j;
+}
+
+jfloat callJNIFloatMethod (jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (float_type, obj, name, sig);
+    return result.f;
+}
+
+jdouble callJNIDoubleMethod (jobject obj, const char *name, const char *sig, ... )
+{
+    CALL_JNI_METHOD (double_type, obj, name, sig);
+    return result.d;
+}
+
+void callJNIVoidMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA (void_type, obj, name, sig, args);
+}
+
+jobject callJNIObjectMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA (object_type, obj, name, sig, args);
+    return result.l;
+}
+
+jbyte callJNIByteMethodA ( jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA (byte_type, obj, name, sig, args);
+    return result.b;
+}
+
+jchar callJNICharMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA (char_type, obj, name, sig, args);
+    return result.c;
+}
+
+jshort callJNIShortMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA (short_type, obj, name, sig, args);
+    return result.s;
+}
+
+jint callJNIIntMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA (int_type, obj, name, sig, args);
+    return result.i;
+}
+
+jlong callJNILongMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA (long_type, obj, name, sig, args);
+    return result.j;
+}
+
+jfloat callJNIFloatMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA  (float_type, obj, name, sig, args);
+    return result.f;
+}
+
+jdouble callJNIDoubleMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA (double_type, obj, name, sig, args);
+    return result.d;
+}
+
+jboolean callJNIBooleanMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
+{
+    jvalue result = callJNIMethodA (boolean_type, obj, name, sig, args);
+    return result.z;
+}
+
+void callJNIVoidMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA (void_type, obj, methodID, args);
+}
+
+jobject callJNIObjectMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA (object_type, obj, methodID, args);
+    return result.l;
+}
+
+jbyte callJNIByteMethodIDA ( jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA (byte_type, obj, methodID, args);
+    return result.b;
+}
+
+jchar callJNICharMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA (char_type, obj, methodID, args);
+    return result.c;
+}
+
+jshort callJNIShortMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA (short_type, obj, methodID, args);
+    return result.s;
+}
+
+jint callJNIIntMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA (int_type, obj, methodID, args);
+    return result.i;
+}
+
+jlong callJNILongMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA (long_type, obj, methodID, args);
+    return result.j;
+}
+
+jfloat callJNIFloatMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA  (float_type, obj, methodID, args);
+    return result.f;
+}
+
+jdouble callJNIDoubleMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA (double_type, obj, methodID, args);
+    return result.d;
+}
+
+jboolean callJNIBooleanMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
+{
+    jvalue result = callJNIMethodIDA (boolean_type, obj, methodID, args);
+    return result.z;
+}
+
+const char *getCharactersFromJString (jstring aJString)
+{
+    return getCharactersFromJStringInEnv (getJNIEnv(), aJString);
+}
+
+void releaseCharactersForJString (jstring aJString, const char *s)
+{
+    releaseCharactersForJStringInEnv (getJNIEnv(), aJString, s);
+}
+
+const char *getCharactersFromJStringInEnv (JNIEnv *env, jstring aJString)
+{
+    jboolean isCopy;
+    const char *s = env->GetStringUTFChars((jstring)aJString, &isCopy);
+    if (!s) {
+        env->ExceptionDescribe();
+        env->ExceptionClear();
+                fprintf (stderr, "\n");
+    }
+    return s;
+}
+
+void releaseCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const char *s)
+{
+    env->ReleaseStringUTFChars (aJString, s);
+}
+
+const jchar *getUCharactersFromJStringInEnv (JNIEnv *env, jstring aJString)
+{
+    jboolean isCopy;
+    const jchar *s = env->GetStringChars((jstring)aJString, &isCopy);
+    if (!s) {
+        env->ExceptionDescribe();
+        env->ExceptionClear();
+                fprintf (stderr, "\n");
+    }
+    return s;
+}
+
+void releaseUCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const jchar *s)
+{
+    env->ReleaseStringChars (aJString, s);
+}
+
+JNIType JNITypeFromClassName(const char *name)
+{
+    JNIType type;
+    
+    if (strcmp("byte",name) == 0)
+        type = byte_type;
+    else if (strcmp("short",name) == 0)
+        type = short_type;
+    else if (strcmp("int",name) == 0)
+        type = int_type;
+    else if (strcmp("long",name) == 0)
+        type = long_type;
+    else if (strcmp("float",name) == 0)
+        type = float_type;
+    else if (strcmp("double",name) == 0)
+        type = double_type;
+    else if (strcmp("char",name) == 0)
+        type = char_type;
+    else if (strcmp("boolean",name) == 0)
+        type = boolean_type;
+    else if (strcmp("void",name) == 0)
+        type = void_type;
+    else if ('[' == name[0]) 
+        type = array_type;
+    else
+        type = object_type;
+        
+    return type;
+}
+
+const char *signatureFromPrimitiveType(JNIType type)
+{
+    switch (type){
+        case void_type: 
+            return "V";
+        
+        case array_type:
+            return "[";
+        
+        case object_type:
+            return "L";
+        
+        case boolean_type:
+            return "Z";
+        
+        case byte_type:
+            return "B";
+            
+        case char_type:
+            return "C";
+        
+        case short_type:
+            return "S";
+        
+        case int_type:
+            return "I";
+        
+        case long_type:
+            return "J";
+        
+        case float_type:
+            return "F";
+        
+        case double_type:
+            return "D";
+
+        case invalid_type:
+        default:
+        break;
+    }
+    return "";
+}
+
+JNIType JNITypeFromPrimitiveType(char type)
+{
+    switch (type){
+        case 'V': 
+            return void_type;
+        
+        case 'L':
+            return object_type;
+            
+        case '[':
+            return array_type;
+        
+        case 'Z':
+            return boolean_type;
+        
+        case 'B':
+            return byte_type;
+            
+        case 'C':
+            return char_type;
+        
+        case 'S':
+            return short_type;
+        
+        case 'I':
+            return int_type;
+        
+        case 'J':
+            return long_type;
+        
+        case 'F':
+            return float_type;
+        
+        case 'D':
+            return double_type;
+
+        default:
+        break;
+    }
+    return invalid_type;
+}
+
+jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *signature)
+{
+    JavaVM *jvm = getJavaVM();
+    JNIEnv *env = getJNIEnv();
+    jvalue result;
+
+    bzero (&result, sizeof(jvalue));
+    if ( obj != NULL && jvm != NULL && env != NULL) {
+        jclass cls = env->GetObjectClass(obj);
+        if ( cls != NULL ) {
+            jfieldID field = env->GetFieldID(cls, name, signature);
+            if ( field != NULL ) {
+                switch (type) {
+                case array_type:
+                case object_type:
+                    result.l = env->functions->GetObjectField(env, obj, field);
+                    break;
+                case boolean_type:
+                    result.z = env->functions->GetBooleanField(env, obj, field);
+                    break;
+                case byte_type:
+                    result.b = env->functions->GetByteField(env, obj, field);
+                    break;
+                case char_type:
+                    result.c = env->functions->GetCharField(env, obj, field);
+                    break;
+                case short_type:
+                    result.s = env->functions->GetShortField(env, obj, field);
+                    break;
+                case int_type:
+                    result.i = env->functions->GetIntField(env, obj, field);
+                    break;
+                case long_type:
+                    result.j = env->functions->GetLongField(env, obj, field);
+                    break;
+                case float_type:
+                    result.f = env->functions->GetFloatField(env, obj, field);
+                    break;
+                case double_type:
+                    result.d = env->functions->GetDoubleField(env, obj, field);
+                    break;
+                default:
+                    fprintf(stderr, "%s: invalid field type (%d)\n", __PRETTY_FUNCTION__, (int)type);
+                }
+            }
+            else
+            {
+                fprintf(stderr, "%s: Could not find field: %s\n", __PRETTY_FUNCTION__, name);
+                env->ExceptionDescribe();
+                env->ExceptionClear();
+                fprintf (stderr, "\n");
+            }
+
+            env->DeleteLocalRef(cls);
+        }
+        else {
+            fprintf(stderr, "%s: Could not find class for object\n", __PRETTY_FUNCTION__);
+        }
+    }
+
+    return result;
+}
+
+static jobject convertArrayInstanceToJavaArray(ExecState *exec, JSValue *value, const char *javaClassName) {
+
+    ASSERT(JSLock::lockCount() > 0);
+    
+    JNIEnv *env = getJNIEnv();
+    // As JS Arrays can contain a mixture of objects, assume we can convert to
+    // the requested Java Array type requested, unless the array type is some object array
+    // other than a string.
+    ArrayInstance *jsArray = static_cast(value);
+    unsigned length = jsArray->getLength();
+    jobjectArray jarray = 0;
+    
+    // Build the correct array type
+    switch (JNITypeFromPrimitiveType(javaClassName[1])) { 
+        case object_type: {
+        // Only support string object types
+        if (0 == strcmp("[Ljava.lang.String;", javaClassName)) {
+            jarray = (jobjectArray)env->NewObjectArray(length,
+                env->FindClass("java/lang/String"),
+                env->NewStringUTF(""));
+            for(unsigned i = 0; i < length; i++) {
+                JSValue* item = jsArray->getItem(i);
+                UString stringValue = item->toString(exec);
+                env->SetObjectArrayElement(jarray,i,
+                    env->functions->NewString(env, (const jchar *)stringValue.data(), stringValue.size()));
+                }
+            }
+            break;
+        }
+        
+        case boolean_type: {
+            jarray = (jobjectArray)env->NewBooleanArray(length);
+            for(unsigned i = 0; i < length; i++) {
+                JSValue* item = jsArray->getItem(i);
+                jboolean value = (jboolean)item->toNumber(exec);
+                env->SetBooleanArrayRegion((jbooleanArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+        
+        case byte_type: {
+            jarray = (jobjectArray)env->NewByteArray(length);
+            for(unsigned i = 0; i < length; i++) {
+                JSValue* item = jsArray->getItem(i);
+                jbyte value = (jbyte)item->toNumber(exec);
+                env->SetByteArrayRegion((jbyteArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+        case char_type: {
+            jarray = (jobjectArray)env->NewCharArray(length);
+            for(unsigned i = 0; i < length; i++) {
+                JSValue* item = jsArray->getItem(i);
+                UString stringValue = item->toString(exec);
+                jchar value = 0;
+                if (stringValue.size() > 0)
+                    value = ((const jchar*)stringValue.data())[0];
+                env->SetCharArrayRegion((jcharArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+        case short_type: {
+            jarray = (jobjectArray)env->NewShortArray(length);
+            for(unsigned i = 0; i < length; i++) {
+                JSValue* item = jsArray->getItem(i);
+                jshort value = (jshort)item->toNumber(exec);
+                env->SetShortArrayRegion((jshortArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+        case int_type: {
+            jarray = (jobjectArray)env->NewIntArray(length);
+            for(unsigned i = 0; i < length; i++) {
+                JSValue* item = jsArray->getItem(i);
+                jint value = (jint)item->toNumber(exec);
+                env->SetIntArrayRegion((jintArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+        case long_type: {
+            jarray = (jobjectArray)env->NewLongArray(length);
+            for(unsigned i = 0; i < length; i++) {
+                JSValue* item = jsArray->getItem(i);
+                jlong value = (jlong)item->toNumber(exec);
+                env->SetLongArrayRegion((jlongArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+        case float_type: {
+            jarray = (jobjectArray)env->NewFloatArray(length);
+            for(unsigned i = 0; i < length; i++) {
+                JSValue* item = jsArray->getItem(i);
+                jfloat value = (jfloat)item->toNumber(exec);
+                env->SetFloatArrayRegion((jfloatArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+    
+        case double_type: {
+            jarray = (jobjectArray)env->NewDoubleArray(length);
+            for(unsigned i = 0; i < length; i++) {
+                JSValue* item = jsArray->getItem(i);
+                jdouble value = (jdouble)item->toNumber(exec);
+                env->SetDoubleArrayRegion((jdoubleArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+        
+        case array_type: // don't handle embedded arrays
+        case void_type: // Don't expect arrays of void objects
+        case invalid_type: // Array of unknown objects
+            break;
+    }
+    
+    // if it was not one of the cases handled, then null is returned
+    return jarray;
+}
+
+
+jvalue convertValueToJValue (ExecState *exec, JSValue *value, JNIType _JNIType, const char *javaClassName)
+{
+    JSLock lock;
+    
+    jvalue result;
+   
+    switch (_JNIType){
+        case array_type:
+        case object_type: {
+            result.l = (jobject)0;
+            
+            // First see if we have a Java instance.
+            if (value->isObject()){
+                JSObject *objectImp = static_cast(value);
+                if (objectImp->classInfo() == &RuntimeObjectImp::info) {
+                    RuntimeObjectImp *imp = static_cast(value);
+                    JavaInstance *instance = static_cast(imp->getInternalInstance());
+                    if (instance)
+                        result.l = instance->javaInstance();
+                }
+                else if (objectImp->classInfo() == &RuntimeArray::info) {
+                // Input is a JavaScript Array that was originally created from a Java Array
+                    RuntimeArray *imp = static_cast(value);
+                    JavaArray *array = static_cast(imp->getConcreteArray());
+                    result.l = array->javaArray();
+                } 
+                else if (objectImp->classInfo() == &ArrayInstance::info) {
+                    // Input is a Javascript Array. We need to create it to a Java Array.
+                    result.l = convertArrayInstanceToJavaArray(exec, value, javaClassName);
+                }
+            }
+            
+            // Now convert value to a string if the target type is a java.lang.string, and we're not
+            // converting from a Null.
+            if (result.l == 0 && strcmp(javaClassName, "java.lang.String") == 0) {
+#ifdef CONVERT_NULL_TO_EMPTY_STRING
+                if (value->isNull()) {
+                    JNIEnv *env = getJNIEnv();
+                    jchar buf[2];
+                    jobject javaString = env->functions->NewString (env, buf, 0);
+                    result.l = javaString;
+                }
+                else 
+#else
+                if (!value->isNull())
+#endif
+                {
+                    UString stringValue = value->toString(exec);
+                    JNIEnv *env = getJNIEnv();
+                    jobject javaString = env->functions->NewString (env, (const jchar *)stringValue.data(), stringValue.size());
+                    result.l = javaString;
+                }
+            } else if (result.l == 0) 
+                bzero (&result, sizeof(jvalue)); // Handle it the same as a void case
+        }
+        break;
+        
+        case boolean_type: {
+            result.z = (jboolean)value->toNumber(exec);
+        }
+        break;
+            
+        case byte_type: {
+            result.b = (jbyte)value->toNumber(exec);
+        }
+        break;
+        
+        case char_type: {
+            result.c = (jchar)value->toNumber(exec);
+        }
+        break;
+
+        case short_type: {
+            result.s = (jshort)value->toNumber(exec);
+        }
+        break;
+
+        case int_type: {
+            result.i = (jint)value->toNumber(exec);
+        }
+        break;
+
+        case long_type: {
+            result.j = (jlong)value->toNumber(exec);
+        }
+        break;
+
+        case float_type: {
+            result.f = (jfloat)value->toNumber(exec);
+        }
+        break;
+
+        case double_type: {
+            result.d = (jdouble)value->toNumber(exec);
+        }
+        break;
+            
+        break;
+
+        case invalid_type:
+        default:
+        case void_type: {
+            bzero (&result, sizeof(jvalue));
+        }
+        break;
+    }
+    return result;
+}
+
+}  // end of namespace Bindings
+
+} // end of namespace KJS
+
+#endif // ENABLE(JAVA_BINDINGS)
diff --git a/bindings/jni/jni_utility.h b/bindings/jni/jni_utility.h
new file mode 100644
index 0000000..3b4955f
--- /dev/null
+++ b/bindings/jni/jni_utility.h
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef _JNI_UTILITY_H_
+#define _JNI_UTILITY_H_
+
+#if ENABLE(JAVA_BINDINGS)
+
+#include 
+
+#include 
+
+// The order of these items can not be modified as they are tightly
+// bound with the JVM on Mac OSX. If new types need to be added, they
+// should be added to the end. It is used in jni_obc.mm when calling
+// through to the JVM. Newly added items need to be made compatible
+// in that file.
+typedef enum {
+    invalid_type = 0,
+    void_type,
+    object_type,
+    boolean_type,
+    byte_type,
+    char_type,
+    short_type,
+    int_type,
+    long_type,
+    float_type,
+    double_type,
+    array_type
+} JNIType;
+
+namespace KJS {
+
+namespace Bindings {
+
+class JavaParameter;
+
+const char *getCharactersFromJString(jstring aJString);
+void releaseCharactersForJString(jstring aJString, const char *s);
+
+const char *getCharactersFromJStringInEnv(JNIEnv *env, jstring aJString);
+void releaseCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const char *s);
+const jchar *getUCharactersFromJStringInEnv(JNIEnv *env, jstring aJString);
+void releaseUCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const jchar *s);
+
+JNIType JNITypeFromClassName(const char *name);
+JNIType JNITypeFromPrimitiveType(char type);
+const char *signatureFromPrimitiveType(JNIType type);
+
+jvalue convertValueToJValue(ExecState *exec, JSValue *value, JNIType _JNIType, const char *javaClassName);
+
+jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature);
+
+jmethodID getMethodID(jobject obj, const char *name, const char *sig);
+
+jobject callJNIObjectMethod(jobject obj, const char *name, const char *sig, ... );
+void callJNIVoidMethod(jobject obj, const char *name, const char *sig, ... );
+jboolean callJNIBooleanMethod(jobject obj, const char *name, const char *sig, ... );
+jboolean callJNIStaticBooleanMethod(jclass cls, const char *name, const char *sig, ... );
+jbyte callJNIByteMethod(jobject obj, const char *name, const char *sig, ... );
+jchar callJNICharMethod(jobject obj, const char *name, const char *sig, ... );
+jshort callJNIShortMethod(jobject obj, const char *name, const char *sig, ... );
+jint callJNIIntMethod(jobject obj, const char *name, const char *sig, ... );
+jlong callJNILongMethod(jobject obj, const char *name, const char *sig, ... );
+jfloat callJNIFloatMethod(jobject obj, const char *name, const char *sig, ... );
+jdouble callJNIDoubleMethod(jobject obj, const char *name, const char *sig, ... );
+
+jobject callJNIObjectMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+void callJNIVoidMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+jboolean callJNIBooleanMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+jbyte callJNIByteMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+jchar callJNICharMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+jshort callJNIShortMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+jint callJNIIntMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+jlong callJNILongMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+jfloat callJNIFloatMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+jdouble callJNIDoubleMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
+
+jobject callJNIObjectMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+void callJNIVoidMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+jboolean callJNIBooleanMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+jbyte callJNIByteMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+jchar callJNICharMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+jshort callJNIShortMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+jint callJNIIntMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+jlong callJNILongMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+jfloat callJNIFloatMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+jdouble callJNIDoubleMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
+
+JavaVM *getJavaVM();
+void    setJavaVM(JavaVM *javaVM);
+JNIEnv *getJNIEnv();
+
+bool dispatchJNICall(const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, JSValue *&exceptionDescription);
+
+} // namespace Bindings
+
+} // namespace KJS
+
+#endif // ENABLE(JAVA_BINDINGS)
+
+#endif // _JNI_UTILITY_H_
diff --git a/bindings/make_testbindings b/bindings/make_testbindings
new file mode 100755
index 0000000..1f528fe
--- /dev/null
+++ b/bindings/make_testbindings
@@ -0,0 +1,2 @@
+cc -g -o testbindingsM testbindings.mm -I../kjs -F$SYMROOTS -framework JavaScriptCore -framework Foundation -lstdc++
+cc -g -o testbindingsC testbindings.cpp -I../kjs -F$SYMROOTS -framework JavaScriptCore -framework Foundation -lstdc++
diff --git a/bindings/npapi.h b/bindings/npapi.h
new file mode 100644
index 0000000..e7cf503
--- /dev/null
+++ b/bindings/npapi.h
@@ -0,0 +1,720 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+ 
+ 
+ /*
+  *  Netscape client plug-in API spec
+  */
+ 
+
+#ifndef _NPAPI_H_
+#define _NPAPI_H_
+
+#include 
+
+#if ENABLE(NETSCAPE_API)
+
+#ifdef INCLUDE_JAVA
+#include "jri.h"                /* Java Runtime Interface */
+#else
+#define jref    void *
+#define JRIEnv  void
+#endif
+
+#ifdef _WIN32
+#    ifndef XP_WIN
+#        define XP_WIN 1
+#    endif /* XP_WIN */
+#endif /* _WIN32 */
+
+#ifdef __MWERKS__
+#    define _declspec __declspec
+#    ifdef macintosh
+#        ifndef XP_MAC
+#            define XP_MAC 1
+#        endif /* XP_MAC */
+#    endif /* macintosh */
+#    ifdef __INTEL__
+#        undef NULL
+#        ifndef XP_WIN
+#            define XP_WIN 1
+#        endif /* __INTEL__ */
+#    endif /* XP_PC */
+#endif /* __MWERKS__ */
+
+#if defined(__APPLE_CC__) && !defined(__MACOS_CLASSIC__) && !defined(XP_UNIX)
+#   define XP_MACOSX
+#endif
+
+#ifdef XP_MAC
+    #include 
+    #include 
+#endif
+
+#ifdef XP_MACOSX
+    #include 
+    #include 
+    #include 
+#endif
+
+#ifdef XP_UNIX
+    #include 
+    #include 
+    #include 
+#endif
+
+#ifdef XP_WIN
+    #include 
+#endif
+
+#if defined(XP_MACOSX) && defined(__LP64__)
+#error 64-bit Netscape plug-ins are not supported on Mac OS X
+#endif
+
+/*----------------------------------------------------------------------*/
+/*             Plugin Version Constants                                 */
+/*----------------------------------------------------------------------*/
+
+#define NP_VERSION_MAJOR 0
+#define NP_VERSION_MINOR 18
+
+
+
+/*----------------------------------------------------------------------*/
+/*             Definition of Basic Types                                */
+/*----------------------------------------------------------------------*/
+
+#ifndef _UINT16
+#define _UINT16
+typedef unsigned short uint16;
+#endif
+
+#ifndef _UINT32
+#define _UINT32
+#ifdef __LP64__
+typedef unsigned int uint32;
+#else /* __LP64__ */
+typedef unsigned long uint32;
+#endif /* __LP64__ */
+#endif
+
+#ifndef _INT16
+#define _INT16
+typedef short int16;
+#endif
+
+#ifndef _INT32
+#define _INT32
+#ifdef __LP64__
+typedef int int32;
+#else /* __LP64__ */
+typedef long int32;
+#endif /* __LP64__ */
+#endif
+
+#ifndef FALSE
+#define FALSE (0)
+#endif
+#ifndef TRUE
+#define TRUE (1)
+#endif
+#ifndef NULL
+#define NULL (0L)
+#endif
+
+typedef unsigned char    NPBool;
+typedef int16            NPError;
+typedef int16            NPReason;
+typedef char*            NPMIMEType;
+
+
+
+/*----------------------------------------------------------------------*/
+/*             Structures and definitions             */
+/*----------------------------------------------------------------------*/
+
+#if !defined(__LP64__)
+#if defined(XP_MAC) || defined(XP_MACOSX)
+#pragma options align=mac68k
+#endif
+#endif /* __LP64__ */
+
+/*
+ *  NPP is a plug-in's opaque instance handle
+ */
+typedef struct _NPP
+{
+    void*    pdata;            /* plug-in private data */
+    void*    ndata;            /* netscape private data */
+} NPP_t;
+
+typedef NPP_t*    NPP;
+
+
+typedef struct _NPStream
+{
+    void*        pdata;        /* plug-in private data */
+    void*        ndata;        /* netscape private data */
+    const char*  url;
+    uint32       end;
+    uint32       lastmodified;
+    void*        notifyData;
+    const char*  headers;      /* Response headers from host.
+                                * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS.
+                                * Used for HTTP only; NULL for non-HTTP.
+                                * Available from NPP_NewStream onwards.
+                                * Plugin should copy this data before storing it.
+                                * Includes HTTP status line and all headers,
+                                * preferably verbatim as received from server,
+                                * headers formatted as in HTTP ("Header: Value"),
+                                * and newlines (\n, NOT \r\n) separating lines.
+                                * Terminated by \n\0 (NOT \n\n\0). */
+} NPStream;
+
+
+typedef struct _NPByteRange
+{
+    int32      offset;         /* negative offset means from the end */
+    uint32     length;
+    struct _NPByteRange* next;
+} NPByteRange;
+
+
+typedef struct _NPSavedData
+{
+    int32    len;
+    void*    buf;
+} NPSavedData;
+
+
+typedef struct _NPRect
+{
+    uint16    top;
+    uint16    left;
+    uint16    bottom;
+    uint16    right;
+} NPRect;
+
+
+#ifdef XP_UNIX
+/*
+ * Unix specific structures and definitions
+ */
+
+/*
+ * Callback Structures.
+ *
+ * These are used to pass additional platform specific information.
+ */
+enum {
+    NP_SETWINDOW = 1,
+    NP_PRINT
+};
+
+typedef struct
+{
+    int32        type;
+} NPAnyCallbackStruct;
+
+typedef struct
+{
+    int32           type;
+    Display*        display;
+    Visual*         visual;
+    Colormap        colormap;
+    unsigned int    depth;
+} NPSetWindowCallbackStruct;
+
+typedef struct
+{
+    int32            type;
+    FILE*            fp;
+} NPPrintCallbackStruct;
+
+#endif /* XP_UNIX */
+
+/*
+ *   The following masks are applied on certain platforms to NPNV and 
+ *   NPPV selectors that pass around pointers to COM interfaces. Newer 
+ *   compilers on some platforms may generate vtables that are not 
+ *   compatible with older compilers. To prevent older plugins from 
+ *   not understanding a new browser's ABI, these masks change the 
+ *   values of those selectors on those platforms. To remain backwards
+ *   compatible with differenet versions of the browser, plugins can 
+ *   use these masks to dynamically determine and use the correct C++
+ *   ABI that the browser is expecting. This does not apply to Windows 
+ *   as Microsoft's COM ABI will likely not change.
+ */
+
+#define NP_ABI_GCC3_MASK  0x10000000
+/*
+ *   gcc 3.x generated vtables on UNIX and OSX are incompatible with 
+ *   previous compilers.
+ */
+#if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
+#define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
+#else
+#define _NP_ABI_MIXIN_FOR_GCC3 0
+#endif
+
+#define NP_ABI_MACHO_MASK 0x01000000
+/*
+ *   On OSX, the Mach-O executable format is significantly
+ *   different than CFM. In addition to having a different
+ *   C++ ABI, it also has has different C calling convention.
+ *   You must use glue code when calling between CFM and
+ *   Mach-O C functions. 
+ */
+#if (defined(TARGET_RT_MAC_MACHO))
+#define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
+#else
+#define _NP_ABI_MIXIN_FOR_MACHO 0
+#endif
+
+
+#define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
+
+/*
+ * List of variable names for which NPP_GetValue shall be implemented
+ */
+typedef enum {
+    NPPVpluginNameString = 1,
+    NPPVpluginDescriptionString,
+    NPPVpluginWindowBool,
+    NPPVpluginTransparentBool,
+
+    NPPVjavaClass,                /* Not implemented in WebKit */
+    NPPVpluginWindowSize,         /* Not implemented in WebKit */
+    NPPVpluginTimerInterval,      /* Not implemented in WebKit */
+
+    NPPVpluginScriptableInstance = (10 | NP_ABI_MASK), /* Not implemented in WebKit */
+    NPPVpluginScriptableIID = 11, /* Not implemented in WebKit */
+
+    /* 12 and over are available on Mozilla builds starting with 0.9.9 */
+    NPPVjavascriptPushCallerBool = 12,  /* Not implemented in WebKit */
+    NPPVpluginKeepLibraryInMemory = 13, /* Not implemented in WebKit */
+    NPPVpluginNeedsXEmbed         = 14, /* Not implemented in WebKit */
+
+    /* Get the NPObject for scripting the plugin. */
+    NPPVpluginScriptableNPObject  = 15,
+
+    /* Get the plugin value (as \0-terminated UTF-8 string data) for
+     * form submission if the plugin is part of a form. Use
+     * NPN_MemAlloc() to allocate memory for the string data.
+     */
+    NPPVformValue = 16,    /* Not implemented in WebKit */
+#ifdef XP_MACOSX
+    /* Used for negotiating drawing models */
+    NPPVpluginDrawingModel = 1000
+#endif
+} NPPVariable;
+
+/*
+ * List of variable names for which NPN_GetValue is implemented by Mozilla
+ */
+typedef enum {
+    NPNVxDisplay = 1,
+    NPNVxtAppContext,
+    NPNVnetscapeWindow,
+    NPNVjavascriptEnabledBool,
+    NPNVasdEnabledBool,
+    NPNVisOfflineBool,
+
+    /* 10 and over are available on Mozilla builds starting with 0.9.4 */
+    NPNVserviceManager = (10 | NP_ABI_MASK),  /* Not implemented in WebKit */
+    NPNVDOMElement     = (11 | NP_ABI_MASK),  /* Not implemented in WebKit */
+    NPNVDOMWindow      = (12 | NP_ABI_MASK),  /* Not implemented in WebKit */
+    NPNVToolkit        = (13 | NP_ABI_MASK),  /* Not implemented in WebKit */
+    NPNVSupportsXEmbedBool = 14,              /* Not implemented in WebKit */
+
+    /* Get the NPObject wrapper for the browser window. */
+    NPNVWindowNPObject = 15,
+
+    /* Get the NPObject wrapper for the plugins DOM element. */
+    NPNVPluginElementNPObject
+
+#ifdef XP_MACOSX
+    , NPNVpluginDrawingModel = 1000 /* The NPDrawingModel specified by the plugin */
+
+#ifndef NP_NO_QUICKDRAW
+    , NPNVsupportsQuickDrawBool = 2000 /* TRUE if the browser supports the QuickDraw drawing model */
+#endif
+    , NPNVsupportsCoreGraphicsBool = 2001 /* TRUE if the browser supports the CoreGraphics drawing model */
+    , NPNVsupportsOpenGLBool = 2002 /* TRUE if the browser supports the OpenGL drawing model (CGL on Mac) */
+#endif /* XP_MACOSX */
+} NPNVariable;
+
+/*
+ * The type of a NPWindow - it specifies the type of the data structure
+ * returned in the window field.
+ */
+typedef enum {
+    NPWindowTypeWindow = 1,
+    NPWindowTypeDrawable
+} NPWindowType;
+
+#ifdef XP_MACOSX
+
+/*
+ * The drawing model for a Mac OS X plugin.  These are the possible values for the NPNVpluginDrawingModel variable.
+ */
+ 
+typedef enum {
+#ifndef NP_NO_QUICKDRAW
+    NPDrawingModelQuickDraw = 0,
+#endif
+    NPDrawingModelCoreGraphics = 1,
+    NPDrawingModelOpenGL = 2
+} NPDrawingModel;
+
+#endif
+
+typedef struct _NPWindow
+{
+    void*    window;     /* Platform specific window handle */
+    int32    x;            /* Position of top left corner relative */
+    int32    y;            /*    to a netscape page.                    */
+    uint32    width;        /* Maximum window size */
+    uint32    height;
+    NPRect    clipRect;    /* Clipping rectangle in port coordinates */
+                        /* Used by MAC only.              */
+#ifdef XP_UNIX
+    void *    ws_info;    /* Platform-dependent additonal data */
+#endif /* XP_UNIX */
+    NPWindowType type;    /* Is this a window or a drawable? */
+} NPWindow;
+
+
+typedef struct _NPFullPrint
+{
+    NPBool    pluginPrinted;    /* Set TRUE if plugin handled fullscreen */
+                            /*    printing                             */
+    NPBool    printOne;        /* TRUE if plugin should print one copy  */
+                            /*    to default printer                     */
+    void*    platformPrint;    /* Platform-specific printing info */
+} NPFullPrint;
+
+typedef struct _NPEmbedPrint
+{
+    NPWindow    window;
+    void*    platformPrint;    /* Platform-specific printing info */
+} NPEmbedPrint;
+
+typedef struct _NPPrint
+{
+    uint16    mode;                        /* NP_FULL or NP_EMBED */
+    union
+    {
+        NPFullPrint     fullPrint;        /* if mode is NP_FULL */
+        NPEmbedPrint    embedPrint;        /* if mode is NP_EMBED */
+    } print;
+} NPPrint;
+
+#if defined(XP_MAC) || defined(XP_MACOSX)
+typedef EventRecord    NPEvent;
+#elif defined(XP_WIN)
+typedef struct _NPEvent
+{
+    uint16   event;
+    uint32   wParam;
+    uint32   lParam;
+} NPEvent;
+#elif defined (XP_UNIX)
+typedef XEvent NPEvent;
+#else
+typedef void*            NPEvent;
+#endif /* XP_MAC */
+
+#if defined(XP_MAC)
+typedef RgnHandle NPRegion;
+#elif defined(XP_MACOSX)
+/* 
+ * NPRegion's type depends on the drawing model specified by the plugin (see NPNVpluginDrawingModel).
+ * NPQDRegion represents a QuickDraw RgnHandle and is used with the QuickDraw drawing model.
+ * NPCGRegion repesents a graphical region when using any other drawing model.
+ */
+typedef void *NPRegion;
+#ifndef NP_NO_QUICKDRAW
+typedef RgnHandle NPQDRegion;
+#endif
+typedef CGPathRef NPCGRegion;
+#elif defined(XP_WIN)
+typedef HRGN NPRegion;
+#elif defined(XP_UNIX)
+typedef Region NPRegion;
+#else
+typedef void *NPRegion;
+#endif /* XP_MAC */
+
+#ifdef XP_MACOSX
+
+/* 
+ * NP_CGContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelCoreGraphics
+ * as its drawing model.
+ */
+
+typedef struct NP_CGContext
+{
+    CGContextRef context;
+    WindowRef window;
+} NP_CGContext;
+
+/* 
+ * NP_GLContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelOpenGL as its
+ * drawing model.
+ */
+
+typedef struct NP_GLContext
+{
+    CGLContextObj context;
+    WindowRef window;
+} NP_GLContext;
+
+#endif /* XP_MACOSX */
+
+#if defined(XP_MAC) || defined(XP_MACOSX)
+
+/*
+ *  Mac-specific structures and definitions.
+ */
+
+#ifndef NP_NO_QUICKDRAW
+
+/* 
+ * NP_Port is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelQuickDraw as its
+ * drawing model, or the plugin does not specify a drawing model.
+ *
+ * It is not recommended that new plugins use NPDrawingModelQuickDraw or NP_Port, as QuickDraw has been
+ * deprecated in Mac OS X 10.5.  CoreGraphics is the preferred drawing API.
+ *
+ * NP_Port is not available in 64-bit.
+ */
+ 
+typedef struct NP_Port
+{
+    CGrafPtr     port;        /* Grafport */
+    int32        portx;        /* position inside the topmost window */
+    int32        porty;
+} NP_Port;
+
+#endif /* NP_NO_QUICKDRAW */
+
+/*
+ *  Non-standard event types that can be passed to HandleEvent
+ */
+#define getFocusEvent        (osEvt + 16)
+#define loseFocusEvent        (osEvt + 17)
+#define adjustCursorEvent   (osEvt + 18)
+
+#endif /* XP_MAC */
+
+
+/*
+ * Values for mode passed to NPP_New:
+ */
+#define NP_EMBED        1
+#define NP_FULL         2
+
+/*
+ * Values for stream type passed to NPP_NewStream:
+ */
+#define NP_NORMAL        1
+#define NP_SEEK         2
+#define NP_ASFILE        3
+#define NP_ASFILEONLY        4
+
+#define NP_MAXREADY    (((unsigned)(~0)<<1)>>1)
+
+#if !defined(__LP64__)
+#if defined(XP_MAC) || defined(XP_MACOSX)
+#pragma options align=reset
+#endif
+#endif /* __LP64__ */
+
+
+/*----------------------------------------------------------------------*/
+/*             Error and Reason Code definitions            */
+/*----------------------------------------------------------------------*/
+
+/*
+ *    Values of type NPError:
+ */
+#define NPERR_BASE                            0
+#define NPERR_NO_ERROR                        (NPERR_BASE + 0)
+#define NPERR_GENERIC_ERROR                    (NPERR_BASE + 1)
+#define NPERR_INVALID_INSTANCE_ERROR        (NPERR_BASE + 2)
+#define NPERR_INVALID_FUNCTABLE_ERROR        (NPERR_BASE + 3)
+#define NPERR_MODULE_LOAD_FAILED_ERROR        (NPERR_BASE + 4)
+#define NPERR_OUT_OF_MEMORY_ERROR            (NPERR_BASE + 5)
+#define NPERR_INVALID_PLUGIN_ERROR            (NPERR_BASE + 6)
+#define NPERR_INVALID_PLUGIN_DIR_ERROR        (NPERR_BASE + 7)
+#define NPERR_INCOMPATIBLE_VERSION_ERROR    (NPERR_BASE + 8)
+#define NPERR_INVALID_PARAM                (NPERR_BASE + 9)
+#define NPERR_INVALID_URL                    (NPERR_BASE + 10)
+#define NPERR_FILE_NOT_FOUND                (NPERR_BASE + 11)
+#define NPERR_NO_DATA                        (NPERR_BASE + 12)
+#define NPERR_STREAM_NOT_SEEKABLE            (NPERR_BASE + 13)
+
+/*
+ *    Values of type NPReason:
+ */
+#define NPRES_BASE                0
+#define NPRES_DONE                    (NPRES_BASE + 0)
+#define NPRES_NETWORK_ERR            (NPRES_BASE + 1)
+#define NPRES_USER_BREAK            (NPRES_BASE + 2)
+
+/*
+ *      Don't use these obsolete error codes any more.
+ */
+#define NP_NOERR  NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
+#define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
+#define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
+
+/*
+ * Version feature information
+ */
+#define NPVERS_HAS_STREAMOUTPUT     8
+#define NPVERS_HAS_NOTIFICATION     9
+#define NPVERS_HAS_LIVECONNECT        9
+#define NPVERS_WIN16_HAS_LIVECONNECT    9
+#define NPVERS_68K_HAS_LIVECONNECT    11
+#define NPVERS_HAS_WINDOWLESS       11
+#define NPVERS_HAS_XPCONNECT_SCRIPTING    13  /* Not implemented in WebKit */
+#define NPVERS_HAS_NPRUNTIME_SCRIPTING    14
+#define NPVERS_HAS_FORM_VALUES            15  /* Not implemented in WebKit; see bug 13061 */
+#define NPVERS_HAS_POPUPS_ENABLED_STATE   16  /* Not implemented in WebKit */
+#define NPVERS_HAS_RESPONSE_HEADERS       17
+#define NPVERS_HAS_NPOBJECT_ENUM          18
+
+
+/*----------------------------------------------------------------------*/
+/*             Function Prototypes                */
+/*----------------------------------------------------------------------*/
+
+#if defined(_WINDOWS) && !defined(WIN32)
+#define NP_LOADDS  _loadds
+#else
+#define NP_LOADDS
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * NPP_* functions are provided by the plugin and called by the navigator.
+ */
+
+#ifdef XP_UNIX
+char*                    NPP_GetMIMEDescription(void);
+#endif /* XP_UNIX */
+
+NPError     NPP_Initialize(void);
+void        NPP_Shutdown(void);
+NPError     NP_LOADDS    NPP_New(NPMIMEType pluginType, NPP instance,
+                                uint16 mode, int16 argc, char* argn[],
+                                char* argv[], NPSavedData* saved);
+NPError     NP_LOADDS    NPP_Destroy(NPP instance, NPSavedData** save);
+NPError     NP_LOADDS    NPP_SetWindow(NPP instance, NPWindow* window);
+NPError     NP_LOADDS    NPP_NewStream(NPP instance, NPMIMEType type,
+                                      NPStream* stream, NPBool seekable,
+                                      uint16* stype);
+NPError     NP_LOADDS    NPP_DestroyStream(NPP instance, NPStream* stream,
+                                          NPReason reason);
+int32        NP_LOADDS    NPP_WriteReady(NPP instance, NPStream* stream);
+int32        NP_LOADDS    NPP_Write(NPP instance, NPStream* stream, int32 offset,
+                                  int32 len, void* buffer);
+void        NP_LOADDS    NPP_StreamAsFile(NPP instance, NPStream* stream,
+                                         const char* fname);
+void        NP_LOADDS    NPP_Print(NPP instance, NPPrint* platformPrint);
+int16            NPP_HandleEvent(NPP instance, void* event);
+void        NP_LOADDS    NPP_URLNotify(NPP instance, const char* url,
+                                      NPReason reason, void* notifyData);
+jref        NP_LOADDS            NPP_GetJavaClass(void);
+NPError     NPP_GetValue(NPP instance, NPPVariable variable,
+                                     void *value);
+NPError     NPP_SetValue(NPP instance, NPNVariable variable,
+                                     void *value);
+
+/*
+ * NPN_* functions are provided by the navigator and called by the plugin.
+ */
+
+void        NPN_Version(int* plugin_major, int* plugin_minor,
+                            int* netscape_major, int* netscape_minor);
+NPError     NPN_GetURLNotify(NPP instance, const char* url,
+                                 const char* target, void* notifyData);
+NPError     NPN_GetURL(NPP instance, const char* url,
+                           const char* target);
+NPError     NPN_PostURLNotify(NPP instance, const char* url,
+                                  const char* target, uint32 len,
+                                  const char* buf, NPBool file,
+                                  void* notifyData);
+NPError     NPN_PostURL(NPP instance, const char* url,
+                            const char* target, uint32 len,
+                            const char* buf, NPBool file);
+NPError     NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
+NPError     NPN_NewStream(NPP instance, NPMIMEType type,
+                              const char* target, NPStream** stream);
+int32        NPN_Write(NPP instance, NPStream* stream, int32 len,
+                          void* buffer);
+NPError     NPN_DestroyStream(NPP instance, NPStream* stream,
+                                  NPReason reason);
+void        NPN_Status(NPP instance, const char* message);
+const char*    NPN_UserAgent(NPP instance);
+void*        NPN_MemAlloc(uint32 size);
+void        NPN_MemFree(void* ptr);
+uint32        NPN_MemFlush(uint32 size);
+void        NPN_ReloadPlugins(NPBool reloadPages);
+JRIEnv*     NPN_GetJavaEnv(void);
+jref        NPN_GetJavaPeer(NPP instance);
+NPError     NPN_GetValue(NPP instance, NPNVariable variable,
+                             void *value);
+NPError     NPN_SetValue(NPP instance, NPPVariable variable,
+                             void *value);
+void        NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
+void        NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
+void        NPN_ForceRedraw(NPP instance);
+void        NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
+void        NPN_PopPopupsEnabledState(NPP instance);
+
+#ifdef __cplusplus
+}  /* end extern "C" */
+#endif
+
+#endif // ENABLE(NETSCAPE_API)
+
+#endif /* _NPAPI_H_ */
diff --git a/bindings/npruntime.cpp b/bindings/npruntime.cpp
new file mode 100644
index 0000000..0413879
--- /dev/null
+++ b/bindings/npruntime.cpp
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(NETSCAPE_API)
+
+#include "npruntime_internal.h"
+#include "npruntime_impl.h"
+#include "npruntime_priv.h"
+
+#include "JSLock.h"
+#include "c_utility.h"
+#include "identifier.h"
+#include 
+#include 
+
+using namespace KJS::Bindings;
+
+typedef HashMap, PrivateIdentifier*> StringIdentifierMap;
+
+static StringIdentifierMap* getStringIdentifierMap()
+{
+    static StringIdentifierMap* stringIdentifierMap = 0;
+    if (!stringIdentifierMap)
+        stringIdentifierMap = new StringIdentifierMap;
+    return stringIdentifierMap;
+}
+
+typedef HashMap IntIdentifierMap;
+
+static IntIdentifierMap* getIntIdentifierMap()
+{
+    static IntIdentifierMap* intIdentifierMap = 0;
+    if (!intIdentifierMap)
+        intIdentifierMap = new IntIdentifierMap;
+    return intIdentifierMap;
+}
+
+NPIdentifier _NPN_GetStringIdentifier(const NPUTF8* name)
+{
+    ASSERT(name);
+    
+    if (name) {
+        PrivateIdentifier* identifier = 0;
+        
+        KJS::JSLock lock;
+        
+        identifier = getStringIdentifierMap()->get(identifierFromNPIdentifier(name).ustring().rep());
+        if (identifier == 0) {
+            identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
+            // We never release identifier names, so this dictionary will grow, as will
+            // the memory for the identifier name strings.
+            identifier->isString = true;
+            identifier->value.string = strdup(name);
+
+            getStringIdentifierMap()->set(identifierFromNPIdentifier(name).ustring().rep(), identifier);
+        }
+        return (NPIdentifier)identifier;
+    }
+    
+    return 0;
+}
+
+void _NPN_GetStringIdentifiers(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers)
+{
+    ASSERT(names);
+    ASSERT(identifiers);
+    
+    if (names && identifiers)
+        for (int i = 0; i < nameCount; i++)
+            identifiers[i] = _NPN_GetStringIdentifier(names[i]);
+}
+
+NPIdentifier _NPN_GetIntIdentifier(int32_t intid)
+{
+    PrivateIdentifier* identifier;
+
+    if (intid == 0 || intid == -1) {
+        static PrivateIdentifier* negativeOneAndZeroIdentifiers[2];
+
+        identifier = negativeOneAndZeroIdentifiers[intid + 1];
+        if (!identifier) {
+            identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
+            identifier->isString = false;
+            identifier->value.number = intid;
+
+            negativeOneAndZeroIdentifiers[intid + 1] = identifier;
+        }
+    } else {
+        identifier = getIntIdentifierMap()->get(intid);
+        if (!identifier) {
+            identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
+            // We never release identifier names, so this dictionary will grow.
+            identifier->isString = false;
+            identifier->value.number = intid;
+
+            getIntIdentifierMap()->set(intid, identifier);
+        }
+    }
+    return (NPIdentifier)identifier;
+}
+
+bool _NPN_IdentifierIsString(NPIdentifier identifier)
+{
+    PrivateIdentifier* i = (PrivateIdentifier*)identifier;
+    return i->isString;
+}
+
+NPUTF8 *_NPN_UTF8FromIdentifier(NPIdentifier identifier)
+{
+    PrivateIdentifier* i = (PrivateIdentifier*)identifier;
+    if (!i->isString || !i->value.string)
+        return NULL;
+        
+    return (NPUTF8 *)strdup(i->value.string);
+}
+
+int32_t _NPN_IntFromIdentifier(NPIdentifier identifier)
+{
+    PrivateIdentifier* i = (PrivateIdentifier*)identifier;
+    if (!i->isString)
+        return 0;
+    return i->value.number;
+}
+
+void NPN_InitializeVariantWithStringCopy(NPVariant* variant, const NPString* value)
+{
+    variant->type = NPVariantType_String;
+    variant->value.stringValue.UTF8Length = value->UTF8Length;
+    variant->value.stringValue.UTF8Characters = (NPUTF8 *)malloc(sizeof(NPUTF8) * value->UTF8Length);
+    memcpy((void*)variant->value.stringValue.UTF8Characters, value->UTF8Characters, sizeof(NPUTF8) * value->UTF8Length);
+}
+
+void _NPN_ReleaseVariantValue(NPVariant* variant)
+{
+    ASSERT(variant);
+
+    if (variant->type == NPVariantType_Object) {
+        _NPN_ReleaseObject(variant->value.objectValue);
+        variant->value.objectValue = 0;
+    } else if (variant->type == NPVariantType_String) {
+        free((void*)variant->value.stringValue.UTF8Characters);
+        variant->value.stringValue.UTF8Characters = 0;
+        variant->value.stringValue.UTF8Length = 0;
+    }
+
+    variant->type = NPVariantType_Void;
+}
+
+NPObject *_NPN_CreateObject(NPP npp, NPClass* aClass)
+{
+    ASSERT(aClass);
+
+    if (aClass) {
+        NPObject* obj;
+        if (aClass->allocate != NULL)
+            obj = aClass->allocate(npp, aClass);
+        else
+            obj = (NPObject*)malloc(sizeof(NPObject));
+
+        obj->_class = aClass;
+        obj->referenceCount = 1;
+
+        return obj;
+    }
+
+    return 0;
+}
+
+NPObject* _NPN_RetainObject(NPObject* obj)
+{
+    ASSERT(obj);
+
+    if (obj)
+        obj->referenceCount++;
+
+    return obj;
+}
+
+void _NPN_ReleaseObject(NPObject* obj)
+{
+    ASSERT(obj);
+    ASSERT(obj->referenceCount >= 1);
+
+    if (obj && obj->referenceCount >= 1) {
+        if (--obj->referenceCount == 0)
+            _NPN_DeallocateObject(obj);
+    }
+}
+
+void _NPN_DeallocateObject(NPObject *obj)
+{
+    ASSERT(obj);
+
+    if (obj) {
+        if (obj->_class->deallocate)
+            obj->_class->deallocate(obj);
+        else
+            free(obj);
+    }
+}
+
+#endif // ENABLE(NETSCAPE_API)
diff --git a/bindings/npruntime.h b/bindings/npruntime.h
new file mode 100644
index 0000000..30b94da
--- /dev/null
+++ b/bindings/npruntime.h
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2004, Apple Computer, Inc. and The Mozilla Foundation. 
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla
+ * Foundation ("Mozilla") nor the names of their contributors may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR
+ * THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Revision 1 (March 4, 2004):
+ * Initial proposal.
+ *
+ * Revision 2 (March 10, 2004):
+ * All calls into script were made asynchronous.  Results are
+ * provided via the NPScriptResultFunctionPtr callback.
+ *
+ * Revision 3 (March 10, 2004):
+ * Corrected comments to not refer to class retain/release FunctionPtrs.
+ *
+ * Revision 4 (March 11, 2004):
+ * Added additional convenience NPN_SetExceptionWithUTF8().
+ * Changed NPHasPropertyFunctionPtr and NPHasMethodFunctionPtr to take NPClass
+ * pointers instead of NPObject pointers.
+ * Added NPIsValidIdentifier().
+ *
+ * Revision 5 (March 17, 2004):
+ * Added context parameter to result callbacks from ScriptObject functions.
+ *
+ * Revision 6 (March 29, 2004):
+ * Renamed functions implemented by user agent to NPN_*.  Removed _ from
+ * type names.
+ * Renamed "JavaScript" types to "Script".
+ *
+ * Revision 7 (April 21, 2004):
+ * NPIdentifier becomes a void*, was int32_t
+ * Remove NP_IsValidIdentifier, renamed NP_IdentifierFromUTF8 to NP_GetIdentifier
+ * Added NPVariant and modified functions to use this new type.
+ *
+ * Revision 8 (July 9, 2004):
+ * Updated to joint Apple-Mozilla license.
+ *
+ * Revision 9 (August 12, 2004):
+ * Changed NPVariantType enum values to form PVariantType_XXX
+ * Added NPP arguments to NPObject functions.
+ * Replaced NPVariant functions with macros.
+ */
+#ifndef _NP_RUNTIME_H_
+#define _NP_RUNTIME_H_
+
+#if ENABLE(NETSCAPE_API)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include "npapi.h"
+
+#if defined(XP_MACOSX) && defined(__LP64__)
+#error 64-bit Netscape plug-ins are not supported on Mac OS X
+#endif
+
+/*
+    This API is used to facilitate binding code written in C to script
+    objects.  The API in this header does not assume the presence of a
+    user agent.  That is, it can be used to bind C code to scripting
+    environments outside of the context of a user agent.
+    
+    However, the normal use of the this API is in the context of a
+    scripting environment running in a browser or other user agent.
+    In particular it is used to support the extended Netscape
+    script-ability API for plugins (NP-SAP).  NP-SAP is an extension
+    of the Netscape plugin API.  As such we have adopted the use of
+    the "NP" prefix for this API.
+
+    The following NP{N|P}Variables were added to the Netscape plugin
+    API (in npapi.h):
+
+    NPNVWindowNPObject
+    NPNVPluginElementNPObject
+    NPPVpluginScriptableNPObject
+
+    These variables are exposed through NPN_GetValue() and
+    NPP_GetValue() (respectively) and are used to establish the
+    initial binding between the user agent and native code.  The DOM
+    objects in the user agent can be examined and manipulated using
+    the NPN_ functions that operate on NPObjects described in this
+    header.
+
+    To the extent possible the assumptions about the scripting
+    language used by the scripting environment have been minimized.
+*/
+
+
+/*
+    Objects (non-primitive data) passed between 'C' and script is
+    always wrapped in an NPObject.  The 'interface' of an NPObject is
+    described by an NPClass.
+*/
+typedef struct NPObject NPObject;
+typedef struct NPClass NPClass;
+
+typedef char NPUTF8;
+typedef struct _NPString {
+    const NPUTF8 *UTF8Characters;
+    uint32_t UTF8Length;
+} NPString;
+  
+typedef enum {
+    NPVariantType_Void,
+    NPVariantType_Null,
+    NPVariantType_Bool,
+    NPVariantType_Int32,
+    NPVariantType_Double,
+    NPVariantType_String,
+    NPVariantType_Object
+} NPVariantType;
+
+typedef struct _NPVariant {
+    NPVariantType type;
+    union {
+        bool boolValue;
+        int32_t intValue;
+        double doubleValue;
+        NPString stringValue;
+        NPObject *objectValue;
+    } value;
+} NPVariant;
+
+/*
+    NPN_ReleaseVariantValue is called on all 'out' parameters references.
+    Specifically it is called on variants that are resultant out parameters
+    in NPGetPropertyFunctionPtr and NPInvokeFunctionPtr.  Resultant variants
+    from these two functions should be initialized using the
+    NPN_InitializeVariantXXX() functions.
+    
+    After calling NPReleaseVariantValue, the type of the variant will
+    be set to NPVariantUndefinedType.
+*/
+void NPN_ReleaseVariantValue (NPVariant *variant);
+
+#define NPVARIANT_IS_VOID(_v)    ((_v).type == NPVariantType_Void)
+#define NPVARIANT_IS_NULL(_v)    ((_v).type == NPVariantType_Null)
+#define NPVARIANT_IS_BOOLEAN(_v) ((_v).type == NPVariantType_Bool)
+#define NPVARIANT_IS_INT32(_v)   ((_v).type == NPVariantType_Int32)
+#define NPVARIANT_IS_DOUBLE(_v)  ((_v).type == NPVariantType_Double)
+#define NPVARIANT_IS_STRING(_v)  ((_v).type == NPVariantType_String)
+#define NPVARIANT_IS_OBJECT(_v)  ((_v).type == NPVariantType_Object)
+
+#define NPVARIANT_TO_BOOLEAN(_v) ((_v).value.boolValue)
+#define NPVARIANT_TO_INT32(_v)   ((_v).value.intValue)
+#define NPVARIANT_TO_DOUBLE(_v)  ((_v).value.doubleValue)
+#define NPVARIANT_TO_STRING(_v)  ((_v).value.stringValue)
+#define NPVARIANT_TO_OBJECT(_v)  ((_v).value.objectValue)
+
+#define NP_BEGIN_MACRO  do {
+#define NP_END_MACRO    } while (0)
+
+#define VOID_TO_NPVARIANT(_v)                NP_BEGIN_MACRO (_v).type = NPVariantType_Void; (_v).value.objectValue = NULL; NP_END_MACRO
+#define NULL_TO_NPVARIANT(_v)                NP_BEGIN_MACRO (_v).type = NPVariantType_Null; (_v).value.objectValue = NULL; NP_END_MACRO
+#define BOOLEAN_TO_NPVARIANT(_val, _v)       NP_BEGIN_MACRO (_v).type = NPVariantType_Bool; (_v).value.boolValue = !!(_val); NP_END_MACRO
+#define INT32_TO_NPVARIANT(_val, _v)         NP_BEGIN_MACRO (_v).type = NPVariantType_Int32; (_v).value.intValue = _val; NP_END_MACRO
+#define DOUBLE_TO_NPVARIANT(_val, _v)        NP_BEGIN_MACRO (_v).type = NPVariantType_Double; (_v).value.doubleValue = _val; NP_END_MACRO
+#define STRINGZ_TO_NPVARIANT(_val, _v)       NP_BEGIN_MACRO (_v).type = NPVariantType_String; NPString str = { _val, strlen(_val) }; (_v).value.stringValue = str; NP_END_MACRO
+#define STRINGN_TO_NPVARIANT(_val, _len, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_String; NPString str = { _val, _len }; (_v).value.stringValue = str; NP_END_MACRO
+#define OBJECT_TO_NPVARIANT(_val, _v)        NP_BEGIN_MACRO (_v).type = NPVariantType_Object; (_v).value.objectValue = _val; NP_END_MACRO
+
+/*
+        Type mappings (JavaScript types have been used for illustration
+    purposes):
+
+        JavaScript       to             C (NPVariant with type:)
+        undefined                       NPVariantType_Void
+        null                            NPVariantType_Null
+        Boolean                         NPVariantType_Bool
+        Number                          NPVariantType_Double or NPVariantType_Int32
+        String                          NPVariantType_String
+        Object                          NPVariantType_Object
+
+        C (NPVariant with type:)   to   JavaScript
+        NPVariantType_Void              undefined
+        NPVariantType_Null              null
+        NPVariantType_Bool              Boolean 
+        NPVariantType_Int32             Number
+        NPVariantType_Double            Number
+        NPVariantType_String            String
+        NPVariantType_Object            Object
+*/
+
+typedef void *NPIdentifier;
+
+/*
+    NPObjects have methods and properties.  Methods and properties are
+    identified with NPIdentifiers.  These identifiers may be reflected
+    in script.  NPIdentifiers can be either strings or integers, IOW,
+    methods and properties can be identified by either strings or
+    integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be
+    compared using ==.  In case of any errors, the requested
+    NPIdentifier(s) will be NULL.
+*/
+NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name);
+void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers);
+NPIdentifier NPN_GetIntIdentifier(int32_t intid);
+bool NPN_IdentifierIsString(NPIdentifier identifier);
+
+/*
+    The NPUTF8 returned from NPN_UTF8FromIdentifier SHOULD be freed.
+*/
+NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier);
+
+/*
+    Get the integer represented by identifier. If identifier is not an
+    integer identifier, the behaviour is undefined.
+*/
+int32_t NPN_IntFromIdentifier(NPIdentifier identifier);
+
+/*
+    NPObject behavior is implemented using the following set of
+    callback functions.
+
+    The NPVariant *result argument of these functions (where
+    applicable) should be released using NPN_ReleaseVariantValue().
+*/
+typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass);
+typedef void (*NPDeallocateFunctionPtr)(NPObject *obj);
+typedef void (*NPInvalidateFunctionPtr)(NPObject *obj);
+typedef bool (*NPHasMethodFunctionPtr)(NPObject *obj, NPIdentifier name);
+typedef bool (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result);
+typedef bool (*NPInvokeDefaultFunctionPtr)(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+typedef bool (*NPHasPropertyFunctionPtr)(NPObject *obj, NPIdentifier name);
+typedef bool (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result);
+typedef bool (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);
+typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj, NPIdentifier name);
+typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value, uint32_t *count);
+
+/*
+    NPObjects returned by create have a reference count of one.  It is the caller's responsibility
+    to release the returned object.
+
+    NPInvokeFunctionPtr function may return false to indicate a the method could not be invoked.
+    
+    NPGetPropertyFunctionPtr and NPSetPropertyFunctionPtr may return false to indicate a property doesn't
+    exist.
+    
+    NPInvalidateFunctionPtr is called by the scripting environment when the native code is
+    shutdown.  Any attempt to message a NPObject instance after the invalidate
+    callback has been called will result in undefined behavior, even if the
+    native code is still retaining those NPObject instances.
+    (The runtime will typically return immediately, with 0 or NULL, from an attempt to
+    dispatch to a NPObject, but this behavior should not be depended upon.)
+    
+    The NPEnumerationFunctionPtr function may pass an array of                  
+    NPIdentifiers back to the caller. The callee allocs the memory of           
+    the array using NPN_MemAlloc(), and it's the caller's responsibility        
+    to release it using NPN_MemFree().           
+*/
+struct NPClass
+{
+    uint32_t structVersion;
+    NPAllocateFunctionPtr allocate;
+    NPDeallocateFunctionPtr deallocate;
+    NPInvalidateFunctionPtr invalidate;
+    NPHasMethodFunctionPtr hasMethod;
+    NPInvokeFunctionPtr invoke;
+    NPInvokeDefaultFunctionPtr invokeDefault;
+    NPHasPropertyFunctionPtr hasProperty;
+    NPGetPropertyFunctionPtr getProperty;
+    NPSetPropertyFunctionPtr setProperty;
+    NPRemovePropertyFunctionPtr removeProperty;
+    NPEnumerationFunctionPtr enumerate;
+};
+
+#define NP_CLASS_STRUCT_VERSION      2
+#define NP_CLASS_STRUCT_VERSION_ENUM 2                           
+#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass)   \
+    ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM)
+
+struct NPObject {
+    NPClass *_class;
+    uint32_t referenceCount;
+    // Additional space may be allocated here by types of NPObjects
+};
+
+/*
+    If the class has an allocate function, NPN_CreateObject invokes that function,
+    otherwise a NPObject is allocated and returned.  If a class has an allocate
+    function it is the responsibility of that implementation to set the initial retain
+    count to 1.
+*/
+NPObject *NPN_CreateObject(NPP npp, NPClass *aClass);
+
+/*
+    Increment the NPObject's reference count.
+*/
+NPObject *NPN_RetainObject (NPObject *obj);
+
+/*
+    Decremented the NPObject's reference count.  If the reference
+    count goes to zero, the class's destroy function is invoke if
+    specified, otherwise the object is freed directly.
+*/
+void NPN_ReleaseObject (NPObject *obj);
+
+/*
+    Functions to access script objects represented by NPObject.
+
+    Calls to script objects are synchronous.  If a function returns a
+    value, it will be supplied via the result NPVariant
+    argument. Successful calls will return true, false will be
+    returned in case of an error.
+    
+    Calls made from plugin code to script must be made from the thread
+    on which the plugin was initialized.
+*/
+bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result);
+bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, NPVariant *result);
+bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result);
+bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value);
+bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
+bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
+bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
+bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
+
+/*
+    NPN_SetException may be called to trigger a script exception upon return
+    from entry points into NPObjects.
+*/
+void NPN_SetException (NPObject *obj, const NPUTF8 *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ENABLE(NETSCAPE_API)
+
+#endif
diff --git a/bindings/npruntime_impl.h b/bindings/npruntime_impl.h
new file mode 100644
index 0000000..17f6d1c
--- /dev/null
+++ b/bindings/npruntime_impl.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef _NP_RUNTIME_IMPL_H_
+#define _NP_RUNTIME_IMPL_H_
+
+#if ENABLE(NETSCAPE_API)
+
+#include "npruntime_internal.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void _NPN_ReleaseVariantValue(NPVariant *variant);
+extern NPIdentifier _NPN_GetStringIdentifier(const NPUTF8 *name);
+extern void _NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers);
+extern NPIdentifier _NPN_GetIntIdentifier(int32_t intid);
+extern bool _NPN_IdentifierIsString(NPIdentifier identifier);
+extern NPUTF8 *_NPN_UTF8FromIdentifier(NPIdentifier identifier);
+extern int32_t _NPN_IntFromIdentifier(NPIdentifier identifier);    
+extern NPObject *_NPN_CreateObject(NPP npp, NPClass *aClass);
+extern NPObject *_NPN_RetainObject(NPObject *obj);
+extern void _NPN_ReleaseObject(NPObject *obj);
+extern void _NPN_DeallocateObject(NPObject *obj);
+extern bool _NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result);
+extern bool _NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+extern bool _NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, NPVariant *result);
+extern bool _NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result);
+extern bool _NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value);
+extern bool _NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
+extern bool _NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
+extern bool _NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
+extern void _NPN_SetException(NPObject *obj, const NPUTF8 *message);
+extern bool _NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
+
+#ifdef __cplusplus
+}  /* end extern "C" */
+#endif
+
+#endif // ENABLE(NETSCAPE_API)
+
+#endif
diff --git a/bindings/npruntime_internal.h b/bindings/npruntime_internal.h
new file mode 100644
index 0000000..f5357cd
--- /dev/null
+++ b/bindings/npruntime_internal.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2007 Collabora, Ltd.  All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * This is a internal include header for npapi.h
+ *
+ * Some of the #defines which are in X11 headers conflict with type and enum
+ * names in JavaScriptCore and WebCore
+ * This header #undefs those defines to fix the conflicts
+ * If you need to include npapi.h or npruntime.h when building on X11,
+ * include this file instead of the actual npapi.h or npruntime.h
+ */
+
+#include "npruntime.h"
+
+#ifdef XP_UNIX
+    #include 
+
+    #undef None
+    #undef Above
+    #undef Below
+    #undef Auto
+    #undef Complex
+    #undef Status
+#endif
diff --git a/bindings/npruntime_priv.h b/bindings/npruntime_priv.h
new file mode 100644
index 0000000..8df3871
--- /dev/null
+++ b/bindings/npruntime_priv.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef NP_RUNTIME_PRIV_H_
+#define NP_RUNTIME_PRIV_H_
+
+#if ENABLE(NETSCAPE_API)
+
+#include "npruntime_internal.h"
+
+/*
+    NPN_InitializeVariantWithStringCopy() will copy string data.  The string data
+    will be deallocated by calls to NPReleaseVariantValue().
+*/
+void NPN_InitializeVariantWithStringCopy(NPVariant*, const NPString*);
+
+#endif // ENABLE(NETSCAPE_API)
+#endif
+
diff --git a/bindings/objc/WebScriptObject.h b/bindings/objc/WebScriptObject.h
new file mode 100644
index 0000000..14d77d7
--- /dev/null
+++ b/bindings/objc/WebScriptObject.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import 
+
+#include "internal.h"
+#include "runtime_root.h"
+
+@class WebUndefined;
+
+@protocol WebScriptObject
++ (NSString *)webScriptNameForSelector:(SEL)aSelector;
++ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector;
++ (NSString *)webScriptNameForKey:(const char *)name;
++ (BOOL)isKeyExcludedFromWebScript:(const char *)name;
+
++ (id)_convertValueToObjcValue:(KJS::JSValue *)value originRootObject:(KJS::Bindings::RootObject*)originRootObject rootObject:(KJS::Bindings::RootObject*)rootObject;
+- _initWithJSObject:(KJS::JSObject*)imp originRootObject:(PassRefPtr)originRootObject rootObject:(PassRefPtr)rootObject;
+- (KJS::JSObject *)_imp;
+@end
+
+@protocol WebUndefined
++ (WebUndefined *)undefined;
+@end
diff --git a/bindings/objc/objc_class.h b/bindings/objc/objc_class.h
new file mode 100644
index 0000000..3faee18
--- /dev/null
+++ b/bindings/objc/objc_class.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef KJS_BINDINGS_OBJC_CLASS_H
+#define KJS_BINDINGS_OBJC_CLASS_H
+
+#include 
+
+namespace KJS {
+namespace Bindings {
+
+class ObjcClass : public Class
+{
+protected:
+    ObjcClass (ClassStructPtr aClass); // Use classForIsA to create an ObjcClass.
+    
+public:
+    // Return the cached ObjC of the specified name.
+    static ObjcClass *classForIsA(ClassStructPtr);
+    
+    virtual const char *name() const;
+    
+    virtual MethodList methodsNamed(const Identifier&, Instance *instance) const;
+    virtual Field *fieldNamed(const Identifier&, Instance *instance) const;
+
+    virtual JSValue *fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
+    
+    ClassStructPtr isa() { return _isa; }
+    
+private:
+    ClassStructPtr _isa;
+    RetainPtr _methods;
+    RetainPtr _fields;
+};
+
+} // namespace Bindings
+} // namespace KJS
+
+#endif
diff --git a/bindings/objc/objc_class.mm b/bindings/objc/objc_class.mm
new file mode 100644
index 0000000..9a6d48c
--- /dev/null
+++ b/bindings/objc/objc_class.mm
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "objc_class.h"
+
+#include "objc_instance.h"
+#include "WebScriptObject.h"
+
+namespace KJS {
+namespace Bindings {
+    
+static void deleteMethod(CFAllocatorRef, const void* value)
+{
+    delete static_cast(value);
+}
+    
+static void deleteField(CFAllocatorRef, const void* value)
+{
+    delete static_cast(value);
+}
+
+const CFDictionaryValueCallBacks MethodDictionaryValueCallBacks = { 0, 0, &deleteMethod, 0 , 0 };
+const CFDictionaryValueCallBacks FieldDictionaryValueCallBacks = { 0, 0, &deleteField, 0 , 0 };    
+    
+ObjcClass::ObjcClass(ClassStructPtr aClass)
+    : _isa(aClass)
+    , _methods(AdoptCF, CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &MethodDictionaryValueCallBacks))
+    , _fields(AdoptCF, CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &FieldDictionaryValueCallBacks))
+{
+}
+
+static CFMutableDictionaryRef classesByIsA = 0;
+
+static void _createClassesByIsAIfNecessary()
+{
+    if (!classesByIsA)
+        classesByIsA = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
+}
+
+ObjcClass* ObjcClass::classForIsA(ClassStructPtr isa)
+{
+    _createClassesByIsAIfNecessary();
+
+    ObjcClass* aClass = (ObjcClass*)CFDictionaryGetValue(classesByIsA, isa);
+    if (!aClass) {
+        aClass = new ObjcClass(isa);
+        CFDictionaryAddValue(classesByIsA, isa, aClass);
+    }
+
+    return aClass;
+}
+
+const char* ObjcClass::name() const
+{
+    return object_getClassName(_isa);
+}
+
+MethodList ObjcClass::methodsNamed(const Identifier& identifier, Instance*) const
+{
+    MethodList methodList;
+    char fixedSizeBuffer[1024];
+    char* buffer = fixedSizeBuffer;
+    const char* JSName = identifier.ascii();
+    if (!convertJSMethodNameToObjc(JSName, buffer, sizeof(fixedSizeBuffer))) {
+        int length = strlen(JSName) + 1;
+        buffer = new char[length];
+        if (!buffer || !convertJSMethodNameToObjc(JSName, buffer, length))
+            return methodList;
+    }
+
+    
+    RetainPtr methodName(AdoptCF, CFStringCreateWithCString(NULL, buffer, kCFStringEncodingASCII));
+    Method* method = (Method*)CFDictionaryGetValue(_methods.get(), methodName.get());
+    if (method) {
+        methodList.append(method);
+        return methodList;
+    }
+
+    ClassStructPtr thisClass = _isa;
+    while (thisClass && methodList.isEmpty()) {
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+        unsigned numMethodsInClass = 0;
+        MethodStructPtr* objcMethodList = class_copyMethodList(thisClass, &numMethodsInClass);
+#else
+        void* iterator = 0;
+        struct objc_method_list* objcMethodList;
+        while ((objcMethodList = class_nextMethodList(thisClass, &iterator))) {
+            unsigned numMethodsInClass = objcMethodList->method_count;
+#endif
+            for (unsigned i = 0; i < numMethodsInClass; i++) {
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+                MethodStructPtr objcMethod = objcMethodList[i];
+                SEL objcMethodSelector = method_getName(objcMethod);
+#else
+                struct objc_method* objcMethod = &objcMethodList->method_list[i];
+                SEL objcMethodSelector = objcMethod->method_name;
+#endif
+                const char* objcMethodSelectorName = sel_getName(objcMethodSelector);
+                NSString* mappedName = nil;
+
+                // See if the class wants to exclude the selector from visibility in JavaScript.
+                if ([thisClass respondsToSelector:@selector(isSelectorExcludedFromWebScript:)])
+                    if ([thisClass isSelectorExcludedFromWebScript:objcMethodSelector])
+                        continue;
+
+                // See if the class want to provide a different name for the selector in JavaScript.
+                // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity
+                // of the class.
+                if ([thisClass respondsToSelector:@selector(webScriptNameForSelector:)])
+                    mappedName = [thisClass webScriptNameForSelector:objcMethodSelector];
+
+                if ((mappedName && [mappedName isEqual:(NSString*)methodName.get()]) || strcmp(objcMethodSelectorName, buffer) == 0) {
+                    Method* aMethod = new ObjcMethod(thisClass, objcMethodSelectorName); // deleted when the dictionary is destroyed
+                    CFDictionaryAddValue(_methods.get(), methodName.get(), aMethod);
+                    methodList.append(aMethod);
+                    break;
+                }
+            }
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+            thisClass = class_getSuperclass(thisClass);
+            free(objcMethodList);
+#else
+        }
+        thisClass = thisClass->super_class;
+#endif
+    }
+
+    if (buffer != fixedSizeBuffer)
+        delete [] buffer;
+
+    return methodList;
+}
+
+Field* ObjcClass::fieldNamed(const Identifier& identifier, Instance* instance) const
+{
+    ClassStructPtr thisClass = _isa;
+
+    const char* name = identifier.ascii();
+    RetainPtr fieldName(AdoptCF, CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII));
+    Field* aField = (Field*)CFDictionaryGetValue(_fields.get(), fieldName.get());
+    if (aField)
+        return aField;
+
+    id targetObject = (static_cast(instance))->getObject();
+    id attributes = [targetObject respondsToSelector:@selector(attributeKeys)] ? [targetObject performSelector:@selector(attributeKeys)] : nil;
+    if (attributes) {
+        // Class overrides attributeKeys, use that array of key names.
+        unsigned count = [attributes count];
+        for (unsigned i = 0; i < count; i++) {
+            NSString* keyName = [attributes objectAtIndex:i];
+            const char* UTF8KeyName = [keyName UTF8String]; // ObjC actually only supports ASCII names.
+
+            // See if the class wants to exclude the selector from visibility in JavaScript.
+            if ([thisClass respondsToSelector:@selector(isKeyExcludedFromWebScript:)])
+                if ([thisClass isKeyExcludedFromWebScript:UTF8KeyName])
+                    continue;
+
+            // See if the class want to provide a different name for the selector in JavaScript.
+            // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity
+            // of the class.
+            NSString* mappedName = nil;
+            if ([thisClass respondsToSelector:@selector(webScriptNameForKey:)])
+                mappedName = [thisClass webScriptNameForKey:UTF8KeyName];
+
+            if ((mappedName && [mappedName isEqual:(NSString*)fieldName.get()]) || [keyName isEqual:(NSString*)fieldName.get()]) {
+                aField = new ObjcField((CFStringRef)keyName); // deleted when the dictionary is destroyed
+                CFDictionaryAddValue(_fields.get(), fieldName.get(), aField);
+                break;
+            }
+        }
+    } else {
+        // Class doesn't override attributeKeys, so fall back on class runtime
+        // introspection.
+
+        while (thisClass) {
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+            unsigned numFieldsInClass = 0;
+            IvarStructPtr* ivarsInClass = class_copyIvarList(thisClass, &numFieldsInClass);
+#else
+            struct objc_ivar_list* fieldsInClass = thisClass->ivars;
+            if (fieldsInClass) {
+                unsigned numFieldsInClass = fieldsInClass->ivar_count;
+#endif
+                for (unsigned i = 0; i < numFieldsInClass; i++) {
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+                    IvarStructPtr objcIVar = ivarsInClass[i];
+                    const char* objcIvarName = ivar_getName(objcIVar);
+#else
+                    IvarStructPtr objcIVar = &fieldsInClass->ivar_list[i];
+                    const char* objcIvarName = objcIVar->ivar_name;
+#endif
+                    NSString* mappedName = 0;
+
+                    // See if the class wants to exclude the selector from visibility in JavaScript.
+                    if ([thisClass respondsToSelector:@selector(isKeyExcludedFromWebScript:)])
+                        if ([thisClass isKeyExcludedFromWebScript:objcIvarName])
+                            continue;
+
+                    // See if the class want to provide a different name for the selector in JavaScript.
+                    // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity
+                    // of the class.
+                    if ([thisClass respondsToSelector:@selector(webScriptNameForKey:)])
+                        mappedName = [thisClass webScriptNameForKey:objcIvarName];
+
+                    if ((mappedName && [mappedName isEqual:(NSString*)fieldName.get()]) || strcmp(objcIvarName, name) == 0) {
+                        aField = new ObjcField(objcIVar); // deleted when the dictionary is destroyed
+                        CFDictionaryAddValue(_fields.get(), fieldName.get(), aField);
+                        break;
+                    }
+                }
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+            thisClass = class_getSuperclass(thisClass);
+            free(ivarsInClass);
+#else
+            }
+            thisClass = thisClass->super_class;
+#endif
+        }
+    }
+
+    return aField;
+}
+
+JSValue* ObjcClass::fallbackObject(ExecState*, Instance* instance, const Identifier &propertyName)
+{
+    ObjcInstance* objcInstance = static_cast(instance);
+    id targetObject = objcInstance->getObject();
+    
+    if (![targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
+        return jsUndefined();
+    return new ObjcFallbackObjectImp(objcInstance, propertyName);
+}
+
+}
+}
diff --git a/bindings/objc/objc_header.h b/bindings/objc/objc_header.h
new file mode 100644
index 0000000..07954a1
--- /dev/null
+++ b/bindings/objc/objc_header.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef KJS_BINDINGS_OBJC_HEADER_H
+#define KJS_BINDINGS_OBJC_HEADER_H
+
+#ifdef __OBJC__
+
+#include 
+#include 
+#include 
+
+typedef Class ClassStructPtr;
+typedef id ObjectStructPtr;
+typedef Method MethodStructPtr;
+typedef Ivar IvarStructPtr;
+
+@class NSMethodSignature;
+
+#else
+
+typedef struct objc_class* ClassStructPtr;
+typedef struct objc_object* ObjectStructPtr;
+typedef struct objc_method* MethodStructPtr;
+typedef struct objc_ivar* IvarStructPtr;
+
+class NSMethodSignature;
+
+#endif
+
+#endif
diff --git a/bindings/objc/objc_instance.h b/bindings/objc/objc_instance.h
new file mode 100644
index 0000000..2233791
--- /dev/null
+++ b/bindings/objc/objc_instance.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef BINDINGS_OBJC_INSTANCE_H_
+#define BINDINGS_OBJC_INSTANCE_H_
+
+#include 
+#include 
+
+namespace KJS {
+
+namespace Bindings {
+
+class ObjcClass;
+
+class ObjcInstance : public Instance {
+public:
+    ObjcInstance(ObjectStructPtr instance, PassRefPtr);
+        
+    ~ObjcInstance();
+    
+    virtual Class *getClass() const;
+    
+    virtual void begin();
+    virtual void end();
+    
+    virtual JSValue *valueOf() const;
+    virtual JSValue *defaultValue(JSType hint) const;
+
+    virtual bool implementsCall() const;
+    
+    virtual JSValue *invokeMethod(ExecState *exec, const MethodList &method, const List &args);
+    virtual JSValue *invokeDefaultMethod(ExecState *exec, const List &args);
+
+    virtual bool supportsSetValueOfUndefinedField();
+    virtual void setValueOfUndefinedField(ExecState *exec, const Identifier &property, JSValue *aValue);
+    
+    virtual JSValue *getValueOfUndefinedField(ExecState *exec, const Identifier &property, JSType hint) const;
+
+    ObjectStructPtr getObject() const { return _instance.get(); }
+    
+    JSValue *stringValue() const;
+    JSValue *numberValue() const;
+    JSValue *booleanValue() const;
+
+    virtual BindingLanguage getBindingLanguage() const { return ObjectiveCLanguage; }
+
+private:
+    RetainPtr _instance;
+    mutable ObjcClass *_class;
+    ObjectStructPtr _pool;
+    int _beginCount;
+};
+
+} // namespace Bindings
+
+} // namespace KJS
+
+#endif // BINDINGS_OBJC_INSTANCE_H_
diff --git a/bindings/objc/objc_instance.mm b/bindings/objc/objc_instance.mm
new file mode 100644
index 0000000..57ebfe8
--- /dev/null
+++ b/bindings/objc/objc_instance.mm
@@ -0,0 +1,349 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "objc_instance.h"
+
+#import "WebScriptObject.h"
+#include 
+
+#ifdef NDEBUG
+#define OBJC_LOG(formatAndArgs...) ((void)0)
+#else
+#define OBJC_LOG(formatAndArgs...) { \
+    fprintf (stderr, "%s:%d -- %s:  ", __FILE__, __LINE__, __FUNCTION__); \
+    fprintf(stderr, formatAndArgs); \
+}
+#endif
+
+using namespace KJS::Bindings;
+using namespace KJS;
+
+ObjcInstance::ObjcInstance(ObjectStructPtr instance, PassRefPtr rootObject) 
+    : Instance(rootObject)
+    , _instance(instance)
+    , _class(0)
+    , _pool(0)
+    , _beginCount(0)
+{
+}
+
+ObjcInstance::~ObjcInstance() 
+{
+    begin(); // -finalizeForWebScript and -dealloc/-finalize may require autorelease pools.
+    if ([_instance.get() respondsToSelector:@selector(finalizeForWebScript)])
+        [_instance.get() performSelector:@selector(finalizeForWebScript)];
+    _instance = 0;
+    end();
+}
+
+void ObjcInstance::begin()
+{
+    if (!_pool)
+        _pool = [[NSAutoreleasePool alloc] init];
+    _beginCount++;
+}
+
+void ObjcInstance::end()
+{
+    _beginCount--;
+    ASSERT(_beginCount >= 0);
+    if (!_beginCount) {
+        [_pool drain];
+        _pool = 0;
+    }
+}
+
+Bindings::Class* ObjcInstance::getClass() const 
+{
+    if (!_instance)
+        return 0;
+    if (!_class)
+        _class = ObjcClass::classForIsA(_instance->isa);
+    return static_cast(_class);
+}
+
+bool ObjcInstance::implementsCall() const
+{
+    return [_instance.get() respondsToSelector:@selector(invokeDefaultMethodWithArguments:)];
+}
+
+JSValue* ObjcInstance::invokeMethod(ExecState* exec, const MethodList &methodList, const List &args)
+{
+    JSValue* result = jsUndefined();
+    
+   JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly.
+
+    // Overloading methods is not allowed in ObjectiveC.  Should only be one
+    // name match for a particular method.
+    ASSERT(methodList.size() == 1);
+
+@try {
+    ObjcMethod* method = 0;
+    method = static_cast(methodList[0]);
+    NSMethodSignature* signature = method->getMethodSignature();
+    NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature];
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+    [invocation setSelector:sel_registerName(method->name())];
+#else
+    [invocation setSelector:(SEL)method->name()];
+#endif
+    [invocation setTarget:_instance.get()];
+
+    if (method->isFallbackMethod()) {
+        if (objcValueTypeForType([signature methodReturnType]) != ObjcObjectType) {
+            NSLog(@"Incorrect signature for invokeUndefinedMethodFromWebScript:withArguments: -- return type must be object.");
+            return result;
+        }
+
+        // Invoke invokeUndefinedMethodFromWebScript:withArguments:, pass JavaScript function
+        // name as first (actually at 2) argument and array of args as second.
+        NSString* jsName = (NSString* )method->javaScriptName();
+        [invocation setArgument:&jsName atIndex:2];
+
+        NSMutableArray* objcArgs = [NSMutableArray array];
+        int count = args.size();
+        for (int i = 0; i < count; i++) {
+            ObjcValue value = convertValueToObjcValue(exec, args.at(i), ObjcObjectType);
+            [objcArgs addObject:value.objectValue];
+        }
+        [invocation setArgument:&objcArgs atIndex:3];
+    } else {
+        unsigned count = [signature numberOfArguments];
+        for (unsigned i = 2; i < count ; i++) {
+            const char* type = [signature getArgumentTypeAtIndex:i];
+            ObjcValueType objcValueType = objcValueTypeForType(type);
+
+            // Must have a valid argument type.  This method signature should have
+            // been filtered already to ensure that it has acceptable argument
+            // types.
+            ASSERT(objcValueType != ObjcInvalidType && objcValueType != ObjcVoidType);
+
+            ObjcValue value = convertValueToObjcValue(exec, args.at(i-2), objcValueType);
+
+            switch (objcValueType) {
+                case ObjcObjectType:
+                    [invocation setArgument:&value.objectValue atIndex:i];
+                    break;
+                case ObjcCharType:
+                case ObjcUnsignedCharType:
+                    [invocation setArgument:&value.charValue atIndex:i];
+                    break;
+                case ObjcShortType:
+                case ObjcUnsignedShortType:
+                    [invocation setArgument:&value.shortValue atIndex:i];
+                    break;
+                case ObjcIntType:
+                case ObjcUnsignedIntType:
+                    [invocation setArgument:&value.intValue atIndex:i];
+                    break;
+                case ObjcLongType:
+                case ObjcUnsignedLongType:
+                    [invocation setArgument:&value.longValue atIndex:i];
+                    break;
+                case ObjcLongLongType:
+                case ObjcUnsignedLongLongType:
+                    [invocation setArgument:&value.longLongValue atIndex:i];
+                    break;
+                case ObjcFloatType:
+                    [invocation setArgument:&value.floatValue atIndex:i];
+                    break;
+                case ObjcDoubleType:
+                    [invocation setArgument:&value.doubleValue atIndex:i];
+                    break;
+                default:
+                    // Should never get here.  Argument types are filtered (and
+                    // the assert above should have fired in the impossible case
+                    // of an invalid type anyway).
+                    fprintf(stderr, "%s: invalid type (%d)\n", __PRETTY_FUNCTION__, (int)objcValueType);
+                    ASSERT(false);
+            }
+        }
+    }
+
+    [invocation invoke];
+
+    // Get the return value type.
+    const char* type = [signature methodReturnType];
+    ObjcValueType objcValueType = objcValueTypeForType(type);
+
+    // Must have a valid return type.  This method signature should have
+    // been filtered already to ensure that it have an acceptable return
+    // type.
+    ASSERT(objcValueType != ObjcInvalidType);
+
+    // Get the return value and convert it to a JavaScript value. Length
+    // of return value will never exceed the size of largest scalar
+    // or a pointer.
+    char buffer[1024];
+    ASSERT([signature methodReturnLength] < 1024);
+
+    if (*type != 'v') {
+        [invocation getReturnValue:buffer];
+        result = convertObjcValueToValue(exec, buffer, objcValueType, _rootObject.get());
+    }
+} @catch(NSException* localException) {
+}
+    return result;
+}
+
+JSValue* ObjcInstance::invokeDefaultMethod(ExecState* exec, const List &args)
+{
+    JSValue* result = jsUndefined();
+
+   JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly.
+
+@try {
+    if (![_instance.get() respondsToSelector:@selector(invokeDefaultMethodWithArguments:)])
+        return result;
+
+    NSMethodSignature* signature = [_instance.get() methodSignatureForSelector:@selector(invokeDefaultMethodWithArguments:)];
+    NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature];
+    [invocation setSelector:@selector(invokeDefaultMethodWithArguments:)];
+    [invocation setTarget:_instance.get()];
+
+    if (objcValueTypeForType([signature methodReturnType]) != ObjcObjectType) {
+        NSLog(@"Incorrect signature for invokeDefaultMethodWithArguments: -- return type must be object.");
+        return result;
+    }
+
+    NSMutableArray* objcArgs = [NSMutableArray array];
+    unsigned count = args.size();
+    for (unsigned i = 0; i < count; i++) {
+        ObjcValue value = convertValueToObjcValue(exec, args.at(i), ObjcObjectType);
+        [objcArgs addObject:value.objectValue];
+    }
+    [invocation setArgument:&objcArgs atIndex:2];
+
+    [invocation invoke];
+
+    // Get the return value type, should always be "@" because of
+    // check above.
+    const char* type = [signature methodReturnType];
+    ObjcValueType objcValueType = objcValueTypeForType(type);
+
+    // Get the return value and convert it to a JavaScript value. Length
+    // of return value will never exceed the size of a pointer, so we're
+    // OK with 32 here.
+    char buffer[32];
+    [invocation getReturnValue:buffer];
+    result = convertObjcValueToValue(exec, buffer, objcValueType, _rootObject.get());
+} @catch(NSException* localException) {
+}
+
+    return result;
+}
+
+bool ObjcInstance::supportsSetValueOfUndefinedField()
+{
+    id targetObject = getObject();
+    if ([targetObject respondsToSelector:@selector(setValue:forUndefinedKey:)])
+        return true;
+    return false;
+}
+
+void ObjcInstance::setValueOfUndefinedField(ExecState* exec, const Identifier &property, JSValue* aValue)
+{
+    id targetObject = getObject();
+
+   JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly.
+
+    // This check is not really necessary because NSObject implements
+    // setValue:forUndefinedKey:, and unfortnately the default implementation
+    // throws an exception.
+    if ([targetObject respondsToSelector:@selector(setValue:forUndefinedKey:)]){
+        ObjcValue objcValue = convertValueToObjcValue(exec, aValue, ObjcObjectType);
+
+        @try {
+            [targetObject setValue:objcValue.objectValue forUndefinedKey:[NSString stringWithCString:property.ascii() encoding:NSASCIIStringEncoding]];
+        } @catch(NSException* localException) {
+            // Do nothing.  Class did not override valueForUndefinedKey:.
+        }
+    }
+}
+
+JSValue* ObjcInstance::getValueOfUndefinedField(ExecState* exec, const Identifier& property, JSType) const
+{
+    JSValue* result = jsUndefined();
+    
+    id targetObject = getObject();
+
+   JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly.
+
+    // This check is not really necessary because NSObject implements
+    // valueForUndefinedKey:, and unfortnately the default implementation
+    // throws an exception.
+    if ([targetObject respondsToSelector:@selector(valueForUndefinedKey:)]){
+        @try {
+            id objcValue = [targetObject valueForUndefinedKey:[NSString stringWithCString:property.ascii() encoding:NSASCIIStringEncoding]];
+            result = convertObjcValueToValue(exec, &objcValue, ObjcObjectType, _rootObject.get());
+        } @catch(NSException* localException) {
+            // Do nothing.  Class did not override valueForUndefinedKey:.
+        }
+    }
+
+    return result;
+}
+
+JSValue* ObjcInstance::defaultValue(JSType hint) const
+{
+    switch (hint) {
+    case StringType:
+        return stringValue();
+    case NumberType:
+        return numberValue();
+    case BooleanType:
+        return booleanValue();
+    case UnspecifiedType:
+        if ([_instance.get() isKindOfClass:[NSString class]])
+            return stringValue();
+        if ([_instance.get() isKindOfClass:[NSNumber class]])
+            return numberValue();
+    default:
+        return valueOf();
+    }
+}
+
+JSValue* ObjcInstance::stringValue() const
+{
+    return convertNSStringToString([getObject() description]);
+}
+
+JSValue* ObjcInstance::numberValue() const
+{
+    // FIXME:  Implement something sensible
+    return jsNumber(0);
+}
+
+JSValue* ObjcInstance::booleanValue() const
+{
+    // FIXME:  Implement something sensible
+    return jsBoolean(false);
+}
+
+JSValue* ObjcInstance::valueOf() const 
+{
+    return stringValue();
+}
diff --git a/bindings/objc/objc_runtime.h b/bindings/objc/objc_runtime.h
new file mode 100644
index 0000000..1151d53
--- /dev/null
+++ b/bindings/objc/objc_runtime.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef KJS_BINDINGS_OBJC_RUNTIME_H
+#define KJS_BINDINGS_OBJC_RUNTIME_H
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+namespace KJS {
+namespace Bindings {
+
+extern ClassStructPtr webScriptObjectClass();
+extern ClassStructPtr webUndefinedClass();
+
+class ObjcInstance;
+
+class ObjcField : public Field
+{
+public:
+    ObjcField(IvarStructPtr ivar);
+    ObjcField(CFStringRef name);
+    
+    virtual JSValue *valueFromInstance(ExecState *exec, const Instance *instance) const;
+    virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const;
+    
+    virtual const char *name() const;
+        
+private:
+    IvarStructPtr _ivar;
+    RetainPtr _name;
+};
+
+class ObjcMethod : public Method
+{
+public:
+    ObjcMethod() : _objcClass(0), _selector(0), _javaScriptName(0) {}
+    ObjcMethod(ClassStructPtr aClass, const char *_selector);
+
+    virtual const char *name() const;
+
+    virtual int numParameters() const;
+
+    NSMethodSignature *getMethodSignature() const;
+    
+    bool isFallbackMethod() const { return strcmp(_selector, "invokeUndefinedMethodFromWebScript:withArguments:") == 0; }
+    void setJavaScriptName(CFStringRef n) { _javaScriptName = n; }
+    CFStringRef javaScriptName() const { return _javaScriptName.get(); }
+    
+private:
+    ClassStructPtr _objcClass;
+    const char *_selector;
+    RetainPtr _javaScriptName;
+};
+
+class ObjcArray : public Array
+{
+public:
+    ObjcArray(ObjectStructPtr, PassRefPtr);
+
+    virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const;
+    virtual JSValue *valueAt(ExecState *exec, unsigned int index) const;
+    virtual unsigned int getLength() const;
+    
+    ObjectStructPtr getObjcArray() const { return _array.get(); }
+
+    static JSValue *convertObjcArrayToArray(ExecState *exec, ObjectStructPtr anObject);
+
+private:
+    RetainPtr _array;
+};
+
+class ObjcFallbackObjectImp : public JSObject {
+public:
+    ObjcFallbackObjectImp(ObjcInstance *i, const Identifier propertyName);
+
+    const ClassInfo *classInfo() const { return &info; }
+
+    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+    virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
+    virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
+    virtual bool implementsCall() const;
+    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
+    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
+    virtual JSValue *defaultValue(ExecState *exec, JSType hint) const;
+
+    virtual JSType type() const;
+    virtual bool toBoolean(ExecState *exec) const;
+
+private:
+    ObjcFallbackObjectImp(); // prevent default construction
+    
+    static const ClassInfo info;
+
+    RefPtr _instance;
+    Identifier _item;
+};
+
+} // namespace Bindings
+} // namespace KJS
+
+#endif
diff --git a/bindings/objc/objc_runtime.mm b/bindings/objc/objc_runtime.mm
new file mode 100644
index 0000000..ec0b41f
--- /dev/null
+++ b/bindings/objc/objc_runtime.mm
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "objc_runtime.h"
+
+#include "objc_instance.h"
+#include "runtime_array.h"
+#include "runtime_object.h"
+#include "WebScriptObject.h"
+
+using namespace KJS;
+using namespace KJS::Bindings;
+
+extern ClassStructPtr KJS::Bindings::webScriptObjectClass()
+{
+    static ClassStructPtr webScriptObjectClass = NSClassFromString(@"WebScriptObject");
+    return webScriptObjectClass;
+}
+
+extern ClassStructPtr KJS::Bindings::webUndefinedClass()
+{
+    static ClassStructPtr webUndefinedClass = NSClassFromString(@"WebUndefined");
+    return webUndefinedClass;
+}
+
+// ---------------------- ObjcMethod ----------------------
+
+ObjcMethod::ObjcMethod(ClassStructPtr aClass, const char* name)
+{
+    _objcClass = aClass;
+    _selector = name;   // Assume ObjC runtime keeps these around forever.
+    _javaScriptName = 0;
+}
+
+const char* ObjcMethod::name() const
+{
+    return _selector;
+}
+
+int ObjcMethod::numParameters() const
+{
+    return [getMethodSignature() numberOfArguments] - 2;
+}
+
+NSMethodSignature* ObjcMethod::getMethodSignature() const
+{
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+    return [_objcClass instanceMethodSignatureForSelector:sel_registerName(_selector)];
+#else
+    return [_objcClass instanceMethodSignatureForSelector:(SEL)_selector];
+#endif
+}
+
+// ---------------------- ObjcField ----------------------
+
+ObjcField::ObjcField(Ivar ivar) 
+{
+    _ivar = ivar;    // Assume ObjectiveC runtime will keep this alive forever
+    _name = 0;
+}
+
+ObjcField::ObjcField(CFStringRef name) 
+{
+    _ivar = 0;
+    _name = (CFStringRef)CFRetain(name);
+}
+
+const char* ObjcField::name() const 
+{
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+    if (_ivar)
+        return ivar_getName(_ivar);
+#else
+    if (_ivar)
+        return _ivar->ivar_name;
+#endif
+    return [(NSString*)_name.get() UTF8String];
+}
+
+JSValue* ObjcField::valueFromInstance(ExecState* exec, const Instance* instance) const
+{
+    JSValue* result = jsUndefined();
+    
+    id targetObject = (static_cast(instance))->getObject();
+
+   JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly.
+
+    @try {
+        NSString* key = [NSString stringWithCString:name() encoding:NSASCIIStringEncoding];
+        if (id objcValue = [targetObject valueForKey:key])
+            result = convertObjcValueToValue(exec, &objcValue, ObjcObjectType, instance->rootObject());
+    } @catch(NSException* localException) {
+        JSLock::lock();
+        throwError(exec, GeneralError, [localException reason]);
+        JSLock::unlock();
+    }
+
+    return result;
+}
+
+static id convertValueToObjcObject(ExecState* exec, JSValue* value)
+{
+    RefPtr rootObject = findRootObject(exec->dynamicGlobalObject());
+    if (!rootObject)
+        return nil;
+    return [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:rootObject.get() rootObject:rootObject.get()];
+}
+
+void ObjcField::setValueToInstance(ExecState* exec, const Instance* instance, JSValue* aValue) const
+{
+    id targetObject = (static_cast(instance))->getObject();
+    id value = convertValueToObjcObject(exec, aValue);
+
+   JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly.
+
+    @try {
+        NSString* key = [NSString stringWithCString:name() encoding:NSASCIIStringEncoding];
+        [targetObject setValue:value forKey:key];
+    } @catch(NSException* localException) {
+        JSLock::lock();
+        throwError(exec, GeneralError, [localException reason]);
+        JSLock::unlock();
+    }
+}
+
+// ---------------------- ObjcArray ----------------------
+
+ObjcArray::ObjcArray(ObjectStructPtr a, PassRefPtr rootObject)
+    : Array(rootObject)
+    , _array(a)
+{
+}
+
+void ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValue* aValue) const
+{
+    if (![_array.get() respondsToSelector:@selector(insertObject:atIndex:)]) {
+        throwError(exec, TypeError, "Array is not mutable.");
+        return;
+    }
+
+    if (index > [_array.get() count]) {
+        throwError(exec, RangeError, "Index exceeds array size.");
+        return;
+    }
+    
+    // Always try to convert the value to an ObjC object, so it can be placed in the
+    // array.
+    ObjcValue oValue = convertValueToObjcValue (exec, aValue, ObjcObjectType);
+
+    @try {
+        [_array.get() insertObject:oValue.objectValue atIndex:index];
+    } @catch(NSException* localException) {
+        throwError(exec, GeneralError, "Objective-C exception.");
+    }
+}
+
+JSValue* ObjcArray::valueAt(ExecState* exec, unsigned int index) const
+{
+    if (index > [_array.get() count])
+        return throwError(exec, RangeError, "Index exceeds array size.");
+    @try {
+        id obj = [_array.get() objectAtIndex:index];
+        if (obj)
+            return convertObjcValueToValue (exec, &obj, ObjcObjectType, _rootObject.get());
+    } @catch(NSException* localException) {
+        return throwError(exec, GeneralError, "Objective-C exception.");
+    }
+    return jsUndefined();
+}
+
+unsigned int ObjcArray::getLength() const
+{
+    return [_array.get() count];
+}
+
+const ClassInfo ObjcFallbackObjectImp::info = { "ObjcFallbackObject", 0, 0 };
+
+ObjcFallbackObjectImp::ObjcFallbackObjectImp(ObjcInstance* i, const KJS::Identifier propertyName)
+: _instance(i)
+, _item(propertyName)
+{
+}
+
+bool ObjcFallbackObjectImp::getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot& slot)
+{
+    // keep the prototype from getting called instead of just returning false
+    slot.setUndefined(this);
+    return true;
+}
+
+void ObjcFallbackObjectImp::put(ExecState*, const Identifier&, JSValue*, int)
+{
+}
+
+bool ObjcFallbackObjectImp::canPut(ExecState*, const Identifier&) const
+{
+    return false;
+}
+
+
+JSType ObjcFallbackObjectImp::type() const
+{
+    id targetObject = _instance->getObject();
+    
+    if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
+        return ObjectType;
+    
+    return UndefinedType;
+}
+
+bool ObjcFallbackObjectImp::implementsCall() const
+{
+    id targetObject = _instance->getObject();
+    
+    if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
+        return true;
+    
+    return false;
+}
+
+JSValue* ObjcFallbackObjectImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
+{
+    if (thisObj->classInfo() != &KJS::RuntimeObjectImp::info)
+        return throwError(exec, TypeError);
+
+    JSValue* result = jsUndefined();
+
+    RuntimeObjectImp* imp = static_cast(thisObj);
+    Instance* instance = imp->getInternalInstance();
+
+    if (!instance)
+        return RuntimeObjectImp::throwInvalidAccessError(exec);
+    
+    instance->begin();
+
+    ObjcInstance* objcInstance = static_cast(instance);
+    id targetObject = objcInstance->getObject();
+    
+    if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)]){
+        MethodList methodList;
+        ObjcClass* objcClass = static_cast(instance->getClass());
+        ObjcMethod* fallbackMethod = new ObjcMethod (objcClass->isa(), sel_getName(@selector(invokeUndefinedMethodFromWebScript:withArguments:)));
+        fallbackMethod->setJavaScriptName((CFStringRef)[NSString stringWithCString:_item.ascii() encoding:NSASCIIStringEncoding]);
+        methodList.append(fallbackMethod);
+        result = instance->invokeMethod(exec, methodList, args);
+        delete fallbackMethod;
+    }
+            
+    instance->end();
+
+    return result;
+}
+
+bool ObjcFallbackObjectImp::deleteProperty(ExecState*, const Identifier&)
+{
+    return false;
+}
+
+JSValue* ObjcFallbackObjectImp::defaultValue(ExecState* exec, JSType hint) const
+{
+    return _instance->getValueOfUndefinedField(exec, _item, hint);
+}
+
+bool ObjcFallbackObjectImp::toBoolean(ExecState *) const
+{
+    id targetObject = _instance->getObject();
+    
+    if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
+        return true;
+    
+    return false;
+}
diff --git a/bindings/objc/objc_utility.h b/bindings/objc/objc_utility.h
new file mode 100644
index 0000000..fbed9b6
--- /dev/null
+++ b/bindings/objc/objc_utility.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef KJS_BINDINGS_OBJC_UTILITY_H
+#define KJS_BINDINGS_OBJC_UTILITY_H
+
+#include 
+
+#include 
+#include 
+
+#ifdef __OBJC__
+@class NSString;
+#else
+class NSString;
+#endif
+
+namespace KJS {
+namespace Bindings {
+
+typedef union {
+    ObjectStructPtr objectValue;
+    bool booleanValue;
+    char charValue;
+    short shortValue;
+    int intValue;
+    long longValue;
+    long long longLongValue;
+    float floatValue;
+    double doubleValue;
+} ObjcValue;
+
+typedef enum {
+    ObjcVoidType,
+    ObjcObjectType,
+    ObjcCharType,
+    ObjcUnsignedCharType,
+    ObjcShortType,
+    ObjcUnsignedShortType,
+    ObjcIntType,
+    ObjcUnsignedIntType,
+    ObjcLongType,
+    ObjcUnsignedLongType,
+    ObjcLongLongType,
+    ObjcUnsignedLongLongType,
+    ObjcFloatType,
+    ObjcDoubleType,
+    ObjcInvalidType
+} ObjcValueType;
+
+class RootObject;
+
+ObjcValue convertValueToObjcValue(ExecState *exec, JSValue *value, ObjcValueType type);
+JSValue *convertNSStringToString(NSString *nsstring);
+JSValue *convertObjcValueToValue(ExecState *exec, void *buffer, ObjcValueType type, RootObject*);
+ObjcValueType objcValueTypeForType(const char *type);
+
+bool convertJSMethodNameToObjc(const char *JSName, char *buffer, size_t bufferSize);
+
+JSObject *throwError(ExecState *, ErrorType, NSString *message);
+
+} // namespace Bindings
+} // namespace KJS
+
+#endif
diff --git a/bindings/objc/objc_utility.mm b/bindings/objc/objc_utility.mm
new file mode 100644
index 0000000..62a0ad0
--- /dev/null
+++ b/bindings/objc/objc_utility.mm
@@ -0,0 +1,372 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "objc_utility.h"
+
+#include "objc_instance.h"
+#include "JSGlobalObject.h"
+#include "runtime_array.h"
+#include "runtime_object.h"
+#include "WebScriptObject.h"
+#include 
+
+#if !defined(_C_LNG_LNG)
+#define _C_LNG_LNG 'q'
+#endif
+
+#if !defined(_C_ULNG_LNG)
+#define _C_ULNG_LNG 'Q'
+#endif
+
+#if !defined(_C_CONST)
+#define _C_CONST 'r'
+#endif
+
+#if !defined(_C_BYCOPY)
+#define _C_BYCOPY 'O'
+#endif
+
+#if !defined(_C_BYREF)
+#define _C_BYREF 'R'
+#endif
+
+#if !defined(_C_ONEWAY)
+#define _C_ONEWAY 'V'
+#endif
+
+#if !defined(_C_GCINVISIBLE)
+#define _C_GCINVISIBLE '!'
+#endif
+
+namespace KJS {
+namespace Bindings {
+
+/*
+    By default, a JavaScript method name is produced by concatenating the 
+    components of an ObjectiveC method name, replacing ':' with '_', and 
+    escaping '_' and '$' with a leading '$', such that '_' becomes "$_" and 
+    '$' becomes "$$". For example:
+
+    ObjectiveC name         Default JavaScript name
+        moveTo::                moveTo__
+        moveTo_                 moveTo$_
+        moveTo$_                moveTo$$$_
+
+    This function performs the inverse of that operation.
+ 
+    @result Fills 'buffer' with the ObjectiveC method name that corresponds to 'JSName'. 
+            Returns true for success, false for failure. (Failure occurs when 'buffer' 
+            is not big enough to hold the result.)
+*/
+bool convertJSMethodNameToObjc(const char *JSName, char *buffer, size_t bufferSize)
+{
+    ASSERT(JSName && buffer);
+    
+    const char *sp = JSName; // source pointer
+    char *dp = buffer; // destination pointer
+        
+    char *end = buffer + bufferSize;
+    while (dp < end) {
+        if (*sp == '$') {
+            ++sp;
+            *dp = *sp;
+        } else if (*sp == '_')
+            *dp = ':';
+        else
+            *dp = *sp;
+
+        // If a future coder puts funny ++ operators above, we might write off the end 
+        // of the buffer in the middle of this loop. Let's make sure to check for that.
+        ASSERT(dp < end);
+        
+        if (*sp == 0) { // We finished converting JSName
+            ASSERT(strlen(JSName) < bufferSize);
+            return true;
+        }
+        
+        ++sp; 
+        ++dp;
+    }
+
+    return false; // We ran out of buffer before converting JSName
+}
+
+/*
+
+    JavaScript to   ObjC
+    Number          coerced to char, short, int, long, float, double, or NSNumber, as appropriate
+    String          NSString
+    wrapper         id
+    Object          WebScriptObject
+    null            NSNull
+    [], other       exception
+
+*/
+ObjcValue convertValueToObjcValue(ExecState *exec, JSValue *value, ObjcValueType type)
+{
+    ObjcValue result;
+    double d = 0;
+
+    if (value->isNumber() || value->isString() || value->isBoolean())
+        d = value->toNumber(exec);
+
+    switch (type) {
+        case ObjcObjectType: {
+            JSLock lock;
+            
+            JSGlobalObject *originGlobalObject = exec->dynamicGlobalObject();
+            RootObject* originRootObject = findRootObject(originGlobalObject);
+
+            JSGlobalObject* globalObject = 0;
+            if (value->isObject() && static_cast(value)->isGlobalObject())
+                globalObject = static_cast(value);
+
+            if (!globalObject)
+                globalObject = originGlobalObject;
+                
+            RootObject* rootObject = findRootObject(globalObject);
+            result.objectValue =  rootObject
+                ? [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:originRootObject rootObject:rootObject]
+                : nil;
+        }
+        break;
+
+        case ObjcCharType:
+        case ObjcUnsignedCharType:
+            result.charValue = (char)d;
+            break;
+        case ObjcShortType:
+        case ObjcUnsignedShortType:
+            result.shortValue = (short)d;
+            break;
+        case ObjcIntType:
+        case ObjcUnsignedIntType:
+            result.intValue = (int)d;
+            break;
+        case ObjcLongType:
+        case ObjcUnsignedLongType:
+            result.longValue = (long)d;
+            break;
+        case ObjcLongLongType:
+        case ObjcUnsignedLongLongType:
+            result.longLongValue = (long long)d;
+            break;
+        case ObjcFloatType:
+            result.floatValue = (float)d;
+            break;
+        case ObjcDoubleType:
+            result.doubleValue = (double)d;
+            break;
+        case ObjcVoidType:
+            bzero(&result, sizeof(ObjcValue));
+            break;
+
+        case ObjcInvalidType:
+        default:
+            // FIXME: throw an exception?
+            break;
+    }
+
+    return result;
+}
+
+JSValue *convertNSStringToString(NSString *nsstring)
+{
+    JSLock lock;
+    
+    unichar *chars;
+    unsigned int length = [nsstring length];
+    chars = (unichar *)malloc(sizeof(unichar)*length);
+    [nsstring getCharacters:chars];
+    UString u((const UChar*)chars, length);
+    JSValue *aValue = jsString(u);
+    free((void *)chars);
+    return aValue;
+}
+
+/*
+    ObjC      to    JavaScript
+    ----            ----------
+    char            number
+    short           number
+    int             number
+    long            number
+    float           number
+    double          number
+    NSNumber        boolean or number
+    NSString        string
+    NSArray         array
+    NSNull          null
+    WebScriptObject underlying JavaScript object
+    WebUndefined    undefined
+    id              object wrapper
+    other           should not happen
+*/
+JSValue* convertObjcValueToValue(ExecState* exec, void* buffer, ObjcValueType type, RootObject* rootObject)
+{
+    JSLock lock;
+    
+    switch (type) {
+        case ObjcObjectType: {
+            id obj = *(id*)buffer;
+            if ([obj isKindOfClass:[NSString class]])
+                return convertNSStringToString((NSString *)obj);
+            if ([obj isKindOfClass:webUndefinedClass()])
+                return jsUndefined();
+            if ((CFBooleanRef)obj == kCFBooleanTrue)
+                return jsBoolean(true);
+            if ((CFBooleanRef)obj == kCFBooleanFalse)
+                return jsBoolean(false);
+            if ([obj isKindOfClass:[NSNumber class]])
+                return jsNumber([obj doubleValue]);
+            if ([obj isKindOfClass:[NSArray class]])
+                return new RuntimeArray(exec, new ObjcArray(obj, rootObject));
+            if ([obj isKindOfClass:webScriptObjectClass()]) {
+                JSObject* imp = [obj _imp];
+                return imp ? imp : jsUndefined();
+            }
+            if ([obj isKindOfClass:[NSNull class]])
+                return jsNull();
+            if (obj == 0)
+                return jsUndefined();
+            return Instance::createRuntimeObject(Instance::ObjectiveCLanguage, obj, rootObject);
+        }
+        case ObjcCharType:
+            return jsNumber(*(char *)buffer);
+        case ObjcUnsignedCharType:
+            return jsNumber(*(unsigned char *)buffer);
+        case ObjcShortType:
+            return jsNumber(*(short *)buffer);
+        case ObjcUnsignedShortType:
+            return jsNumber(*(unsigned short *)buffer);
+        case ObjcIntType:
+            return jsNumber(*(int *)buffer);
+        case ObjcUnsignedIntType:
+            return jsNumber(*(unsigned int *)buffer);
+        case ObjcLongType:
+            return jsNumber(*(long *)buffer);
+        case ObjcUnsignedLongType:
+            return jsNumber(*(unsigned long *)buffer);
+        case ObjcLongLongType:
+            return jsNumber(*(long long *)buffer);
+        case ObjcUnsignedLongLongType:
+            return jsNumber(*(unsigned long long *)buffer);
+        case ObjcFloatType:
+            return jsNumber(*(float *)buffer);
+        case ObjcDoubleType:
+            return jsNumber(*(double *)buffer);
+        default:
+            // Should never get here. Argument types are filtered.
+            fprintf(stderr, "%s: invalid type (%d)\n", __PRETTY_FUNCTION__, (int)type);
+            ASSERT(false);
+    }
+    
+    return 0;
+}
+
+ObjcValueType objcValueTypeForType(const char *type)
+{
+    int typeLength = strlen(type);
+    ObjcValueType objcValueType = ObjcInvalidType;
+
+    for (int i = 0; i < typeLength; ++i) {
+        char typeChar = type[i];
+        switch (typeChar) {
+            case _C_CONST:
+            case _C_BYCOPY:
+            case _C_BYREF:
+            case _C_ONEWAY:
+            case _C_GCINVISIBLE:
+                // skip these type modifiers
+                break;
+            case _C_ID:
+                objcValueType = ObjcObjectType;
+                break;
+            case _C_CHR:
+                objcValueType = ObjcCharType;
+                break;
+            case _C_UCHR:
+                objcValueType = ObjcUnsignedCharType;
+                break;
+            case _C_SHT:
+                objcValueType = ObjcShortType;
+                break;
+            case _C_USHT:
+                objcValueType = ObjcUnsignedShortType;
+                break;
+            case _C_INT:
+                objcValueType = ObjcIntType;
+                break;
+            case _C_UINT:
+                objcValueType = ObjcUnsignedIntType;
+                break;
+            case _C_LNG:
+                objcValueType = ObjcLongType;
+                break;
+            case _C_ULNG:
+                objcValueType = ObjcUnsignedLongType;
+                break;
+            case _C_LNG_LNG:
+                objcValueType = ObjcLongLongType;
+                break;
+            case _C_ULNG_LNG:
+                objcValueType = ObjcUnsignedLongLongType;
+                break;
+            case _C_FLT:
+                objcValueType = ObjcFloatType;
+                break;
+            case _C_DBL:
+                objcValueType = ObjcDoubleType;
+                break;
+            case _C_VOID:
+                objcValueType = ObjcVoidType;
+                break;
+            default:
+                // Unhandled type. We don't handle C structs, unions, etc.
+                // FIXME: throw an exception?
+                ASSERT(false);
+        }
+
+        if (objcValueType != ObjcInvalidType)
+            break;
+    }
+
+    return objcValueType;
+}
+
+JSObject *throwError(ExecState *exec, ErrorType type, NSString *message)
+{
+    ASSERT(message);
+    size_t length = [message length];
+    unichar *buffer = new unichar[length];
+    [message getCharacters:buffer];
+    JSObject *error = throwError(exec, type, UString(reinterpret_cast(buffer), length));
+    delete [] buffer;
+    return error;
+}
+
+}
+}
diff --git a/bindings/qt/qt_class.cpp b/bindings/qt/qt_class.cpp
new file mode 100644
index 0000000..59730b8
--- /dev/null
+++ b/bindings/qt/qt_class.cpp
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2006 Trolltech ASA
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include "config.h"
+#include "identifier.h"
+
+#include "qt_class.h"
+#include "qt_instance.h"
+#include "qt_runtime.h"
+
+#include 
+#include 
+
+namespace KJS {
+namespace Bindings {
+
+QtClass::QtClass(const QMetaObject* mo)
+    : m_metaObject(mo)
+{
+}
+
+QtClass::~QtClass()
+{
+}
+
+typedef HashMap ClassesByMetaObject;
+static ClassesByMetaObject* classesByMetaObject = 0;
+
+QtClass* QtClass::classForObject(QObject* o)
+{
+    if (!classesByMetaObject)
+        classesByMetaObject = new ClassesByMetaObject;
+
+    const QMetaObject* mo = o->metaObject();
+    QtClass* aClass = classesByMetaObject->get(mo);
+    if (!aClass) {
+        aClass = new QtClass(mo);
+        classesByMetaObject->set(mo, aClass);
+    }
+
+    return aClass;
+}
+
+const char* QtClass::name() const
+{
+    return m_metaObject->className();
+}
+
+// We use this to get at signals (so we can return a proper function object,
+// and not get wrapped in RuntimeMethod).  Also, use this for methods,
+// so we can cache the JSValue* and return the same JSValue for the same
+// identifier...
+//
+// Unfortunately... we need to gcProtect our JSValues, since we don't have
+// access to an actual JS class that can mark() our JSValues.
+//
+JSValue* QtClass::fallbackObject(ExecState *exec, Instance *inst, const Identifier &identifier)
+{
+    QtInstance* qtinst = static_cast(inst);
+
+    QByteArray name(identifier.ascii());
+
+    // First see if we have a cache hit
+    JSValue* val = qtinst->m_methods.value(name);
+    if (val)
+        return val;
+
+    // Nope, create an entry
+    QByteArray normal = QMetaObject::normalizedSignature(name.constData());
+
+    // See if there is an exact match
+    int index = -1;
+    if (normal.contains('(') && (index = m_metaObject->indexOfMethod(normal)) != -1) {
+        QMetaMethod m = m_metaObject->method(index);
+        if (m.access() != QMetaMethod::Private) {
+            JSValue *val = new QtRuntimeMetaMethod(exec, identifier, static_cast(inst), index, normal, false);
+            gcProtect(val);
+            qtinst->m_methods.insert(name, val);
+            return val;
+        }
+    }
+
+    // Nope.. try a basename match
+    int count = m_metaObject->methodCount();
+    for (index = count - 1; index >= 0; --index) {
+        const QMetaMethod m = m_metaObject->method(index);
+        if (m.access() == QMetaMethod::Private)
+            continue;
+
+        QByteArray signature = m.signature();
+        signature.truncate(signature.indexOf('('));
+
+        if (normal == signature) {
+            JSValue* val = new QtRuntimeMetaMethod(exec, identifier, static_cast(inst), index, normal, false);
+            gcProtect(val);
+            qtinst->m_methods.insert(name, val);
+            return val;
+        }
+    }
+
+    return jsUndefined();
+}
+
+// This functionality is handled by the fallback case above...
+MethodList QtClass::methodsNamed(const Identifier&, Instance*) const
+{
+    return MethodList();
+}
+
+// ### we may end up with a different search order than QtScript by not
+// folding this code into the fallbackMethod above, but Fields propagate out
+// of the binding code
+Field* QtClass::fieldNamed(const Identifier& identifier, Instance* instance) const
+{
+    // Check static properties first
+    QtInstance* qtinst = static_cast(instance);
+
+    QObject* obj = qtinst->getObject();
+    UString ustring = identifier.ustring();
+    QString objName(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()));
+    QByteArray ba = objName.toAscii();
+
+    // First check for a cached field
+    QtField* f = qtinst->m_fields.value(objName);
+
+    if (obj) {
+        if (f) {
+            // We only cache real metaproperties, but we do store the
+            // other types so we can delete them later
+            if (f->fieldType() == QtField::MetaProperty)
+                return f;
+            else if (f->fieldType() == QtField::DynamicProperty) {
+                if (obj->dynamicPropertyNames().indexOf(ba) >= 0)
+                    return f;
+                else {
+                    // Dynamic property that disappeared
+                    qtinst->m_fields.remove(objName);
+                    delete f;
+                }
+            } else {
+                QList children = obj->children();
+                for (int index = 0; index < children.count(); ++index) {
+                    QObject *child = children.at(index);
+                    if (child->objectName() == objName)
+                        return f;
+                }
+
+                // Didn't find it, delete it from the cache
+                qtinst->m_fields.remove(objName);
+                delete f;
+            }
+        }
+
+        int index = m_metaObject->indexOfProperty(identifier.ascii());
+        if (index >= 0) {
+            QMetaProperty prop = m_metaObject->property(index);
+
+            if (prop.isScriptable(obj)) {
+                f = new QtField(prop);
+                qtinst->m_fields.insert(objName, f);
+                return f;
+            }
+        }
+
+        // Dynamic properties
+        index = obj->dynamicPropertyNames().indexOf(ba);
+        if (index >= 0) {
+            f = new QtField(ba);
+            qtinst->m_fields.insert(objName, f);
+            return f;
+        }
+
+        // Child objects
+
+        QList children = obj->children();
+        for (index = 0; index < children.count(); ++index) {
+            QObject *child = children.at(index);
+            if (child->objectName() == objName) {
+                f = new QtField(child);
+                qtinst->m_fields.insert(objName, f);
+                return f;
+            }
+        }
+
+        // Nothing named this
+        return 0;
+    } else {
+        QByteArray ba(identifier.ascii());
+        // For compatibility with qtscript, cached methods don't cause
+        // errors until they are accessed, so don't blindly create an error
+        // here.
+        if (qtinst->m_methods.contains(ba))
+            return 0;
+
+        // deleted qobject, but can't throw an error from here (no exec)
+        // create a fake QtField that will throw upon access
+        if (!f) {
+            f = new QtField(ba);
+            qtinst->m_fields.insert(objName, f);
+        }
+        return f;
+    }
+}
+
+}
+}
+
diff --git a/bindings/qt/qt_class.h b/bindings/qt/qt_class.h
new file mode 100644
index 0000000..c3e59ec
--- /dev/null
+++ b/bindings/qt/qt_class.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2006 Trolltech ASA
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef BINDINGS_QT_CLASS_H_
+#define BINDINGS_QT_CLASS_H_
+
+#include "runtime.h"
+class QObject;
+class QMetaObject;
+
+namespace KJS {
+namespace Bindings {
+
+
+class QtClass : public Class {
+protected:
+    QtClass(const QMetaObject*);
+
+public:
+    static QtClass* classForObject(QObject*);
+    virtual ~QtClass();
+
+    virtual const char* name() const;
+    virtual MethodList methodsNamed(const Identifier&, Instance*) const;
+    virtual Field* fieldNamed(const Identifier&, Instance*) const;
+
+    virtual JSValue* fallbackObject(ExecState*, Instance*, const Identifier&);
+
+private:
+    QtClass(const QtClass&); // prohibit copying
+    QtClass& operator=(const QtClass&); // prohibit assignment
+
+    const QMetaObject* m_metaObject;
+};
+
+} // namespace Bindings
+} // namespace KJS
+
+#endif
diff --git a/bindings/qt/qt_instance.cpp b/bindings/qt/qt_instance.cpp
new file mode 100644
index 0000000..0197b84
--- /dev/null
+++ b/bindings/qt/qt_instance.cpp
@@ -0,0 +1,394 @@
+/*
+ * Copyright (C) 2006 Trolltech ASA
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include "config.h"
+#include "qt_instance.h"
+
+#include "JSGlobalObject.h"
+#include "list.h"
+#include "qt_class.h"
+#include "qt_runtime.h"
+#include "PropertyNameArray.h"
+#include "runtime_object.h"
+#include "object_object.h"
+
+#include 
+#include 
+#include 
+#include 
+
+namespace KJS {
+namespace Bindings {
+
+// Cache QtInstances
+typedef QMultiHash QObjectInstanceMap;
+static QObjectInstanceMap cachedInstances;
+
+// Cache JSObjects
+typedef QHash InstanceJSObjectMap;
+static InstanceJSObjectMap cachedObjects;
+
+// Derived RuntimeObject
+class QtRuntimeObjectImp : public RuntimeObjectImp {
+    public:
+        QtRuntimeObjectImp(Instance*);
+        ~QtRuntimeObjectImp();
+        virtual void invalidate();
+
+        // Additions
+        virtual bool implementsConstruct() const {return implementsCall();}
+        virtual JSObject* construct(ExecState* exec, const List& args);
+    protected:
+        void removeFromCache();
+};
+
+QtRuntimeObjectImp::QtRuntimeObjectImp(Instance* instance)
+    : RuntimeObjectImp(instance)
+{
+}
+
+QtRuntimeObjectImp::~QtRuntimeObjectImp()
+{
+    removeFromCache();
+}
+
+void QtRuntimeObjectImp::invalidate()
+{
+    removeFromCache();
+    RuntimeObjectImp::invalidate();
+}
+
+void QtRuntimeObjectImp::removeFromCache()
+{
+    JSLock lock;
+    QtInstance* key = cachedObjects.key(this);
+    if (key)
+        cachedObjects.remove(key);
+}
+
+JSObject* QtRuntimeObjectImp::construct(ExecState* exec, const List& args)
+{
+    // ECMA 15.2.2.1 (?)
+    JSValue *val = callAsFunction(exec, this, args);
+
+    if (!val || val->type() == NullType || val->type() == UndefinedType)
+        return new JSObject(exec->lexicalGlobalObject()->objectPrototype());
+    else
+        return val->toObject(exec);
+}
+
+// QtInstance
+QtInstance::QtInstance(QObject* o, PassRefPtr rootObject)
+    : Instance(rootObject)
+    , m_class(0)
+    , m_object(o)
+    , m_hashkey(o)
+    , m_defaultMethod(0)
+    , m_defaultMethodIndex(-2)
+{
+}
+
+QtInstance::~QtInstance()
+{
+    JSLock lock;
+
+    cachedObjects.remove(this);
+    cachedInstances.remove(m_hashkey);
+
+    // clean up (unprotect from gc) the JSValues we've created
+    foreach(JSValue* val, m_methods.values()) {
+        gcUnprotect(val);
+    }
+    m_methods.clear();
+
+    foreach(QtField* f, m_fields.values()) {
+        delete f;
+    }
+    m_fields.clear();
+
+    if (m_defaultMethod)
+        gcUnprotect(m_defaultMethod);
+}
+
+QtInstance* QtInstance::getQtInstance(QObject* o, PassRefPtr rootObject)
+{
+    JSLock lock;
+
+    foreach(QtInstance* instance, cachedInstances.values(o)) {
+        if (instance->rootObject() == rootObject)
+            return instance;
+    }
+
+    QtInstance* ret = new QtInstance(o, rootObject);
+    cachedInstances.insert(o, ret);
+
+    return ret;
+}
+
+JSObject* QtInstance::getRuntimeObject(QtInstance* instance)
+{
+    JSLock lock;
+    JSObject* ret = cachedObjects.value(instance);
+    if (!ret) {
+        ret = new QtRuntimeObjectImp(instance);
+        cachedObjects.insert(instance, ret);
+    }
+    return ret;
+}
+
+Class* QtInstance::getClass() const
+{
+    if (!m_class)
+        m_class = QtClass::classForObject(m_object);
+    return m_class;
+}
+
+void QtInstance::begin()
+{
+    // Do nothing.
+}
+
+void QtInstance::end()
+{
+    // Do nothing.
+}
+
+void QtInstance::getPropertyNames(ExecState* , PropertyNameArray& array)
+{
+    // This is the enumerable properties, so put:
+    // properties
+    // dynamic properties
+    // slots
+    QObject* obj = getObject();
+    if (obj) {
+        const QMetaObject* meta = obj->metaObject();
+
+        int i;
+        for (i=0; i < meta->propertyCount(); i++) {
+            QMetaProperty prop = meta->property(i);
+            if (prop.isScriptable()) {
+                array.add(Identifier(prop.name()));
+            }
+        }
+
+        QList dynProps = obj->dynamicPropertyNames();
+        foreach(QByteArray ba, dynProps) {
+            array.add(Identifier(ba.constData()));
+        }
+
+        for (i=0; i < meta->methodCount(); i++) {
+            QMetaMethod method = meta->method(i);
+            if (method.access() != QMetaMethod::Private) {
+                array.add(Identifier(method.signature()));
+            }
+        }
+    }
+}
+
+JSValue* QtInstance::invokeMethod(ExecState*, const MethodList&, const List&)
+{
+    // Implemented via fallbackMethod & QtRuntimeMetaMethod::callAsFunction
+    return jsUndefined();
+}
+
+bool QtInstance::implementsCall() const
+{
+    // See if we have qscript_call
+    if (m_defaultMethodIndex == -2) {
+        if (m_object) {
+            const QMetaObject* meta = m_object->metaObject();
+            int count = meta->methodCount();
+            const QByteArray defsig("qscript_call");
+            for (int index = count - 1; index >= 0; --index) {
+                const QMetaMethod m = meta->method(index);
+
+                QByteArray signature = m.signature();
+                signature.truncate(signature.indexOf('('));
+
+                if (defsig == signature) {
+                    m_defaultMethodIndex = index;
+                    break;
+                }
+            }
+        }
+
+        if (m_defaultMethodIndex == -2) // Not checked
+            m_defaultMethodIndex = -1; // No qscript_call
+    }
+
+    // typeof object that implements call == function
+    return (m_defaultMethodIndex >= 0);
+}
+
+JSValue* QtInstance::invokeDefaultMethod(ExecState* exec, const List& args)
+{
+    // QtScript tries to invoke a meta method qscript_call
+    if (!getObject())
+        return throwError(exec, GeneralError, "cannot call function of deleted QObject");
+
+    // implementsCall will update our default method cache, if possible
+    if (implementsCall()) {
+        if (!m_defaultMethod) {
+            m_defaultMethod = new QtRuntimeMetaMethod(exec, Identifier("[[Call]]"),this, m_defaultMethodIndex, QByteArray("qscript_call"), true);
+            gcProtect(m_defaultMethod);
+        }
+
+        return m_defaultMethod->callAsFunction(exec, 0, args); // Luckily QtRuntimeMetaMethod ignores the obj parameter
+    } else
+        return throwError(exec, TypeError, "not a function");
+}
+
+JSValue* QtInstance::defaultValue(JSType hint) const
+{
+    if (hint == StringType)
+        return stringValue();
+    if (hint == NumberType)
+        return numberValue();
+    if (hint == BooleanType)
+        return booleanValue();
+    return valueOf();
+}
+
+JSValue* QtInstance::stringValue() const
+{
+    // Hmm.. see if there is a toString defined
+    QByteArray buf;
+    bool useDefault = true;
+    getClass();
+    QObject* obj = getObject();
+    if (m_class && obj) {
+        // Cheat and don't use the full name resolution
+        int index = obj->metaObject()->indexOfMethod("toString()");
+        if (index >= 0) {
+            QMetaMethod m = obj->metaObject()->method(index);
+            // Check to see how much we can call it
+            if (m.access() != QMetaMethod::Private
+                && m.methodType() != QMetaMethod::Signal
+                && m.parameterTypes().count() == 0) {
+                const char* retsig = m.typeName();
+                if (retsig && *retsig) {
+                    QVariant ret(QMetaType::type(retsig), (void*)0);
+                    void * qargs[1];
+                    qargs[0] = ret.data();
+
+                    if (obj->qt_metacall(QMetaObject::InvokeMetaMethod, index, qargs) < 0) {
+                        if (ret.isValid() && ret.canConvert(QVariant::String)) {
+                            buf = ret.toString().toLatin1().constData(); // ### Latin 1? Ascii?
+                            useDefault = false;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    if (useDefault) {
+        const QMetaObject* meta = obj ? obj->metaObject() : &QObject::staticMetaObject;
+        QString name = obj ? obj->objectName() : QString::fromUtf8("unnamed");
+        QString str = QString::fromUtf8("%0(name = \"%1\")")
+                      .arg(QLatin1String(meta->className())).arg(name);
+
+        buf = str.toLatin1();
+    }
+    return jsString(buf.constData());
+}
+
+JSValue* QtInstance::numberValue() const
+{
+    return jsNumber(0);
+}
+
+JSValue* QtInstance::booleanValue() const
+{
+    // ECMA 9.2
+    return jsBoolean(true);
+}
+
+JSValue* QtInstance::valueOf() const
+{
+    return stringValue();
+}
+
+// In qt_runtime.cpp
+JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr root, const QVariant& variant);
+QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type hint, int *distance);
+
+const char* QtField::name() const
+{
+    if (m_type == MetaProperty)
+        return m_property.name();
+    else if (m_type == ChildObject && m_childObject)
+        return m_childObject->objectName().toLatin1();
+    else if (m_type == DynamicProperty)
+        return m_dynamicProperty.constData();
+    return ""; // deleted child object
+}
+
+JSValue* QtField::valueFromInstance(ExecState* exec, const Instance* inst) const
+{
+    const QtInstance* instance = static_cast(inst);
+    QObject* obj = instance->getObject();
+
+    if (obj) {
+        QVariant val;
+        if (m_type == MetaProperty) {
+            if (m_property.isReadable())
+                val = m_property.read(obj);
+            else
+                return jsUndefined();
+        } else if (m_type == ChildObject)
+            val = QVariant::fromValue((QObject*) m_childObject);
+        else if (m_type == DynamicProperty)
+            val = obj->property(m_dynamicProperty);
+
+        return convertQVariantToValue(exec, inst->rootObject(), val);
+    } else {
+        QString msg = QString("cannot access member `%1' of deleted QObject").arg(name());
+        return throwError(exec, GeneralError, msg.toLatin1().constData());
+    }
+}
+
+void QtField::setValueToInstance(ExecState* exec, const Instance* inst, JSValue* aValue) const
+{
+    if (m_type == ChildObject) // QtScript doesn't allow setting to a named child
+        return;
+
+    const QtInstance* instance = static_cast(inst);
+    QObject* obj = instance->getObject();
+    if (obj) {
+        QMetaType::Type argtype = QMetaType::Void;
+        if (m_type == MetaProperty)
+            argtype = (QMetaType::Type) QMetaType::type(m_property.typeName());
+
+        // dynamic properties just get any QVariant
+        QVariant val = convertValueToQVariant(exec, aValue, argtype, 0);
+        if (m_type == MetaProperty) {
+            if (m_property.isWritable())
+                m_property.write(obj, val);
+        } else if (m_type == DynamicProperty)
+            obj->setProperty(m_dynamicProperty.constData(), val);
+    } else {
+        QString msg = QString("cannot access member `%1' of deleted QObject").arg(name());
+        throwError(exec, GeneralError, msg.toLatin1().constData());
+    }
+}
+
+
+}
+}
diff --git a/bindings/qt/qt_instance.h b/bindings/qt/qt_instance.h
new file mode 100644
index 0000000..2304ac5
--- /dev/null
+++ b/bindings/qt/qt_instance.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2006 Trolltech ASA
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef BINDINGS_QT_INSTANCE_H_
+#define BINDINGS_QT_INSTANCE_H_
+
+#include "runtime.h"
+#include "runtime_root.h"
+#include 
+#include 
+
+class QObject;
+
+namespace KJS {
+
+namespace Bindings {
+
+class QtClass;
+class QtField;
+class QtRuntimeMetaMethod;
+
+class QtInstance : public Instance
+{
+public:
+    ~QtInstance ();
+
+    virtual Class* getClass() const;
+
+    virtual void begin();
+    virtual void end();
+
+    virtual JSValue* valueOf() const;
+    virtual JSValue* defaultValue (JSType hint) const;
+
+    virtual bool implementsCall() const;
+
+    virtual JSValue* invokeMethod (ExecState *exec, const MethodList &method, const List &args);
+    virtual JSValue* invokeDefaultMethod (ExecState *exec, const List &args);
+
+    virtual void getPropertyNames(ExecState*, PropertyNameArray&);
+
+    virtual BindingLanguage getBindingLanguage() const { return QtLanguage; }
+
+    JSValue* stringValue() const;
+    JSValue* numberValue() const;
+    JSValue* booleanValue() const;
+
+    QObject* getObject() const { return m_object; }
+
+    static QtInstance* getQtInstance(QObject*, PassRefPtr);
+    static JSObject* getRuntimeObject(QtInstance*);
+
+private:
+    friend class QtClass;
+    QtInstance(QObject*, PassRefPtr); // Factory produced only..
+    mutable QtClass* m_class;
+    QPointer m_object;
+    QObject* m_hashkey;
+    mutable QHash m_methods;
+    mutable QHash m_fields;
+    mutable QtRuntimeMetaMethod* m_defaultMethod;
+    mutable int m_defaultMethodIndex;
+};
+
+} // namespace Bindings
+
+} // namespace KJS
+
+#endif
diff --git a/bindings/qt/qt_runtime.cpp b/bindings/qt/qt_runtime.cpp
new file mode 100644
index 0000000..113f0c5
--- /dev/null
+++ b/bindings/qt/qt_runtime.cpp
@@ -0,0 +1,1590 @@
+/*
+ * Copyright (C) 2006 Trolltech ASA
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include "config.h"
+#include "qt_runtime.h"
+#include "qt_instance.h"
+#include "object.h"
+#include "array_instance.h"
+#include "date_object.h"
+#include "DateMath.h"
+#include "regexp_object.h"
+#include 
+#include 
+#include 
+#include "PropertyNameArray.h"
+#include "qmetatype.h"
+#include "qmetaobject.h"
+#include "qobject.h"
+#include "qstringlist.h"
+#include "qdebug.h"
+#include "qvarlengtharray.h"
+#include "qdatetime.h"
+#include 
+
+// QtScript has these
+Q_DECLARE_METATYPE(QObjectList);
+Q_DECLARE_METATYPE(QList);
+Q_DECLARE_METATYPE(QVariant);
+
+
+namespace KJS {
+namespace Bindings {
+
+// Debugging
+//#define QTWK_RUNTIME_CONVERSION_DEBUG
+//#define QTWK_RUNTIME_MATCH_DEBUG
+
+class QWKNoDebug
+{
+public:
+    inline QWKNoDebug(){}
+    inline ~QWKNoDebug(){}
+
+    template
+    inline QWKNoDebug &operator<<(const T &) { return *this; }
+};
+
+#ifdef QTWK_RUNTIME_CONVERSION_DEBUG
+#define qConvDebug() qDebug()
+#else
+#define qConvDebug() QWKNoDebug()
+#endif
+
+#ifdef QTWK_RUNTIME_MATCH_DEBUG
+#define qMatchDebug() qDebug()
+#else
+#define qMatchDebug() QWKNoDebug()
+#endif
+
+typedef enum {
+    Variant,
+    Number,
+    Boolean,
+    String,
+    Date,
+    RegExp,
+    Array,
+    QObj,
+    Object,
+    Null
+} JSRealType;
+
+static JSRealType valueRealType(ExecState* exec, JSValue* val)
+{
+    if (val->isNumber())
+        return Number;
+    else if (val->isString())
+        return String;
+    else if (val->isBoolean())
+        return Boolean;
+    else if (val->isNull())
+        return Null;
+    else if (val->isObject()) {
+        JSObject *object = val->toObject(exec);
+        if (object->inherits(&ArrayInstance::info))
+            return Array;
+        else if (object->inherits(&DateInstance::info))
+            return Date;
+        else if (object->inherits(&RegExpImp::info))
+            return RegExp;
+        else if (object->inherits(&RuntimeObjectImp::info))
+            return QObj;
+        return Object;
+    }
+
+    return String; // I don't know.
+}
+
+QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type hint, int *distance)
+{
+    // check magic pointer values before dereferencing value
+    if (value == jsNaN() || value == jsUndefined()) {
+        if (distance)
+            *distance = -1;
+        return QVariant();
+    }
+
+    JSLock lock;
+    JSRealType type = valueRealType(exec, value);
+    if (hint == QMetaType::Void) {
+        switch(type) {
+            case Number:
+                hint = QMetaType::Double;
+                break;
+            case Boolean:
+                hint = QMetaType::Bool;
+                break;
+            case String:
+            default:
+                hint = QMetaType::QString;
+                break;
+            case Date:
+                hint = QMetaType::QDateTime;
+                break;
+            case RegExp:
+                hint = QMetaType::QRegExp;
+                break;
+            case QObj:
+                hint = QMetaType::QObjectStar;
+                break;
+            case Array:
+                hint = QMetaType::QVariantList;
+                break;
+        }
+    }
+
+    if (value == jsNull() 
+        && hint != QMetaType::QObjectStar
+        && hint != QMetaType::VoidStar) {
+        if (distance)
+            *distance = -1;
+        return QVariant();
+    }
+
+    QVariant ret;
+    int dist = -1;
+    switch (hint) {
+        case QMetaType::Bool:
+            ret = QVariant(value->toBoolean(exec));
+            if (type == Boolean)
+                dist = 0;
+            else
+                dist = 10;
+            break;
+
+        case QMetaType::Int:
+        case QMetaType::UInt:
+        case QMetaType::Long:
+        case QMetaType::ULong:
+        case QMetaType::LongLong:
+        case QMetaType::ULongLong:
+        case QMetaType::Short:
+        case QMetaType::UShort:
+        case QMetaType::Float:
+        case QMetaType::Double:
+            ret = QVariant(value->toNumber(exec));
+            ret.convert((QVariant::Type)hint);
+            if (type == Number) {
+                switch (hint) {
+                case QMetaType::Double:
+                    dist = 0;
+                    break;
+                case QMetaType::Float:
+                    dist = 1;
+                    break;
+                case QMetaType::LongLong:
+                case QMetaType::ULongLong:
+                    dist = 2;
+                    break;
+                case QMetaType::Long:
+                case QMetaType::ULong:
+                    dist = 3;
+                    break;
+                case QMetaType::Int:
+                case QMetaType::UInt:
+                    dist = 4;
+                    break;
+                case QMetaType::Short:
+                case QMetaType::UShort:
+                    dist = 5;
+                    break;
+                    break;
+                default:
+                    dist = 10;
+                    break;
+                }
+            } else {
+                dist = 10;
+            }
+            break;
+
+        case QMetaType::QChar:
+            if (type == Number || type == Boolean) {
+                ret = QVariant(QChar((ushort)value->toNumber(exec)));
+                if (type == Boolean)
+                    dist = 3;
+                else
+                    dist = 6;
+            } else {
+                UString str = value->toString(exec);
+                ret = QVariant(QChar(str.size() ? *(const ushort*)str.rep()->data() : 0));
+                if (type == String)
+                    dist = 3;
+                else
+                    dist = 10;
+            }
+            break;
+
+        case QMetaType::QString: {
+            UString ustring = value->toString(exec);
+            ret = QVariant(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()));
+            if (type == String)
+                dist = 0;
+            else
+                dist = 10;
+            break;
+        }
+
+        case QMetaType::QVariantMap: 
+            if (type == Object || type == Array) {
+                // Enumerate the contents of the object
+                JSObject* object = value->toObject(exec);
+
+                PropertyNameArray properties;
+                object->getPropertyNames(exec, properties);
+                PropertyNameArray::const_iterator it = properties.begin();
+
+                QVariantMap result;
+                int objdist = 0;
+                while(it != properties.end()) {
+                    if (object->propertyIsEnumerable(exec, *it)) {
+                        JSValue* val = object->get(exec, *it);
+                        QVariant v = convertValueToQVariant(exec, val, QMetaType::Void, &objdist);
+                        if (objdist >= 0) {
+                            UString ustring = (*it).ustring();
+                            QString id = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
+                            result.insert(id, v);
+                        }
+                    }
+                    ++it;
+                }
+                dist = 1;
+                ret = QVariant(result);
+            }
+            break;
+
+        case QMetaType::QVariantList:
+            if (type == Array) {
+                JSObject* object = value->toObject(exec);
+                ArrayInstance* array = static_cast(object);
+
+                QVariantList result;
+                int len = array->getLength();
+                int objdist = 0;
+                for (int i = 0; i < len; ++i) {
+                    JSValue *val = array->getItem(i);
+                    result.append(convertValueToQVariant(exec, val, QMetaType::Void, &objdist));
+                    if (objdist == -1)
+                        break; // Failed converting a list entry, so fail the array
+                }
+                if (objdist != -1) {
+                    dist = 5;
+                    ret = QVariant(result);
+                }
+            } else {
+                // Make a single length array
+                QVariantList result;
+                int objdist;
+                result.append(convertValueToQVariant(exec, value, QMetaType::Void, &objdist));
+                if (objdist != -1) {
+                    ret = QVariant(result);
+                    dist = 10;
+                }
+            }
+            break;
+
+        case QMetaType::QStringList: {
+            if (type == Array) {
+                JSObject* object = value->toObject(exec);
+                ArrayInstance* array = static_cast(object);
+
+                QStringList result;
+                int len = array->getLength();
+                for (int i = 0; i < len; ++i) {
+                    JSValue* val = array->getItem(i);
+                    UString ustring = val->toString(exec);
+                    QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
+
+                    result.append(qstring);
+                }
+                dist = 5;
+                ret = QVariant(result);
+            } else {
+                // Make a single length array
+                UString ustring = value->toString(exec);
+                QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
+                QStringList result;
+                result.append(qstring);
+                ret = QVariant(result);
+                dist = 10;
+            }
+            break;
+        }
+
+        case QMetaType::QByteArray: {
+            UString ustring = value->toString(exec);
+            ret = QVariant(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()).toLatin1());
+            if (type == String)
+                dist = 5;
+            else
+                dist = 10;
+            break;
+        }
+
+        case QMetaType::QDateTime:
+        case QMetaType::QDate:
+        case QMetaType::QTime:
+            if (type == Date) {
+                JSObject* object = value->toObject(exec);
+                DateInstance* date = static_cast(object);
+                GregorianDateTime gdt;
+                date->getUTCTime(gdt);
+                if (hint == QMetaType::QDateTime) {
+                    ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
+                    dist = 0;
+                } else if (hint == QMetaType::QDate) {
+                    ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
+                    dist = 1;
+                } else {
+                    ret = QTime(gdt.hour + 1900, gdt.minute, gdt.second);
+                    dist = 2;
+                }
+            } else if (type == Number) {
+                double b = value->toNumber(exec);
+                GregorianDateTime gdt;
+                msToGregorianDateTime(b, true, gdt);
+                if (hint == QMetaType::QDateTime) {
+                    ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
+                    dist = 6;
+                } else if (hint == QMetaType::QDate) {
+                    ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
+                    dist = 8;
+                } else {
+                    ret = QTime(gdt.hour, gdt.minute, gdt.second);
+                    dist = 10;
+                }
+            } else if (type == String) {
+                UString ustring = value->toString(exec);
+                QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
+
+                if (hint == QMetaType::QDateTime) {
+                    QDateTime dt = QDateTime::fromString(qstring, Qt::ISODate);
+                    if (!dt.isValid())
+                        dt = QDateTime::fromString(qstring, Qt::TextDate);
+                    if (!dt.isValid())
+                        dt = QDateTime::fromString(qstring, Qt::SystemLocaleDate);
+                    if (!dt.isValid())
+                        dt = QDateTime::fromString(qstring, Qt::LocaleDate);
+                    if (dt.isValid()) {
+                        ret = dt;
+                        dist = 2;
+                    }
+                } else if (hint == QMetaType::QDate) {
+                    QDate dt = QDate::fromString(qstring, Qt::ISODate);
+                    if (!dt.isValid())
+                        dt = QDate::fromString(qstring, Qt::TextDate);
+                    if (!dt.isValid())
+                        dt = QDate::fromString(qstring, Qt::SystemLocaleDate);
+                    if (!dt.isValid())
+                        dt = QDate::fromString(qstring, Qt::LocaleDate);
+                    if (dt.isValid()) {
+                        ret = dt;
+                        dist = 3;
+                    }
+                } else {
+                    QTime dt = QTime::fromString(qstring, Qt::ISODate);
+                    if (!dt.isValid())
+                        dt = QTime::fromString(qstring, Qt::TextDate);
+                    if (!dt.isValid())
+                        dt = QTime::fromString(qstring, Qt::SystemLocaleDate);
+                    if (!dt.isValid())
+                        dt = QTime::fromString(qstring, Qt::LocaleDate);
+                    if (dt.isValid()) {
+                        ret = dt;
+                        dist = 3;
+                    }
+                }
+            }
+            break;
+
+        case QMetaType::QRegExp:
+            if (type == RegExp) {
+/*                JSObject *object = value->toObject(exec);
+                RegExpImp *re = static_cast(object);
+*/
+                // Attempt to convert.. a bit risky
+                UString ustring = value->toString(exec);
+                QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
+
+                // this is of the form '/xxxxxx/i'
+                int firstSlash = qstring.indexOf('/');
+                int lastSlash = qstring.lastIndexOf('/');
+                if (firstSlash >=0 && lastSlash > firstSlash) {
+                    QRegExp realRe;
+
+                    realRe.setPattern(qstring.mid(firstSlash + 1, lastSlash - firstSlash - 1));
+
+                    if (qstring.mid(lastSlash + 1).contains('i'))
+                        realRe.setCaseSensitivity(Qt::CaseInsensitive);
+
+                    ret = qVariantFromValue(realRe);
+                    dist = 0;
+                } else {
+                    qConvDebug() << "couldn't parse a JS regexp";
+                }
+            } else if (type == String) {
+                UString ustring = value->toString(exec);
+                QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
+
+                QRegExp re(qstring);
+                if (re.isValid()) {
+                    ret = qVariantFromValue(re);
+                    dist = 10;
+                }
+            }
+            break;
+
+        case QMetaType::QObjectStar:
+            if (type == QObj) {
+                JSObject* object = value->toObject(exec);
+                QtInstance* qtinst = static_cast(Instance::getInstance(object, Instance::QtLanguage));
+                if (qtinst) {
+                    if (qtinst->getObject()) {
+                        qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject();
+                        ret = qVariantFromValue(qtinst->getObject());
+                        qConvDebug() << ret;
+                        dist = 0;
+                    } else {
+                        qConvDebug() << "can't convert deleted qobject";
+                    }
+                } else {
+                    qConvDebug() << "wasn't a qtinstance";
+                }
+            } else if (type == Null) {
+                QObject* nullobj = 0;
+                ret = qVariantFromValue(nullobj);
+                dist = 0;
+            } else {
+                qConvDebug() << "previous type was not an object:" << type;
+            }
+            break;
+
+        case QMetaType::VoidStar:
+            if (type == QObj) {
+                JSObject* object = value->toObject(exec);
+                QtInstance* qtinst = static_cast(Instance::getInstance(object, Instance::QtLanguage));
+                if (qtinst) {
+                    if (qtinst->getObject()) {
+                        qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject();
+                        ret = qVariantFromValue((void *)qtinst->getObject());
+                        qConvDebug() << ret;
+                        dist = 0;
+                    } else {
+                        qConvDebug() << "can't convert deleted qobject";
+                    }
+                } else {
+                    qConvDebug() << "wasn't a qtinstance";
+                }
+            } else if (type == Null) {
+                ret = qVariantFromValue((void*)0);
+                dist = 0;
+            } else if (type == Number) {
+                // I don't think that converting a double to a pointer is a wise
+                // move.  Except maybe 0.
+                qConvDebug() << "got number for void * - not converting, seems unsafe:" << value->toNumber(exec);
+            } else {
+                qConvDebug() << "void* - unhandled type" << type;
+            }
+            break;
+
+        default:
+            // Non const type ids
+            if (hint == (QMetaType::Type) qMetaTypeId())
+            {
+                if (type == Array) {
+                    JSObject* object = value->toObject(exec);
+                    ArrayInstance* array = static_cast(object);
+
+                    QObjectList result;
+                    int len = array->getLength();
+                    for (int i = 0; i < len; ++i) {
+                        JSValue *val = array->getItem(i);
+                        int itemdist = -1;
+                        QVariant item = convertValueToQVariant(exec, val, QMetaType::QObjectStar, &itemdist);
+                        if (itemdist >= 0)
+                            result.append(item.value());
+                        else
+                            break;
+                    }
+                    // If we didn't fail conversion
+                    if (result.count() == len) {
+                        dist = 5;
+                        ret = QVariant::fromValue(result);
+                    } else {
+                        qConvDebug() << "type conversion failed (wanted" << len << ", got " << result.count() << ")";
+                    }
+                } else {
+                    // Make a single length array
+                    QObjectList result;
+                    int itemdist = -1;
+                    QVariant item = convertValueToQVariant(exec, value, QMetaType::QObjectStar, &itemdist);
+                    if (itemdist >= 0) {
+                        result.append(item.value());
+                        dist = 10;
+                        ret = QVariant::fromValue(result);
+                    }
+                }
+                break;
+            } else if (hint == (QMetaType::Type) qMetaTypeId >()) {
+                if (type == Array) {
+                    JSObject* object = value->toObject(exec);
+                    ArrayInstance* array = static_cast(object);
+
+                    QList result;
+                    int len = array->getLength();
+                    for (int i = 0; i < len; ++i) {
+                        JSValue* val = array->getItem(i);
+                        int itemdist = -1;
+                        QVariant item = convertValueToQVariant(exec, val, QMetaType::Int, &itemdist);
+                        if (itemdist >= 0)
+                            result.append(item.value());
+                        else
+                            break;
+                    }
+                    // If we didn't fail conversion
+                    if (result.count() == len) {
+                        dist = 5;
+                        ret = QVariant::fromValue(result);
+                    } else {
+                        qConvDebug() << "type conversion failed (wanted" << len << ", got " << result.count() << ")";
+                    }
+                } else {
+                    // Make a single length array
+                    QList result;
+                    int itemdist = -1;
+                    QVariant item = convertValueToQVariant(exec, value, QMetaType::Int, &itemdist);
+                    if (itemdist >= 0) {
+                        result.append(item.value());
+                        dist = 10;
+                        ret = QVariant::fromValue(result);
+                    }
+                }
+                break;
+            } else if (hint == (QMetaType::Type) qMetaTypeId()) {
+                // Well.. we can do anything... just recurse with the autodetect flag
+                ret = convertValueToQVariant(exec, value, QMetaType::Void, distance);
+                dist = 10;
+                break;
+            }
+
+            dist = 10;
+            break;
+    }
+
+    if (!ret.isValid())
+        dist = -1;
+    if (distance)
+        *distance = dist;
+
+    return ret;
+}
+
+JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr root, const QVariant& variant)
+{
+    // Variants with QObject * can be isNull but not a null pointer
+    // An empty QString variant is also null
+    QMetaType::Type type = (QMetaType::Type) variant.userType();
+    if (variant.isNull() &&
+        type != QMetaType::QObjectStar &&
+        type != QMetaType::VoidStar &&
+        type != QMetaType::QWidgetStar &&
+        type != QMetaType::QString) {
+        return jsNull();
+    }
+
+    JSLock lock;
+
+    if (type == QMetaType::Bool)
+        return jsBoolean(variant.toBool());
+
+    if (type == QMetaType::Int ||
+        type == QMetaType::UInt ||
+        type == QMetaType::Long ||
+        type == QMetaType::ULong ||
+        type == QMetaType::LongLong ||
+        type == QMetaType::ULongLong ||
+        type == QMetaType::Short ||
+        type == QMetaType::UShort ||
+        type == QMetaType::Float ||
+        type == QMetaType::Double)
+        return jsNumber(variant.toDouble());
+
+    if (type == QMetaType::QRegExp) {
+        QRegExp re = variant.value();
+
+        if (re.isValid()) {
+            RegExpObjectImp* regExpObj = static_cast(exec->lexicalGlobalObject()->regExpConstructor());
+            List args;
+            UString uflags;
+
+            if (re.caseSensitivity() == Qt::CaseInsensitive)
+                uflags = "i"; // ### Can't do g or m
+            UString ustring((KJS::UChar*)re.pattern().utf16(), re.pattern().length());
+            args.append(jsString(ustring));
+            args.append(jsString(uflags));
+            return regExpObj->construct(exec, args);
+        }
+    }
+
+    if (type == QMetaType::QDateTime ||
+        type == QMetaType::QDate ||
+        type == QMetaType::QTime) {
+        DateObjectImp *dateObj = static_cast(exec->lexicalGlobalObject()->dateConstructor());
+        List args;
+
+        QDate date = QDate::currentDate();
+        QTime time(0,0,0); // midnight
+
+        if (type == QMetaType::QDate)
+            date = variant.value();
+        else if (type == QMetaType::QTime)
+            time = variant.value();
+        else {
+            QDateTime dt = variant.value().toLocalTime();
+            date = dt.date();
+            time = dt.time();
+        }
+
+        // Dates specified this way are in local time (we convert DateTimes above)
+        args.append(jsNumber(date.year()));
+        args.append(jsNumber(date.month() - 1));
+        args.append(jsNumber(date.day()));
+        args.append(jsNumber(time.hour()));
+        args.append(jsNumber(time.minute()));
+        args.append(jsNumber(time.second()));
+        args.append(jsNumber(time.msec()));
+        return dateObj->construct(exec, args);
+    }
+
+    if (type == QMetaType::QByteArray) {
+        QByteArray ba = variant.value();
+        UString ustring(ba.constData());
+        return jsString(ustring);
+    }
+
+    if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) {
+        QObject* obj = variant.value();
+        return Instance::createRuntimeObject(Instance::QtLanguage, obj, root);
+    }
+
+    if (type == QMetaType::QVariantMap) {
+        // create a new object, and stuff properties into it
+        JSObject* ret = new JSObject(exec->lexicalGlobalObject()->objectPrototype());
+        QVariantMap map = variant.value();
+        QVariantMap::const_iterator i = map.constBegin();
+        while (i != map.constEnd()) {
+            QString s = i.key();
+            JSValue* val = convertQVariantToValue(exec, root, i.value());
+            if (val)
+                ret->put(exec, Identifier((const UChar *)s.constData(), s.length()), val);
+            // ### error case?
+            ++i;
+        }
+
+        return ret;
+    }
+
+    // List types
+    if (type == QMetaType::QVariantList) {
+        QVariantList vl = variant.toList();
+        return new RuntimeArray(exec, new QtArray(vl, QMetaType::Void, root));
+    } else if (type == QMetaType::QStringList) {
+        QStringList sl = variant.value();
+        return new RuntimeArray(exec, new QtArray(sl, QMetaType::QString, root));
+    } else if (type == (QMetaType::Type) qMetaTypeId()) {
+        QObjectList ol= variant.value();
+        return new RuntimeArray(exec, new QtArray(ol, QMetaType::QObjectStar, root));
+    } else if (type == (QMetaType::Type)qMetaTypeId >()) {
+        QList il= variant.value >();
+        return new RuntimeArray(exec, new QtArray(il, QMetaType::Int, root));
+    }
+
+    if (type == (QMetaType::Type)qMetaTypeId()) {
+        QVariant real = variant.value();
+        qConvDebug() << "real variant is:" << real;
+        return convertQVariantToValue(exec, root, real);
+    }
+
+    qConvDebug() << "fallback path for" << variant << variant.userType();
+
+    QString string = variant.toString();
+    UString ustring((KJS::UChar*)string.utf16(), string.length());
+    return jsString(ustring);
+}
+
+// ===============
+
+// Qt-like macros
+#define QW_D(Class) Class##Data* d = d_func()
+#define QW_DS(Class,Instance) Class##Data* d = Instance->d_func()
+
+QtRuntimeMethod::QtRuntimeMethod(QtRuntimeMethodData* dd, ExecState *exec, const Identifier &ident, PassRefPtr inst)
+    : InternalFunctionImp (static_cast(exec->lexicalGlobalObject()->functionPrototype()), ident)
+    , d_ptr(dd)
+{
+    QW_D(QtRuntimeMethod);
+    d->m_instance = inst;
+}
+
+QtRuntimeMethod::~QtRuntimeMethod()
+{
+    delete d_ptr;
+}
+
+CodeType QtRuntimeMethod::codeType() const
+{
+    return FunctionCode;
+}
+
+Completion QtRuntimeMethod::execute(ExecState*)
+{
+    return Completion(Normal, jsUndefined());
+}
+
+// ===============
+
+QtRuntimeMethodData::~QtRuntimeMethodData()
+{
+}
+
+QtRuntimeMetaMethodData::~QtRuntimeMetaMethodData()
+{
+
+}
+
+QtRuntimeConnectionMethodData::~QtRuntimeConnectionMethodData()
+{
+
+}
+
+// ===============
+
+// Type conversion metadata (from QtScript originally)
+class QtMethodMatchType
+{
+public:
+    enum Kind {
+        Invalid,
+        Variant,
+        MetaType,
+        Unresolved,
+        MetaEnum
+    };
+
+
+    QtMethodMatchType()
+        : m_kind(Invalid) { }
+
+    Kind kind() const
+    { return m_kind; }
+
+    QMetaType::Type typeId() const;
+
+    bool isValid() const
+    { return (m_kind != Invalid); }
+
+    bool isVariant() const
+    { return (m_kind == Variant); }
+
+    bool isMetaType() const
+    { return (m_kind == MetaType); }
+
+    bool isUnresolved() const
+    { return (m_kind == Unresolved); }
+
+    bool isMetaEnum() const
+    { return (m_kind == MetaEnum); }
+
+    QByteArray name() const;
+
+    int enumeratorIndex() const
+    { Q_ASSERT(isMetaEnum()); return m_typeId; }
+
+    static QtMethodMatchType variant()
+    { return QtMethodMatchType(Variant); }
+
+    static QtMethodMatchType metaType(int typeId, const QByteArray &name)
+    { return QtMethodMatchType(MetaType, typeId, name); }
+
+    static QtMethodMatchType metaEnum(int enumIndex, const QByteArray &name)
+    { return QtMethodMatchType(MetaEnum, enumIndex, name); }
+
+    static QtMethodMatchType unresolved(const QByteArray &name)
+    { return QtMethodMatchType(Unresolved, /*typeId=*/0, name); }
+
+private:
+    QtMethodMatchType(Kind kind, int typeId = 0, const QByteArray &name = QByteArray())
+        : m_kind(kind), m_typeId(typeId), m_name(name) { }
+
+    Kind m_kind;
+    int m_typeId;
+    QByteArray m_name;
+};
+
+QMetaType::Type QtMethodMatchType::typeId() const
+{
+    if (isVariant())
+        return (QMetaType::Type) QMetaType::type("QVariant");
+    return (QMetaType::Type) (isMetaEnum() ? QMetaType::Int : m_typeId);
+}
+
+QByteArray QtMethodMatchType::name() const
+{
+    if (!m_name.isEmpty())
+        return m_name;
+    else if (m_kind == Variant)
+        return "QVariant";
+    return QByteArray();
+}
+
+struct QtMethodMatchData
+{
+    int matchDistance;
+    int index;
+    QVector types;
+    QVarLengthArray args;
+
+    QtMethodMatchData(int dist, int idx, QVector typs,
+                                const QVarLengthArray &as)
+        : matchDistance(dist), index(idx), types(typs), args(as) { }
+    QtMethodMatchData()
+        : index(-1) { }
+
+    bool isValid() const
+    { return (index != -1); }
+
+    int firstUnresolvedIndex() const
+    {
+        for (int i=0; i < types.count(); i++) {
+            if (types.at(i).isUnresolved())
+                return i;
+        }
+        return -1;
+    }
+};
+
+static int indexOfMetaEnum(const QMetaObject *meta, const QByteArray &str)
+{
+    QByteArray scope;
+    QByteArray name;
+    int scopeIdx = str.indexOf("::");
+    if (scopeIdx != -1) {
+        scope = str.left(scopeIdx);
+        name = str.mid(scopeIdx + 2);
+    } else {
+        name = str;
+    }
+    for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
+        QMetaEnum m = meta->enumerator(i);
+        if ((m.name() == name)/* && (scope.isEmpty() || (m.scope() == scope))*/)
+            return i;
+    }
+    return -1;
+}
+
+// Helper function for resolving methods
+// Largely based on code in QtScript for compatibility reasons
+static int findMethodIndex(ExecState* exec,
+                           const QMetaObject* meta,
+                           const QByteArray& signature,
+                           bool allowPrivate,
+                           const List& jsArgs,
+                           QVarLengthArray &vars,
+                           void** vvars,
+                           JSObject **pError)
+{
+    QList matchingIndices;
+
+    bool overloads = !signature.contains('(');
+
+    int count = meta->methodCount();
+    for (int i = count - 1; i >= 0; --i) {
+        const QMetaMethod m = meta->method(i);
+
+        // Don't choose private methods
+        if (m.access() == QMetaMethod::Private && !allowPrivate)
+            continue;
+
+        // try and find all matching named methods
+        if (m.signature() == signature)
+            matchingIndices.append(i);
+        else if (overloads) {
+            QByteArray rawsignature = m.signature();
+            rawsignature.truncate(rawsignature.indexOf('('));
+            if (rawsignature == signature)
+                matchingIndices.append(i);
+        }
+    }
+
+    int chosenIndex = -1;
+    *pError = 0;
+    QVector chosenTypes;
+
+    QVarLengthArray args;
+    QVector candidates;
+    QVector unresolved;
+    QVector tooFewArgs;
+    QVector conversionFailed;
+
+    foreach(int index, matchingIndices) {
+        QMetaMethod method = meta->method(index);
+
+        QVector types;
+        bool unresolvedTypes = false;
+
+        // resolve return type
+        QByteArray returnTypeName = method.typeName();
+        int rtype = QMetaType::type(returnTypeName);
+        if ((rtype == 0) && !returnTypeName.isEmpty()) {
+            if (returnTypeName == "QVariant") {
+                types.append(QtMethodMatchType::variant());
+            } else if (returnTypeName.endsWith('*')) {
+                types.append(QtMethodMatchType::metaType(QMetaType::VoidStar, returnTypeName));
+            } else {
+                int enumIndex = indexOfMetaEnum(meta, returnTypeName);
+                if (enumIndex != -1)
+                    types.append(QtMethodMatchType::metaEnum(enumIndex, returnTypeName));
+                else {
+                    unresolvedTypes = true;
+                    types.append(QtMethodMatchType::unresolved(returnTypeName));
+                }
+            }
+        } else {
+            if (returnTypeName == "QVariant")
+                types.append(QtMethodMatchType::variant());
+            else
+                types.append(QtMethodMatchType::metaType(rtype, returnTypeName));
+        }
+
+        // resolve argument types
+        QList parameterTypeNames = method.parameterTypes();
+        for (int i = 0; i < parameterTypeNames.count(); ++i) {
+            QByteArray argTypeName = parameterTypeNames.at(i);
+            int atype = QMetaType::type(argTypeName);
+            if (atype == 0) {
+                if (argTypeName == "QVariant") {
+                    types.append(QtMethodMatchType::variant());
+                } else {
+                    int enumIndex = indexOfMetaEnum(meta, argTypeName);
+                    if (enumIndex != -1)
+                        types.append(QtMethodMatchType::metaEnum(enumIndex, argTypeName));
+                    else {
+                        unresolvedTypes = true;
+                        types.append(QtMethodMatchType::unresolved(argTypeName));
+                    }
+                }
+            } else {
+                if (argTypeName == "QVariant")
+                    types.append(QtMethodMatchType::variant());
+                else
+                    types.append(QtMethodMatchType::metaType(atype, argTypeName));
+            }
+        }
+
+        if (jsArgs.size() < (types.count() - 1)) {
+            qMatchDebug() << "Match:too few args for" << method.signature();
+            tooFewArgs.append(index);
+            continue;
+        }
+
+        if (unresolvedTypes) {
+            qMatchDebug() << "Match:unresolved arg types for" << method.signature();
+            // remember it so we can give an error message later, if necessary
+            unresolved.append(QtMethodMatchData(/*matchDistance=*/INT_MAX, index,
+                                                   types, QVarLengthArray()));
+            continue;
+        }
+
+        // Now convert arguments
+        if (args.count() != types.count())
+            args.resize(types.count());
+
+        QtMethodMatchType retType = types[0];
+        args[0] = QVariant(retType.typeId(), (void *)0); // the return value
+
+        bool converted = true;
+        int matchDistance = 0;
+        for (int i = 0; converted && i < types.count() - 1; ++i) {
+            JSValue* arg = i < jsArgs.size() ? jsArgs[i] : jsUndefined();
+
+            int argdistance = -1;
+            QVariant v = convertValueToQVariant(exec, arg, types.at(i+1).typeId(), &argdistance);
+            if (argdistance >= 0) {
+                matchDistance += argdistance;
+                args[i+1] = v;
+            } else {
+                qMatchDebug() << "failed to convert argument " << i << "type" << types.at(i+1).typeId() << QMetaType::typeName(types.at(i+1).typeId());
+                converted = false;
+            }
+        }
+
+        qMatchDebug() << "Match: " << method.signature() << (converted ? "converted":"failed to convert") << "distance " << matchDistance;
+
+        if (converted) {
+            if ((jsArgs.size() == types.count() - 1)
+                && (matchDistance == 0)) {
+                // perfect match, use this one
+                chosenIndex = index;
+                break;
+            } else {
+                QtMethodMatchData metaArgs(matchDistance, index, types, args);
+                if (candidates.isEmpty()) {
+                    candidates.append(metaArgs);
+                } else {
+                    QtMethodMatchData otherArgs = candidates.at(0);
+                    if ((args.count() > otherArgs.args.count())
+                        || ((args.count() == otherArgs.args.count())
+                            && (matchDistance <= otherArgs.matchDistance))) {
+                        candidates.prepend(metaArgs);
+                    } else {
+                        candidates.append(metaArgs);
+                    }
+                }
+            }
+        } else {
+            conversionFailed.append(index);
+        }
+
+        if (!overloads)
+            break;
+    }
+
+    if (chosenIndex == -1 && candidates.count() == 0) {
+        // No valid functions at all - format an error message
+        if (!conversionFailed.isEmpty()) {
+            QString message = QString::fromLatin1("incompatible type of argument(s) in call to %0(); candidates were\n")
+                              .arg(QLatin1String(signature));
+            for (int i = 0; i < conversionFailed.size(); ++i) {
+                if (i > 0)
+                    message += QLatin1String("\n");
+                QMetaMethod mtd = meta->method(conversionFailed.at(i));
+                message += QString::fromLatin1("    %0").arg(QString::fromLatin1(mtd.signature()));
+            }
+            *pError = throwError(exec, TypeError, message.toLatin1().constData());
+        } else if (!unresolved.isEmpty()) {
+            QtMethodMatchData argsInstance = unresolved.first();
+            int unresolvedIndex = argsInstance.firstUnresolvedIndex();
+            Q_ASSERT(unresolvedIndex != -1);
+            QtMethodMatchType unresolvedType = argsInstance.types.at(unresolvedIndex);
+            QString message = QString::fromLatin1("cannot call %0(): unknown type `%1'")
+                .arg(QString::fromLatin1(signature))
+                .arg(QLatin1String(unresolvedType.name()));
+            *pError = throwError(exec, TypeError, message.toLatin1().constData());
+        } else {
+            QString message = QString::fromLatin1("too few arguments in call to %0(); candidates are\n")
+                              .arg(QLatin1String(signature));
+            for (int i = 0; i < tooFewArgs.size(); ++i) {
+                if (i > 0)
+                    message += QLatin1String("\n");
+                QMetaMethod mtd = meta->method(tooFewArgs.at(i));
+                message += QString::fromLatin1("    %0").arg(QString::fromLatin1(mtd.signature()));
+            }
+            *pError = throwError(exec, SyntaxError, message.toLatin1().constData());
+        }
+    }
+
+    if (chosenIndex == -1 && candidates.count() > 0) {
+        QtMethodMatchData metaArgs = candidates.at(0);
+        if ((candidates.size() > 1)
+            && (metaArgs.args.count() == candidates.at(1).args.count())
+            && (metaArgs.matchDistance == candidates.at(1).matchDistance)) {
+            // ambiguous call
+            QString message = QString::fromLatin1("ambiguous call of overloaded function %0(); candidates were\n")
+                                .arg(QLatin1String(signature));
+            for (int i = 0; i < candidates.size(); ++i) {
+                if (i > 0)
+                    message += QLatin1String("\n");
+                QMetaMethod mtd = meta->method(candidates.at(i).index);
+                message += QString::fromLatin1("    %0").arg(QString::fromLatin1(mtd.signature()));
+            }
+            *pError = throwError(exec, TypeError, message.toLatin1().constData());
+        } else {
+            chosenIndex = metaArgs.index;
+            args = metaArgs.args;
+        }
+    }
+
+    if (chosenIndex != -1) {
+        /* Copy the stuff over */
+        int i;
+        vars.resize(args.count());
+        for (i=0; i < args.count(); i++) {
+            vars[i] = args[i];
+            vvars[i] = vars[i].data();
+        }
+    }
+
+    return chosenIndex;
+}
+
+// Signals are not fuzzy matched as much as methods
+static int findSignalIndex(const QMetaObject* meta, int initialIndex, QByteArray signature)
+{
+    int index = initialIndex;
+    QMetaMethod method = meta->method(index);
+    bool overloads = !signature.contains('(');
+    if (overloads && (method.attributes() & QMetaMethod::Cloned)) {
+        // find the most general method
+        do {
+            method = meta->method(--index);
+        } while (method.attributes() & QMetaMethod::Cloned);
+    }
+    return index;
+}
+
+QtRuntimeMetaMethod::QtRuntimeMetaMethod(ExecState* exec, const Identifier& ident, PassRefPtr inst, int index, const QByteArray& signature, bool allowPrivate)
+    : QtRuntimeMethod (new QtRuntimeMetaMethodData(), exec, ident, inst)
+{
+    QW_D(QtRuntimeMetaMethod);
+    d->m_signature = signature;
+    d->m_index = index;
+    d->m_connect = 0;
+    d->m_disconnect = 0;
+    d->m_allowPrivate = allowPrivate;
+}
+
+void QtRuntimeMetaMethod::mark()
+{
+    QtRuntimeMethod::mark();
+    QW_D(QtRuntimeMetaMethod);
+    if (d->m_connect)
+        d->m_connect->mark();
+    if (d->m_disconnect)
+        d->m_disconnect->mark();
+}
+
+JSValue* QtRuntimeMetaMethod::callAsFunction(ExecState* exec, JSObject*, const List& args)
+{
+    QW_D(QtRuntimeMetaMethod);
+
+    // We're limited to 10 args
+    if (args.size() > 10)
+        return jsUndefined();
+
+    // We have to pick a method that matches..
+    JSLock lock;
+
+    QObject *obj = d->m_instance->getObject();
+    if (obj) {
+        QVarLengthArray vargs;
+        void *qargs[11];
+
+        int methodIndex;
+        JSObject* errorObj = 0;
+        if ((methodIndex = findMethodIndex(exec, obj->metaObject(), d->m_signature, d->m_allowPrivate, args, vargs, (void **)qargs, &errorObj)) != -1) {
+            if (obj->qt_metacall(QMetaObject::InvokeMetaMethod, methodIndex, qargs) >= 0)
+                return jsUndefined();
+
+            if (vargs[0].isValid())
+                return convertQVariantToValue(exec, d->m_instance->rootObject(), vargs[0]);
+        }
+
+        if (errorObj)
+            return errorObj;
+    } else {
+        return throwError(exec, GeneralError, "cannot call function of deleted QObject");
+    }
+
+    // void functions return undefined
+    return jsUndefined();
+}
+
+bool QtRuntimeMetaMethod::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+{
+    if (propertyName == "connect") {
+        slot.setCustom(this, connectGetter);
+        return true;
+    } else if (propertyName == "disconnect") {
+        slot.setCustom(this, disconnectGetter);
+        return true;
+    } else if (propertyName == exec->propertyNames().length) {
+        slot.setCustom(this, lengthGetter);
+        return true;
+    }
+
+    return QtRuntimeMethod::getOwnPropertySlot(exec, propertyName, slot);
+}
+
+JSValue *QtRuntimeMetaMethod::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&)
+{
+    // QtScript always returns 0
+    return jsNumber(0);
+}
+
+JSValue *QtRuntimeMetaMethod::connectGetter(ExecState* exec, JSObject*, const Identifier& ident, const PropertySlot& slot)
+{
+    QtRuntimeMetaMethod* thisObj = static_cast(slot.slotBase());
+    QW_DS(QtRuntimeMetaMethod, thisObj);
+
+    if (!d->m_connect)
+        d->m_connect = new QtRuntimeConnectionMethod(exec, ident, true, d->m_instance, d->m_index, d->m_signature);
+    return d->m_connect;
+}
+
+JSValue* QtRuntimeMetaMethod::disconnectGetter(ExecState* exec, JSObject*, const Identifier& ident, const PropertySlot& slot)
+{
+    QtRuntimeMetaMethod* thisObj = static_cast(slot.slotBase());
+    QW_DS(QtRuntimeMetaMethod, thisObj);
+
+    if (!d->m_disconnect)
+        d->m_disconnect = new QtRuntimeConnectionMethod(exec, ident, false, d->m_instance, d->m_index, d->m_signature);
+    return d->m_disconnect;
+}
+
+// ===============
+
+QMultiMap QtRuntimeConnectionMethod::connections;
+
+QtRuntimeConnectionMethod::QtRuntimeConnectionMethod(ExecState* exec, const Identifier& ident, bool isConnect, PassRefPtr inst, int index, const QByteArray& signature)
+    : QtRuntimeMethod (new QtRuntimeConnectionMethodData(), exec, ident, inst)
+{
+    QW_D(QtRuntimeConnectionMethod);
+
+    d->m_signature = signature;
+    d->m_index = index;
+    d->m_isConnect = isConnect;
+}
+
+JSValue *QtRuntimeConnectionMethod::callAsFunction(ExecState* exec, JSObject*, const List& args)
+{
+    QW_D(QtRuntimeConnectionMethod);
+
+    JSLock lock;
+
+    QObject* sender = d->m_instance->getObject();
+
+    if (sender) {
+
+        JSObject* thisObject = exec->lexicalGlobalObject();
+        JSObject* funcObject = 0;
+
+        // QtScript checks signalness first, arguments second
+        int signalIndex = -1;
+
+        // Make sure the initial index is a signal
+        QMetaMethod m = sender->metaObject()->method(d->m_index);
+        if (m.methodType() == QMetaMethod::Signal)
+            signalIndex = findSignalIndex(sender->metaObject(), d->m_index, d->m_signature);
+
+        if (signalIndex != -1) {
+            if (args.size() == 1) {
+                funcObject = args[0]->toObject(exec);
+                if (!funcObject->implementsCall()) {
+                    if (d->m_isConnect)
+                        return throwError(exec, TypeError, "QtMetaMethod.connect: target is not a function");
+                    else
+                        return throwError(exec, TypeError, "QtMetaMethod.disconnect: target is not a function");
+                }
+            } else if (args.size() >= 2) {
+                if (args[0]->type() == ObjectType) {
+                    thisObject = args[0]->toObject(exec);
+
+                    // Get the actual function to call
+                    JSObject *asObj = args[1]->toObject(exec);
+                    if (asObj->implementsCall()) {
+                        // Function version
+                        funcObject = asObj;
+                    } else {
+                        // Convert it to a string
+                        UString funcName = args[1]->toString(exec);
+                        Identifier funcIdent(funcName);
+
+                        // ### DropAllLocks
+                        // This is resolved at this point in QtScript
+                        JSValue* val = thisObject->get(exec, funcIdent);
+                        JSObject* asFuncObj = val->toObject(exec);
+
+                        if (asFuncObj->implementsCall()) {
+                            funcObject = asFuncObj;
+                        } else {
+                            if (d->m_isConnect)
+                                return throwError(exec, TypeError, "QtMetaMethod.connect: target is not a function");
+                            else
+                                return throwError(exec, TypeError, "QtMetaMethod.disconnect: target is not a function");
+                        }
+                    }
+                } else {
+                    if (d->m_isConnect)
+                        return throwError(exec, TypeError, "QtMetaMethod.connect: thisObject is not an object");
+                    else
+                        return throwError(exec, TypeError, "QtMetaMethod.disconnect: thisObject is not an object");
+                }
+            } else {
+                if (d->m_isConnect)
+                    return throwError(exec, GeneralError, "QtMetaMethod.connect: no arguments given");
+                else
+                    return throwError(exec, GeneralError, "QtMetaMethod.disconnect: no arguments given");
+            }
+
+            if (d->m_isConnect) {
+                // to connect, we need:
+                //  target object [from ctor]
+                //  target signal index etc. [from ctor]
+                //  receiver function [from arguments]
+                //  receiver this object [from arguments]
+
+                QtConnectionObject* conn = new QtConnectionObject(d->m_instance, signalIndex, thisObject, funcObject);
+                bool ok = QMetaObject::connect(sender, signalIndex, conn, conn->metaObject()->methodOffset());
+                if (!ok) {
+                    delete conn;
+                    QString msg = QString("QtMetaMethod.connect: failed to connect to %1::%2()")
+                            .arg(sender->metaObject()->className())
+                            .arg(QLatin1String(d->m_signature));
+                    return throwError(exec, GeneralError, msg.toLatin1().constData());
+                }
+                else {
+                    // Store connection
+                    connections.insert(sender, conn);
+                }
+            } else {
+                // Now to find our previous connection object. Hmm.
+                QList conns = connections.values(sender);
+                bool ret = false;
+
+                foreach(QtConnectionObject* conn, conns) {
+                    // Is this the right connection?
+                    if (conn->match(sender, signalIndex, thisObject, funcObject)) {
+                        // Yep, disconnect it
+                        QMetaObject::disconnect(sender, signalIndex, conn, conn->metaObject()->methodOffset());
+                        delete conn; // this will also remove it from the map
+                        ret = true;
+                        break;
+                    }
+                }
+
+                if (!ret) {
+                    QString msg = QString("QtMetaMethod.disconnect: failed to disconnect from %1::%2()")
+                            .arg(sender->metaObject()->className())
+                            .arg(QLatin1String(d->m_signature));
+                    return throwError(exec, GeneralError, msg.toLatin1().constData());
+                }
+            }
+        } else {
+            QString msg = QString("QtMetaMethod.%1: %2::%3() is not a signal")
+                    .arg(d->m_isConnect ? "connect": "disconnect")
+                    .arg(sender->metaObject()->className())
+                    .arg(QLatin1String(d->m_signature));
+            return throwError(exec, TypeError, msg.toLatin1().constData());
+        }
+    } else {
+        return throwError(exec, GeneralError, "cannot call function of deleted QObject");
+    }
+
+    return jsUndefined();
+}
+
+bool QtRuntimeConnectionMethod::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+{
+    if (propertyName == exec->propertyNames().length) {
+        slot.setCustom(this, lengthGetter);
+        return true;
+    }
+
+    return QtRuntimeMethod::getOwnPropertySlot(exec, propertyName, slot);
+}
+
+JSValue *QtRuntimeConnectionMethod::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&)
+{
+    // we have one formal argument, and one optional
+    return jsNumber(1);
+}
+
+// ===============
+
+QtConnectionObject::QtConnectionObject(PassRefPtr instance, int signalIndex, JSObject* thisObject, JSObject* funcObject)
+    : m_instance(instance)
+    , m_signalIndex(signalIndex)
+    , m_originalObject(m_instance->getObject())
+    , m_thisObject(thisObject)
+    , m_funcObject(funcObject)
+{
+    setParent(m_originalObject);
+    ASSERT(JSLock::currentThreadIsHoldingLock()); // so our ProtectedPtrs are safe
+}
+
+QtConnectionObject::~QtConnectionObject()
+{
+    // Remove us from the map of active connections
+    QtRuntimeConnectionMethod::connections.remove(m_originalObject, this);
+}
+
+static const uint qt_meta_data_QtConnectionObject[] = {
+
+ // content:
+       1,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       1,   10, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+
+ // slots: signature, parameters, type, tag, flags
+      28,   27,   27,   27, 0x0a,
+
+       0        // eod
+};
+
+static const char qt_meta_stringdata_QtConnectionObject[] = {
+    "KJS::Bindings::QtConnectionObject\0\0execute()\0"
+};
+
+const QMetaObject QtConnectionObject::staticMetaObject = {
+    { &QObject::staticMetaObject, qt_meta_stringdata_QtConnectionObject,
+      qt_meta_data_QtConnectionObject, 0 }
+};
+
+const QMetaObject *QtConnectionObject::metaObject() const
+{
+    return &staticMetaObject;
+}
+
+void *QtConnectionObject::qt_metacast(const char *_clname)
+{
+    if (!_clname) return 0;
+    if (!strcmp(_clname, qt_meta_stringdata_QtConnectionObject))
+        return static_cast(const_cast(this));
+    return QObject::qt_metacast(_clname);
+}
+
+int QtConnectionObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QObject::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        switch (_id) {
+        case 0: execute(_a); break;
+        }
+        _id -= 1;
+    }
+    return _id;
+}
+
+void QtConnectionObject::execute(void **argv)
+{
+    QObject* obj = m_instance->getObject();
+    if (obj) {
+        const QMetaObject* meta = obj->metaObject();
+        const QMetaMethod method = meta->method(m_signalIndex);
+
+        QList parameterTypes = method.parameterTypes();
+
+        int argc = parameterTypes.count();
+
+        JSLock lock;
+
+        // ### Should the Interpreter/ExecState come from somewhere else?
+        RefPtr ro = m_instance->rootObject();
+        if (ro) {
+            JSGlobalObject* globalobj = ro->globalObject();
+            if (globalobj) {
+                ExecState* exec = globalobj->globalExec();
+                if (exec) {
+                    // Build the argument list (up to the formal argument length of the slot)
+                    List l;
+                    // ### DropAllLocks?
+                    int funcArgC = m_funcObject->get(exec, exec->propertyNames().length)->toInt32(exec);
+                    int argTotal = qMax(funcArgC, argc);
+                    for(int i=0; i < argTotal; i++) {
+                        if (i < argc) {
+                            int argType = QMetaType::type(parameterTypes.at(i));
+                            l.append(convertQVariantToValue(exec, ro, QVariant(argType, argv[i+1])));
+                        } else {
+                            l.append(jsUndefined());
+                        }
+                    }
+                    // Stuff in the __qt_sender property, if we can
+                    if (m_funcObject->inherits(&FunctionImp::info)) {
+                        FunctionImp* fimp = static_cast(m_funcObject.get());
+
+                        JSObject* qt_sender = Instance::createRuntimeObject(Instance::QtLanguage, sender(), ro);
+                        JSObject* wrapper = new JSObject();
+                        wrapper->put(exec, "__qt_sender__", qt_sender);
+                        ScopeChain oldsc = fimp->scope();
+                        ScopeChain sc = oldsc;
+                        sc.push(wrapper);
+                        fimp->setScope(sc);
+                        fimp->call(exec, m_thisObject, l);
+                        fimp->setScope(oldsc);
+                    } else
+                        m_funcObject->call(exec, m_thisObject, l);
+                }
+            }
+        }
+    } else {
+        // A strange place to be - a deleted object emitted a signal here.
+        qWarning() << "sender deleted, cannot deliver signal";
+    }
+}
+
+bool QtConnectionObject::match(QObject* sender, int signalIndex, JSObject* thisObject, JSObject *funcObject)
+{
+    if (m_originalObject == sender && m_signalIndex == signalIndex
+        && thisObject == (JSObject*)m_thisObject && funcObject == (JSObject*)m_funcObject)
+        return true;
+    return false;
+}
+
+// ===============
+
+template  QtArray::QtArray(QList list, QMetaType::Type type, PassRefPtr rootObject)
+    : Array(rootObject)
+    , m_list(list)
+    , m_type(type)
+{
+    m_length = m_list.count();
+}
+
+template  QtArray::~QtArray ()
+{
+}
+
+template  RootObject* QtArray::rootObject() const
+{
+    return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0;
+}
+
+template  void QtArray::setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const
+{
+    // QtScript sets the value, but doesn't forward it to the original source
+    // (e.g. if you do 'object.intList[5] = 6', the object is not updated, but the
+    // copy of the list is).
+    int dist = -1;
+    QVariant val = convertValueToQVariant(exec, aValue, m_type, &dist);
+
+    if (dist >= 0) {
+        m_list[index] = val.value();
+    }
+}
+
+
+template  JSValue* QtArray::valueAt(ExecState *exec, unsigned int index) const
+{
+    if (index < m_length) {
+        T val = m_list.at(index);
+        return convertQVariantToValue(exec, rootObject(), QVariant::fromValue(val));
+    }
+
+    return jsUndefined();
+}
+
+// ===============
+
+} }
diff --git a/bindings/qt/qt_runtime.h b/bindings/qt/qt_runtime.h
new file mode 100644
index 0000000..e44af7b
--- /dev/null
+++ b/bindings/qt/qt_runtime.h
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2006 Trolltech ASA
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef BINDINGS_QT_RUNTIME_H_
+#define BINDINGS_QT_RUNTIME_H_
+
+#include "runtime.h"
+#include "runtime_method.h"
+#include "protect.h"
+
+#include 
+#include 
+#include 
+
+namespace KJS {
+namespace Bindings {
+
+class QtInstance;
+
+class QtField : public Field {
+public:
+
+    typedef enum {
+        MetaProperty,
+        DynamicProperty,
+        ChildObject
+    } QtFieldType;
+
+    QtField(const QMetaProperty &p)
+        : m_type(MetaProperty), m_property(p)
+        {}
+
+    QtField(const QByteArray &b)
+        : m_type(DynamicProperty), m_dynamicProperty(b)
+        {}
+
+    QtField(QObject *child)
+        : m_type(ChildObject), m_childObject(child)
+        {}
+
+    virtual JSValue* valueFromInstance(ExecState*, const Instance*) const;
+    virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const;
+    virtual const char* name() const;
+    QtFieldType fieldType() const {return m_type;}
+private:
+    QtFieldType m_type;
+    QByteArray m_dynamicProperty;
+    QMetaProperty m_property;
+    QPointer m_childObject;
+};
+
+
+class QtMethod : public Method
+{
+public:
+    QtMethod(const QMetaObject *mo, int i, const QByteArray &ident, int numParameters)
+        : m_metaObject(mo),
+          m_index(i),
+          m_identifier(ident),
+          m_nParams(numParameters)
+        { }
+
+    virtual const char* name() const { return m_identifier.constData(); }
+    virtual int numParameters() const { return m_nParams; }
+
+private:
+    friend class QtInstance;
+    const QMetaObject *m_metaObject;
+    int m_index;
+    QByteArray m_identifier;
+    int m_nParams;
+};
+
+
+template  class QtArray : public Array
+{
+public:
+    QtArray(QList list, QMetaType::Type type, PassRefPtr);
+    virtual ~QtArray();
+
+    RootObject* rootObject() const;
+
+    virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const;
+    virtual JSValue *valueAt(ExecState *exec, unsigned int index) const;
+    virtual unsigned int getLength() const {return m_length;}
+
+private:
+    mutable QList m_list; // setValueAt is const!
+    unsigned int m_length;
+    QMetaType::Type m_type;
+};
+
+// Based on RuntimeMethod
+
+// Extra data classes (to avoid the CELL_SIZE limit on JS objects)
+
+class QtRuntimeMethodData {
+    public:
+        virtual ~QtRuntimeMethodData();
+        RefPtr m_instance;
+};
+
+class QtRuntimeConnectionMethod;
+class QtRuntimeMetaMethodData : public QtRuntimeMethodData {
+    public:
+        ~QtRuntimeMetaMethodData();
+        QByteArray m_signature;
+        bool m_allowPrivate;
+        int m_index;
+        QtRuntimeConnectionMethod *m_connect;
+        QtRuntimeConnectionMethod *m_disconnect;
+};
+
+class QtRuntimeConnectionMethodData : public QtRuntimeMethodData {
+    public:
+        ~QtRuntimeConnectionMethodData();
+        QByteArray m_signature;
+        int m_index;
+        bool m_isConnect;
+};
+
+// Common base class (doesn't really do anything interesting)
+class QtRuntimeMethod : public InternalFunctionImp
+{
+public:
+    virtual ~QtRuntimeMethod();
+
+    virtual CodeType codeType() const;
+    virtual Completion execute(ExecState *exec);
+
+protected:
+    QtRuntimeMethodData *d_func() const {return d_ptr;}
+    QtRuntimeMethod(QtRuntimeMethodData *dd, ExecState *exec, const Identifier &n, PassRefPtr inst);
+    QtRuntimeMethodData *d_ptr;
+};
+
+class QtRuntimeMetaMethod : public QtRuntimeMethod
+{
+public:
+    QtRuntimeMetaMethod(ExecState *exec, const Identifier &n, PassRefPtr inst, int index, const QByteArray& signature, bool allowPrivate);
+
+    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
+
+    virtual void mark();
+
+protected:
+    QtRuntimeMetaMethodData* d_func() const {return reinterpret_cast(d_ptr);}
+
+private:
+    static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+    static JSValue *connectGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+    static JSValue *disconnectGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+};
+
+class QtConnectionObject;
+class QtRuntimeConnectionMethod : public QtRuntimeMethod
+{
+public:
+    QtRuntimeConnectionMethod(ExecState *exec, const Identifier &n, bool isConnect, PassRefPtr inst, int index, const QByteArray& signature );
+
+    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
+
+protected:
+    QtRuntimeConnectionMethodData* d_func() const {return reinterpret_cast(d_ptr);}
+
+private:
+    static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+    static QMultiMap connections;
+    friend class QtConnectionObject;
+};
+
+class QtConnectionObject: public QObject
+{
+public:
+    QtConnectionObject(PassRefPtr instance, int signalIndex, JSObject* thisObject, JSObject* funcObject);
+    ~QtConnectionObject();
+
+    static const QMetaObject staticMetaObject;
+    virtual const QMetaObject *metaObject() const;
+    virtual void *qt_metacast(const char *);
+    virtual int qt_metacall(QMetaObject::Call, int, void **argv);
+
+    bool match(QObject *sender, int signalIndex, JSObject* thisObject, JSObject *funcObject);
+
+    // actual slot:
+    void execute(void **argv);
+
+private:
+    RefPtr m_instance;
+    int m_signalIndex;
+    QObject* m_originalObject; // only used as a key, not dereferenced
+    ProtectedPtr m_thisObject;
+    ProtectedPtr m_funcObject;
+};
+
+} // namespace Bindings
+} // namespace KJS
+
+#endif
diff --git a/bindings/runtime.cpp b/bindings/runtime.cpp
new file mode 100644
index 0000000..9e7e1b7
--- /dev/null
+++ b/bindings/runtime.cpp
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "runtime.h"
+
+#include "JSLock.h"
+#if ENABLE(NETSCAPE_API)
+#include "NP_jsobject.h"
+#include "c_instance.h"
+#endif
+#include "runtime_object.h"
+#include "runtime_root.h"
+
+#if HAVE(JNI)
+#include "jni_instance.h"
+#endif
+#include "objc_instance.h"
+#if PLATFORM(QT)
+#include "qt_instance.h"
+#endif
+
+namespace KJS { namespace Bindings {
+
+Array::Array(PassRefPtr rootObject)
+    : _rootObject(rootObject)
+{
+    ASSERT(_rootObject);
+}
+
+Array::~Array()
+{
+}
+
+Instance::Instance(PassRefPtr rootObject)
+    : _rootObject(rootObject)
+    , _refCount(0)
+{
+    ASSERT(_rootObject);
+}
+
+Instance::~Instance()
+{
+}
+
+static KJSDidExecuteFunctionPtr _DidExecuteFunction;
+
+void Instance::setDidExecuteFunction(KJSDidExecuteFunctionPtr func) { _DidExecuteFunction = func; }
+KJSDidExecuteFunctionPtr Instance::didExecuteFunction() { return _DidExecuteFunction; }
+
+JSValue *Instance::getValueOfField(ExecState *exec, const Field *aField) const
+{
+    return aField->valueFromInstance(exec, this);
+}
+
+void Instance::setValueOfField(ExecState *exec, const Field *aField, JSValue *aValue) const
+{
+    aField->setValueToInstance(exec, this, aValue);
+}
+
+Instance* Instance::createBindingForLanguageInstance(BindingLanguage language, void* nativeInstance, PassRefPtr rootObject)
+{
+    Instance *newInstance = 0;
+
+    switch (language) {
+#if HAVE(JNI)
+        case Instance::JavaLanguage: {
+            newInstance = new Bindings::JavaInstance((jobject)nativeInstance, rootObject);
+            break;
+        }
+#endif
+        case Instance::ObjectiveCLanguage: {
+            newInstance = new Bindings::ObjcInstance((ObjectStructPtr)nativeInstance, rootObject);
+            break;
+        }
+#if ENABLE(NETSCAPE_API)
+        case Instance::CLanguage: {
+            newInstance = new Bindings::CInstance((NPObject *)nativeInstance, rootObject);
+            break;
+        }
+#endif
+#if PLATFORM(QT)
+        case Instance::QtLanguage: {
+            newInstance = Bindings::QtInstance::getQtInstance((QObject *)nativeInstance, rootObject);
+            break;
+        }
+#endif
+        default:
+            break;
+    }
+
+    return newInstance;
+}
+
+JSObject* Instance::createRuntimeObject(BindingLanguage language, void* nativeInstance, PassRefPtr rootObject)
+{
+    Instance* instance = Instance::createBindingForLanguageInstance(language, nativeInstance, rootObject);
+
+    return createRuntimeObject(instance);
+}
+
+JSObject* Instance::createRuntimeObject(Instance* instance)
+{
+#if PLATFORM(QT)
+    if (instance->getBindingLanguage() == QtLanguage)
+        return QtInstance::getRuntimeObject(static_cast(instance));
+#endif
+    JSLock lock;
+
+    return new RuntimeObjectImp(instance);
+}
+
+Instance* Instance::getInstance(JSObject* object, BindingLanguage language)
+{
+    if (!object)
+        return 0;
+    if (!object->inherits(&RuntimeObjectImp::info))
+        return 0;
+    Instance* instance = (static_cast(object))->getInternalInstance();
+    if (!instance)
+        return 0;
+    if (instance->getBindingLanguage() != language)
+        return 0;
+    return instance;
+}
+
+RootObject* Instance::rootObject() const 
+{ 
+    return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0;
+}
+
+} } // namespace KJS::Bindings
diff --git a/bindings/runtime.h b/bindings/runtime.h
new file mode 100644
index 0000000..dbb324c
--- /dev/null
+++ b/bindings/runtime.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef JAVASCRIPTCORE_BINDINGS_RUNTIME_H
+#define JAVASCRIPTCORE_BINDINGS_RUNTIME_H
+
+#include "value.h"
+
+#include 
+#include 
+#include 
+
+namespace KJS  {
+
+class Identifier;
+class List;
+class PropertyNameArray;
+
+namespace Bindings {
+
+class Instance;
+class Method;
+class RootObject;
+
+typedef Vector MethodList;
+
+class Field
+{
+public:
+    virtual const char* name() const = 0;
+
+    virtual JSValue* valueFromInstance(ExecState*, const Instance*) const = 0;
+    virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const = 0;
+
+    virtual ~Field() {}
+};
+
+class Method : Noncopyable
+{
+public:
+    virtual const char *name() const = 0;
+
+    virtual int numParameters() const = 0;
+        
+    virtual ~Method() {}
+};
+
+class Class : Noncopyable
+{
+public:
+    virtual const char *name() const = 0;
+    
+    virtual MethodList methodsNamed(const Identifier&, Instance*) const = 0;
+    
+    virtual Field *fieldNamed(const Identifier&, Instance*) const = 0;
+
+    virtual JSValue* fallbackObject(ExecState*, Instance*, const Identifier&) { return jsUndefined(); }
+    
+    virtual ~Class() {}
+};
+
+typedef void (*KJSDidExecuteFunctionPtr)(ExecState*, JSObject* rootObject);
+
+class Instance : Noncopyable {
+public:
+    typedef enum {
+        JavaLanguage,
+        ObjectiveCLanguage,
+        CLanguage
+#if PLATFORM(QT)
+        , QtLanguage
+#endif
+    } BindingLanguage;
+
+    Instance(PassRefPtr);
+
+    static void setDidExecuteFunction(KJSDidExecuteFunctionPtr func);
+    static KJSDidExecuteFunctionPtr didExecuteFunction();
+    
+    static Instance* createBindingForLanguageInstance(BindingLanguage, void* nativeInstance, PassRefPtr);
+    static JSObject* createRuntimeObject(BindingLanguage, void* nativeInstance, PassRefPtr);
+    static JSObject* createRuntimeObject(Instance*);
+
+    static Instance* getInstance(JSObject*, BindingLanguage);
+
+    void ref() { _refCount++; }
+    void deref() 
+    { 
+        if (--_refCount == 0) 
+            delete this; 
+    }
+
+    // These functions are called before and after the main entry points into
+    // the native implementations.  They can be used to establish and cleanup
+    // any needed state.
+    virtual void begin() {}
+    virtual void end() {}
+    
+    virtual Class *getClass() const = 0;
+    
+    virtual JSValue* getValueOfField(ExecState*, const Field*) const;
+    virtual JSValue* getValueOfUndefinedField(ExecState*, const Identifier&, JSType) const { return jsUndefined(); }
+    virtual void setValueOfField(ExecState*, const Field*, JSValue*) const;
+    virtual bool supportsSetValueOfUndefinedField() { return false; }
+    virtual void setValueOfUndefinedField(ExecState*, const Identifier&, JSValue*) {}
+
+    virtual bool implementsCall() const { return false; }
+    
+    virtual JSValue* invokeMethod(ExecState*, const MethodList&, const List& args) = 0;
+    virtual JSValue* invokeDefaultMethod(ExecState*, const List&) { return jsUndefined(); }
+    
+    virtual void getPropertyNames(ExecState*, PropertyNameArray&) { }
+
+    virtual JSValue* defaultValue(JSType hint) const = 0;
+    
+    virtual JSValue* valueOf() const { return jsString(getClass()->name()); }
+    
+    RootObject* rootObject() const;
+    
+    virtual ~Instance();
+
+    virtual BindingLanguage getBindingLanguage() const = 0;
+
+protected:
+    RefPtr _rootObject;
+    unsigned _refCount;
+};
+
+class Array : Noncopyable
+{
+public:
+    Array(PassRefPtr);
+    virtual ~Array();
+    
+    virtual void setValueAt(ExecState *, unsigned index, JSValue*) const = 0;
+    virtual JSValue* valueAt(ExecState *, unsigned index) const = 0;
+    virtual unsigned int getLength() const = 0;
+protected:
+    RefPtr _rootObject;
+};
+
+const char *signatureForParameters(const List&);
+
+typedef HashMap, MethodList*> MethodListMap;
+typedef HashMap, Method*> MethodMap; 
+typedef HashMap, Field*> FieldMap; 
+    
+} // namespace Bindings
+
+} // namespace KJS
+
+#endif
diff --git a/bindings/runtime_array.cpp b/bindings/runtime_array.cpp
new file mode 100644
index 0000000..c8ff075
--- /dev/null
+++ b/bindings/runtime_array.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "runtime_array.h"
+
+#include "JSGlobalObject.h"
+#include "array_object.h"
+
+using namespace KJS;
+
+const ClassInfo RuntimeArray::info = { "RuntimeArray", &ArrayInstance::info, 0 };
+
+RuntimeArray::RuntimeArray(ExecState *exec, Bindings::Array *a)
+    : JSObject(exec->lexicalGlobalObject()->arrayPrototype())
+    , _array(a)
+{
+}
+
+JSValue *RuntimeArray::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
+{
+    RuntimeArray *thisObj = static_cast(slot.slotBase());
+    return jsNumber(thisObj->getLength());
+}
+
+JSValue *RuntimeArray::indexGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot)
+{
+    RuntimeArray *thisObj = static_cast(slot.slotBase());
+    return thisObj->getConcreteArray()->valueAt(exec, slot.index());
+}
+
+bool RuntimeArray::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+{
+    if (propertyName == exec->propertyNames().length) {
+        slot.setCustom(this, lengthGetter);
+        return true;
+    }
+    
+    bool ok;
+    unsigned index = propertyName.toArrayIndex(&ok);
+    if (ok) {
+        if (index < getLength()) {
+            slot.setCustomIndex(this, index, indexGetter);
+            return true;
+        }
+    }
+    
+    return JSObject::getOwnPropertySlot(exec, propertyName, slot);
+}
+
+bool RuntimeArray::getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot& slot)
+{
+    if (index < getLength()) {
+        slot.setCustomIndex(this, index, indexGetter);
+        return true;
+    }
+    
+    return JSObject::getOwnPropertySlot(exec, index, slot);
+}
+
+void RuntimeArray::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
+{
+    if (propertyName == exec->propertyNames().length) {
+        throwError(exec, RangeError);
+        return;
+    }
+    
+    bool ok;
+    unsigned index = propertyName.toArrayIndex(&ok);
+    if (ok) {
+        getConcreteArray()->setValueAt(exec, index, value);
+        return;
+    }
+    
+    JSObject::put(exec, propertyName, value, attr);
+}
+
+void RuntimeArray::put(ExecState* exec, unsigned index, JSValue* value, int)
+{
+    if (index >= getLength()) {
+        throwError(exec, RangeError);
+        return;
+    }
+    
+    getConcreteArray()->setValueAt(exec, index, value);
+}
+
+bool RuntimeArray::deleteProperty(ExecState*, const Identifier&)
+{
+    return false;
+}
+
+bool RuntimeArray::deleteProperty(ExecState*, unsigned)
+{
+    return false;
+}
diff --git a/bindings/runtime_array.h b/bindings/runtime_array.h
new file mode 100644
index 0000000..2182b31
--- /dev/null
+++ b/bindings/runtime_array.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef RUNTIME_ARRAY_H_
+#define RUNTIME_ARRAY_H_
+
+#include 
+
+#include "array_instance.h"
+#include "runtime.h"
+
+namespace KJS {
+    
+class RuntimeArray : public JSObject {
+public:
+    RuntimeArray(ExecState *exec, Bindings::Array *i);
+    
+    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+    virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
+    virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
+    virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None);
+    
+    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
+    virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
+    
+    virtual const ClassInfo *classInfo() const { return &info; }
+    
+    unsigned getLength() const { return getConcreteArray()->getLength(); }
+    
+    Bindings::Array *getConcreteArray() const { return _array.get(); }
+
+    static const ClassInfo info;
+
+private:
+    static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+    static JSValue *indexGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+
+    OwnPtr _array;
+};
+    
+} // namespace KJS
+
+#endif // RUNTIME_ARRAY_H_
diff --git a/bindings/runtime_method.cpp b/bindings/runtime_method.cpp
new file mode 100644
index 0000000..4430f25
--- /dev/null
+++ b/bindings/runtime_method.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+ 
+#include "config.h"
+#include "runtime_method.h"
+
+#include "ExecState.h"
+#include "JSGlobalObject.h"
+#include "runtime_object.h"
+#include "function_object.h"
+
+using namespace KJS::Bindings;
+using namespace KJS;
+
+RuntimeMethod::RuntimeMethod(ExecState *exec, const Identifier &ident, Bindings::MethodList &m) 
+    : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), ident)
+    , _methodList(new MethodList(m))
+{
+}
+
+JSValue *RuntimeMethod::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
+{
+    RuntimeMethod *thisObj = static_cast(slot.slotBase());
+
+    // Ick!  There may be more than one method with this name.  Arbitrarily
+    // just pick the first method.  The fundamental problem here is that 
+    // JavaScript doesn't have the notion of method overloading and
+    // Java does.
+    // FIXME: a better solution might be to give the maximum number of parameters
+    // of any method
+    return jsNumber(thisObj->_methodList->at(0)->numParameters());
+}
+
+bool RuntimeMethod::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot &slot)
+{
+    if (propertyName == exec->propertyNames().length) {
+        slot.setCustom(this, lengthGetter);
+        return true;
+    }
+    
+    return InternalFunctionImp::getOwnPropertySlot(exec, propertyName, slot);
+}
+
+JSValue *RuntimeMethod::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+{
+    if (_methodList->isEmpty())
+        return jsUndefined();
+    
+    RuntimeObjectImp *imp = 0;
+
+    if (thisObj->classInfo() == &KJS::RuntimeObjectImp::info) {
+        imp = static_cast(thisObj);
+    } else {
+        // If thisObj is the DOM object for a plugin, get the corresponding
+        // runtime object from the DOM object.
+        JSValue* value = thisObj->get(exec, "__apple_runtime_object");
+        if (value->isObject(&KJS::RuntimeObjectImp::info))    
+            imp = static_cast(value);
+    }
+
+    if (!imp)
+        return throwError(exec, TypeError);
+
+    RefPtr instance = imp->getInternalInstance();
+    if (!instance) 
+        return RuntimeObjectImp::throwInvalidAccessError(exec);
+        
+    instance->begin();
+    JSValue *aValue = instance->invokeMethod(exec, *_methodList, args);
+    instance->end();
+    return aValue;
+}
diff --git a/bindings/runtime_method.h b/bindings/runtime_method.h
new file mode 100644
index 0000000..7fbe32a
--- /dev/null
+++ b/bindings/runtime_method.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef RUNTIME_FUNCTION_H_
+#define RUNTIME_FUNCTION_H_
+
+#include "function.h"
+#include "runtime.h"
+#include "object.h"
+
+namespace KJS {
+
+class RuntimeMethod : public InternalFunctionImp {
+public:
+    RuntimeMethod(ExecState *exec, const Identifier &n, Bindings::MethodList &methodList);
+    
+    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+
+    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
+
+private:
+    static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+
+    OwnPtr _methodList;
+};
+
+} // namespace KJS
+
+#endif
diff --git a/bindings/runtime_object.cpp b/bindings/runtime_object.cpp
new file mode 100644
index 0000000..c2cb3e8
--- /dev/null
+++ b/bindings/runtime_object.cpp
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "runtime_object.h"
+
+#include "error_object.h"
+#include "operations.h"
+#include "runtime_method.h"
+#include "runtime_root.h"
+
+using namespace KJS;
+using namespace Bindings;
+
+const ClassInfo RuntimeObjectImp::info = { "RuntimeObject", 0, 0 };
+
+RuntimeObjectImp::RuntimeObjectImp(Bindings::Instance *i)
+: instance(i)
+{
+    instance->rootObject()->addRuntimeObject(this);
+}
+
+RuntimeObjectImp::~RuntimeObjectImp()
+{
+    if (instance)
+        instance->rootObject()->removeRuntimeObject(this);
+}
+
+void RuntimeObjectImp::invalidate()
+{
+    ASSERT(instance);
+    instance = 0;
+}
+
+JSValue *RuntimeObjectImp::fallbackObjectGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
+{
+    RuntimeObjectImp *thisObj = static_cast(slot.slotBase());
+    RefPtr instance = thisObj->instance;
+
+    if (!instance)
+        return throwInvalidAccessError(exec);
+    
+    instance->begin();
+
+    Class *aClass = instance->getClass();
+    JSValue* result = aClass->fallbackObject(exec, instance.get(), propertyName);
+
+    instance->end();
+            
+    return result;
+}
+
+JSValue *RuntimeObjectImp::fieldGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
+{    
+    RuntimeObjectImp *thisObj = static_cast(slot.slotBase());
+    RefPtr instance = thisObj->instance;
+
+    if (!instance)
+        return throwInvalidAccessError(exec);
+    
+    instance->begin();
+
+    Class *aClass = instance->getClass();
+    Field* aField = aClass->fieldNamed(propertyName, instance.get());
+    JSValue *result = instance->getValueOfField(exec, aField); 
+    
+    instance->end();
+            
+    return result;
+}
+
+JSValue *RuntimeObjectImp::methodGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
+{
+    RuntimeObjectImp *thisObj = static_cast(slot.slotBase());
+    RefPtr instance = thisObj->instance;
+
+    if (!instance)
+        return throwInvalidAccessError(exec);
+    
+    instance->begin();
+
+    Class *aClass = instance->getClass();
+    MethodList methodList = aClass->methodsNamed(propertyName, instance.get());
+    JSValue *result = new RuntimeMethod(exec, propertyName, methodList);
+
+    instance->end();
+            
+    return result;
+}
+
+bool RuntimeObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+{
+    if (!instance) {
+        throwInvalidAccessError(exec);
+        return false;
+    }
+    
+    instance->begin();
+    
+    Class *aClass = instance->getClass();
+    
+    if (aClass) {
+        // See if the instance has a field with the specified name.
+        Field *aField = aClass->fieldNamed(propertyName, instance.get());
+        if (aField) {
+            slot.setCustom(this, fieldGetter);
+            instance->end();
+            return true;
+        } else {
+            // Now check if a method with specified name exists, if so return a function object for
+            // that method.
+            MethodList methodList = aClass->methodsNamed(propertyName, instance.get());
+            if (methodList.size() > 0) {
+                slot.setCustom(this, methodGetter);
+                
+                instance->end();
+                return true;
+            }
+        }
+
+        // Try a fallback object.
+        if (!aClass->fallbackObject(exec, instance.get(), propertyName)->isUndefined()) {
+            slot.setCustom(this, fallbackObjectGetter);
+            instance->end();
+            return true;
+        }
+    }
+        
+    instance->end();
+
+    // don't call superclass, because runtime objects can't have custom properties or a prototype
+    return false;
+}
+
+void RuntimeObjectImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int)
+{
+    if (!instance) {
+        throwInvalidAccessError(exec);
+        return;
+    }
+    
+    RefPtr protector(instance);
+    instance->begin();
+
+    // Set the value of the property.
+    Field *aField = instance->getClass()->fieldNamed(propertyName, instance.get());
+    if (aField)
+        instance->setValueOfField(exec, aField, value);
+    else if (instance->supportsSetValueOfUndefinedField())
+        instance->setValueOfUndefinedField(exec, propertyName, value);
+
+    instance->end();
+}
+
+bool RuntimeObjectImp::canPut(ExecState* exec, const Identifier& propertyName) const
+{
+    if (!instance) {
+        throwInvalidAccessError(exec);
+        return false;
+    }
+    
+    instance->begin();
+
+    Field *aField = instance->getClass()->fieldNamed(propertyName, instance.get());
+
+    instance->end();
+
+    return !!aField;
+}
+
+bool RuntimeObjectImp::deleteProperty(ExecState*, const Identifier&)
+{
+    // Can never remove a property of a RuntimeObject.
+    return false;
+}
+
+JSValue *RuntimeObjectImp::defaultValue(ExecState* exec, JSType hint) const
+{
+    if (!instance)
+        return throwInvalidAccessError(exec);
+    
+    JSValue *result;
+    
+    RefPtr protector(instance);
+    instance->begin();
+
+    result = instance->defaultValue(hint);
+    
+    instance->end();
+    
+    return result;
+}
+    
+bool RuntimeObjectImp::implementsCall() const
+{
+    if (!instance)
+        return false;
+    
+    return instance->implementsCall();
+}
+
+JSValue *RuntimeObjectImp::callAsFunction(ExecState* exec, JSObject*, const List& args)
+{
+    if (!instance)
+        return throwInvalidAccessError(exec);
+
+    RefPtr protector(instance);
+    instance->begin();
+
+    JSValue *aValue = instance->invokeDefaultMethod(exec, args);
+    
+    instance->end();
+    
+    return aValue;
+}
+
+void RuntimeObjectImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
+{
+    if (!instance) {
+        throwInvalidAccessError(exec);
+        return;
+    }
+    
+    instance->begin();
+    instance->getPropertyNames(exec, propertyNames);
+    instance->end();
+}
+
+JSObject* RuntimeObjectImp::throwInvalidAccessError(ExecState* exec)
+{
+    return throwError(exec, ReferenceError, "Trying to access object from destroyed plug-in.");
+}
diff --git a/bindings/runtime_object.h b/bindings/runtime_object.h
new file mode 100644
index 0000000..0ce7d74
--- /dev/null
+++ b/bindings/runtime_object.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef KJS_RUNTIME_OBJECT_H
+#define KJS_RUNTIME_OBJECT_H
+
+#include "runtime.h"
+#include "object.h"
+
+#include 
+
+namespace KJS {
+
+class RuntimeObjectImp : public JSObject {
+public:
+    virtual ~RuntimeObjectImp();
+    
+    const ClassInfo *classInfo() const { return &info; }
+
+    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+    virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
+    virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
+    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
+    virtual JSValue *defaultValue(ExecState *exec, JSType hint) const;
+    virtual bool implementsCall() const;
+    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
+    virtual void getPropertyNames(ExecState*, PropertyNameArray&);
+
+    virtual void invalidate();
+    Bindings::Instance *getInternalInstance() const { return instance.get(); }
+    
+    static JSObject* throwInvalidAccessError(ExecState*);
+    
+    static const ClassInfo info;
+
+protected:
+    friend class Bindings::Instance;
+    RuntimeObjectImp(Bindings::Instance*); // Only allow Instances and derived classes to create us
+
+private:
+    RuntimeObjectImp(); // prevent default construction
+    
+    static JSValue *fallbackObjectGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+    static JSValue *fieldGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+    static JSValue *methodGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
+
+    RefPtr instance;
+};
+    
+} // namespace
+
+#endif
diff --git a/bindings/runtime_root.cpp b/bindings/runtime_root.cpp
new file mode 100644
index 0000000..aa1fa86
--- /dev/null
+++ b/bindings/runtime_root.cpp
@@ -0,0 +1,309 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "runtime_root.h"
+
+#include "JSGlobalObject.h"
+#include "object.h"
+#include "runtime.h"
+#include "runtime_object.h"
+#include 
+#include 
+
+namespace KJS { namespace Bindings {
+
+// This code attempts to solve two problems: (1) plug-ins leaking references to 
+// JS and the DOM; (2) plug-ins holding stale references to JS and the DOM. Previous 
+// comments in this file claimed that problem #1 was an issue in Java, in particular, 
+// because Java, allegedly, didn't always call finalize when collecting an object.
+
+typedef HashSet RootObjectSet;
+
+static RootObjectSet* rootObjectSet()
+{
+    static RootObjectSet staticRootObjectSet;
+    return &staticRootObjectSet;
+}
+
+// FIXME:  These two functions are a potential performance problem.  We could 
+// fix them by adding a JSObject to RootObject dictionary.
+
+RootObject* findProtectingRootObject(JSObject* jsObject)
+{
+    RootObjectSet::const_iterator end = rootObjectSet()->end();
+    for (RootObjectSet::const_iterator it = rootObjectSet()->begin(); it != end; ++it) {
+        if ((*it)->gcIsProtected(jsObject))
+            return *it;
+    }
+    return 0;
+}
+
+RootObject* findRootObject(JSGlobalObject* globalObject)
+{
+    RootObjectSet::const_iterator end = rootObjectSet()->end();
+    for (RootObjectSet::const_iterator it = rootObjectSet()->begin(); it != end; ++it) {
+        if ((*it)->globalObject() == globalObject)
+            return *it;
+    }
+    return 0;
+}
+
+// May only be set by dispatchToJavaScriptThread().
+#if ENABLE(JAVA_BINDINGS)
+static CFRunLoopSourceRef completionSource;
+
+static void completedJavaScriptAccess (void *i)
+{
+    assert (CFRunLoopGetCurrent() != RootObject::runLoop());
+
+    JSObjectCallContext *callContext = (JSObjectCallContext *)i;
+    CFRunLoopRef runLoop = (CFRunLoopRef)callContext->originatingLoop;
+
+    assert (CFRunLoopGetCurrent() == runLoop);
+
+    CFRunLoopStop(runLoop);
+}
+
+static pthread_once_t javaScriptAccessLockOnce = PTHREAD_ONCE_INIT;
+static pthread_mutex_t javaScriptAccessLock;
+static int javaScriptAccessLockCount = 0;
+
+static void initializeJavaScriptAccessLock()
+{
+    pthread_mutexattr_t attr;
+    
+    pthread_mutexattr_init(&attr);
+    pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+    
+    pthread_mutex_init(&javaScriptAccessLock, &attr);
+}
+
+static inline void lockJavaScriptAccess()
+{
+    // Perhaps add deadlock detection?
+    pthread_once(&javaScriptAccessLockOnce, initializeJavaScriptAccessLock);
+    pthread_mutex_lock(&javaScriptAccessLock);
+    javaScriptAccessLockCount++;
+}
+
+static inline void unlockJavaScriptAccess()
+{
+    javaScriptAccessLockCount--;
+    pthread_mutex_unlock(&javaScriptAccessLock);
+}
+
+
+void RootObject::dispatchToJavaScriptThread(JSObjectCallContext *context)
+{
+    // This lock guarantees that only one thread can invoke
+    // at a time, and also guarantees that completionSource;
+    // won't get clobbered.
+    lockJavaScriptAccess();
+
+    CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
+
+    assert (currentRunLoop != RootObject::runLoop());
+
+    // Setup a source to signal once the invocation of the JavaScript
+    // call completes.
+    //
+    // FIXME:  This could be a potential performance issue.  Creating and
+    // adding run loop sources is expensive.  We could create one source 
+    // per thread, as needed, instead.
+    context->originatingLoop = currentRunLoop;
+    CFRunLoopSourceContext sourceContext = {0, context, NULL, NULL, NULL, NULL, NULL, NULL, NULL, completedJavaScriptAccess};
+    completionSource = CFRunLoopSourceCreate(NULL, 0, &sourceContext);
+    CFRunLoopAddSource(currentRunLoop, completionSource, kCFRunLoopDefaultMode);
+
+    // Wakeup JavaScript access thread and make it do it's work.
+    CFRunLoopSourceSignal(RootObject::performJavaScriptSource());
+    if (CFRunLoopIsWaiting(RootObject::runLoop())) {
+        CFRunLoopWakeUp(RootObject::runLoop());
+    }
+    
+    // Wait until the JavaScript access thread is done.
+    CFRunLoopRun ();
+
+    CFRunLoopRemoveSource(currentRunLoop, completionSource, kCFRunLoopDefaultMode);
+    CFRelease (completionSource);
+
+    unlockJavaScriptAccess();
+}
+
+static void performJavaScriptAccess(void*)
+{
+    assert (CFRunLoopGetCurrent() == RootObject::runLoop());
+    
+    // Dispatch JavaScript calls here.
+    CFRunLoopSourceContext sourceContext;
+    CFRunLoopSourceGetContext (completionSource, &sourceContext);
+    JSObjectCallContext *callContext = (JSObjectCallContext *)sourceContext.info;    
+    CFRunLoopRef originatingLoop = callContext->originatingLoop;
+
+    JavaJSObject::invoke (callContext);
+    
+    // Signal the originating thread that we're done.
+    CFRunLoopSourceSignal (completionSource);
+    if (CFRunLoopIsWaiting(originatingLoop)) {
+        CFRunLoopWakeUp(originatingLoop);
+    }
+}
+#endif // ENABLE(JAVA_BINDINGS)
+
+CreateRootObjectFunction RootObject::_createRootObject = 0;
+CFRunLoopRef RootObject::_runLoop = 0;
+CFRunLoopSourceRef RootObject::_performJavaScriptSource = 0;
+
+// Must be called from the thread that will be used to access JavaScript.
+void RootObject::setCreateRootObject(CreateRootObjectFunction createRootObject) {
+    // Should only be called once.
+    ASSERT(!_createRootObject);
+
+    _createRootObject = createRootObject;
+    
+    // Assume that we can retain this run loop forever.  It'll most 
+    // likely (always?) be the main loop.
+    _runLoop = (CFRunLoopRef)CFRetain (CFRunLoopGetCurrent ());
+
+    // Setup a source the other threads can use to signal the _runLoop
+    // thread that a JavaScript call needs to be invoked.
+
+#if ENABLE(JAVA_BINDINGS)
+    CFRunLoopSourceContext sourceContext = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, performJavaScriptAccess};
+    RootObject::_performJavaScriptSource = CFRunLoopSourceCreate(NULL, 0, &sourceContext);
+    CFRunLoopAddSource(RootObject::_runLoop, RootObject::_performJavaScriptSource, kCFRunLoopDefaultMode);
+#endif // ENABLE(JAVA_BINDINGS)
+}
+
+
+PassRefPtr RootObject::create(const void* nativeHandle, JSGlobalObject* globalObject)
+{
+    return new RootObject(nativeHandle, globalObject);
+}
+
+RootObject::RootObject(const void* nativeHandle, JSGlobalObject* globalObject)
+    : m_isValid(true)
+    , m_nativeHandle(nativeHandle)
+    , m_globalObject(globalObject)
+{
+    ASSERT(globalObject);
+    rootObjectSet()->add(this);
+}
+
+RootObject::~RootObject()
+{
+    if (m_isValid)
+        invalidate();
+}
+
+void RootObject::invalidate()
+{
+    if (!m_isValid)
+        return;
+
+    {
+        HashSet::iterator end = m_runtimeObjects.end();
+        for (HashSet::iterator it = m_runtimeObjects.begin(); it != end; ++it)
+            (*it)->invalidate();
+        
+        m_runtimeObjects.clear();
+    }
+    
+    m_isValid = false;
+
+    m_nativeHandle = 0;
+    m_globalObject = 0;
+
+    ProtectCountSet::iterator end = m_protectCountSet.end();
+    for (ProtectCountSet::iterator it = m_protectCountSet.begin(); it != end; ++it) {
+        JSLock lock;
+        KJS::gcUnprotect(it->first);
+    }
+    m_protectCountSet.clear();
+
+    rootObjectSet()->remove(this);
+}
+
+void RootObject::gcProtect(JSObject* jsObject)
+{
+    ASSERT(m_isValid);
+    
+    if (!m_protectCountSet.contains(jsObject)) {
+        JSLock lock;
+        KJS::gcProtect(jsObject);
+    }
+    m_protectCountSet.add(jsObject);
+}
+
+void RootObject::gcUnprotect(JSObject* jsObject)
+{
+    ASSERT(m_isValid);
+    
+    if (!jsObject)
+        return;
+
+    if (m_protectCountSet.count(jsObject) == 1) {
+        JSLock lock;
+        KJS::gcUnprotect(jsObject);
+    }
+    m_protectCountSet.remove(jsObject);
+}
+
+bool RootObject::gcIsProtected(JSObject* jsObject)
+{
+    ASSERT(m_isValid);
+    return m_protectCountSet.contains(jsObject);
+}
+
+const void* RootObject::nativeHandle() const 
+{ 
+    ASSERT(m_isValid);
+    return m_nativeHandle; 
+}
+
+JSGlobalObject* RootObject::globalObject() const
+{
+    ASSERT(m_isValid);
+    return m_globalObject;
+}
+
+void RootObject::addRuntimeObject(RuntimeObjectImp* object)
+{
+    ASSERT(m_isValid);
+    ASSERT(!m_runtimeObjects.contains(object));
+    
+    m_runtimeObjects.add(object);
+}        
+    
+void RootObject::removeRuntimeObject(RuntimeObjectImp* object)
+{
+    ASSERT(m_isValid);
+    ASSERT(m_runtimeObjects.contains(object));
+    
+    m_runtimeObjects.remove(object);
+}
+
+} } // namespace KJS::Bindings
diff --git a/bindings/runtime_root.h b/bindings/runtime_root.h
new file mode 100644
index 0000000..a941b5f
--- /dev/null
+++ b/bindings/runtime_root.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef RUNTIME_ROOT_H_
+#define RUNTIME_ROOT_H_
+
+#include 
+
+#if ENABLE(JAVA_BINDINGS)
+#include "jni_jsobject.h"
+#endif
+#include "protect.h"
+
+#include 
+#include 
+#include 
+
+namespace KJS {
+
+class Interpreter;
+class JSGlobalObject;
+class RuntimeObjectImp;
+
+namespace Bindings {
+
+class RootObject;
+
+typedef PassRefPtr (*CreateRootObjectFunction)(void* nativeHandle);
+typedef HashCountedSet ProtectCountSet;
+
+extern RootObject* findProtectingRootObject(JSObject*);
+extern RootObject* findRootObject(JSGlobalObject*);
+
+class RootObject : public RefCounted {
+    friend class JavaJSObject;
+
+public:
+    ~RootObject();
+    
+    static PassRefPtr create(const void* nativeHandle, JSGlobalObject*);
+
+    bool isValid() { return m_isValid; }
+    void invalidate();
+    
+    void gcProtect(JSObject*);
+    void gcUnprotect(JSObject*);
+    bool gcIsProtected(JSObject*);
+
+    const void* nativeHandle() const;
+    JSGlobalObject* globalObject() const;
+
+    // Must be called from the thread that will be used to access JavaScript.
+    static void setCreateRootObject(CreateRootObjectFunction);
+    static CreateRootObjectFunction createRootObject() {
+        return _createRootObject;
+    }
+    
+    static CFRunLoopRef runLoop() { return _runLoop; }
+    static CFRunLoopSourceRef performJavaScriptSource() { return _performJavaScriptSource; }
+    
+#if ENABLE(JAVA_BINDINGS)
+    static void dispatchToJavaScriptThread(JSObjectCallContext *context);
+#endif
+
+    void addRuntimeObject(RuntimeObjectImp*);
+    void removeRuntimeObject(RuntimeObjectImp*);
+private:
+    RootObject(const void* nativeHandle, JSGlobalObject*);
+    
+    bool m_isValid;
+    
+    const void* m_nativeHandle;
+    ProtectedPtr m_globalObject;
+    ProtectCountSet m_protectCountSet;
+
+    HashSet m_runtimeObjects;
+    
+    static CreateRootObjectFunction _createRootObject;
+    static CFRunLoopRef _runLoop;
+    static CFRunLoopSourceRef _performJavaScriptSource;
+};
+
+} // namespace Bindings
+
+} // namespace KJS
+
+#endif // RUNTIME_ROOT_H_
diff --git a/bindings/test.js b/bindings/test.js
new file mode 100644
index 0000000..5d4f79f
--- /dev/null
+++ b/bindings/test.js
@@ -0,0 +1,19 @@
+myInterface.logMessage ("Starting test");
+
+myInterface.logMessage ("Testing properties:");
+myInterface.logMessage ("myInterface.doubleValue = " + myInterface.doubleValue);
+myInterface.logMessage ("myInterface.intValue = " + myInterface.intValue);
+myInterface.logMessage ("myInterface.stringValue = " + myInterface.stringValue);
+myInterface.logMessage ("myInterface.booleanValue = " + myInterface.booleanValue);
+myInterface.logMessage ("myInterface.nullValue = " + myInterface.nullValue);
+myInterface.logMessage ("myInterface.undefinedValue = " + myInterface.undefinedValue);
+
+myInterface.logMessage ("myInterface.setInt_(666) = " + myInterface.setInt_(666));
+myInterface.logMessage ("myInterface.getInt() = " + myInterface.getInt());
+myInterface.logMessage ("myInterface.getString() = " + myInterface.getString());
+myInterface.logMessage ("myInterface.myInt = " + myInterface.myInt);
+myInterface.logMessage ("setting myInterface.myInt = 777");
+myInterface.myInt = 777;
+myInterface.logMessage ("myInterface.myInt = " + myInterface.myInt);
+myInterface.logMessage ("myInterface.getMySecondInterface().doubleValue = " + myInterface.getMySecondInterface().doubleValue);
+myInterface.logMessage ("myInterface.getMySecondInterface() = " + myInterface.getMySecondInterface());
diff --git a/bindings/testC.js b/bindings/testC.js
new file mode 100644
index 0000000..44677c7
--- /dev/null
+++ b/bindings/testC.js
@@ -0,0 +1,21 @@
+myInterface.logMessage ("Starting test");
+
+myInterface.logMessage ("Testing properties:");
+myInterface.logMessage ("  myInterface.doubleValue = " + myInterface.doubleValue);
+myInterface.logMessage ("  myInterface.intValue = " + myInterface.intValue);
+myInterface.logMessage ("  myInterface.stringValue = " + myInterface.stringValue);
+myInterface.logMessage ("  myInterface.booleanValue = " + myInterface.booleanValue);
+myInterface.logMessage ("  myInterface.nullValue = " + myInterface.nullValue);
+myInterface.logMessage ("  myInterface.undefinedValue = " + myInterface.undefinedValue);
+
+myInterface.logMessage ("Testing methods:");
+myInterface.logMessage ("  myInterface.setDoubleValue(1234.1234) = " + myInterface.setDoubleValue(1234.1234));
+myInterface.logMessage ("  myInterface.setIntValue(5678) = " + myInterface.setIntValue(5678));
+myInterface.logMessage ("  myInterface.setStringValue(Goodbye) = " + myInterface.setStringValue('Goodbye'));
+myInterface.logMessage ("  myInterface.setBooleanValue(false) = " + myInterface.setBooleanValue(false));
+
+myInterface.logMessage ("Value of properties after calling setters:");
+myInterface.logMessage ("  myInterface.getDoubleValue() = " + myInterface.getDoubleValue());
+myInterface.logMessage ("  myInterface.getIntValue() = " + myInterface.getIntValue());
+myInterface.logMessage ("  myInterface.getStringValue() = " + myInterface.getStringValue());
+myInterface.logMessage ("  myInterface.getBooleanValue() = " + myInterface.getBooleanValue());
diff --git a/bindings/testM.js b/bindings/testM.js
new file mode 100644
index 0000000..7985d21
--- /dev/null
+++ b/bindings/testM.js
@@ -0,0 +1,29 @@
+myInterface.logMessage ("Starting test");
+
+myInterface.logMessage ("Testing properties:");
+
+myInterface.jsobject = new Function ("arg1","arg2","return arg1 + arg2;");
+myInterface.logMessage ("myInterface.jsobject =" + myInterface.jsobject);
+
+var functionBody = 'return arg1*arg2;'
+
+myInterface.setJSObject_(new Function ("arg1","arg2",functionBody));
+myInterface.logMessage ("myInterface.jsobject =" + myInterface.jsobject);
+myInterface.callJSObject__(5,6);
+myInterface.callJSObject__(8,9);
+
+myInterface.logMessage ("myInterface.setInt_(666) = " + myInterface.setInt_(666));
+myInterface.logMessage ("myInterface.getInt() = " + myInterface.getInt());
+myInterface.logMessage ("myInterface.getString().foo() = " + myInterface.getString().foo());
+myInterface.logMessage ("myInterface.myInt = " + myInterface.myInt);
+myInterface.logMessage ("setting myInterface.myInt = 777");
+myInterface.myInt = 777;
+myInterface.logMessage ("myInterface.myInt = " + myInterface.myInt);
+myInterface.logMessage ("myInterface.getMySecondInterface().doubleValue = " + myInterface.getMySecondInterface().doubleValue);
+myInterface.logMessage ("myInterface.getMySecondInterface() = " + myInterface.getMySecondInterface());
+
+myInterface.logMessageWithPrefix ("msg", "prefix");
+
+var strings = [ "one", "two", "three" ];
+
+myInterface.logMessages (strings);
\ No newline at end of file
diff --git a/bindings/testbindings.cpp b/bindings/testbindings.cpp
new file mode 100644
index 0000000..25f1f99
--- /dev/null
+++ b/bindings/testbindings.cpp
@@ -0,0 +1,422 @@
+// -*- c-basic-offset: 2 -*-
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+#include "config.h"
+#include 
+#include 
+#include 
+
+#include "value.h"
+#include "object.h"
+#include "types.h"
+#include "interpreter.h"
+
+#include "npruntime_internal.h"
+
+#include "runtime.h"
+#include "runtime_object.h"
+
+
+#define LOG(formatAndArgs...) { \
+    fprintf (stderr, "%s:  ", __PRETTY_FUNCTION__); \
+    fprintf(stderr, formatAndArgs); \
+}
+
+
+// ------------------ NP Interface definition --------------------
+typedef struct
+{
+    NPObject object;
+    double doubleValue;
+    int intValue;
+    NPVariant stringValue;
+    bool boolValue;
+} MyObject;
+
+
+static bool identifiersInitialized = false;
+
+#define ID_DOUBLE_VALUE                         0
+#define ID_INT_VALUE                            1
+#define ID_STRING_VALUE                         2
+#define ID_BOOLEAN_VALUE                        3
+#define ID_NULL_VALUE                           4
+#define ID_UNDEFINED_VALUE                      5
+#define NUM_PROPERTY_IDENTIFIERS                6
+
+static NPIdentifier myPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
+static const NPUTF8 *myPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
+    "doubleValue",
+    "intValue",
+    "stringValue",
+    "booleanValue",
+    "nullValue",
+    "undefinedValue"
+};
+
+#define ID_LOG_MESSAGE                          0
+#define ID_SET_DOUBLE_VALUE                     1
+#define ID_SET_INT_VALUE                        2
+#define ID_SET_STRING_VALUE                     3
+#define ID_SET_BOOLEAN_VALUE                    4
+#define ID_GET_DOUBLE_VALUE                     5
+#define ID_GET_INT_VALUE                        6
+#define ID_GET_STRING_VALUE                     7
+#define ID_GET_BOOLEAN_VALUE                    8
+#define NUM_METHOD_IDENTIFIERS                  9
+
+static NPIdentifier myMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
+static const NPUTF8 *myMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
+    "logMessage",
+    "setDoubleValue",
+    "setIntValue",
+    "setStringValue",
+    "setBooleanValue",
+    "getDoubleValue",
+    "getIntValue",
+    "getStringValue",
+    "getBooleanValue"
+};
+
+static void initializeIdentifiers()
+{
+    NPN_GetStringIdentifiers (myPropertyIdentifierNames, NUM_PROPERTY_IDENTIFIERS, myPropertyIdentifiers);
+    NPN_GetStringIdentifiers (myMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, myMethodIdentifiers);
+};
+
+bool myHasProperty (NPClass *theClass, NPIdentifier name)
+{
+    int i;
+    for (i = 0; i < NUM_PROPERTY_IDENTIFIERS; i++) {
+        if (name == myPropertyIdentifiers[i]){
+            return true;
+        }
+    }
+    return false;
+}
+
+bool myHasMethod (NPClass *theClass, NPIdentifier name)
+{
+    int i;
+    for (i = 0; i < NUM_METHOD_IDENTIFIERS; i++) {
+        if (name == myMethodIdentifiers[i]){
+            return true;
+        }
+    }
+    return false;
+}
+
+
+void logMessage (const NPVariant *message)
+{
+    if (message->type == NPVariantStringType) {
+        char msgBuf[1024];
+        strncpy (msgBuf, message->value.stringValue.UTF8Characters, message->value.stringValue.UTF8Length);
+        msgBuf[message->value.stringValue.UTF8Length] = 0;
+        printf ("%s\n", msgBuf);
+    }
+    else if (message->type == NPVariantDoubleType)
+        printf ("%f\n", (float)message->value.doubleValue);
+    else if (message->type == NPVariantInt32Type)
+        printf ("%d\n", message->value.intValue);
+    else if (message->type == NPVariantObjectType)
+        printf ("%p\n", message->value.objectValue);
+}
+
+void setDoubleValue (MyObject *obj, const NPVariant *variant)
+{
+    if (!NPN_VariantToDouble (variant, &obj->doubleValue)) {
+        NPUTF8 *msg = "Attempt to set double value with invalid type.";
+        NPString aString;
+        aString.UTF8Characters = msg;
+        aString.UTF8Length = strlen (msg);
+        NPN_SetException ((NPObject *)obj, &aString);
+    }
+}
+
+void setIntValue (MyObject *obj, const NPVariant *variant)
+{
+    if (!NPN_VariantToInt32 (variant, &obj->intValue)) {
+        NPUTF8 *msg = "Attempt to set int value with invalid type.";
+        NPString aString;
+        aString.UTF8Characters = msg;
+        aString.UTF8Length = strlen (msg);
+        NPN_SetException ((NPObject *)obj, &aString);
+    }
+}
+
+void setStringValue (MyObject *obj, const NPVariant *variant)
+{
+    NPN_ReleaseVariantValue (&obj->stringValue);
+    NPN_InitializeVariantWithVariant (&obj->stringValue, variant);
+}
+
+void setBooleanValue (MyObject *obj, const NPVariant *variant)
+{
+    if (!NPN_VariantToBool (variant, (NPBool *)&obj->boolValue)) {
+        NPUTF8 *msg = "Attempt to set bool value with invalid type.";
+        NPString aString;
+        aString.UTF8Characters = msg;
+        aString.UTF8Length = strlen (msg);
+        NPN_SetException ((NPObject *)obj, &aString);
+    }
+}
+
+void getDoubleValue (MyObject *obj, NPVariant *variant)
+{
+    NPN_InitializeVariantWithDouble (variant, obj->doubleValue);
+}
+
+void getIntValue (MyObject *obj, NPVariant *variant)
+{
+    NPN_InitializeVariantWithInt32 (variant, obj->intValue);
+}
+
+void getStringValue (MyObject *obj, NPVariant *variant)
+{
+    NPN_InitializeVariantWithVariant (variant, &obj->stringValue);
+}
+
+void getBooleanValue (MyObject *obj, NPVariant *variant)
+{
+    NPN_InitializeVariantWithBool (variant, obj->boolValue);
+}
+
+void myGetProperty (MyObject *obj, NPIdentifier name, NPVariant *variant)
+{
+    if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]){
+        getDoubleValue (obj, variant);
+    }
+    else if (name == myPropertyIdentifiers[ID_INT_VALUE]){
+        getIntValue (obj, variant);
+    }
+    else if (name == myPropertyIdentifiers[ID_STRING_VALUE]){
+        getStringValue (obj, variant);
+    }
+    else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]){
+        getBooleanValue (obj, variant);
+    }
+    else if (name == myPropertyIdentifiers[ID_NULL_VALUE]){
+        return NPN_InitializeVariantAsNull (variant);
+    }
+    else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]){
+        return NPN_InitializeVariantAsUndefined (variant); 
+    }
+    else
+        NPN_InitializeVariantAsUndefined(variant);
+}
+
+void mySetProperty (MyObject *obj, NPIdentifier name, const NPVariant *variant)
+{
+    if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]) {
+        setDoubleValue (obj, variant);
+    }
+    else if (name == myPropertyIdentifiers[ID_INT_VALUE]) {
+        setIntValue (obj, variant);
+    }
+    else if (name == myPropertyIdentifiers[ID_STRING_VALUE]) {
+        setStringValue (obj, variant);
+    }
+    else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]) {
+        setBooleanValue (obj, variant);
+    }
+    else if (name == myPropertyIdentifiers[ID_NULL_VALUE]) {
+        // Do nothing!
+    }
+    else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]) {
+        // Do nothing!
+    }
+}
+
+void myInvoke (MyObject *obj, NPIdentifier name, NPVariant *args, unsigned argCount, NPVariant *result)
+{
+    if (name == myMethodIdentifiers[ID_LOG_MESSAGE]) {
+        if (argCount == 1 && NPN_VariantIsString(&args[0]))
+            logMessage (&args[0]);
+        NPN_InitializeVariantAsVoid (result);
+    }
+    else if (name == myMethodIdentifiers[ID_SET_DOUBLE_VALUE]) {
+        if (argCount == 1 && NPN_VariantIsDouble (&args[0]))
+            setDoubleValue (obj, &args[0]);
+        NPN_InitializeVariantAsVoid (result);
+    }
+    else if (name == myMethodIdentifiers[ID_SET_INT_VALUE]) {
+        if (argCount == 1 && (NPN_VariantIsDouble (&args[0]) || NPN_VariantIsInt32 (&args[0])))
+            setIntValue (obj, &args[0]);
+        NPN_InitializeVariantAsVoid (result);
+    }
+    else if (name == myMethodIdentifiers[ID_SET_STRING_VALUE]) {
+        if (argCount == 1 && NPN_VariantIsString (&args[0]))
+            setStringValue (obj, &args[0]);
+        NPN_InitializeVariantAsVoid (result);
+    }
+    else if (name == myMethodIdentifiers[ID_SET_BOOLEAN_VALUE]) {
+        if (argCount == 1 && NPN_VariantIsBool (&args[0]))
+            setBooleanValue (obj, &args[0]);
+        NPN_InitializeVariantAsVoid (result);
+    }
+    else if (name == myMethodIdentifiers[ID_GET_DOUBLE_VALUE]) {
+        getDoubleValue (obj, result);
+    }
+    else if (name == myMethodIdentifiers[ID_GET_INT_VALUE]) {
+        getIntValue (obj, result);
+    }
+    else if (name == myMethodIdentifiers[ID_GET_STRING_VALUE]) {
+        getStringValue (obj, result);
+    }
+    else if (name == myMethodIdentifiers[ID_GET_BOOLEAN_VALUE]) {
+        getBooleanValue (obj, result);
+    }
+    else 
+        NPN_InitializeVariantAsUndefined (result);
+}
+
+NPObject *myAllocate ()
+{
+    MyObject *newInstance = (MyObject *)malloc (sizeof(MyObject));
+    
+    if (!identifiersInitialized) {
+        identifiersInitialized = true;
+        initializeIdentifiers();
+    }
+    
+    
+    newInstance->doubleValue = 666.666;
+    newInstance->intValue = 1234;
+    newInstance->boolValue = true;
+    newInstance->stringValue.type = NPVariantType_String;
+    newInstance->stringValue.value.stringValue.UTF8Length = strlen ("Hello world");
+    newInstance->stringValue.value.stringValue.UTF8Characters = strdup ("Hello world");
+    
+    return (NPObject *)newInstance;
+}
+
+void myInvalidate ()
+{
+    // Make sure we've released any remaining references to JavaScript objects.
+}
+
+void myDeallocate (MyObject *obj) 
+{
+    free ((void *)obj);
+}
+
+static NPClass _myFunctionPtrs = { 
+    kNPClassStructVersionCurrent,
+    (NPAllocateFunctionPtr) myAllocate, 
+    (NPDeallocateFunctionPtr) myDeallocate, 
+    (NPInvalidateFunctionPtr) myInvalidate,
+    (NPHasMethodFunctionPtr) myHasMethod,
+    (NPInvokeFunctionPtr) myInvoke,
+    (NPHasPropertyFunctionPtr) myHasProperty,
+    (NPGetPropertyFunctionPtr) myGetProperty,
+    (NPSetPropertyFunctionPtr) mySetProperty,
+};
+static NPClass *myFunctionPtrs = &_myFunctionPtrs;
+
+// --------------------------------------------------------
+
+using namespace KJS;
+using namespace KJS::Bindings;
+
+class GlobalImp : public ObjectImp {
+public:
+  virtual UString className() const { return "global"; }
+};
+
+#define BufferSize 200000
+static char code[BufferSize];
+
+const char *readJavaScriptFromFile (const char *file)
+{
+    FILE *f = fopen(file, "r");
+    if (!f) {
+        fprintf(stderr, "Error opening %s.\n", file);
+        return 0;
+    }
+    
+    int num = fread(code, 1, BufferSize, f);
+    code[num] = '\0';
+    if(num >= BufferSize)
+        fprintf(stderr, "Warning: File may have been too long.\n");
+
+    fclose(f);
+    
+    return code;
+}
+
+int main(int argc, char **argv)
+{
+    // expecting a filename
+    if (argc < 2) {
+        fprintf(stderr, "You have to specify at least one filename\n");
+        return -1;
+    }
+    
+    bool ret = true;
+    {
+        JSLock lock;
+        
+        // create interpreter w/ global object
+        Object global(new GlobalImp());
+        Interpreter interp;
+        interp.setGlobalObject(global);
+        ExecState *exec = interp.globalExec();
+        
+        MyObject *myObject = (MyObject *)NPN_CreateObject (myFunctionPtrs);
+        
+        global.put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::CLanguage, (void *)myObject));
+        
+        for (int i = 1; i < argc; i++) {
+            const char *code = readJavaScriptFromFile(argv[i]);
+            
+            if (code) {
+                // run
+                Completion comp(interp.evaluate(code));
+                
+                if (comp.complType() == Throw) {
+                    Value exVal = comp.value();
+                    char *msg = exVal.toString(exec).ascii();
+                    int lineno = -1;
+                    if (exVal.type() == ObjectType) {
+                        Value lineVal = Object::dynamicCast(exVal).get(exec,Identifier("line"));
+                        if (lineVal.type() == NumberType)
+                            lineno = int(lineVal.toNumber(exec));
+                    }
+                    if (lineno != -1)
+                        fprintf(stderr,"Exception, line %d: %s\n",lineno,msg);
+                    else
+                        fprintf(stderr,"Exception: %s\n",msg);
+                    ret = false;
+                }
+                else if (comp.complType() == ReturnValue) {
+                    char *msg = comp.value().toString(interp.globalExec()).ascii();
+                    fprintf(stderr,"Return value: %s\n",msg);
+                }
+            }
+        }
+                
+        NPN_ReleaseObject ((NPObject *)myObject);
+        
+    } // end block, so that Interpreter and global get deleted
+    
+    return ret ? 0 : 3;
+}
diff --git a/bindings/testbindings.mm b/bindings/testbindings.mm
new file mode 100644
index 0000000..7061503
--- /dev/null
+++ b/bindings/testbindings.mm
@@ -0,0 +1,289 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include 
+
+#import 
+
+#include 
+#include 
+
+#include "value.h"
+#include "object.h"
+#include "types.h"
+#include "interpreter.h"
+
+#include "runtime.h"
+#include "runtime_object.h"
+
+#define LOG(formatAndArgs...) { \
+    fprintf (stderr, "%s:  ", __PRETTY_FUNCTION__); \
+    fprintf(stderr, formatAndArgs); \
+}
+
+@interface MySecondInterface : NSObject
+{
+    double doubleValue;
+}
+
+- init;
+
+@end
+
+@implementation MySecondInterface
+
+- init
+{
+    LOG ("\n");
+    doubleValue = 666.666;
+    return self;
+}
+
+@end
+
+@interface MyFirstInterface : NSObject
+{
+    int myInt;
+    MySecondInterface *mySecondInterface;
+    id jsobject;
+    NSString *string;
+}
+
+- (int)getInt;
+- (void)setInt: (int)anInt;
+- (MySecondInterface *)getMySecondInterface;
+- (void)logMessage:(NSString *)message;
+- (void)setJSObject:(id)jsobject;
+@end
+
+@implementation MyFirstInterface
+
++ (NSString *)webScriptNameForSelector:(SEL)aSelector
+{
+    if (aSelector == @selector(logMessage:))
+        return @"logMessage";
+    if (aSelector == @selector(logMessages:))
+        return @"logMessages";
+    if (aSelector == @selector(logMessage:prefix:))
+        return @"logMessageWithPrefix";
+    return nil;
+}
+
++ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
+{
+    return NO;
+}
+
++ (BOOL)isKeyExcludedFromWebScript:(const char *)name
+{
+    return NO;
+}
+
+/*
+- (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args;
+{
+    NSLog (@"Call to undefined method %@", name);
+    NSLog (@"%d args\n", [args count]);
+    int i;
+    for (i = 0; i < [args count]; i++) {
+            NSLog (@"%d: %@\n", i, [args objectAtIndex:i]);
+    }
+    return @"success";
+}
+*/
+
+/*
+- (id)valueForUndefinedKey:(NSString *)key
+{
+    NSLog (@"%s:  key = %@", __PRETTY_FUNCTION__, key);
+    return @"aValue";
+}
+*/
+
+- (void)setValue:(id)value forUndefinedKey:(NSString *)key
+{
+    NSLog (@"%s:  key = %@", __PRETTY_FUNCTION__, key);
+}
+
+- init
+{
+    LOG ("\n");
+    mySecondInterface = [[MySecondInterface alloc] init];
+    return self;
+}
+
+- (void)dealloc
+{
+    LOG ("\n");
+    [mySecondInterface release];
+    [super dealloc];
+}
+
+- (int)getInt 
+{
+    LOG ("myInt = %d\n", myInt);
+    return myInt;
+}
+
+- (void)setInt: (int)anInt 
+{
+    LOG ("anInt = %d\n", anInt);
+    myInt = anInt;
+}
+
+- (NSString *)getString
+{
+    return string;
+}
+
+- (MySecondInterface *)getMySecondInterface 
+{
+    LOG ("\n");
+    return mySecondInterface;
+}
+
+- (void)logMessage:(NSString *)message
+{
+    printf ("%s\n", [message lossyCString]);
+}
+
+- (void)logMessages:(id)messages
+{
+    int i, count = [[messages valueForKey:@"length"] intValue];
+    for (i = 0; i < count; i++)
+        printf ("%s\n", [[messages webScriptValueAtIndex:i] lossyCString]);
+}
+
+- (void)logMessage:(NSString *)message prefix:(NSString *)prefix
+{
+    printf ("%s:%s\n", [prefix lossyCString], [message lossyCString]);
+}
+
+- (void)setJSObject:(id)jso
+{
+    [jsobject autorelease];
+    jsobject = [jso retain];
+}
+
+- (void)callJSObject:(int)arg1 :(int)arg2
+{
+    id foo1 = [jsobject callWebScriptMethod:@"call" withArguments:[NSArray arrayWithObjects:jsobject, [NSNumber numberWithInt:arg1], [NSNumber numberWithInt:arg2], nil]];
+    printf ("foo (via call) = %s\n", [[foo1 description] lossyCString] );
+    id foo2 = [jsobject callWebScriptMethod:@"apply" withArguments:[NSArray arrayWithObjects:jsobject, [NSArray arrayWithObjects:[NSNumber numberWithInt:arg1], [NSNumber numberWithInt:arg2], nil], nil]];
+    printf ("foo (via apply) = %s\n", [[foo2 description] lossyCString] );
+}
+
+@end
+
+
+using namespace KJS;
+using namespace KJS::Bindings;
+
+class GlobalImp : public ObjectImp {
+public:
+  virtual UString className() const { return "global"; }
+};
+
+#define BufferSize 200000
+static char code[BufferSize];
+
+const char *readJavaScriptFromFile (const char *file)
+{
+    FILE *f = fopen(file, "r");
+    if (!f) {
+        fprintf(stderr, "Error opening %s.\n", file);
+        return 0;
+    }
+    
+    int num = fread(code, 1, BufferSize, f);
+    code[num] = '\0';
+    if(num >= BufferSize)
+        fprintf(stderr, "Warning: File may have been too long.\n");
+
+    fclose(f);
+    
+    return code;
+}
+
+int main(int argc, char **argv)
+{
+    // expecting a filename
+    if (argc < 2) {
+        fprintf(stderr, "You have to specify at least one filename\n");
+        return -1;
+    }
+    
+    bool ret = true;
+    {
+        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+        
+        JSLock lock;
+        
+        // create interpreter w/ global object
+        Object global(new GlobalImp());
+        Interpreter interp;
+        interp.setGlobalObject(global);
+        ExecState *exec = interp.globalExec();
+        
+        MyFirstInterface *myInterface = [[MyFirstInterface alloc] init];
+        
+        global.put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::ObjectiveCLanguage, (void *)myInterface));
+        
+        for (int i = 1; i < argc; i++) {
+            const char *code = readJavaScriptFromFile(argv[i]);
+            
+            if (code) {
+                // run
+                Completion comp(interp.evaluate(code));
+                
+                if (comp.complType() == Throw) {
+                    Value exVal = comp.value();
+                    char *msg = exVal.toString(exec).ascii();
+                    int lineno = -1;
+                    if (exVal.type() == ObjectType) {
+                        Value lineVal = Object::dynamicCast(exVal).get(exec,Identifier("line"));
+                        if (lineVal.type() == NumberType)
+                            lineno = int(lineVal.toNumber(exec));
+                    }
+                    if (lineno != -1)
+                        fprintf(stderr,"Exception, line %d: %s\n",lineno,msg);
+                    else
+                        fprintf(stderr,"Exception: %s\n",msg);
+                    ret = false;
+                }
+                else if (comp.complType() == ReturnValue) {
+                    char *msg = comp.value().toString(interp.globalExec()).ascii();
+                    fprintf(stderr,"Return value: %s\n",msg);
+                }
+            }
+        }
+        
+        [myInterface release];
+        [pool drain];
+    } // end block, so that Interpreter and global get deleted
+    
+    return ret ? 0 : 3;
+}
diff --git a/bindings/testbindings.pro b/bindings/testbindings.pro
new file mode 100644
index 0000000..e6e0b9d
--- /dev/null
+++ b/bindings/testbindings.pro
@@ -0,0 +1,8 @@
+QT -= gui
+
+include(../../WebKit.pri)
+INCLUDEPATH += .. ../kjs .
+qt-port:INCLUDEPATH += bindings/qt
+
+SOURCES += testqtbindings.cpp
+
diff --git a/bindings/testqtbindings.cpp b/bindings/testqtbindings.cpp
new file mode 100644
index 0000000..490b3ff
--- /dev/null
+++ b/bindings/testqtbindings.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2006 Trolltech ASA
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#include "config.h"
+#include 
+#include 
+#include 
+
+#include "value.h"
+#include "object.h"
+#include "types.h"
+#include "interpreter.h"
+
+#include "qobject.h"
+#include "qdebug.h"
+
+#include "runtime.h"
+#include "runtime_object.h"
+
+
+
+class MyObject : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(QString testString READ testString WRITE setTestString)
+    Q_PROPERTY(int testInt READ testInt WRITE setTestInt)
+
+public:
+    MyObject() : QObject(0), integer(0){}
+
+    void setTestString(const QString &str) {
+        qDebug() << "called setTestString" << str;
+        string = str;
+    }
+    void setTestInt(int i) {
+        qDebug() << "called setTestInt" << i;
+        integer = i;
+    }
+    QString testString() const {
+        qDebug() << "called testString" << string;
+        return string;
+    }
+    int testInt() const {
+        qDebug() << "called testInt" << integer;
+        return integer;
+    }
+    QString string;
+    int integer;
+
+public slots:
+    void foo() { qDebug() << "foo invoked"; }
+};
+
+// --------------------------------------------------------
+
+using namespace KJS;
+using namespace KJS::Bindings;
+
+class Global : public JSObject {
+public:
+  virtual UString className() const { return "global"; }
+};
+
+static char code[] =
+    "myInterface.foo();\n"
+    "myInterface.testString = \"Hello\";\n"
+    "str = myInterface.testString;\n"
+    "myInterface.testInt = 10;\n"
+    "i = myInterface.testInt;\n";
+
+int main(int argc, char** argv)
+{
+    // expecting a filename
+    bool ret = true;
+    {
+        JSLock lock;
+        
+        // create interpreter w/ global object
+        Global* global = new Global();
+
+        // create interpreter
+        RefPtr interp = new Interpreter(global);
+        ExecState* exec = interp->globalExec();
+        
+        MyObject* myObject = new MyObject;
+        
+        global->put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::QtLanguage, (void*)myObject));
+        
+        
+        if (code) {
+            // run
+            Completion comp(interp->evaluate("", 0, code));
+            
+            if (comp.complType() == Throw) {
+                qDebug() << "exception thrown";
+                JSValue* exVal = comp.value();
+                char* msg = exVal->toString(exec).ascii();
+                int lineno = -1;
+                if (exVal->type() == ObjectType) {
+                    JSValue* lineVal = exVal->getObject()->get(exec, Identifier("line"));
+                    if (lineVal->type() == NumberType)
+                        lineno = int(lineVal->toNumber(exec));
+                }
+                if (lineno != -1)
+                    fprintf(stderr,"Exception, line %d: %s\n",lineno,msg);
+                else
+                    fprintf(stderr,"Exception: %s\n",msg);
+                ret = false;
+            }
+            else if (comp.complType() == ReturnValue) {
+                char* msg = comp.value()->toString(interp->globalExec()).ascii();
+                fprintf(stderr,"Return value: %s\n",msg);
+            }
+        }
+        
+    } // end block, so that Interpreter and global get deleted
+    
+    return ret ? 0 : 1;
+}
+
+#include "testqtbindings.moc"
diff --git a/headers.pri b/headers.pri
new file mode 100644
index 0000000..3fb886b
--- /dev/null
+++ b/headers.pri
@@ -0,0 +1,9 @@
+JS_API_HEADERS += \
+    JSBase.h \
+    JSContextRef.h \
+    JSObjectRef.h \
+    JSStringRef.h \
+    JSStringRefCF.h \
+    JSStringRefBSTR.h \
+    JSValueRef.h \
+    JavaScriptCore.h
diff --git a/icu/LICENSE b/icu/LICENSE
new file mode 100644
index 0000000..385d130
--- /dev/null
+++ b/icu/LICENSE
@@ -0,0 +1,25 @@
+COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 1995-2006 International Business Machines Corporation and others
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this
+software and associated documentation files (the "Software"), to deal in the Software
+without restriction, including without limitation the rights to use, copy, modify,
+merge, publish, distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above copyright notice(s)
+and this permission notice appear in all copies of the Software and that both the above
+copyright notice(s) and this permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder shall not be used in
+advertising or otherwise to promote the sale, use or other dealings in this Software
+without prior written authorization of the copyright holder.
diff --git a/icu/README b/icu/README
new file mode 100644
index 0000000..389e2e8
--- /dev/null
+++ b/icu/README
@@ -0,0 +1,4 @@
+The headers in this directory are for compiling on Mac OS X 10.4.
+The Mac OS X 10.4 release includes the ICU binary, but not ICU headers.
+For other platforms, installed ICU headers should be used rather than these.
+They are specific to Mac OS X 10.4.
diff --git a/icu/unicode/platform.h b/icu/unicode/platform.h
new file mode 100644
index 0000000..9595a26
--- /dev/null
+++ b/icu/unicode/platform.h
@@ -0,0 +1,267 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1997-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+*  FILE NAME : platform.h
+*
+*   Date        Name        Description
+*   05/13/98    nos         Creation (content moved here from ptypes.h).
+*   03/02/99    stephen     Added AS400 support.
+*   03/30/99    stephen     Added Linux support.
+*   04/13/99    stephen     Reworked for autoconf.
+******************************************************************************
+*/
+
+/* Define the platform we're on. */
+#ifndef U_DARWIN
+#define U_DARWIN
+#endif
+
+/* Define whether inttypes.h is available */
+#ifndef U_HAVE_INTTYPES_H
+#define U_HAVE_INTTYPES_H 1
+#endif
+
+/*
+ * Define what support for C++ streams is available.
+ *     If U_IOSTREAM_SOURCE is set to 199711, then  is available
+ * (1997711 is the date the ISO/IEC C++ FDIS was published), and then
+ * one should qualify streams using the std namespace in ICU header
+ * files.
+ *     If U_IOSTREAM_SOURCE is set to 198506, then  is
+ * available instead (198506 is the date when Stroustrup published
+ * "An Extensible I/O Facility for C++" at the summer USENIX conference).
+ *     If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and
+ * support for them will be silently suppressed in ICU.
+ *
+ */
+
+#ifndef U_IOSTREAM_SOURCE
+#define U_IOSTREAM_SOURCE 199711
+#endif
+
+/* Determines whether specific types are available */
+#ifndef U_HAVE_INT8_T
+#define U_HAVE_INT8_T 1
+#endif
+
+#ifndef U_HAVE_UINT8_T
+#define U_HAVE_UINT8_T 0
+#endif
+
+#ifndef U_HAVE_INT16_T
+#define U_HAVE_INT16_T 1
+#endif
+
+#ifndef U_HAVE_UINT16_T
+#define U_HAVE_UINT16_T 0
+#endif
+
+#ifndef U_HAVE_INT32_T
+#define U_HAVE_INT32_T 1
+#endif
+
+#ifndef U_HAVE_UINT32_T
+#define U_HAVE_UINT32_T 0
+#endif
+
+#ifndef U_HAVE_INT64_T
+#define U_HAVE_INT64_T 1
+#endif
+
+#ifndef U_HAVE_UINT64_T
+#define U_HAVE_UINT64_T 0
+#endif
+
+/*===========================================================================*/
+/* Generic data types                                                        */
+/*===========================================================================*/
+
+#include 
+
+/* If your platform does not have the  header, you may
+   need to edit the typedefs below. */
+#if U_HAVE_INTTYPES_H
+
+/* autoconf 2.13 sometimes can't properly find the data types in  */
+/* os/390 needs , but it doesn't have int8_t, and it sometimes */
+/* doesn't have uint8_t depending on the OS version. */
+/* So we have this work around. */
+#ifdef OS390
+/* The features header is needed to get (u)int64_t sometimes. */
+#include 
+#if ! U_HAVE_INT8_T
+typedef signed char int8_t;
+#endif
+#if !defined(__uint8_t)
+#define __uint8_t 1
+typedef unsigned char uint8_t;
+#endif
+#endif /* OS390 */
+
+#include 
+
+#else /* U_HAVE_INTTYPES_H */
+
+#if ! U_HAVE_INT8_T
+typedef signed char int8_t;
+#endif
+
+#if ! U_HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+
+#if ! U_HAVE_INT16_T
+typedef signed short int16_t;
+#endif
+
+#if ! U_HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+
+#if ! U_HAVE_INT32_T
+typedef signed int int32_t;
+#endif
+
+#if ! U_HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+
+#if ! U_HAVE_INT64_T
+    typedef signed long long int64_t;
+/* else we may not have a 64-bit type */
+#endif
+
+#if ! U_HAVE_UINT64_T
+    typedef unsigned long long uint64_t;
+/* else we may not have a 64-bit type */
+#endif
+
+#endif
+
+/*===========================================================================*/
+/* Compiler and environment features                                         */
+/*===========================================================================*/
+
+/* Define whether namespace is supported */
+#ifndef U_HAVE_NAMESPACE
+#define U_HAVE_NAMESPACE 1
+#endif
+
+/* Determines the endianness of the platform
+   It's done this way in case multiple architectures are being built at once.
+   For example, Darwin supports fat binaries, which can be both PPC and x86 based. */
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN)
+#define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
+#else
+#define U_IS_BIG_ENDIAN 1
+#endif
+
+/* 1 or 0 to enable or disable threads.  If undefined, default is: enable threads. */
+#define ICU_USE_THREADS 1
+
+#ifndef U_DEBUG
+#define U_DEBUG 0
+#endif
+
+#ifndef U_RELEASE
+#define U_RELEASE 1
+#endif
+
+/* Determine whether to disable renaming or not. This overrides the
+   setting in umachine.h which is for all platforms. */
+#ifndef U_DISABLE_RENAMING
+#define U_DISABLE_RENAMING 1
+#endif
+
+/* Determine whether to override new and delete. */
+#ifndef U_OVERRIDE_CXX_ALLOCATION
+#define U_OVERRIDE_CXX_ALLOCATION 1
+#endif
+/* Determine whether to override placement new and delete for STL. */
+#ifndef U_HAVE_PLACEMENT_NEW
+#define U_HAVE_PLACEMENT_NEW 1
+#endif
+
+/* Determine whether to enable tracing. */
+#ifndef U_ENABLE_TRACING
+#define U_ENABLE_TRACING 1
+#endif
+
+/* Define the library suffix in a C syntax. */
+#define U_HAVE_LIB_SUFFIX 0
+#define U_LIB_SUFFIX_C_NAME 
+#define U_LIB_SUFFIX_C_NAME_STRING ""
+
+/*===========================================================================*/
+/* Character data types                                                      */
+/*===========================================================================*/
+
+#if defined(OS390) || defined(OS400)
+#   define U_CHARSET_FAMILY 1
+#endif
+
+/*===========================================================================*/
+/* Information about wchar support                                           */
+/*===========================================================================*/
+
+#define U_HAVE_WCHAR_H      1
+#define U_SIZEOF_WCHAR_T    4
+
+#define U_HAVE_WCSCPY       1
+
+/*===========================================================================*/
+/* Information about POSIX support                                           */
+/*===========================================================================*/
+
+#define U_HAVE_NL_LANGINFO          1
+#define U_HAVE_NL_LANGINFO_CODESET  1
+#define U_NL_LANGINFO_CODESET       CODESET
+
+#if 1
+#define U_TZSET         tzset
+#endif
+#if 0
+#define U_TIMEZONE      
+#endif
+#if 1
+#define U_TZNAME        tzname
+#endif
+
+#define U_HAVE_MMAP     1
+#define U_HAVE_POPEN    1
+
+/*===========================================================================*/
+/* Symbol import-export control                                              */
+/*===========================================================================*/
+
+#define U_EXPORT
+/* U_CALLCONV is releated to U_EXPORT2 */
+#define U_EXPORT2
+
+/* cygwin needs to export/import data */
+#ifdef U_CYGWIN
+#define U_IMPORT __declspec(dllimport)
+#else
+#define U_IMPORT 
+#endif
+
+/*===========================================================================*/
+/* Code alignment and C function inlining                                    */
+/*===========================================================================*/
+
+#ifndef U_INLINE
+#define U_INLINE inline
+#endif
+
+#define U_ALIGN_CODE(n) 
+
+/*===========================================================================*/
+/* Programs used by ICU code                                                 */
+/*===========================================================================*/
+
+#define U_MAKE  "/usr/bin/gnumake"
diff --git a/icu/unicode/putil.h b/icu/unicode/putil.h
new file mode 100644
index 0000000..685df53
--- /dev/null
+++ b/icu/unicode/putil.h
@@ -0,0 +1,180 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1997-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+*  FILE NAME : putil.h
+*
+*   Date        Name        Description
+*   05/14/98    nos         Creation (content moved here from utypes.h).
+*   06/17/99    erm         Added IEEE_754
+*   07/22/98    stephen     Added IEEEremainder, max, min, trunc
+*   08/13/98    stephen     Added isNegativeInfinity, isPositiveInfinity
+*   08/24/98    stephen     Added longBitsFromDouble
+*   03/02/99    stephen     Removed openFile().  Added AS400 support.
+*   04/15/99    stephen     Converted to C
+*   11/15/99    helena      Integrated S/390 changes for IEEE support.
+*   01/11/00    helena      Added u_getVersion.
+******************************************************************************
+*/
+
+#ifndef PUTIL_H
+#define PUTIL_H
+
+#include "unicode/utypes.h"
+
+/* Define this to 1 if your platform supports IEEE 754 floating point,
+   to 0 if it does not. */
+#ifndef IEEE_754
+#   define IEEE_754 1
+#endif
+
+/*==========================================================================*/
+/* Platform utilities                                                       */
+/*==========================================================================*/
+
+/**
+ * Platform utilities isolates the platform dependencies of the
+ * libarary.  For each platform which this code is ported to, these
+ * functions may have to be re-implemented.
+ */
+
+/**
+ * Return the ICU data directory. 
+ * The data directory is where common format ICU data files (.dat files)
+ *   are loaded from.  Note that normal use of the built-in ICU
+ *   facilities does not require loading of an external data file;
+ *   unless you are adding custom data to ICU, the data directory
+ *   does not need to be set.
+ *
+ * The data directory is determined as follows:
+ *    If u_setDataDirectory() has been called, that is it, otherwise
+ *    if the ICU_DATA environment variable is set, use that, otherwise
+ *    If a data directory was specifed at ICU build time
+ *      (#define ICU_DATA_DIR "path"), use that,
+ *    otherwise no data directory is available.
+ *
+ * @return the data directory, or an empty string ("") if no data directory has
+ *         been specified.
+ *   
+ * @stable ICU 2.0
+ */
+U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
+
+/** 
+ * Set the ICU data directory. 
+ * The data directory is where common format ICU data files (.dat files)
+ *   are loaded from.  Note that normal use of the built-in ICU
+ *   facilities does not require loading of an external data file;
+ *   unless you are adding custom data to ICU, the data directory
+ *   does not need to be set.
+ *
+ * This function should be called at most once in a process, before the
+ * first ICU operation (e.g., u_init()) that will require the loading of an
+ * ICU data file.
+ * This function is not thread-safe. Use it before calling ICU APIs from
+ * multiple threads.
+ *
+ * @param directory The directory to be set.
+ *
+ * @see u_init
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
+
+/**
+ * Please use ucnv_getDefaultName() instead.
+ * Return the default codepage for this platform and locale.
+ * This function can call setlocale() on Unix platforms. Please read the
+ * platform documentation on setlocale() before calling this function.
+ * @return the default codepage for this platform 
+ * @internal
+ */
+U_INTERNAL const char*  U_EXPORT2 uprv_getDefaultCodepage(void);
+
+/**
+ * Please use uloc_getDefault() instead.
+ * Return the default locale ID string by querying ths system, or
+ *     zero if one cannot be found. 
+ * This function can call setlocale() on Unix platforms. Please read the
+ * platform documentation on setlocale() before calling this function.
+ * @return the default locale ID string
+ * @internal
+ */
+U_INTERNAL const char*  U_EXPORT2 uprv_getDefaultLocaleID(void);
+
+/**
+ * Filesystem file and path separator characters.
+ * Example: '/' and ':' on Unix, '\\' and ';' on Windows.
+ * @stable ICU 2.0
+ */
+#ifdef XP_MAC
+#   define U_FILE_SEP_CHAR ':'
+#   define U_FILE_ALT_SEP_CHAR ':'
+#   define U_PATH_SEP_CHAR ';'
+#   define U_FILE_SEP_STRING ":"
+#   define U_FILE_ALT_SEP_STRING ":"
+#   define U_PATH_SEP_STRING ";"
+#elif defined(WIN32) || defined(OS2)
+#   define U_FILE_SEP_CHAR '\\'
+#   define U_FILE_ALT_SEP_CHAR '/'
+#   define U_PATH_SEP_CHAR ';'
+#   define U_FILE_SEP_STRING "\\"
+#   define U_FILE_ALT_SEP_STRING "/"
+#   define U_PATH_SEP_STRING ";"
+#else
+#   define U_FILE_SEP_CHAR '/'
+#   define U_FILE_ALT_SEP_CHAR '/'
+#   define U_PATH_SEP_CHAR ':'
+#   define U_FILE_SEP_STRING "/"
+#   define U_FILE_ALT_SEP_STRING "/"
+#   define U_PATH_SEP_STRING ":"
+#endif
+
+/**
+ * Convert char characters to UChar characters.
+ * This utility function is useful only for "invariant characters"
+ * that are encoded in the platform default encoding.
+ * They are a small, constant subset of the encoding and include
+ * just the latin letters, digits, and some punctuation.
+ * For details, see U_CHARSET_FAMILY.
+ *
+ * @param cs Input string, points to length
+ *           character bytes from a subset of the platform encoding.
+ * @param us Output string, points to memory for length
+ *           Unicode characters.
+ * @param length The number of characters to convert; this may
+ *               include the terminating NUL.
+ *
+ * @see U_CHARSET_FAMILY
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+u_charsToUChars(const char *cs, UChar *us, int32_t length);
+
+/**
+ * Convert UChar characters to char characters.
+ * This utility function is useful only for "invariant characters"
+ * that can be encoded in the platform default encoding.
+ * They are a small, constant subset of the encoding and include
+ * just the latin letters, digits, and some punctuation.
+ * For details, see U_CHARSET_FAMILY.
+ *
+ * @param us Input string, points to length
+ *           Unicode characters that can be encoded with the
+ *           codepage-invariant subset of the platform encoding.
+ * @param cs Output string, points to memory for length
+ *           character bytes.
+ * @param length The number of characters to convert; this may
+ *               include the terminating NUL.
+ *
+ * @see U_CHARSET_FAMILY
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+u_UCharsToChars(const UChar *us, char *cs, int32_t length);
+
+#endif
diff --git a/icu/unicode/uchar.h b/icu/unicode/uchar.h
new file mode 100644
index 0000000..7fd490c
--- /dev/null
+++ b/icu/unicode/uchar.h
@@ -0,0 +1,2798 @@
+/*
+**********************************************************************
+*   Copyright (C) 1997-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*
+* File UCHAR.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   04/02/97    aliu        Creation.
+*   03/29/99    helena      Updated for C APIs.
+*   4/15/99     Madhu       Updated for C Implementation and Javadoc
+*   5/20/99     Madhu       Added the function u_getVersion()
+*   8/19/1999   srl         Upgraded scripts to Unicode 3.0
+*   8/27/1999   schererm    UCharDirection constants: U_...
+*   11/11/1999  weiv        added u_isalnum(), cleaned comments
+*   01/11/2000  helena      Renamed u_getVersion to u_getUnicodeVersion().
+******************************************************************************
+*/
+
+#ifndef UCHAR_H
+#define UCHAR_H
+
+#include "unicode/utypes.h"
+
+U_CDECL_BEGIN
+
+/*==========================================================================*/
+/* Unicode version number                                                   */
+/*==========================================================================*/
+/**
+ * Unicode version number, default for the current ICU version.
+ * The actual Unicode Character Database (UCD) data is stored in uprops.dat
+ * and may be generated from UCD files from a different Unicode version.
+ * Call u_getUnicodeVersion to get the actual Unicode version of the data.
+ *
+ * @see u_getUnicodeVersion
+ * @stable ICU 2.0
+ */
+#define U_UNICODE_VERSION "4.0.1"
+
+/**
+ * \file
+ * \brief C API: Unicode Properties
+ *
+ * This C API provides low-level access to the Unicode Character Database.
+ * In addition to raw property values, some convenience functions calculate
+ * derived properties, for example for Java-style programming.
+ *
+ * Unicode assigns each code point (not just assigned character) values for
+ * many properties.
+ * Most of them are simple boolean flags, or constants from a small enumerated list.
+ * For some properties, values are strings or other relatively more complex types.
+ *
+ * For more information see
+ * "About the Unicode Character Database" (http://www.unicode.org/ucd/)
+ * and the ICU User Guide chapter on Properties (http://oss.software.ibm.com/icu/userguide/properties.html).
+ *
+ * Many functions are designed to match java.lang.Character functions.
+ * See the individual function documentation,
+ * and see the JDK 1.4.1 java.lang.Character documentation
+ * at http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Character.html
+ *
+ * There are also functions that provide easy migration from C/POSIX functions
+ * like isblank(). Their use is generally discouraged because the C/POSIX
+ * standards do not define their semantics beyond the ASCII range, which means
+ * that different implementations exhibit very different behavior.
+ * Instead, Unicode properties should be used directly.
+ *
+ * There are also only a few, broad C/POSIX character classes, and they tend
+ * to be used for conflicting purposes. For example, the "isalpha()" class
+ * is sometimes used to determine word boundaries, while a more sophisticated
+ * approach would at least distinguish initial letters from continuation
+ * characters (the latter including combining marks).
+ * (In ICU, BreakIterator is the most sophisticated API for word boundaries.)
+ * Another example: There is no "istitle()" class for titlecase characters.
+ *
+ * A summary of the behavior of some C/POSIX character classification implementations
+ * for Unicode is available at http://oss.software.ibm.com/cvs/icu/~checkout~/icuhtml/design/posix_classes.html
+ *
+ * Important:
+ * The behavior of the ICU C/POSIX-style character classification
+ * functions is subject to change according to discussion of the above summary.
+ *
+ * Note: There are several ICU whitespace functions.
+ * Comparison:
+ * - u_isUWhiteSpace=UCHAR_WHITE_SPACE: Unicode White_Space property;
+ *       most of general categories "Z" (separators) + most whitespace ISO controls
+ *       (including no-break spaces, but excluding IS1..IS4 and ZWSP)
+ * - u_isWhitespace: Java isWhitespace; Z + whitespace ISO controls but excluding no-break spaces
+ * - u_isJavaSpaceChar: Java isSpaceChar; just Z (including no-break spaces)
+ * - u_isspace: Z + whitespace ISO controls (including no-break spaces)
+ * - u_isblank: "horizontal spaces" = TAB + Zs - ZWSP
+ */
+
+/**
+ * Constants.
+ */
+
+/** The lowest Unicode code point value. Code points are non-negative. @stable ICU 2.0 */
+#define UCHAR_MIN_VALUE 0
+
+/**
+ * The highest Unicode code point value (scalar value) according to
+ * The Unicode Standard. This is a 21-bit value (20.1 bits, rounded up).
+ * For a single character, UChar32 is a simple type that can hold any code point value.
+ *
+ * @see UChar32
+ * @stable ICU 2.0
+ */
+#define UCHAR_MAX_VALUE 0x10ffff
+
+/**
+ * Get a single-bit bit set (a flag) from a bit number 0..31.
+ * @stable ICU 2.1
+ */
+#define U_MASK(x) ((uint32_t)1<<(x))
+
+/*
+ * !! Note: Several comments in this file are machine-read by the
+ * genpname tool.  These comments describe the correspondence between
+ * icu enum constants and UCD entities.  Do not delete them.  Update
+ * these comments as needed.
+ *
+ * Any comment of the form "/ *[name]* /" (spaces added) is such
+ * a comment.
+ *
+ * The U_JG_* and U_GC_*_MASK constants are matched by their symbolic
+ * name, which must match PropertyValueAliases.txt.
+ */
+
+/**
+ * Selection constants for Unicode properties.
+ * These constants are used in functions like u_hasBinaryProperty to select
+ * one of the Unicode properties.
+ *
+ * The properties APIs are intended to reflect Unicode properties as defined
+ * in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR).
+ * For details about the properties see http://www.unicode.org/ucd/ .
+ * For names of Unicode properties see the UCD file PropertyAliases.txt.
+ *
+ * Important: If ICU is built with UCD files from Unicode versions below, e.g., 3.2,
+ * then properties marked with "new in Unicode 3.2" are not or not fully available.
+ * Check u_getUnicodeVersion to be sure.
+ *
+ * @see u_hasBinaryProperty
+ * @see u_getIntPropertyValue
+ * @see u_getUnicodeVersion
+ * @stable ICU 2.1
+ */
+typedef enum UProperty {
+    /*  See note !!.  Comments of the form "Binary property Dash",
+        "Enumerated property Script", "Double property Numeric_Value",
+        and "String property Age" are read by genpname. */
+
+    /*  Note: Place UCHAR_ALPHABETIC before UCHAR_BINARY_START so that
+    debuggers display UCHAR_ALPHABETIC as the symbolic name for 0,
+    rather than UCHAR_BINARY_START.  Likewise for other *_START
+    identifiers. */
+
+    /** Binary property Alphabetic. Same as u_isUAlphabetic, different from u_isalpha.
+        Lu+Ll+Lt+Lm+Lo+Nl+Other_Alphabetic @stable ICU 2.1 */
+    UCHAR_ALPHABETIC=0,
+    /** First constant for binary Unicode properties. @stable ICU 2.1 */
+    UCHAR_BINARY_START=UCHAR_ALPHABETIC,
+    /** Binary property ASCII_Hex_Digit. 0-9 A-F a-f @stable ICU 2.1 */
+    UCHAR_ASCII_HEX_DIGIT,
+    /** Binary property Bidi_Control.
+        Format controls which have specific functions
+        in the Bidi Algorithm. @stable ICU 2.1 */
+    UCHAR_BIDI_CONTROL,
+    /** Binary property Bidi_Mirrored.
+        Characters that may change display in RTL text.
+        Same as u_isMirrored.
+        See Bidi Algorithm, UTR 9. @stable ICU 2.1 */
+    UCHAR_BIDI_MIRRORED,
+    /** Binary property Dash. Variations of dashes. @stable ICU 2.1 */
+    UCHAR_DASH,
+    /** Binary property Default_Ignorable_Code_Point (new in Unicode 3.2).
+        Ignorable in most processing.
+        <2060..206F, FFF0..FFFB, E0000..E0FFF>+Other_Default_Ignorable_Code_Point+(Cf+Cc+Cs-White_Space) @stable ICU 2.1 */
+    UCHAR_DEFAULT_IGNORABLE_CODE_POINT,
+    /** Binary property Deprecated (new in Unicode 3.2).
+        The usage of deprecated characters is strongly discouraged. @stable ICU 2.1 */
+    UCHAR_DEPRECATED,
+    /** Binary property Diacritic. Characters that linguistically modify
+        the meaning of another character to which they apply. @stable ICU 2.1 */
+    UCHAR_DIACRITIC,
+    /** Binary property Extender.
+        Extend the value or shape of a preceding alphabetic character,
+        e.g., length and iteration marks. @stable ICU 2.1 */
+    UCHAR_EXTENDER,
+    /** Binary property Full_Composition_Exclusion.
+        CompositionExclusions.txt+Singleton Decompositions+
+        Non-Starter Decompositions. @stable ICU 2.1 */
+    UCHAR_FULL_COMPOSITION_EXCLUSION,
+    /** Binary property Grapheme_Base (new in Unicode 3.2).
+        For programmatic determination of grapheme cluster boundaries.
+        [0..10FFFF]-Cc-Cf-Cs-Co-Cn-Zl-Zp-Grapheme_Link-Grapheme_Extend-CGJ @stable ICU 2.1 */
+    UCHAR_GRAPHEME_BASE,
+    /** Binary property Grapheme_Extend (new in Unicode 3.2).
+        For programmatic determination of grapheme cluster boundaries.
+        Me+Mn+Mc+Other_Grapheme_Extend-Grapheme_Link-CGJ @stable ICU 2.1 */
+    UCHAR_GRAPHEME_EXTEND,
+    /** Binary property Grapheme_Link (new in Unicode 3.2).
+        For programmatic determination of grapheme cluster boundaries. @stable ICU 2.1 */
+    UCHAR_GRAPHEME_LINK,
+    /** Binary property Hex_Digit.
+        Characters commonly used for hexadecimal numbers. @stable ICU 2.1 */
+    UCHAR_HEX_DIGIT,
+    /** Binary property Hyphen. Dashes used to mark connections
+        between pieces of words, plus the Katakana middle dot. @stable ICU 2.1 */
+    UCHAR_HYPHEN,
+    /** Binary property ID_Continue.
+        Characters that can continue an identifier.
+        DerivedCoreProperties.txt also says "NOTE: Cf characters should be filtered out."
+        ID_Start+Mn+Mc+Nd+Pc @stable ICU 2.1 */
+    UCHAR_ID_CONTINUE,
+    /** Binary property ID_Start.
+        Characters that can start an identifier.
+        Lu+Ll+Lt+Lm+Lo+Nl @stable ICU 2.1 */
+    UCHAR_ID_START,
+    /** Binary property Ideographic.
+        CJKV ideographs. @stable ICU 2.1 */
+    UCHAR_IDEOGRAPHIC,
+    /** Binary property IDS_Binary_Operator (new in Unicode 3.2).
+        For programmatic determination of
+        Ideographic Description Sequences. @stable ICU 2.1 */
+    UCHAR_IDS_BINARY_OPERATOR,
+    /** Binary property IDS_Trinary_Operator (new in Unicode 3.2).
+        For programmatic determination of
+        Ideographic Description Sequences. @stable ICU 2.1 */
+    UCHAR_IDS_TRINARY_OPERATOR,
+    /** Binary property Join_Control.
+        Format controls for cursive joining and ligation. @stable ICU 2.1 */
+    UCHAR_JOIN_CONTROL,
+    /** Binary property Logical_Order_Exception (new in Unicode 3.2).
+        Characters that do not use logical order and
+        require special handling in most processing. @stable ICU 2.1 */
+    UCHAR_LOGICAL_ORDER_EXCEPTION,
+    /** Binary property Lowercase. Same as u_isULowercase, different from u_islower.
+        Ll+Other_Lowercase @stable ICU 2.1 */
+    UCHAR_LOWERCASE,
+    /** Binary property Math. Sm+Other_Math @stable ICU 2.1 */
+    UCHAR_MATH,
+    /** Binary property Noncharacter_Code_Point.
+        Code points that are explicitly defined as illegal
+        for the encoding of characters. @stable ICU 2.1 */
+    UCHAR_NONCHARACTER_CODE_POINT,
+    /** Binary property Quotation_Mark. @stable ICU 2.1 */
+    UCHAR_QUOTATION_MARK,
+    /** Binary property Radical (new in Unicode 3.2).
+        For programmatic determination of
+        Ideographic Description Sequences. @stable ICU 2.1 */
+    UCHAR_RADICAL,
+    /** Binary property Soft_Dotted (new in Unicode 3.2).
+        Characters with a "soft dot", like i or j.
+        An accent placed on these characters causes
+        the dot to disappear. @stable ICU 2.1 */
+    UCHAR_SOFT_DOTTED,
+    /** Binary property Terminal_Punctuation.
+        Punctuation characters that generally mark
+        the end of textual units. @stable ICU 2.1 */
+    UCHAR_TERMINAL_PUNCTUATION,
+    /** Binary property Unified_Ideograph (new in Unicode 3.2).
+        For programmatic determination of
+        Ideographic Description Sequences. @stable ICU 2.1 */
+    UCHAR_UNIFIED_IDEOGRAPH,
+    /** Binary property Uppercase. Same as u_isUUppercase, different from u_isupper.
+        Lu+Other_Uppercase @stable ICU 2.1 */
+    UCHAR_UPPERCASE,
+    /** Binary property White_Space.
+        Same as u_isUWhiteSpace, different from u_isspace and u_isWhitespace.
+        Space characters+TAB+CR+LF-ZWSP-ZWNBSP @stable ICU 2.1 */
+    UCHAR_WHITE_SPACE,
+    /** Binary property XID_Continue.
+        ID_Continue modified to allow closure under
+        normalization forms NFKC and NFKD. @stable ICU 2.1 */
+    UCHAR_XID_CONTINUE,
+    /** Binary property XID_Start. ID_Start modified to allow
+        closure under normalization forms NFKC and NFKD. @stable ICU 2.1 */
+    UCHAR_XID_START,
+    /** Binary property Case_Sensitive. Either the source of a case
+        mapping or _in_ the target of a case mapping. Not the same as
+        the general category Cased_Letter. @stable ICU 2.6 */
+    UCHAR_CASE_SENSITIVE,
+    /** Binary property STerm (new in Unicode 4.0.1).
+        Sentence Terminal. Used in UAX #29: Text Boundaries
+        (http://www.unicode.org/reports/tr29/)
+        @draft ICU 3.0 */
+    UCHAR_S_TERM,
+    /** Binary property Variation_Selector (new in Unicode 4.0.1).
+        Indicates all those characters that qualify as Variation Selectors.
+        For details on the behavior of these characters,
+        see StandardizedVariants.html and 15.6 Variation Selectors.
+        @draft ICU 3.0 */
+    UCHAR_VARIATION_SELECTOR,
+    /** Binary property NFD_Inert.
+        ICU-specific property for characters that are inert under NFD,
+        i.e., they do not interact with adjacent characters.
+        Used for example in normalizing transforms in incremental mode
+        to find the boundary of safely normalizable text despite possible
+        text additions.
+
+        There is one such property per normalization form.
+        These properties are computed as follows - an inert character is:
+        a) unassigned, or ALL of the following:
+        b) of combining class 0.
+        c) not decomposed by this normalization form.
+        AND if NFC or NFKC,
+        d) can never compose with a previous character.
+        e) can never compose with a following character.
+        f) can never change if another character is added.
+           Example: a-breve might satisfy all but f, but if you
+           add an ogonek it changes to a-ogonek + breve
+
+        See also com.ibm.text.UCD.NFSkippable in the ICU4J repository,
+        and icu/source/common/unormimp.h .
+        @draft ICU 3.0 */
+    UCHAR_NFD_INERT,
+    /** Binary property NFKD_Inert.
+        ICU-specific property for characters that are inert under NFKD,
+        i.e., they do not interact with adjacent characters.
+        Used for example in normalizing transforms in incremental mode
+        to find the boundary of safely normalizable text despite possible
+        text additions.
+        @see UCHAR_NFD_INERT
+        @draft ICU 3.0 */
+    UCHAR_NFKD_INERT,
+    /** Binary property NFC_Inert.
+        ICU-specific property for characters that are inert under NFC,
+        i.e., they do not interact with adjacent characters.
+        Used for example in normalizing transforms in incremental mode
+        to find the boundary of safely normalizable text despite possible
+        text additions.
+        @see UCHAR_NFD_INERT
+        @draft ICU 3.0 */
+    UCHAR_NFC_INERT,
+    /** Binary property NFKC_Inert.
+        ICU-specific property for characters that are inert under NFKC,
+        i.e., they do not interact with adjacent characters.
+        Used for example in normalizing transforms in incremental mode
+        to find the boundary of safely normalizable text despite possible
+        text additions.
+        @see UCHAR_NFD_INERT
+        @draft ICU 3.0 */
+    UCHAR_NFKC_INERT,
+    /** Binary Property Segment_Starter.
+        ICU-specific property for characters that are starters in terms of
+        Unicode normalization and combining character sequences.
+        They have ccc=0 and do not occur in non-initial position of the
+        canonical decomposition of any character
+        (like " in NFD(a-umlaut) and a Jamo T in an NFD(Hangul LVT)).
+        ICU uses this property for segmenting a string for generating a set of
+        canonically equivalent strings, e.g. for canonical closure while
+        processing collation tailoring rules.
+        @draft ICU 3.0 */
+    UCHAR_SEGMENT_STARTER,
+    /** One more than the last constant for binary Unicode properties. @stable ICU 2.1 */
+    UCHAR_BINARY_LIMIT,
+
+    /** Enumerated property Bidi_Class.
+        Same as u_charDirection, returns UCharDirection values. @stable ICU 2.2 */
+    UCHAR_BIDI_CLASS=0x1000,
+    /** First constant for enumerated/integer Unicode properties. @stable ICU 2.2 */
+    UCHAR_INT_START=UCHAR_BIDI_CLASS,
+    /** Enumerated property Block.
+        Same as ublock_getCode, returns UBlockCode values. @stable ICU 2.2 */
+    UCHAR_BLOCK,
+    /** Enumerated property Canonical_Combining_Class.
+        Same as u_getCombiningClass, returns 8-bit numeric values. @stable ICU 2.2 */
+    UCHAR_CANONICAL_COMBINING_CLASS,
+    /** Enumerated property Decomposition_Type.
+        Returns UDecompositionType values. @stable ICU 2.2 */
+    UCHAR_DECOMPOSITION_TYPE,
+    /** Enumerated property East_Asian_Width.
+        See http://www.unicode.org/reports/tr11/
+        Returns UEastAsianWidth values. @stable ICU 2.2 */
+    UCHAR_EAST_ASIAN_WIDTH,
+    /** Enumerated property General_Category.
+        Same as u_charType, returns UCharCategory values. @stable ICU 2.2 */
+    UCHAR_GENERAL_CATEGORY,
+    /** Enumerated property Joining_Group.
+        Returns UJoiningGroup values. @stable ICU 2.2 */
+    UCHAR_JOINING_GROUP,
+    /** Enumerated property Joining_Type.
+        Returns UJoiningType values. @stable ICU 2.2 */
+    UCHAR_JOINING_TYPE,
+    /** Enumerated property Line_Break.
+        Returns ULineBreak values. @stable ICU 2.2 */
+    UCHAR_LINE_BREAK,
+    /** Enumerated property Numeric_Type.
+        Returns UNumericType values. @stable ICU 2.2 */
+    UCHAR_NUMERIC_TYPE,
+    /** Enumerated property Script.
+        Same as uscript_getScript, returns UScriptCode values. @stable ICU 2.2 */
+    UCHAR_SCRIPT,
+    /** Enumerated property Hangul_Syllable_Type, new in Unicode 4.
+        Returns UHangulSyllableType values. @stable ICU 2.6 */
+    UCHAR_HANGUL_SYLLABLE_TYPE,
+    /** Enumerated property NFD_Quick_Check.
+        Returns UNormalizationCheckResult values. @draft ICU 3.0 */
+    UCHAR_NFD_QUICK_CHECK,
+    /** Enumerated property NFKD_Quick_Check.
+        Returns UNormalizationCheckResult values. @draft ICU 3.0 */
+    UCHAR_NFKD_QUICK_CHECK,
+    /** Enumerated property NFC_Quick_Check.
+        Returns UNormalizationCheckResult values. @draft ICU 3.0 */
+    UCHAR_NFC_QUICK_CHECK,
+    /** Enumerated property NFKC_Quick_Check.
+        Returns UNormalizationCheckResult values. @draft ICU 3.0 */
+    UCHAR_NFKC_QUICK_CHECK,
+    /** Enumerated property Lead_Canonical_Combining_Class.
+        ICU-specific property for the ccc of the first code point
+        of the decomposition, or lccc(c)=ccc(NFD(c)[0]).
+        Useful for checking for canonically ordered text;
+        see UNORM_FCD and http://www.unicode.org/notes/tn5/#FCD .
+        Returns 8-bit numeric values like UCHAR_CANONICAL_COMBINING_CLASS. @draft ICU 3.0 */
+    UCHAR_LEAD_CANONICAL_COMBINING_CLASS,
+    /** Enumerated property Trail_Canonical_Combining_Class.
+        ICU-specific property for the ccc of the last code point
+        of the decomposition, or tccc(c)=ccc(NFD(c)[last]).
+        Useful for checking for canonically ordered text;
+        see UNORM_FCD and http://www.unicode.org/notes/tn5/#FCD .
+        Returns 8-bit numeric values like UCHAR_CANONICAL_COMBINING_CLASS. @draft ICU 3.0 */
+    UCHAR_TRAIL_CANONICAL_COMBINING_CLASS,
+    /** One more than the last constant for enumerated/integer Unicode properties. @stable ICU 2.2 */
+    UCHAR_INT_LIMIT,
+
+    /** Bitmask property General_Category_Mask.
+        This is the General_Category property returned as a bit mask.
+        When used in u_getIntPropertyValue(c), same as U_MASK(u_charType(c)),
+        returns bit masks for UCharCategory values where exactly one bit is set.
+        When used with u_getPropertyValueName() and u_getPropertyValueEnum(),
+        a multi-bit mask is used for sets of categories like "Letters".
+        Mask values should be cast to uint32_t.
+        @stable ICU 2.4 */
+    UCHAR_GENERAL_CATEGORY_MASK=0x2000,
+    /** First constant for bit-mask Unicode properties. @stable ICU 2.4 */
+    UCHAR_MASK_START=UCHAR_GENERAL_CATEGORY_MASK,
+    /** One more than the last constant for bit-mask Unicode properties. @stable ICU 2.4 */
+    UCHAR_MASK_LIMIT,
+
+    /** Double property Numeric_Value.
+        Corresponds to u_getNumericValue. @stable ICU 2.4 */
+    UCHAR_NUMERIC_VALUE=0x3000,
+    /** First constant for double Unicode properties. @stable ICU 2.4 */
+    UCHAR_DOUBLE_START=UCHAR_NUMERIC_VALUE,
+    /** One more than the last constant for double Unicode properties. @stable ICU 2.4 */
+    UCHAR_DOUBLE_LIMIT,
+
+    /** String property Age.
+        Corresponds to u_charAge. @stable ICU 2.4 */
+    UCHAR_AGE=0x4000,
+    /** First constant for string Unicode properties. @stable ICU 2.4 */
+    UCHAR_STRING_START=UCHAR_AGE,
+    /** String property Bidi_Mirroring_Glyph.
+        Corresponds to u_charMirror. @stable ICU 2.4 */
+    UCHAR_BIDI_MIRRORING_GLYPH,
+    /** String property Case_Folding.
+        Corresponds to u_strFoldCase in ustring.h. @stable ICU 2.4 */
+    UCHAR_CASE_FOLDING,
+    /** String property ISO_Comment.
+        Corresponds to u_getISOComment. @stable ICU 2.4 */
+    UCHAR_ISO_COMMENT,
+    /** String property Lowercase_Mapping.
+        Corresponds to u_strToLower in ustring.h. @stable ICU 2.4 */
+    UCHAR_LOWERCASE_MAPPING,
+    /** String property Name.
+        Corresponds to u_charName. @stable ICU 2.4 */
+    UCHAR_NAME,
+    /** String property Simple_Case_Folding.
+        Corresponds to u_foldCase. @stable ICU 2.4 */
+    UCHAR_SIMPLE_CASE_FOLDING,
+    /** String property Simple_Lowercase_Mapping.
+        Corresponds to u_tolower. @stable ICU 2.4 */
+    UCHAR_SIMPLE_LOWERCASE_MAPPING,
+    /** String property Simple_Titlecase_Mapping.
+        Corresponds to u_totitle. @stable ICU 2.4 */
+    UCHAR_SIMPLE_TITLECASE_MAPPING,
+    /** String property Simple_Uppercase_Mapping.
+        Corresponds to u_toupper. @stable ICU 2.4 */
+    UCHAR_SIMPLE_UPPERCASE_MAPPING,
+    /** String property Titlecase_Mapping.
+        Corresponds to u_strToTitle in ustring.h. @stable ICU 2.4 */
+    UCHAR_TITLECASE_MAPPING,
+    /** String property Unicode_1_Name.
+        Corresponds to u_charName. @stable ICU 2.4 */
+    UCHAR_UNICODE_1_NAME,
+    /** String property Uppercase_Mapping.
+        Corresponds to u_strToUpper in ustring.h. @stable ICU 2.4 */
+    UCHAR_UPPERCASE_MAPPING,
+    /** One more than the last constant for string Unicode properties. @stable ICU 2.4 */
+    UCHAR_STRING_LIMIT,
+
+    /** Represents a nonexistent or invalid property or property value. @stable ICU 2.4 */
+    UCHAR_INVALID_CODE = -1
+} UProperty;
+
+/**
+ * Data for enumerated Unicode general category types.
+ * See http://www.unicode.org/Public/UNIDATA/UnicodeData.html .
+ * @stable ICU 2.0
+ */
+typedef enum UCharCategory
+{
+    /** See note !!.  Comments of the form "Cn" are read by genpname. */
+
+    /** Non-category for unassigned and non-character code points. @stable ICU 2.0 */
+    U_UNASSIGNED              = 0,
+    /** Cn "Other, Not Assigned (no characters in [UnicodeData.txt] have this property)" (same as U_UNASSIGNED!) @stable ICU 2.0 */
+    U_GENERAL_OTHER_TYPES     = 0,
+    /** Lu @stable ICU 2.0 */
+    U_UPPERCASE_LETTER        = 1,
+    /** Ll @stable ICU 2.0 */
+    U_LOWERCASE_LETTER        = 2,
+    /** Lt @stable ICU 2.0 */
+    U_TITLECASE_LETTER        = 3,
+    /** Lm @stable ICU 2.0 */
+    U_MODIFIER_LETTER         = 4,
+    /** Lo @stable ICU 2.0 */
+    U_OTHER_LETTER            = 5,
+    /** Mn @stable ICU 2.0 */
+    U_NON_SPACING_MARK        = 6,
+    /** Me @stable ICU 2.0 */
+    U_ENCLOSING_MARK          = 7,
+    /** Mc @stable ICU 2.0 */
+    U_COMBINING_SPACING_MARK  = 8,
+    /** Nd @stable ICU 2.0 */
+    U_DECIMAL_DIGIT_NUMBER    = 9,
+    /** Nl @stable ICU 2.0 */
+    U_LETTER_NUMBER           = 10,
+    /** No @stable ICU 2.0 */
+    U_OTHER_NUMBER            = 11,
+    /** Zs @stable ICU 2.0 */
+    U_SPACE_SEPARATOR         = 12,
+    /** Zl @stable ICU 2.0 */
+    U_LINE_SEPARATOR          = 13,
+    /** Zp @stable ICU 2.0 */
+    U_PARAGRAPH_SEPARATOR     = 14,
+    /** Cc @stable ICU 2.0 */
+    U_CONTROL_CHAR            = 15,
+    /** Cf @stable ICU 2.0 */
+    U_FORMAT_CHAR             = 16,
+    /** Co @stable ICU 2.0 */
+    U_PRIVATE_USE_CHAR        = 17,
+    /** Cs @stable ICU 2.0 */
+    U_SURROGATE               = 18,
+    /** Pd @stable ICU 2.0 */
+    U_DASH_PUNCTUATION        = 19,
+    /** Ps @stable ICU 2.0 */
+    U_START_PUNCTUATION       = 20,
+    /** Pe @stable ICU 2.0 */
+    U_END_PUNCTUATION         = 21,
+    /** Pc @stable ICU 2.0 */
+    U_CONNECTOR_PUNCTUATION   = 22,
+    /** Po @stable ICU 2.0 */
+    U_OTHER_PUNCTUATION       = 23,
+    /** Sm @stable ICU 2.0 */
+    U_MATH_SYMBOL             = 24,
+    /** Sc @stable ICU 2.0 */
+    U_CURRENCY_SYMBOL         = 25,
+    /** Sk @stable ICU 2.0 */
+    U_MODIFIER_SYMBOL         = 26,
+    /** So @stable ICU 2.0 */
+    U_OTHER_SYMBOL            = 27,
+    /** Pi @stable ICU 2.0 */
+    U_INITIAL_PUNCTUATION     = 28,
+    /** Pf @stable ICU 2.0 */
+    U_FINAL_PUNCTUATION       = 29,
+    /** One higher than the last enum UCharCategory constant. @stable ICU 2.0 */
+    U_CHAR_CATEGORY_COUNT
+} UCharCategory;
+
+/**
+ * U_GC_XX_MASK constants are bit flags corresponding to Unicode
+ * general category values.
+ * For each category, the nth bit is set if the numeric value of the
+ * corresponding UCharCategory constant is n.
+ *
+ * There are also some U_GC_Y_MASK constants for groups of general categories
+ * like L for all letter categories.
+ *
+ * @see u_charType
+ * @see U_GET_GC_MASK
+ * @see UCharCategory
+ * @stable ICU 2.1
+ */
+#define U_GC_CN_MASK    U_MASK(U_GENERAL_OTHER_TYPES)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LU_MASK    U_MASK(U_UPPERCASE_LETTER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LL_MASK    U_MASK(U_LOWERCASE_LETTER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LT_MASK    U_MASK(U_TITLECASE_LETTER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LM_MASK    U_MASK(U_MODIFIER_LETTER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LO_MASK    U_MASK(U_OTHER_LETTER)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_MN_MASK    U_MASK(U_NON_SPACING_MARK)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ME_MASK    U_MASK(U_ENCLOSING_MARK)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_MC_MASK    U_MASK(U_COMBINING_SPACING_MARK)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ND_MASK    U_MASK(U_DECIMAL_DIGIT_NUMBER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_NL_MASK    U_MASK(U_LETTER_NUMBER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_NO_MASK    U_MASK(U_OTHER_NUMBER)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ZS_MASK    U_MASK(U_SPACE_SEPARATOR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ZL_MASK    U_MASK(U_LINE_SEPARATOR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ZP_MASK    U_MASK(U_PARAGRAPH_SEPARATOR)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_CC_MASK    U_MASK(U_CONTROL_CHAR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_CF_MASK    U_MASK(U_FORMAT_CHAR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_CO_MASK    U_MASK(U_PRIVATE_USE_CHAR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_CS_MASK    U_MASK(U_SURROGATE)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PD_MASK    U_MASK(U_DASH_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PS_MASK    U_MASK(U_START_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PE_MASK    U_MASK(U_END_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PC_MASK    U_MASK(U_CONNECTOR_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PO_MASK    U_MASK(U_OTHER_PUNCTUATION)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_SM_MASK    U_MASK(U_MATH_SYMBOL)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_SC_MASK    U_MASK(U_CURRENCY_SYMBOL)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_SK_MASK    U_MASK(U_MODIFIER_SYMBOL)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_SO_MASK    U_MASK(U_OTHER_SYMBOL)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PI_MASK    U_MASK(U_INITIAL_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PF_MASK    U_MASK(U_FINAL_PUNCTUATION)
+
+
+/** Mask constant for multiple UCharCategory bits (L Letters). @stable ICU 2.1 */
+#define U_GC_L_MASK \
+            (U_GC_LU_MASK|U_GC_LL_MASK|U_GC_LT_MASK|U_GC_LM_MASK|U_GC_LO_MASK)
+
+/** Mask constant for multiple UCharCategory bits (LC Cased Letters). @stable ICU 2.1 */
+#define U_GC_LC_MASK \
+            (U_GC_LU_MASK|U_GC_LL_MASK|U_GC_LT_MASK)
+
+/** Mask constant for multiple UCharCategory bits (M Marks). @stable ICU 2.1 */
+#define U_GC_M_MASK (U_GC_MN_MASK|U_GC_ME_MASK|U_GC_MC_MASK)
+
+/** Mask constant for multiple UCharCategory bits (N Numbers). @stable ICU 2.1 */
+#define U_GC_N_MASK (U_GC_ND_MASK|U_GC_NL_MASK|U_GC_NO_MASK)
+
+/** Mask constant for multiple UCharCategory bits (Z Separators). @stable ICU 2.1 */
+#define U_GC_Z_MASK (U_GC_ZS_MASK|U_GC_ZL_MASK|U_GC_ZP_MASK)
+
+/** Mask constant for multiple UCharCategory bits (C Others). @stable ICU 2.1 */
+#define U_GC_C_MASK \
+            (U_GC_CN_MASK|U_GC_CC_MASK|U_GC_CF_MASK|U_GC_CO_MASK|U_GC_CS_MASK)
+
+/** Mask constant for multiple UCharCategory bits (P Punctuation). @stable ICU 2.1 */
+#define U_GC_P_MASK \
+            (U_GC_PD_MASK|U_GC_PS_MASK|U_GC_PE_MASK|U_GC_PC_MASK|U_GC_PO_MASK| \
+             U_GC_PI_MASK|U_GC_PF_MASK)
+
+/** Mask constant for multiple UCharCategory bits (S Symbols). @stable ICU 2.1 */
+#define U_GC_S_MASK (U_GC_SM_MASK|U_GC_SC_MASK|U_GC_SK_MASK|U_GC_SO_MASK)
+
+/**
+ * This specifies the language directional property of a character set.
+ * @stable ICU 2.0
+ */
+typedef enum UCharDirection {
+    /** See note !!.  Comments of the form "EN" are read by genpname. */
+
+    /** L @stable ICU 2.0 */
+    U_LEFT_TO_RIGHT               = 0,
+    /** R @stable ICU 2.0 */
+    U_RIGHT_TO_LEFT               = 1,
+    /** EN @stable ICU 2.0 */
+    U_EUROPEAN_NUMBER             = 2,
+    /** ES @stable ICU 2.0 */
+    U_EUROPEAN_NUMBER_SEPARATOR   = 3,
+    /** ET @stable ICU 2.0 */
+    U_EUROPEAN_NUMBER_TERMINATOR  = 4,
+    /** AN @stable ICU 2.0 */
+    U_ARABIC_NUMBER               = 5,
+    /** CS @stable ICU 2.0 */
+    U_COMMON_NUMBER_SEPARATOR     = 6,
+    /** B @stable ICU 2.0 */
+    U_BLOCK_SEPARATOR             = 7,
+    /** S @stable ICU 2.0 */
+    U_SEGMENT_SEPARATOR           = 8,
+    /** WS @stable ICU 2.0 */
+    U_WHITE_SPACE_NEUTRAL         = 9,
+    /** ON @stable ICU 2.0 */
+    U_OTHER_NEUTRAL               = 10,
+    /** LRE @stable ICU 2.0 */
+    U_LEFT_TO_RIGHT_EMBEDDING     = 11,
+    /** LRO @stable ICU 2.0 */
+    U_LEFT_TO_RIGHT_OVERRIDE      = 12,
+    /** AL @stable ICU 2.0 */
+    U_RIGHT_TO_LEFT_ARABIC        = 13,
+    /** RLE @stable ICU 2.0 */
+    U_RIGHT_TO_LEFT_EMBEDDING     = 14,
+    /** RLO @stable ICU 2.0 */
+    U_RIGHT_TO_LEFT_OVERRIDE      = 15,
+    /** PDF @stable ICU 2.0 */
+    U_POP_DIRECTIONAL_FORMAT      = 16,
+    /** NSM @stable ICU 2.0 */
+    U_DIR_NON_SPACING_MARK        = 17,
+    /** BN @stable ICU 2.0 */
+    U_BOUNDARY_NEUTRAL            = 18,
+    /** @stable ICU 2.0 */
+    U_CHAR_DIRECTION_COUNT
+} UCharDirection;
+
+/**
+ * Constants for Unicode blocks, see the Unicode Data file Blocks.txt
+ * @stable ICU 2.0
+ */
+enum UBlockCode {
+
+    /** New No_Block value in Unicode 4. @stable ICU 2.6 */
+    UBLOCK_NO_BLOCK = 0, /*[none]*/ /* Special range indicating No_Block */
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BASIC_LATIN = 1, /*[0000]*/ /*See note !!*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LATIN_1_SUPPLEMENT=2, /*[0080]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LATIN_EXTENDED_A =3, /*[0100]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LATIN_EXTENDED_B =4, /*[0180]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_IPA_EXTENSIONS =5, /*[0250]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SPACING_MODIFIER_LETTERS =6, /*[02B0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_COMBINING_DIACRITICAL_MARKS =7, /*[0300]*/
+
+    /**
+     * Unicode 3.2 renames this block to "Greek and Coptic".
+     * @stable ICU 2.0
+     */
+    UBLOCK_GREEK =8, /*[0370]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CYRILLIC =9, /*[0400]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARMENIAN =10, /*[0530]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HEBREW =11, /*[0590]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARABIC =12, /*[0600]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SYRIAC =13, /*[0700]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_THAANA =14, /*[0780]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_DEVANAGARI =15, /*[0900]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BENGALI =16, /*[0980]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GURMUKHI =17, /*[0A00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GUJARATI =18, /*[0A80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ORIYA =19, /*[0B00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_TAMIL =20, /*[0B80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_TELUGU =21, /*[0C00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KANNADA =22, /*[0C80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MALAYALAM =23, /*[0D00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SINHALA =24, /*[0D80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_THAI =25, /*[0E00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LAO =26, /*[0E80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_TIBETAN =27, /*[0F00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MYANMAR =28, /*[1000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GEORGIAN =29, /*[10A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HANGUL_JAMO =30, /*[1100]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ETHIOPIC =31, /*[1200]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CHEROKEE =32, /*[13A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS =33, /*[1400]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_OGHAM =34, /*[1680]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_RUNIC =35, /*[16A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KHMER =36, /*[1780]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MONGOLIAN =37, /*[1800]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LATIN_EXTENDED_ADDITIONAL =38, /*[1E00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GREEK_EXTENDED =39, /*[1F00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GENERAL_PUNCTUATION =40, /*[2000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SUPERSCRIPTS_AND_SUBSCRIPTS =41, /*[2070]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CURRENCY_SYMBOLS =42, /*[20A0]*/
+
+    /**
+     * Unicode 3.2 renames this block to "Combining Diacritical Marks for Symbols".
+     * @stable ICU 2.0
+     */
+    UBLOCK_COMBINING_MARKS_FOR_SYMBOLS =43, /*[20D0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LETTERLIKE_SYMBOLS =44, /*[2100]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_NUMBER_FORMS =45, /*[2150]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARROWS =46, /*[2190]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MATHEMATICAL_OPERATORS =47, /*[2200]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MISCELLANEOUS_TECHNICAL =48, /*[2300]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CONTROL_PICTURES =49, /*[2400]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_OPTICAL_CHARACTER_RECOGNITION =50, /*[2440]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ENCLOSED_ALPHANUMERICS =51, /*[2460]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BOX_DRAWING =52, /*[2500]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BLOCK_ELEMENTS =53, /*[2580]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GEOMETRIC_SHAPES =54, /*[25A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MISCELLANEOUS_SYMBOLS =55, /*[2600]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_DINGBATS =56, /*[2700]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BRAILLE_PATTERNS =57, /*[2800]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_RADICALS_SUPPLEMENT =58, /*[2E80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KANGXI_RADICALS =59, /*[2F00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_IDEOGRAPHIC_DESCRIPTION_CHARACTERS =60, /*[2FF0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION =61, /*[3000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HIRAGANA =62, /*[3040]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KATAKANA =63, /*[30A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BOPOMOFO =64, /*[3100]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HANGUL_COMPATIBILITY_JAMO =65, /*[3130]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KANBUN =66, /*[3190]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BOPOMOFO_EXTENDED =67, /*[31A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ENCLOSED_CJK_LETTERS_AND_MONTHS =68, /*[3200]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_COMPATIBILITY =69, /*[3300]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A =70, /*[3400]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_UNIFIED_IDEOGRAPHS =71, /*[4E00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_YI_SYLLABLES =72, /*[A000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_YI_RADICALS =73, /*[A490]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HANGUL_SYLLABLES =74, /*[AC00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HIGH_SURROGATES =75, /*[D800]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HIGH_PRIVATE_USE_SURROGATES =76, /*[DB80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LOW_SURROGATES =77, /*[DC00]*/
+
+    /**
+     * Same as UBLOCK_PRIVATE_USE_AREA.
+     * Until Unicode 3.1.1, the corresponding block name was "Private Use",
+     * and multiple code point ranges had this block.
+     * Unicode 3.2 renames the block for the BMP PUA to "Private Use Area" and
+     * adds separate blocks for the supplementary PUAs.
+     *
+     * @stable ICU 2.0
+     */
+    UBLOCK_PRIVATE_USE = 78,
+    /**
+     * Same as UBLOCK_PRIVATE_USE.
+     * Until Unicode 3.1.1, the corresponding block name was "Private Use",
+     * and multiple code point ranges had this block.
+     * Unicode 3.2 renames the block for the BMP PUA to "Private Use Area" and
+     * adds separate blocks for the supplementary PUAs.
+     *
+     * @stable ICU 2.0
+     */
+    UBLOCK_PRIVATE_USE_AREA =UBLOCK_PRIVATE_USE, /*[E000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS =79, /*[F900]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ALPHABETIC_PRESENTATION_FORMS =80, /*[FB00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARABIC_PRESENTATION_FORMS_A =81, /*[FB50]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_COMBINING_HALF_MARKS =82, /*[FE20]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_COMPATIBILITY_FORMS =83, /*[FE30]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SMALL_FORM_VARIANTS =84, /*[FE50]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARABIC_PRESENTATION_FORMS_B =85, /*[FE70]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SPECIALS =86, /*[FFF0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS =87, /*[FF00]*/
+
+    /* New blocks in Unicode 3.1 */
+
+    /** @stable ICU 2.0 */
+    UBLOCK_OLD_ITALIC = 88  , /*[10300]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_GOTHIC = 89 , /*[10330]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_DESERET = 90 , /*[10400]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_BYZANTINE_MUSICAL_SYMBOLS = 91 , /*[1D000]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_MUSICAL_SYMBOLS = 92 , /*[1D100]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS = 93  , /*[1D400]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B  = 94 , /*[20000]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT = 95 , /*[2F800]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_TAGS = 96, /*[E0000]*/
+
+    /* New blocks in Unicode 3.2 */
+
+    /**
+     * Unicode 4.0.1 renames the "Cyrillic Supplementary" block to "Cyrillic Supplement".
+     * @stable ICU 2.2
+     */
+    UBLOCK_CYRILLIC_SUPPLEMENTARY = 97, 
+    /** @draft ICU 3.0  */
+    UBLOCK_CYRILLIC_SUPPLEMENT = UBLOCK_CYRILLIC_SUPPLEMENTARY, /*[0500]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_TAGALOG = 98, /*[1700]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_HANUNOO = 99, /*[1720]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_BUHID = 100, /*[1740]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_TAGBANWA = 101, /*[1760]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A = 102, /*[27C0]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTAL_ARROWS_A = 103, /*[27F0]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTAL_ARROWS_B = 104, /*[2900]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B = 105, /*[2980]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS = 106, /*[2A00]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_KATAKANA_PHONETIC_EXTENSIONS = 107, /*[31F0]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_VARIATION_SELECTORS = 108, /*[FE00]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_A = 109, /*[F0000]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_B = 110, /*[100000]*/
+
+    /* New blocks in Unicode 4 */
+
+    /** @stable ICU 2.6 */
+    UBLOCK_LIMBU = 111, /*[1900]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_TAI_LE = 112, /*[1950]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_KHMER_SYMBOLS = 113, /*[19E0]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_PHONETIC_EXTENSIONS = 114, /*[1D00]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS = 115, /*[2B00]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_YIJING_HEXAGRAM_SYMBOLS = 116, /*[4DC0]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_LINEAR_B_SYLLABARY = 117, /*[10000]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_LINEAR_B_IDEOGRAMS = 118, /*[10080]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_AEGEAN_NUMBERS = 119, /*[10100]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_UGARITIC = 120, /*[10380]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_SHAVIAN = 121, /*[10450]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_OSMANYA = 122, /*[10480]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_CYPRIOT_SYLLABARY = 123, /*[10800]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_TAI_XUAN_JING_SYMBOLS = 124, /*[1D300]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_VARIATION_SELECTORS_SUPPLEMENT = 125, /*[E0100]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_COUNT,
+
+    /** @stable ICU 2.0 */
+    UBLOCK_INVALID_CODE=-1
+};
+
+/** @stable ICU 2.0 */
+typedef enum UBlockCode UBlockCode;
+
+/**
+ * East Asian Width constants.
+ *
+ * @see UCHAR_EAST_ASIAN_WIDTH
+ * @see u_getIntPropertyValue
+ * @stable ICU 2.2
+ */
+typedef enum UEastAsianWidth {
+    U_EA_NEUTRAL,   /*[N]*/ /*See note !!*/
+    U_EA_AMBIGUOUS, /*[A]*/
+    U_EA_HALFWIDTH, /*[H]*/
+    U_EA_FULLWIDTH, /*[F]*/
+    U_EA_NARROW,    /*[Na]*/
+    U_EA_WIDE,      /*[W]*/
+    U_EA_COUNT
+} UEastAsianWidth;
+/*
+ * Implementation note:
+ * Keep UEastAsianWidth constant values in sync with names list in genprops/props2.c.
+ */
+
+/**
+ * Selector constants for u_charName().
+ * u_charName() returns the "modern" name of a
+ * Unicode character; or the name that was defined in
+ * Unicode version 1.0, before the Unicode standard merged
+ * with ISO-10646; or an "extended" name that gives each
+ * Unicode code point a unique name.
+ *
+ * @see u_charName
+ * @stable ICU 2.0
+ */
+typedef enum UCharNameChoice {
+    U_UNICODE_CHAR_NAME,
+    U_UNICODE_10_CHAR_NAME,
+    U_EXTENDED_CHAR_NAME,
+    U_CHAR_NAME_CHOICE_COUNT
+} UCharNameChoice;
+
+/**
+ * Selector constants for u_getPropertyName() and
+ * u_getPropertyValueName().  These selectors are used to choose which
+ * name is returned for a given property or value.  All properties and
+ * values have a long name.  Most have a short name, but some do not.
+ * Unicode allows for additional names, beyond the long and short
+ * name, which would be indicated by U_LONG_PROPERTY_NAME + i, where
+ * i=1, 2,...
+ *
+ * @see u_getPropertyName()
+ * @see u_getPropertyValueName()
+ * @stable ICU 2.4
+ */
+typedef enum UPropertyNameChoice {
+    U_SHORT_PROPERTY_NAME,
+    U_LONG_PROPERTY_NAME,
+    U_PROPERTY_NAME_CHOICE_COUNT
+} UPropertyNameChoice;
+
+/**
+ * Decomposition Type constants.
+ *
+ * @see UCHAR_DECOMPOSITION_TYPE
+ * @stable ICU 2.2
+ */
+typedef enum UDecompositionType {
+    U_DT_NONE,              /*[none]*/ /*See note !!*/
+    U_DT_CANONICAL,         /*[can]*/
+    U_DT_COMPAT,            /*[com]*/
+    U_DT_CIRCLE,            /*[enc]*/
+    U_DT_FINAL,             /*[fin]*/
+    U_DT_FONT,              /*[font]*/
+    U_DT_FRACTION,          /*[fra]*/
+    U_DT_INITIAL,           /*[init]*/
+    U_DT_ISOLATED,          /*[iso]*/
+    U_DT_MEDIAL,            /*[med]*/
+    U_DT_NARROW,            /*[nar]*/
+    U_DT_NOBREAK,           /*[nb]*/
+    U_DT_SMALL,             /*[sml]*/
+    U_DT_SQUARE,            /*[sqr]*/
+    U_DT_SUB,               /*[sub]*/
+    U_DT_SUPER,             /*[sup]*/
+    U_DT_VERTICAL,          /*[vert]*/
+    U_DT_WIDE,              /*[wide]*/
+    U_DT_COUNT /* 18 */
+} UDecompositionType;
+
+/**
+ * Joining Type constants.
+ *
+ * @see UCHAR_JOINING_TYPE
+ * @stable ICU 2.2
+ */
+typedef enum UJoiningType {
+    U_JT_NON_JOINING,       /*[U]*/ /*See note !!*/
+    U_JT_JOIN_CAUSING,      /*[C]*/
+    U_JT_DUAL_JOINING,      /*[D]*/
+    U_JT_LEFT_JOINING,      /*[L]*/
+    U_JT_RIGHT_JOINING,     /*[R]*/
+    U_JT_TRANSPARENT,       /*[T]*/
+    U_JT_COUNT /* 6 */
+} UJoiningType;
+
+/**
+ * Joining Group constants.
+ *
+ * @see UCHAR_JOINING_GROUP
+ * @stable ICU 2.2
+ */
+typedef enum UJoiningGroup {
+    U_JG_NO_JOINING_GROUP,
+    U_JG_AIN,
+    U_JG_ALAPH,
+    U_JG_ALEF,
+    U_JG_BEH,
+    U_JG_BETH,
+    U_JG_DAL,
+    U_JG_DALATH_RISH,
+    U_JG_E,
+    U_JG_FEH,
+    U_JG_FINAL_SEMKATH,
+    U_JG_GAF,
+    U_JG_GAMAL,
+    U_JG_HAH,
+    U_JG_HAMZA_ON_HEH_GOAL,
+    U_JG_HE,
+    U_JG_HEH,
+    U_JG_HEH_GOAL,
+    U_JG_HETH,
+    U_JG_KAF,
+    U_JG_KAPH,
+    U_JG_KNOTTED_HEH,
+    U_JG_LAM,
+    U_JG_LAMADH,
+    U_JG_MEEM,
+    U_JG_MIM,
+    U_JG_NOON,
+    U_JG_NUN,
+    U_JG_PE,
+    U_JG_QAF,
+    U_JG_QAPH,
+    U_JG_REH,
+    U_JG_REVERSED_PE,
+    U_JG_SAD,
+    U_JG_SADHE,
+    U_JG_SEEN,
+    U_JG_SEMKATH,
+    U_JG_SHIN,
+    U_JG_SWASH_KAF,
+    U_JG_SYRIAC_WAW,
+    U_JG_TAH,
+    U_JG_TAW,
+    U_JG_TEH_MARBUTA,
+    U_JG_TETH,
+    U_JG_WAW,
+    U_JG_YEH,
+    U_JG_YEH_BARREE,
+    U_JG_YEH_WITH_TAIL,
+    U_JG_YUDH,
+    U_JG_YUDH_HE,
+    U_JG_ZAIN,
+    U_JG_FE,        /**< @stable ICU 2.6 */
+    U_JG_KHAPH,     /**< @stable ICU 2.6 */
+    U_JG_ZHAIN,     /**< @stable ICU 2.6 */
+    U_JG_COUNT
+} UJoiningGroup;
+
+/**
+ * Line Break constants.
+ *
+ * @see UCHAR_LINE_BREAK
+ * @stable ICU 2.2
+ */
+typedef enum ULineBreak {
+    U_LB_UNKNOWN,           /*[XX]*/ /*See note !!*/
+    U_LB_AMBIGUOUS,         /*[AI]*/
+    U_LB_ALPHABETIC,        /*[AL]*/
+    U_LB_BREAK_BOTH,        /*[B2]*/
+    U_LB_BREAK_AFTER,       /*[BA]*/
+    U_LB_BREAK_BEFORE,      /*[BB]*/
+    U_LB_MANDATORY_BREAK,   /*[BK]*/
+    U_LB_CONTINGENT_BREAK,  /*[CB]*/
+    U_LB_CLOSE_PUNCTUATION, /*[CL]*/
+    U_LB_COMBINING_MARK,    /*[CM]*/
+    U_LB_CARRIAGE_RETURN,   /*[CR]*/
+    U_LB_EXCLAMATION,       /*[EX]*/
+    U_LB_GLUE,              /*[GL]*/
+    U_LB_HYPHEN,            /*[HY]*/
+    U_LB_IDEOGRAPHIC,       /*[ID]*/
+    U_LB_INSEPERABLE,
+    /** Renamed from the misspelled "inseperable" in Unicode 4.0.1/ICU 3.0 @draft ICU 3.0 */
+    U_LB_INSEPARABLE=U_LB_INSEPERABLE,/*[IN]*/
+    U_LB_INFIX_NUMERIC,     /*[IS]*/
+    U_LB_LINE_FEED,         /*[LF]*/
+    U_LB_NONSTARTER,        /*[NS]*/
+    U_LB_NUMERIC,           /*[NU]*/
+    U_LB_OPEN_PUNCTUATION,  /*[OP]*/
+    U_LB_POSTFIX_NUMERIC,   /*[PO]*/
+    U_LB_PREFIX_NUMERIC,    /*[PR]*/
+    U_LB_QUOTATION,         /*[QU]*/
+    U_LB_COMPLEX_CONTEXT,   /*[SA]*/
+    U_LB_SURROGATE,         /*[SG]*/
+    U_LB_SPACE,             /*[SP]*/
+    U_LB_BREAK_SYMBOLS,     /*[SY]*/
+    U_LB_ZWSPACE,           /*[ZW]*/
+    U_LB_NEXT_LINE,         /*[NL]*/ /* from here on: new in Unicode 4/ICU 2.6 */
+    U_LB_WORD_JOINER,       /*[WJ]*/
+    U_LB_COUNT
+} ULineBreak;
+
+/**
+ * Numeric Type constants.
+ *
+ * @see UCHAR_NUMERIC_TYPE
+ * @stable ICU 2.2
+ */
+typedef enum UNumericType {
+    U_NT_NONE,              /*[None]*/ /*See note !!*/
+    U_NT_DECIMAL,           /*[de]*/
+    U_NT_DIGIT,             /*[di]*/
+    U_NT_NUMERIC,           /*[nu]*/
+    U_NT_COUNT
+} UNumericType;
+
+/**
+ * Hangul Syllable Type constants.
+ *
+ * @see UCHAR_HANGUL_SYLLABLE_TYPE
+ * @stable ICU 2.6
+ */
+typedef enum UHangulSyllableType {
+    U_HST_NOT_APPLICABLE,   /*[NA]*/ /*See note !!*/
+    U_HST_LEADING_JAMO,     /*[L]*/
+    U_HST_VOWEL_JAMO,       /*[V]*/
+    U_HST_TRAILING_JAMO,    /*[T]*/
+    U_HST_LV_SYLLABLE,      /*[LV]*/
+    U_HST_LVT_SYLLABLE,     /*[LVT]*/
+    U_HST_COUNT
+} UHangulSyllableType;
+
+/**
+ * Check a binary Unicode property for a code point.
+ *
+ * Unicode, especially in version 3.2, defines many more properties than the
+ * original set in UnicodeData.txt.
+ *
+ * The properties APIs are intended to reflect Unicode properties as defined
+ * in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR).
+ * For details about the properties see http://www.unicode.org/ucd/ .
+ * For names of Unicode properties see the UCD file PropertyAliases.txt.
+ *
+ * Important: If ICU is built with UCD files from Unicode versions below 3.2,
+ * then properties marked with "new in Unicode 3.2" are not or not fully available.
+ *
+ * @param c Code point to test.
+ * @param which UProperty selector constant, identifies which binary property to check.
+ *        Must be UCHAR_BINARY_START<=which=0.
+ * True for characters with general category "Nd" (decimal digit numbers)
+ * as well as Latin letters a-f and A-F in both ASCII and Fullwidth ASCII.
+ * (That is, for letters with code points
+ * 0041..0046, 0061..0066, FF21..FF26, FF41..FF46.)
+ *
+ * In order to narrow the definition of hexadecimal digits to only ASCII
+ * characters, use (c<=0x7f && u_isxdigit(c)).
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a hexadecimal digit
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isxdigit(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a punctuation character.
+ * True for characters with general categories "P" (punctuation).
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a punctuation character
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_ispunct(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a "graphic" character
+ * (printable, excluding spaces).
+ * TRUE for all characters except those with general categories
+ * "Cc" (control codes), "Cf" (format controls), "Cs" (surrogates),
+ * "Cn" (unassigned), and "Z" (separators).
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a "graphic" character
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isgraph(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a "blank" or "horizontal space",
+ * a character that visibly separates words on a line.
+ * The following are equivalent definitions:
+ *
+ * TRUE for Unicode White_Space characters except for "vertical space controls"
+ * where "vertical space controls" are the following characters:
+ * U+000A (LF) U+000B (VT) U+000C (FF) U+000D (CR) U+0085 (NEL) U+2028 (LS) U+2029 (PS)
+ *
+ * same as
+ *
+ * TRUE for U+0009 (TAB) and characters with general category "Zs" (space separators)
+ * except Zero Width Space (ZWSP, U+200B).
+ *
+ * Note: There are several ICU whitespace functions; please see the uchar.h
+ * file documentation for a detailed comparison.
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a "blank"
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isblank(UChar32 c);
+
+/**
+ * Determines whether the specified code point is "defined",
+ * which usually means that it is assigned a character.
+ * True for general categories other than "Cn" (other, not assigned),
+ * i.e., true for all code points mentioned in UnicodeData.txt.
+ *
+ * Note that non-character code points (e.g., U+FDD0) are not "defined"
+ * (they are Cn), but surrogate code points are "defined" (Cs).
+ *
+ * Same as java.lang.Character.isDefined().
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is assigned a character
+ *
+ * @see u_isdigit
+ * @see u_isalpha
+ * @see u_isalnum
+ * @see u_isupper
+ * @see u_islower
+ * @see u_istitle
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isdefined(UChar32 c);
+
+/**
+ * Determines if the specified character is a space character or not.
+ *
+ * Note: There are several ICU whitespace functions; please see the uchar.h
+ * file documentation for a detailed comparison.
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c    the character to be tested
+ * @return  true if the character is a space character; false otherwise.
+ *
+ * @see u_isJavaSpaceChar
+ * @see u_isWhitespace
+ * @see u_isUWhiteSpace
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isspace(UChar32 c);
+
+/**
+ * Determine if the specified code point is a space character according to Java.
+ * True for characters with general categories "Z" (separators),
+ * which does not include control codes (e.g., TAB or Line Feed).
+ *
+ * Same as java.lang.Character.isSpaceChar().
+ *
+ * Note: There are several ICU whitespace functions; please see the uchar.h
+ * file documentation for a detailed comparison.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a space character according to Character.isSpaceChar()
+ *
+ * @see u_isspace
+ * @see u_isWhitespace
+ * @see u_isUWhiteSpace
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isJavaSpaceChar(UChar32 c);
+
+/**
+ * Determines if the specified code point is a whitespace character according to Java/ICU.
+ * A character is considered to be a Java whitespace character if and only
+ * if it satisfies one of the following criteria:
+ *
+ * - It is a Unicode separator (categories "Z"), but is not
+ *      a no-break space (U+00A0 NBSP or U+2007 Figure Space or U+202F Narrow NBSP).
+ * - It is U+0009 HORIZONTAL TABULATION.
+ * - It is U+000A LINE FEED.
+ * - It is U+000B VERTICAL TABULATION.
+ * - It is U+000C FORM FEED.
+ * - It is U+000D CARRIAGE RETURN.
+ * - It is U+001C FILE SEPARATOR.
+ * - It is U+001D GROUP SEPARATOR.
+ * - It is U+001E RECORD SEPARATOR.
+ * - It is U+001F UNIT SEPARATOR.
+ * - It is U+0085 NEXT LINE.
+ *
+ * Same as java.lang.Character.isWhitespace() except that Java omits U+0085.
+ *
+ * Note: There are several ICU whitespace functions; please see the uchar.h
+ * file documentation for a detailed comparison.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a whitespace character according to Java/ICU
+ *
+ * @see u_isspace
+ * @see u_isJavaSpaceChar
+ * @see u_isUWhiteSpace
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isWhitespace(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a control character
+ * (as defined by this function).
+ * A control character is one of the following:
+ * - ISO 8-bit control character (U+0000..U+001f and U+007f..U+009f)
+ * - U_CONTROL_CHAR (Cc)
+ * - U_FORMAT_CHAR (Cf)
+ * - U_LINE_SEPARATOR (Zl)
+ * - U_PARAGRAPH_SEPARATOR (Zp)
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a control character
+ *
+ * @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT
+ * @see u_isprint
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_iscntrl(UChar32 c);
+
+/**
+ * Determines whether the specified code point is an ISO control code.
+ * True for U+0000..U+001f and U+007f..U+009f (general category "Cc").
+ *
+ * Same as java.lang.Character.isISOControl().
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is an ISO control code
+ *
+ * @see u_iscntrl
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isISOControl(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a printable character.
+ * True for general categories other than "C" (controls).
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a printable character
+ *
+ * @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT
+ * @see u_iscntrl
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isprint(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a base character.
+ * True for general categories "L" (letters), "N" (numbers),
+ * "Mc" (spacing combining marks), and "Me" (enclosing marks).
+ *
+ * Note that this is different from the Unicode definition in
+ * chapter 3.5, conformance clause D13,
+ * which defines base characters to be all characters (not Cn)
+ * that do not graphically combine with preceding characters (M)
+ * and that are neither control (Cc) or format (Cf) characters.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a base character according to this function
+ *
+ * @see u_isalpha
+ * @see u_isdigit
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isbase(UChar32 c);
+
+/**
+ * Returns the bidirectional category value for the code point,
+ * which is used in the Unicode bidirectional algorithm
+ * (UAX #9 http://www.unicode.org/reports/tr9/).
+ * Note that some unassigned code points have bidi values
+ * of R or AL because they are in blocks that are reserved
+ * for Right-To-Left scripts.
+ *
+ * Same as java.lang.Character.getDirectionality()
+ *
+ * @param c the code point to be tested
+ * @return the bidirectional category (UCharDirection) value
+ *
+ * @see UCharDirection
+ * @stable ICU 2.0
+ */
+U_STABLE UCharDirection U_EXPORT2
+u_charDirection(UChar32 c);
+
+/**
+ * Determines whether the code point has the Bidi_Mirrored property.
+ * This property is set for characters that are commonly used in
+ * Right-To-Left contexts and need to be displayed with a "mirrored"
+ * glyph.
+ *
+ * Same as java.lang.Character.isMirrored().
+ * Same as UCHAR_BIDI_MIRRORED
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the character has the Bidi_Mirrored property
+ *
+ * @see UCHAR_BIDI_MIRRORED
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isMirrored(UChar32 c);
+
+/**
+ * Maps the specified character to a "mirror-image" character.
+ * For characters with the Bidi_Mirrored property, implementations
+ * sometimes need a "poor man's" mapping to another Unicode
+ * character (code point) such that the default glyph may serve
+ * as the mirror-image of the default glyph of the specified
+ * character. This is useful for text conversion to and from
+ * codepages with visual order, and for displays without glyph
+ * selecetion capabilities.
+ *
+ * @param c the code point to be mapped
+ * @return another Unicode code point that may serve as a mirror-image
+ *         substitute, or c itself if there is no such mapping or c
+ *         does not have the Bidi_Mirrored property
+ *
+ * @see UCHAR_BIDI_MIRRORED
+ * @see u_isMirrored
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32 U_EXPORT2
+u_charMirror(UChar32 c);
+
+/**
+ * Returns the general category value for the code point.
+ *
+ * Same as java.lang.Character.getType().
+ *
+ * @param c the code point to be tested
+ * @return the general category (UCharCategory) value
+ *
+ * @see UCharCategory
+ * @stable ICU 2.0
+ */
+U_STABLE int8_t U_EXPORT2
+u_charType(UChar32 c);
+
+/**
+ * Get a single-bit bit set for the general category of a character.
+ * This bit set can be compared bitwise with U_GC_SM_MASK, U_GC_L_MASK, etc.
+ * Same as U_MASK(u_charType(c)).
+ *
+ * @param c the code point to be tested
+ * @return a single-bit mask corresponding to the general category (UCharCategory) value
+ *
+ * @see u_charType
+ * @see UCharCategory
+ * @see U_GC_CN_MASK
+ * @stable ICU 2.1
+ */
+#define U_GET_GC_MASK(c) U_MASK(u_charType(c))
+
+/**
+ * Callback from u_enumCharTypes(), is called for each contiguous range
+ * of code points c (where start<=cnameChoice, the character name written
+ * into the buffer is the "modern" name or the name that was defined
+ * in Unicode version 1.0.
+ * The name contains only "invariant" characters
+ * like A-Z, 0-9, space, and '-'.
+ * Unicode 1.0 names are only retrieved if they are different from the modern
+ * names and if the data file contains the data for them. gennames may or may
+ * not be called with a command line option to include 1.0 names in unames.dat.
+ *
+ * @param code The character (code point) for which to get the name.
+ *             It must be 0<=code<=0x10ffff.
+ * @param nameChoice Selector for which name to get.
+ * @param buffer Destination address for copying the name.
+ *               The name will always be zero-terminated.
+ *               If there is no name, then the buffer will be set to the empty string.
+ * @param bufferLength ==sizeof(buffer)
+ * @param pErrorCode Pointer to a UErrorCode variable;
+ *        check for U_SUCCESS() after u_charName()
+ *        returns.
+ * @return The length of the name, or 0 if there is no name for this character.
+ *         If the bufferLength is less than or equal to the length, then the buffer
+ *         contains the truncated name and the returned length indicates the full
+ *         length of the name.
+ *         The length does not include the zero-termination.
+ *
+ * @see UCharNameChoice
+ * @see u_charFromName
+ * @see u_enumCharNames
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_charName(UChar32 code, UCharNameChoice nameChoice,
+           char *buffer, int32_t bufferLength,
+           UErrorCode *pErrorCode);
+
+/**
+ * Get the ISO 10646 comment for a character.
+ * The ISO 10646 comment is an informative field in the Unicode Character
+ * Database (UnicodeData.txt field 11) and is from the ISO 10646 names list.
+ *
+ * @param c The character (code point) for which to get the ISO comment.
+ *             It must be 0<=c<=0x10ffff.
+ * @param dest Destination address for copying the comment.
+ *             The comment will be zero-terminated if possible.
+ *             If there is no comment, then the buffer will be set to the empty string.
+ * @param destCapacity ==sizeof(dest)
+ * @param pErrorCode Pointer to a UErrorCode variable;
+ *        check for U_SUCCESS() after u_getISOComment()
+ *        returns.
+ * @return The length of the comment, or 0 if there is no comment for this character.
+ *         If the destCapacity is less than or equal to the length, then the buffer
+ *         contains the truncated name and the returned length indicates the full
+ *         length of the name.
+ *         The length does not include the zero-termination.
+ *
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+u_getISOComment(UChar32 c,
+                char *dest, int32_t destCapacity,
+                UErrorCode *pErrorCode);
+
+/**
+ * Find a Unicode character by its name and return its code point value.
+ * The name is matched exactly and completely.
+ * If the name does not correspond to a code point, pErrorCode
+ * is set to U_INVALID_CHAR_FOUND.
+ * A Unicode 1.0 name is matched only if it differs from the modern name.
+ * Unicode names are all uppercase. Extended names are lowercase followed
+ * by an uppercase hexadecimal number, and within angle brackets.
+ *
+ * @param nameChoice Selector for which name to match.
+ * @param name The name to match.
+ * @param pErrorCode Pointer to a UErrorCode variable
+ * @return The Unicode value of the code point with the given name,
+ *         or an undefined value if there is no such code point.
+ *
+ * @see UCharNameChoice
+ * @see u_charName
+ * @see u_enumCharNames
+ * @stable ICU 1.7
+ */
+U_STABLE UChar32 U_EXPORT2
+u_charFromName(UCharNameChoice nameChoice,
+               const char *name,
+               UErrorCode *pErrorCode);
+
+/**
+ * Type of a callback function for u_enumCharNames() that gets called
+ * for each Unicode character with the code point value and
+ * the character name.
+ * If such a function returns FALSE, then the enumeration is stopped.
+ *
+ * @param context The context pointer that was passed to u_enumCharNames().
+ * @param code The Unicode code point for the character with this name.
+ * @param nameChoice Selector for which kind of names is enumerated.
+ * @param name The character's name, zero-terminated.
+ * @param length The length of the name.
+ * @return TRUE if the enumeration should continue, FALSE to stop it.
+ *
+ * @see UCharNameChoice
+ * @see u_enumCharNames
+ * @stable ICU 1.7
+ */
+typedef UBool UEnumCharNamesFn(void *context,
+                               UChar32 code,
+                               UCharNameChoice nameChoice,
+                               const char *name,
+                               int32_t length);
+
+/**
+ * Enumerate all assigned Unicode characters between the start and limit
+ * code points (start inclusive, limit exclusive) and call a function
+ * for each, passing the code point value and the character name.
+ * For Unicode 1.0 names, only those are enumerated that differ from the
+ * modern names.
+ *
+ * @param start The first code point in the enumeration range.
+ * @param limit One more than the last code point in the enumeration range
+ *              (the first one after the range).
+ * @param fn The function that is to be called for each character name.
+ * @param context An arbitrary pointer that is passed to the function.
+ * @param nameChoice Selector for which kind of names to enumerate.
+ * @param pErrorCode Pointer to a UErrorCode variable
+ *
+ * @see UCharNameChoice
+ * @see UEnumCharNamesFn
+ * @see u_charName
+ * @see u_charFromName
+ * @stable ICU 1.7
+ */
+U_STABLE void U_EXPORT2
+u_enumCharNames(UChar32 start, UChar32 limit,
+                UEnumCharNamesFn *fn,
+                void *context,
+                UCharNameChoice nameChoice,
+                UErrorCode *pErrorCode);
+
+/**
+ * Return the Unicode name for a given property, as given in the
+ * Unicode database file PropertyAliases.txt.
+ *
+ * In addition, this function maps the property
+ * UCHAR_GENERAL_CATEGORY_MASK to the synthetic names "gcm" /
+ * "General_Category_Mask".  These names are not in
+ * PropertyAliases.txt.
+ *
+ * @param property UProperty selector other than UCHAR_INVALID_CODE.
+ *         If out of range, NULL is returned.
+ *
+ * @param nameChoice selector for which name to get.  If out of range,
+ *         NULL is returned.  All properties have a long name.  Most
+ *         have a short name, but some do not.  Unicode allows for
+ *         additional names; if present these will be returned by
+ *         U_LONG_PROPERTY_NAME + i, where i=1, 2,...
+ *
+ * @return a pointer to the name, or NULL if either the
+ *         property or the nameChoice is out of range.  If a given
+ *         nameChoice returns NULL, then all larger values of
+ *         nameChoice will return NULL, with one exception: if NULL is
+ *         returned for U_SHORT_PROPERTY_NAME, then
+ *         U_LONG_PROPERTY_NAME (and higher) may still return a
+ *         non-NULL value.  The returned pointer is valid until
+ *         u_cleanup() is called.
+ *
+ * @see UProperty
+ * @see UPropertyNameChoice
+ * @stable ICU 2.4
+ */
+U_STABLE const char* U_EXPORT2
+u_getPropertyName(UProperty property,
+                  UPropertyNameChoice nameChoice);
+
+/**
+ * Return the UProperty enum for a given property name, as specified
+ * in the Unicode database file PropertyAliases.txt.  Short, long, and
+ * any other variants are recognized.
+ *
+ * In addition, this function maps the synthetic names "gcm" /
+ * "General_Category_Mask" to the property
+ * UCHAR_GENERAL_CATEGORY_MASK.  These names are not in
+ * PropertyAliases.txt.
+ *
+ * @param alias the property name to be matched.  The name is compared
+ *         using "loose matching" as described in PropertyAliases.txt.
+ *
+ * @return a UProperty enum, or UCHAR_INVALID_CODE if the given name
+ *         does not match any property.
+ *
+ * @see UProperty
+ * @stable ICU 2.4
+ */
+U_STABLE UProperty U_EXPORT2
+u_getPropertyEnum(const char* alias);
+
+/**
+ * Return the Unicode name for a given property value, as given in the
+ * Unicode database file PropertyValueAliases.txt.
+ *
+ * Note: Some of the names in PropertyValueAliases.txt can only be
+ * retrieved using UCHAR_GENERAL_CATEGORY_MASK, not
+ * UCHAR_GENERAL_CATEGORY.  These include: "C" / "Other", "L" /
+ * "Letter", "LC" / "Cased_Letter", "M" / "Mark", "N" / "Number", "P"
+ * / "Punctuation", "S" / "Symbol", and "Z" / "Separator".
+ *
+ * @param property UProperty selector constant.
+ *        Must be UCHAR_BINARY_START<=which2<=radix<=36 or if the
+ * value of c is not a valid digit in the specified
+ * radix, -1 is returned. A character is a valid digit
+ * if at least one of the following is true:
+ * 
    + *
  • The character has a decimal digit value. + * Such characters have the general category "Nd" (decimal digit numbers) + * and a Numeric_Type of Decimal. + * In this case the value is the character's decimal digit value.
  • + *
  • The character is one of the uppercase Latin letters + * 'A' through 'Z'. + * In this case the value is c-'A'+10.
  • + *
  • The character is one of the lowercase Latin letters + * 'a' through 'z'. + * In this case the value is ch-'a'+10.
  • + *
  • Latin letters from both the ASCII range (0061..007A, 0041..005A) + * as well as from the Fullwidth ASCII range (FF41..FF5A, FF21..FF3A) + * are recognized.
  • + *
+ * + * Same as java.lang.Character.digit(). + * + * @param ch the code point to be tested. + * @param radix the radix. + * @return the numeric value represented by the character in the + * specified radix, + * or -1 if there is no value or if the value exceeds the radix. + * + * @see UCHAR_NUMERIC_TYPE + * @see u_forDigit + * @see u_charDigitValue + * @see u_isdigit + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_digit(UChar32 ch, int8_t radix); + +/** + * Determines the character representation for a specific digit in + * the specified radix. If the value of radix is not a + * valid radix, or the value of digit is not a valid + * digit in the specified radix, the null character + * (U+0000) is returned. + *

+ * The radix argument is valid if it is greater than or + * equal to 2 and less than or equal to 36. + * The digit argument is valid if + * 0 <= digit < radix. + *

+ * If the digit is less than 10, then + * '0' + digit is returned. Otherwise, the value + * 'a' + digit - 10 is returned. + * + * Same as java.lang.Character.forDigit(). + * + * @param digit the number to convert to a character. + * @param radix the radix. + * @return the char representation of the specified digit + * in the specified radix. + * + * @see u_digit + * @see u_charDigitValue + * @see u_isdigit + * @stable ICU 2.0 + */ +U_STABLE UChar32 U_EXPORT2 +u_forDigit(int32_t digit, int8_t radix); + +/** + * Get the "age" of the code point. + * The "age" is the Unicode version when the code point was first + * designated (as a non-character or for Private Use) + * or assigned a character. + * This can be useful to avoid emitting code points to receiving + * processes that do not accept newer characters. + * The data is from the UCD file DerivedAge.txt. + * + * @param c The code point. + * @param versionArray The Unicode version number array, to be filled in. + * + * @stable ICU 2.1 + */ +U_STABLE void U_EXPORT2 +u_charAge(UChar32 c, UVersionInfo versionArray); + +/** + * Gets the Unicode version information. + * The version array is filled in with the version information + * for the Unicode standard that is currently used by ICU. + * For example, Unicode version 3.1.1 is represented as an array with + * the values { 3, 1, 1, 0 }. + * + * @param versionArray an output array that will be filled in with + * the Unicode version number + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +u_getUnicodeVersion(UVersionInfo versionArray); + +/** + * Get the FC_NFKC_Closure property string for a character. + * See Unicode Standard Annex #15 for details, search for "FC_NFKC_Closure" + * or for "FNC": http://www.unicode.org/reports/tr15/ + * + * @param c The character (code point) for which to get the FC_NFKC_Closure string. + * It must be 0<=c<=0x10ffff. + * @param dest Destination address for copying the string. + * The string will be zero-terminated if possible. + * If there is no FC_NFKC_Closure string, + * then the buffer will be set to the empty string. + * @param destCapacity ==sizeof(dest) + * @param pErrorCode Pointer to a UErrorCode variable. + * @return The length of the string, or 0 if there is no FC_NFKC_Closure string for this character. + * If the destCapacity is less than or equal to the length, then the buffer + * contains the truncated name and the returned length indicates the full + * length of the name. + * The length does not include the zero-termination. + * + * @stable ICU 2.2 + */ +U_STABLE int32_t U_EXPORT2 +u_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode); + +U_CDECL_END + +#endif /*_UCHAR*/ +/*eof*/ diff --git a/icu/unicode/ucnv.h b/icu/unicode/ucnv.h new file mode 100644 index 0000000..a042f7a --- /dev/null +++ b/icu/unicode/ucnv.h @@ -0,0 +1,1817 @@ +/* +********************************************************************** +* Copyright (C) 1999-2004, International Business Machines +* Corporation and others. All Rights Reserved. +********************************************************************** + * ucnv.h: + * External APIs for the ICU's codeset conversion library + * Bertrand A. Damiba + * + * Modification History: + * + * Date Name Description + * 04/04/99 helena Fixed internal header inclusion. + * 05/11/00 helena Added setFallback and usesFallback APIs. + * 06/29/2000 helena Major rewrite of the callback APIs. + * 12/07/2000 srl Update of documentation + */ + +/** + * \file + * \brief C API: Character conversion + * + *

Character Conversion C API

+ * + *

This API is used to convert codepage or character encoded data to and + * from UTF-16. You can open a converter with {@link ucnv_open() }. With that + * converter, you can get its properties, set options, convert your data and + * close the converter.

+ * + *

Since many software programs recogize different converter names for + * different types of converters, there are other functions in this API to + * iterate over the converter aliases. The functions {@link ucnv_getAvailableName() }, + * {@link ucnv_getAlias() } and {@link ucnv_getStandardName() } are some of the + * more frequently used alias functions to get this information.

+ * + *

When a converter encounters an illegal, irregular, invalid or unmappable character + * its default behavior is to use a substitution character to replace the + * bad byte sequence. This behavior can be changed by using {@link ucnv_getFromUCallBack() } + * or {@link ucnv_getToUCallBack() } on the converter. The header ucnv_err.h defines + * many other callback actions that can be used instead of a character substitution.

+ * + *

More information about this API can be found in our + * User's + * Guide.

+ */ + +#ifndef UCNV_H +#define UCNV_H + +#include "unicode/ucnv_err.h" +#include "unicode/uenum.h" + +#ifndef __USET_H__ + +/** + * USet is the C API type for Unicode sets. + * It is forward-declared here to avoid including the header file if related + * conversion APIs are not used. + * See unicode/uset.h + * + * @see ucnv_getUnicodeSet + * @stable ICU 2.6 + */ +struct USet; +/** @stable ICU 2.6 */ +typedef struct USet USet; + +#endif + +#if !UCONFIG_NO_CONVERSION + +U_CDECL_BEGIN + +/** Maximum length of a converter name including the terminating NULL @stable ICU 2.0 */ +#define UCNV_MAX_CONVERTER_NAME_LENGTH 60 +/** Maximum length of a converter name including path and terminating NULL @stable ICU 2.0 */ +#define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH) + +/** Shift in for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */ +#define UCNV_SI 0x0F +/** Shift out for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */ +#define UCNV_SO 0x0E + +/** + * Enum for specifying basic types of converters + * @see ucnv_getType + * @stable ICU 2.0 + */ +typedef enum { + UCNV_UNSUPPORTED_CONVERTER = -1, + UCNV_SBCS = 0, + UCNV_DBCS = 1, + UCNV_MBCS = 2, + UCNV_LATIN_1 = 3, + UCNV_UTF8 = 4, + UCNV_UTF16_BigEndian = 5, + UCNV_UTF16_LittleEndian = 6, + UCNV_UTF32_BigEndian = 7, + UCNV_UTF32_LittleEndian = 8, + UCNV_EBCDIC_STATEFUL = 9, + UCNV_ISO_2022 = 10, + + UCNV_LMBCS_1 = 11, + UCNV_LMBCS_2, + UCNV_LMBCS_3, + UCNV_LMBCS_4, + UCNV_LMBCS_5, + UCNV_LMBCS_6, + UCNV_LMBCS_8, + UCNV_LMBCS_11, + UCNV_LMBCS_16, + UCNV_LMBCS_17, + UCNV_LMBCS_18, + UCNV_LMBCS_19, + UCNV_LMBCS_LAST = UCNV_LMBCS_19, + UCNV_HZ, + UCNV_SCSU, + UCNV_ISCII, + UCNV_US_ASCII, + UCNV_UTF7, + UCNV_BOCU1, + UCNV_UTF16, + UCNV_UTF32, + UCNV_CESU8, + UCNV_IMAP_MAILBOX, + + /* Number of converter types for which we have conversion routines. */ + UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES + +} UConverterType; + +/** + * Enum for specifying which platform a converter ID refers to. + * The use of platform/CCSID is not recommended. See ucnv_openCCSID(). + * + * @see ucnv_getPlatform + * @see ucnv_openCCSID + * @see ucnv_getCCSID + * @stable ICU 2.0 + */ +typedef enum { + UCNV_UNKNOWN = -1, + UCNV_IBM = 0 +} UConverterPlatform; + +/** + * Function pointer for error callback in the codepage to unicode direction. + * Called when an error has occured in conversion to unicode, or on open/close of the callback (see reason). + * @param context Pointer to the callback's private data + * @param args Information about the conversion in progress + * @param codeUnits Points to 'length' bytes of the concerned codepage sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param reason Defines the reason the callback was invoked + * @see ucnv_setToUCallBack + * @see UConverterToUnicodeArgs + * @stable ICU 2.0 + */ +typedef void (U_EXPORT2 *UConverterToUCallback) ( + const void* context, + UConverterToUnicodeArgs *args, + const char *codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode *); + +/** + * Function pointer for error callback in the unicode to codepage direction. + * Called when an error has occured in conversion from unicode, or on open/close of the callback (see reason). + * @param context Pointer to the callback's private data + * @param args Information about the conversion in progress + * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. + * @param reason Defines the reason the callback was invoked + * @see ucnv_setFromUCallBack + * @stable ICU 2.0 + */ +typedef void (U_EXPORT2 *UConverterFromUCallback) ( + const void* context, + UConverterFromUnicodeArgs *args, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode *); + +U_CDECL_END + +/** + * Character that separates converter names from options and options from each other. + * @see ucnv_open + * @stable ICU 2.0 + */ +#define UCNV_OPTION_SEP_CHAR ',' + +/** + * String version of UCNV_OPTION_SEP_CHAR. + * @see ucnv_open + * @stable ICU 2.0 + */ +#define UCNV_OPTION_SEP_STRING "," + +/** + * Character that separates a converter option from its value. + * @see ucnv_open + * @stable ICU 2.0 + */ +#define UCNV_VALUE_SEP_CHAR '=' + +/** + * String version of UCNV_VALUE_SEP_CHAR. + * @see ucnv_open + * @stable ICU 2.0 + */ +#define UCNV_VALUE_SEP_STRING "=" + +/** + * Converter option for specifying a locale. + * For example, ucnv_open("SCSU,locale=ja", &errorCode); + * See convrtrs.txt. + * + * @see ucnv_open + * @stable ICU 2.0 + */ +#define UCNV_LOCALE_OPTION_STRING ",locale=" + +/** + * Converter option for specifying a version selector (0..9) for some converters. + * For example, ucnv_open("UTF-7,version=1", &errorCode); + * See convrtrs.txt. + * + * @see ucnv_open + * @stable ICU 2.4 + */ +#define UCNV_VERSION_OPTION_STRING ",version=" + +/** + * Converter option for EBCDIC SBCS or mixed-SBCS/DBCS (stateful) codepages. + * Swaps Unicode mappings for EBCDIC LF and NL codes, as used on + * S/390 (z/OS) Unix System Services (Open Edition). + * For example, ucnv_open("ibm-1047,swaplfnl", &errorCode); + * See convrtrs.txt. + * + * @see ucnv_open + * @stable ICU 2.4 + */ +#define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl" + +/** + * Do a fuzzy compare of a two converter/alias names. The comparison + * is case-insensitive. It also ignores the characters '-', '_', and + * ' ' (dash, underscore, and space). Thus the strings "UTF-8", + * "utf_8", and "Utf 8" are exactly equivalent. + * + * @param name1 a converter name or alias, zero-terminated + * @param name2 a converter name or alias, zero-terminated + * @return 0 if the names match, or a negative value if the name1 + * lexically precedes name2, or a positive value if the name1 + * lexically follows name2. + * @stable ICU 2.0 + */ +U_STABLE int U_EXPORT2 +ucnv_compareNames(const char *name1, const char *name2); + + +/** + * Creates a UConverter object with the names specified as a C string. + * The actual name will be resolved with the alias file + * using a case-insensitive string comparison that ignores + * the delimiters '-', '_', and ' ' (dash, underscore, and space). + * E.g., the names "UTF8", "utf-8", and "Utf 8" are all equivalent. + * If NULL is passed for the converter name, it will create one with the + * getDefaultName return value. + * + *

A converter name for ICU 1.5 and above may contain options + * like a locale specification to control the specific behavior of + * the newly instantiated converter. + * The meaning of the options depends on the particular converter. + * If an option is not defined for or recognized by a given converter, then it is ignored.

+ * + *

Options are appended to the converter name string, with a + * UCNV_OPTION_SEP_CHAR between the name and the first option and + * also between adjacent options.

+ * + *

If the alias is ambiguous, then the preferred converter is used + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.

+ * + *

The conversion behavior and names can vary between platforms. ICU may + * convert some characters differently from other platforms. Details on this topic + * are in the User's + * Guide.

+ * + * @param converterName Name of the uconv table, may have options appended + * @param err outgoing error status U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR + * @return the created Unicode converter object, or NULL if an error occured + * @see ucnv_openU + * @see ucnv_openCCSID + * @see ucnv_close + * @stable ICU 2.0 + */ +U_STABLE UConverter* U_EXPORT2 +ucnv_open(const char *converterName, UErrorCode *err); + + +/** + * Creates a Unicode converter with the names specified as unicode string. + * The name should be limited to the ASCII-7 alphanumerics range. + * The actual name will be resolved with the alias file + * using a case-insensitive string comparison that ignores + * the delimiters '-', '_', and ' ' (dash, underscore, and space). + * E.g., the names "UTF8", "utf-8", and "Utf 8" are all equivalent. + * If NULL is passed for the converter name, it will create + * one with the ucnv_getDefaultName() return value. + * If the alias is ambiguous, then the preferred converter is used + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. + * @param name : name of the uconv table in a zero terminated + * Unicode string + * @param err outgoing error status U_MEMORY_ALLOCATION_ERROR, + * U_FILE_ACCESS_ERROR + * @return the created Unicode converter object, or NULL if an + * error occured + * @see ucnv_open + * @see ucnv_openCCSID + * @see ucnv_close + * @see ucnv_getDefaultName + * @stable ICU 2.0 + */ +U_STABLE UConverter* U_EXPORT2 +ucnv_openU(const UChar *name, + UErrorCode *err); + +/** + * Creates a UConverter object from a CCSID number and platform pair. + * Note that the usefulness of this function is limited to platforms with numeric + * encoding IDs. Only IBM and Microsoft platforms use numeric (16-bit) identifiers for + * encodings. + * + * In addition, IBM CCSIDs and Unicode conversion tables are not 1:1 related. + * For many IBM CCSIDs there are multiple (up to six) Unicode conversion tables, and + * for some Unicode conversion tables there are multiple CCSIDs. + * Some "alternate" Unicode conversion tables are provided by the + * IBM CDRA conversion table registry. + * The most prominent example of a systematic modification of conversion tables that is + * not provided in the form of conversion table files in the repository is + * that S/390 Unix System Services swaps the codes for Line Feed and New Line in all + * EBCDIC codepages, which requires such a swap in the Unicode conversion tables as well. + * + * Only IBM default conversion tables are accessible with ucnv_openCCSID(). + * ucnv_getCCSID() will return the same CCSID for all conversion tables that are associated + * with that CCSID. + * + * Currently, the only "platform" supported in the ICU converter API is UCNV_IBM. + * + * In summary, the use of CCSIDs and the associated API functions is not recommended. + * + * In order to open a converter with the default IBM CDRA Unicode conversion table, + * you can use this function or use the prefix "ibm-": + * \code + * char name[20]; + * sprintf(name, "ibm-%hu", ccsid); + * cnv=ucnv_open(name, &errorCode); + * \endcode + * + * In order to open a converter with the IBM S/390 Unix System Services variant + * of a Unicode/EBCDIC conversion table, + * you can use the prefix "ibm-" together with the option string UCNV_SWAP_LFNL_OPTION_STRING: + * \code + * char name[20]; + * sprintf(name, "ibm-%hu" UCNV_SWAP_LFNL_OPTION_STRING, ccsid); + * cnv=ucnv_open(name, &errorCode); + * \endcode + * + * In order to open a converter from a Microsoft codepage number, use the prefix "cp": + * \code + * char name[20]; + * sprintf(name, "cp%hu", codepageID); + * cnv=ucnv_open(name, &errorCode); + * \endcode + * + * If the alias is ambiguous, then the preferred converter is used + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. + * + * @param codepage codepage number to create + * @param platform the platform in which the codepage number exists + * @param err error status U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR + * @return the created Unicode converter object, or NULL if an error + * occured. + * @see ucnv_open + * @see ucnv_openU + * @see ucnv_close + * @see ucnv_getCCSID + * @see ucnv_getPlatform + * @see UConverterPlatform + * @stable ICU 2.0 + */ +U_STABLE UConverter* U_EXPORT2 +ucnv_openCCSID(int32_t codepage, + UConverterPlatform platform, + UErrorCode * err); + +/** + *

Creates a UConverter object specified from a packageName and a converterName.

+ * + *

The packageName and converterName must point to an ICU udata object, as defined by + * udata_open( packageName, "cnv", converterName, err) or equivalent. + * Typically, packageName will refer to a (.dat) file, or to a package registered with + * udata_setAppData().

+ * + *

The name will NOT be looked up in the alias mechanism, nor will the converter be + * stored in the converter cache or the alias table. The only way to open further converters + * is call this function multiple times, or use the ucnv_safeClone() function to clone a + * 'master' converter.

+ * + *

A future version of ICU may add alias table lookups and/or caching + * to this function.

+ * + *

Example Use: + * cnv = ucnv_openPackage("myapp", "myconverter", &err); + *

+ * + * @param packageName name of the package (equivalent to 'path' in udata_open() call) + * @param converterName name of the data item to be used, without suffix. + * @param err outgoing error status U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR + * @return the created Unicode converter object, or NULL if an error occured + * @see udata_open + * @see ucnv_open + * @see ucnv_safeClone + * @see ucnv_close + * @stable ICU 2.2 + */ +U_STABLE UConverter* U_EXPORT2 +ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err); + +/** + * Thread safe cloning operation + * @param cnv converter to be cloned + * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. + * If buffer is not large enough, new memory will be allocated. + * Clients can use the U_CNV_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations. + * @param pBufferSize pointer to size of allocated space. + * If *pBufferSize == 0, a sufficient size for use in cloning will + * be returned ('pre-flighting') + * If *pBufferSize is not enough for a stack-based safe clone, + * new memory will be allocated. + * @param status to indicate whether the operation went on smoothly or there were errors + * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were necessary. + * @return pointer to the new clone + * @stable ICU 2.0 + */ +U_STABLE UConverter * U_EXPORT2 +ucnv_safeClone(const UConverter *cnv, + void *stackBuffer, + int32_t *pBufferSize, + UErrorCode *status); + +/** + * \def U_CNV_SAFECLONE_BUFFERSIZE + * Definition of a buffer size that is designed to be large enough for + * converters to be cloned with ucnv_safeClone(). + * @stable ICU 2.0 + */ +#define U_CNV_SAFECLONE_BUFFERSIZE 1024 + +/** + * Deletes the unicode converter and releases resources associated + * with just this instance. + * Does not free up shared converter tables. + * + * @param converter the converter object to be deleted + * @see ucnv_open + * @see ucnv_openU + * @see ucnv_openCCSID + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_close(UConverter * converter); + +/** + * Fills in the output parameter, subChars, with the substitution characters + * as multiple bytes. + * + * @param converter the Unicode converter + * @param subChars the subsitution characters + * @param len on input the capacity of subChars, on output the number + * of bytes copied to it + * @param err the outgoing error status code. + * If the substitution character array is too small, an + * U_INDEX_OUTOFBOUNDS_ERROR will be returned. + * @see ucnv_setSubstChars + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_getSubstChars(const UConverter *converter, + char *subChars, + int8_t *len, + UErrorCode *err); + +/** + * Sets the substitution chars when converting from unicode to a codepage. The + * substitution is specified as a string of 1-4 bytes, and may contain + * NULL byte. + * @param converter the Unicode converter + * @param subChars the substitution character byte sequence we want set + * @param len the number of bytes in subChars + * @param err the error status code. U_INDEX_OUTOFBOUNDS_ERROR if + * len is bigger than the maximum number of bytes allowed in subchars + * @see ucnv_getSubstChars + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_setSubstChars(UConverter *converter, + const char *subChars, + int8_t len, + UErrorCode *err); + +/** + * Fills in the output parameter, errBytes, with the error characters from the + * last failing conversion. + * + * @param converter the Unicode converter + * @param errBytes the codepage bytes which were in error + * @param len on input the capacity of errBytes, on output the number of + * bytes which were copied to it + * @param err the error status code. + * If the substitution character array is too small, an + * U_INDEX_OUTOFBOUNDS_ERROR will be returned. + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_getInvalidChars(const UConverter *converter, + char *errBytes, + int8_t *len, + UErrorCode *err); + +/** + * Fills in the output parameter, errChars, with the error characters from the + * last failing conversion. + * + * @param converter the Unicode converter + * @param errUChars the UChars which were in error + * @param len on input the capacity of errUChars, on output the number of + * UChars which were copied to it + * @param err the error status code. + * If the substitution character array is too small, an + * U_INDEX_OUTOFBOUNDS_ERROR will be returned. + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_getInvalidUChars(const UConverter *converter, + UChar *errUChars, + int8_t *len, + UErrorCode *err); + +/** + * Resets the state of a converter to the default state. This is used + * in the case of an error, to restart a conversion from a known default state. + * It will also empty the internal output buffers. + * @param converter the Unicode converter + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_reset(UConverter *converter); + +/** + * Resets the to-Unicode part of a converter state to the default state. + * This is used in the case of an error to restart a conversion to + * Unicode to a known default state. It will also empty the internal + * output buffers used for the conversion to Unicode codepoints. + * @param converter the Unicode converter + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_resetToUnicode(UConverter *converter); + +/** + * Resets the from-Unicode part of a converter state to the default state. + * This is used in the case of an error to restart a conversion from + * Unicode to a known default state. It will also empty the internal output + * buffers used for the conversion from Unicode codepoints. + * @param converter the Unicode converter + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_resetFromUnicode(UConverter *converter); + +/** + * Returns the maximum number of bytes that are output per UChar in conversion + * from Unicode using this converter. + * The returned number can be used with UCNV_GET_MAX_BYTES_FOR_STRING + * to calculate the size of a target buffer for conversion from Unicode. + * + * Note: Before ICU 2.8, this function did not return reliable numbers for + * some stateful converters (EBCDIC_STATEFUL, ISO-2022) and LMBCS. + * + * This number may not be the same as the maximum number of bytes per + * "conversion unit". In other words, it may not be the intuitively expected + * number of bytes per character that would be published for a charset, + * and may not fulfill any other purpose than the allocation of an output + * buffer of guaranteed sufficient size for a given input length and converter. + * + * Examples for special cases that are taken into account: + * - Supplementary code points may convert to more bytes than BMP code points. + * This function returns bytes per UChar (UTF-16 code unit), not per + * Unicode code point, for efficient buffer allocation. + * - State-shifting output (SI/SO, escapes, etc.) from stateful converters. + * - When m input UChars are converted to n output bytes, then the maximum m/n + * is taken into account. + * + * The number returned here does not take into account + * (see UCNV_GET_MAX_BYTES_FOR_STRING): + * - callbacks which output more than one charset character sequence per call, + * like escape callbacks + * - initial and final non-character bytes that are output by some converters + * (automatic BOMs, initial escape sequence, final SI, etc.) + * + * Examples for returned values: + * - SBCS charsets: 1 + * - Shift-JIS: 2 + * - UTF-16: 2 (2 per BMP, 4 per surrogate _pair_, BOM not counted) + * - UTF-8: 3 (3 per BMP, 4 per surrogate _pair_) + * - EBCDIC_STATEFUL (EBCDIC mixed SBCS/DBCS): 3 (SO + DBCS) + * - ISO-2022: 3 (always outputs UTF-8) + * - ISO-2022-JP: 6 (4-byte escape sequences + DBCS) + * - ISO-2022-CN: 8 (4-byte designator sequences + 2-byte SS2/SS3 + DBCS) + * + * @param converter The Unicode converter. + * @return The maximum number of bytes per UChar that are output by ucnv_fromUnicode(), + * to be used together with UCNV_GET_MAX_BYTES_FOR_STRING for buffer allocation. + * + * @see UCNV_GET_MAX_BYTES_FOR_STRING + * @see ucnv_getMinCharSize + * @stable ICU 2.0 + */ +U_STABLE int8_t U_EXPORT2 +ucnv_getMaxCharSize(const UConverter *converter); + +#ifndef U_HIDE_DRAFT_API + +/** + * Calculates the size of a buffer for conversion from Unicode to a charset. + * The calculated size is guaranteed to be sufficient for this conversion. + * + * It takes into account initial and final non-character bytes that are output + * by some converters. + * It does not take into account callbacks which output more than one charset + * character sequence per call, like escape callbacks. + * The default (substitution) callback only outputs one charset character sequence. + * + * @param length Number of UChars to be converted. + * @param maxCharSize Return value from ucnv_getMaxCharSize() for the converter + * that will be used. + * @return Size of a buffer that will be large enough to hold the output bytes of + * converting length UChars with the converter that returned the maxCharSize. + * + * @see ucnv_getMaxCharSize + * @draft ICU 2.8 + */ +#define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \ + (((int32_t)(length)+10)*(int32_t)(maxCharSize)) + +#endif /*U_HIDE_DRAFT_API*/ + +/** + * Returns the minimum byte length for characters in this codepage. + * This is usually either 1 or 2. + * @param converter the Unicode converter + * @return the minimum number of bytes allowed by this particular converter + * @see ucnv_getMaxCharSize + * @stable ICU 2.0 + */ +U_STABLE int8_t U_EXPORT2 +ucnv_getMinCharSize(const UConverter *converter); + +/** + * Returns the display name of the converter passed in based on the Locale + * passed in. If the locale contains no display name, the internal ASCII + * name will be filled in. + * + * @param converter the Unicode converter. + * @param displayLocale is the specific Locale we want to localised for + * @param displayName user provided buffer to be filled in + * @param displayNameCapacity size of displayName Buffer + * @param err error status code + * @return displayNameLength number of UChar needed in displayName + * @see ucnv_getName + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +ucnv_getDisplayName(const UConverter *converter, + const char *displayLocale, + UChar *displayName, + int32_t displayNameCapacity, + UErrorCode *err); + +/** + * Gets the internal, canonical name of the converter (zero-terminated). + * The lifetime of the returned string will be that of the converter + * passed to this function. + * @param converter the Unicode converter + * @param err UErrorCode status + * @return the internal name of the converter + * @see ucnv_getDisplayName + * @stable ICU 2.0 + */ +U_STABLE const char * U_EXPORT2 +ucnv_getName(const UConverter *converter, UErrorCode *err); + +/** + * Gets a codepage number associated with the converter. This is not guaranteed + * to be the one used to create the converter. Some converters do not represent + * platform registered codepages and return zero for the codepage number. + * The error code fill-in parameter indicates if the codepage number + * is available. + * Does not check if the converter is NULL or if converter's data + * table is NULL. + * + * Important: The use of CCSIDs is not recommended because it is limited + * to only two platforms in principle and only one (UCNV_IBM) in the current + * ICU converter API. + * Also, CCSIDs are insufficient to identify IBM Unicode conversion tables precisely. + * For more details see ucnv_openCCSID(). + * + * @param converter the Unicode converter + * @param err the error status code. + * @return If any error occurrs, -1 will be returned otherwise, the codepage number + * will be returned + * @see ucnv_openCCSID + * @see ucnv_getPlatform + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +ucnv_getCCSID(const UConverter *converter, + UErrorCode *err); + +/** + * Gets a codepage platform associated with the converter. Currently, + * only UCNV_IBM will be returned. + * Does not test if the converter is NULL or if converter's data + * table is NULL. + * @param converter the Unicode converter + * @param err the error status code. + * @return The codepage platform + * @stable ICU 2.0 + */ +U_STABLE UConverterPlatform U_EXPORT2 +ucnv_getPlatform(const UConverter *converter, + UErrorCode *err); + +/** + * Gets the type of the converter + * e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022, + * EBCDIC_STATEFUL, LATIN_1 + * @param converter a valid, opened converter + * @return the type of the converter + * @stable ICU 2.0 + */ +U_STABLE UConverterType U_EXPORT2 +ucnv_getType(const UConverter * converter); + +/** + * Gets the "starter" (lead) bytes for converters of type MBCS. + * Will fill in an U_ILLEGAL_ARGUMENT_ERROR if converter passed in + * is not MBCS. Fills in an array of type UBool, with the value of the byte + * as offset to the array. For example, if (starters[0x20] == TRUE) at return, + * it means that the byte 0x20 is a starter byte in this converter. + * Context pointers are always owned by the caller. + * + * @param converter a valid, opened converter of type MBCS + * @param starters an array of size 256 to be filled in + * @param err error status, U_ILLEGAL_ARGUMENT_ERROR if the + * converter is not a type which can return starters. + * @see ucnv_getType + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_getStarters(const UConverter* converter, + UBool starters[256], + UErrorCode* err); + + +/** + * Selectors for Unicode sets that can be returned by ucnv_getUnicodeSet(). + * @see ucnv_getUnicodeSet + * @stable ICU 2.6 + */ +typedef enum UConverterUnicodeSet { + /** Select the set of roundtrippable Unicode code points. @stable ICU 2.6 */ + UCNV_ROUNDTRIP_SET, + /** Number of UConverterUnicodeSet selectors. @stable ICU 2.6 */ + UCNV_SET_COUNT +} UConverterUnicodeSet; + + +/** + * Returns the set of Unicode code points that can be converted by an ICU converter. + * + * The current implementation returns only one kind of set (UCNV_ROUNDTRIP_SET): + * The set of all Unicode code points that can be roundtrip-converted + * (converted without any data loss) with the converter. + * This set will not include code points that have fallback mappings + * or are only the result of reverse fallback mappings. + * See UTR #22 "Character Mapping Markup Language" + * at http://www.unicode.org/reports/tr22/ + * + * This is useful for example for + * - checking that a string or document can be roundtrip-converted with a converter, + * without/before actually performing the conversion + * - testing if a converter can be used for text for typical text for a certain locale, + * by comparing its roundtrip set with the set of ExemplarCharacters from + * ICU's locale data or other sources + * + * In the future, there may be more UConverterUnicodeSet choices to select + * sets with different properties. + * + * @param cnv The converter for which a set is requested. + * @param setFillIn A valid USet *. It will be cleared by this function before + * the converter's specific set is filled into the USet. + * @param whichSet A UConverterUnicodeSet selector; + * currently UCNV_ROUNDTRIP_SET is the only supported value. + * @param pErrorCode ICU error code in/out parameter. + * Must fulfill U_SUCCESS before the function call. + * + * @see UConverterUnicodeSet + * @see uset_open + * @see uset_close + * @stable ICU 2.6 + */ +U_STABLE void U_EXPORT2 +ucnv_getUnicodeSet(const UConverter *cnv, + USet *setFillIn, + UConverterUnicodeSet whichSet, + UErrorCode *pErrorCode); + +/** + * Gets the current calback function used by the converter when an illegal + * or invalid codepage sequence is found. + * Context pointers are always owned by the caller. + * + * @param converter the unicode converter + * @param action fillin: returns the callback function pointer + * @param context fillin: returns the callback's private void* context + * @see ucnv_setToUCallBack + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_getToUCallBack (const UConverter * converter, + UConverterToUCallback *action, + const void **context); + +/** + * Gets the current callback function used by the converter when illegal + * or invalid Unicode sequence is found. + * Context pointers are always owned by the caller. + * + * @param converter the unicode converter + * @param action fillin: returns the callback function pointer + * @param context fillin: returns the callback's private void* context + * @see ucnv_setFromUCallBack + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_getFromUCallBack (const UConverter * converter, + UConverterFromUCallback *action, + const void **context); + +/** + * Changes the callback function used by the converter when + * an illegal or invalid sequence is found. + * Context pointers are always owned by the caller. + * Predefined actions and contexts can be found in the ucnv_err.h header. + * + * @param converter the unicode converter + * @param newAction the new callback function + * @param newContext the new toUnicode callback context pointer. This can be NULL. + * @param oldAction fillin: returns the old callback function pointer. This can be NULL. + * @param oldContext fillin: returns the old callback's private void* context. This can be NULL. + * @param err The error code status + * @see ucnv_getToUCallBack + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_setToUCallBack (UConverter * converter, + UConverterToUCallback newAction, + const void* newContext, + UConverterToUCallback *oldAction, + const void** oldContext, + UErrorCode * err); + +/** + * Changes the current callback function used by the converter when + * an illegal or invalid sequence is found. + * Context pointers are always owned by the caller. + * Predefined actions and contexts can be found in the ucnv_err.h header. + * + * @param converter the unicode converter + * @param newAction the new callback function + * @param newContext the new fromUnicode callback context pointer. This can be NULL. + * @param oldAction fillin: returns the old callback function pointer. This can be NULL. + * @param oldContext fillin: returns the old callback's private void* context. This can be NULL. + * @param err The error code status + * @see ucnv_getFromUCallBack + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_setFromUCallBack (UConverter * converter, + UConverterFromUCallback newAction, + const void *newContext, + UConverterFromUCallback *oldAction, + const void **oldContext, + UErrorCode * err); + +/** + * Converts an array of unicode characters to an array of codepage + * characters. This function is optimized for converting a continuous + * stream of data in buffer-sized chunks, where the entire source and + * target does not fit in available buffers. + * + * The source pointer is an in/out parameter. It starts out pointing where the + * conversion is to begin, and ends up pointing after the last UChar consumed. + * + * Target similarly starts out pointer at the first available byte in the output + * buffer, and ends up pointing after the last byte written to the output. + * + * The converter always attempts to consume the entire source buffer, unless + * (1.) the target buffer is full, or (2.) a failing error is returned from the + * current callback function. When a successful error status has been + * returned, it means that all of the source buffer has been + * consumed. At that point, the caller should reset the source and + * sourceLimit pointers to point to the next chunk. + * + * At the end of the stream (flush==TRUE), the input is completely consumed + * when *source==sourceLimit and no error code is set. + * The converter object is then automatically reset by this function. + * (This means that a converter need not be reset explicitly between data + * streams if it finishes the previous stream without errors.) + * + * This is a stateful conversion. Additionally, even when all source data has + * been consumed, some data may be in the converters' internal state. + * Call this function repeatedly, updating the target pointers with + * the next empty chunk of target in case of a + * U_BUFFER_OVERFLOW_ERROR, and updating the source pointers + * with the next chunk of source when a successful error status is + * returned, until there are no more chunks of source data. + * @param converter the Unicode converter + * @param target I/O parameter. Input : Points to the beginning of the buffer to copy + * codepage characters to. Output : points to after the last codepage character copied + * to target. + * @param targetLimit the pointer just after last of the target buffer + * @param source I/O parameter, pointer to pointer to the source Unicode character buffer. + * @param sourceLimit the pointer just after the last of the source buffer + * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number + * of allocated cells as target. Will fill in offsets from target to source pointer + * e.g: offsets[3] is equal to 6, it means that the target[3] was a result of transcoding source[6] + * For output data carried across calls, and other data without a specific source character + * (such as from escape sequences or callbacks) -1 will be placed for offsets. + * @param flush set to TRUE if the current source buffer is the last available + * chunk of the source, FALSE otherwise. Note that if a failing status is returned, + * this function may have to be called multiple times with flush set to TRUE until + * the source buffer is consumed. + * @param err the error status. U_ILLEGAL_ARGUMENT_ERROR will be set if the + * converter is NULL. + * U_BUFFER_OVERFLOW_ERROR will be set if the target is full and there is + * still data to be written to the target. + * @see ucnv_fromUChars + * @see ucnv_convert + * @see ucnv_getMinCharSize + * @see ucnv_setToUCallBack + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_fromUnicode (UConverter * converter, + char **target, + const char *targetLimit, + const UChar ** source, + const UChar * sourceLimit, + int32_t* offsets, + UBool flush, + UErrorCode * err); + +/** + * Converts a buffer of codepage bytes into an array of unicode UChars + * characters. This function is optimized for converting a continuous + * stream of data in buffer-sized chunks, where the entire source and + * target does not fit in available buffers. + * + * The source pointer is an in/out parameter. It starts out pointing where the + * conversion is to begin, and ends up pointing after the last byte of source consumed. + * + * Target similarly starts out pointer at the first available UChar in the output + * buffer, and ends up pointing after the last UChar written to the output. + * It does NOT necessarily keep UChar sequences together. + * + * The converter always attempts to consume the entire source buffer, unless + * (1.) the target buffer is full, or (2.) a failing error is returned from the + * current callback function. When a successful error status has been + * returned, it means that all of the source buffer has been + * consumed. At that point, the caller should reset the source and + * sourceLimit pointers to point to the next chunk. + * + * At the end of the stream (flush==TRUE), the input is completely consumed + * when *source==sourceLimit and no error code is set + * The converter object is then automatically reset by this function. + * (This means that a converter need not be reset explicitly between data + * streams if it finishes the previous stream without errors.) + * + * This is a stateful conversion. Additionally, even when all source data has + * been consumed, some data may be in the converters' internal state. + * Call this function repeatedly, updating the target pointers with + * the next empty chunk of target in case of a + * U_BUFFER_OVERFLOW_ERROR, and updating the source pointers + * with the next chunk of source when a successful error status is + * returned, until there are no more chunks of source data. + * @param converter the Unicode converter + * @param target I/O parameter. Input : Points to the beginning of the buffer to copy + * UChars into. Output : points to after the last UChar copied. + * @param targetLimit the pointer just after the end of the target buffer + * @param source I/O parameter, pointer to pointer to the source codepage buffer. + * @param sourceLimit the pointer to the byte after the end of the source buffer + * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number + * of allocated cells as target. Will fill in offsets from target to source pointer + * e.g: offsets[3] is equal to 6, it means that the target[3] was a result of transcoding source[6] + * For output data carried across calls, and other data without a specific source character + * (such as from escape sequences or callbacks) -1 will be placed for offsets. + * @param flush set to TRUE if the current source buffer is the last available + * chunk of the source, FALSE otherwise. Note that if a failing status is returned, + * this function may have to be called multiple times with flush set to TRUE until + * the source buffer is consumed. + * @param err the error status. U_ILLEGAL_ARGUMENT_ERROR will be set if the + * converter is NULL. + * U_BUFFER_OVERFLOW_ERROR will be set if the target is full and there is + * still data to be written to the target. + * @see ucnv_fromUChars + * @see ucnv_convert + * @see ucnv_getMinCharSize + * @see ucnv_setFromUCallBack + * @see ucnv_getNextUChar + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_toUnicode(UConverter *converter, + UChar **target, + const UChar *targetLimit, + const char **source, + const char *sourceLimit, + int32_t *offsets, + UBool flush, + UErrorCode *err); + +/** + * Convert the Unicode string into a codepage string using an existing UConverter. + * The output string is NUL-terminated if possible. + * + * This function is a more convenient but less powerful version of ucnv_fromUnicode(). + * It is only useful for whole strings, not for streaming conversion. + * + * The maximum output buffer capacity required (barring output from callbacks) will be + * UCNV_GET_MAX_BYTES_FOR_STRING(srcLength, ucnv_getMaxCharSize(cnv)). + * + * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called) + * @param src the input Unicode string + * @param srcLength the input string length, or -1 if NUL-terminated + * @param dest destination string buffer, can be NULL if destCapacity==0 + * @param destCapacity the number of chars available at dest + * @param pErrorCode normal ICU error code; + * common error codes that may be set by this function include + * U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING, + * U_ILLEGAL_ARGUMENT_ERROR, and conversion errors + * @return the length of the output string, not counting the terminating NUL; + * if the length is greater than destCapacity, then the string will not fit + * and a buffer of the indicated length would need to be passed in + * @see ucnv_fromUnicode + * @see ucnv_convert + * @see UCNV_GET_MAX_BYTES_FOR_STRING + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +ucnv_fromUChars(UConverter *cnv, + char *dest, int32_t destCapacity, + const UChar *src, int32_t srcLength, + UErrorCode *pErrorCode); + +/** + * Convert the codepage string into a Unicode string using an existing UConverter. + * The output string is NUL-terminated if possible. + * + * This function is a more convenient but less powerful version of ucnv_toUnicode(). + * It is only useful for whole strings, not for streaming conversion. + * + * The maximum output buffer capacity required (barring output from callbacks) will be + * 2*srcLength (each char may be converted into a surrogate pair). + * + * @param cnv the converter object to be used (ucnv_resetToUnicode() will be called) + * @param src the input codepage string + * @param srcLength the input string length, or -1 if NUL-terminated + * @param dest destination string buffer, can be NULL if destCapacity==0 + * @param destCapacity the number of UChars available at dest + * @param pErrorCode normal ICU error code; + * common error codes that may be set by this function include + * U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING, + * U_ILLEGAL_ARGUMENT_ERROR, and conversion errors + * @return the length of the output string, not counting the terminating NUL; + * if the length is greater than destCapacity, then the string will not fit + * and a buffer of the indicated length would need to be passed in + * @see ucnv_toUnicode + * @see ucnv_convert + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +ucnv_toUChars(UConverter *cnv, + UChar *dest, int32_t destCapacity, + const char *src, int32_t srcLength, + UErrorCode *pErrorCode); + +/** + * Convert a codepage buffer into Unicode one character at a time. + * The input is completely consumed when the U_INDEX_OUTOFBOUNDS_ERROR is set. + * + * Advantage compared to ucnv_toUnicode() or ucnv_toUChars(): + * - Faster for small amounts of data, for most converters, e.g., + * US-ASCII, ISO-8859-1, UTF-8/16/32, and most "normal" charsets. + * (For complex converters, e.g., SCSU, UTF-7 and ISO 2022 variants, + * it uses ucnv_toUnicode() internally.) + * - Convenient. + * + * Limitations compared to ucnv_toUnicode(): + * - Always assumes flush=TRUE. + * This makes ucnv_getNextUChar() unsuitable for "streaming" conversion, + * that is, for where the input is supplied in multiple buffers, + * because ucnv_getNextUChar() will assume the end of the input at the end + * of the first buffer. + * - Does not provide offset output. + * + * It is possible to "mix" ucnv_getNextUChar() and ucnv_toUnicode() because + * ucnv_getNextUChar() uses the current state of the converter + * (unlike ucnv_toUChars() which always resets first). + * However, if ucnv_getNextUChar() is called after ucnv_toUnicode() + * stopped in the middle of a character sequence (with flush=FALSE), + * then ucnv_getNextUChar() will always use the slower ucnv_toUnicode() + * internally until the next character boundary. + * (This is new in ICU 2.6. In earlier releases, ucnv_getNextUChar() had to + * start at a character boundary.) + * + * Instead of using ucnv_getNextUChar(), it is recommended + * to convert using ucnv_toUnicode() or ucnv_toUChars() + * and then iterate over the text using U16_NEXT() or a UCharIterator (uiter.h) + * or a C++ CharacterIterator or similar. + * This allows streaming conversion and offset output, for example. + * + *

Handling of surrogate pairs and supplementary-plane code points:
+ * There are two different kinds of codepages that provide mappings for surrogate characters: + *

    + *
  • Codepages like UTF-8, UTF-32, and GB 18030 provide direct representations for Unicode + * code points U+10000-U+10ffff as well as for single surrogates U+d800-U+dfff. + * Each valid sequence will result in exactly one returned code point. + * If a sequence results in a single surrogate, then that will be returned + * by itself, even if a neighboring sequence encodes the matching surrogate.
  • + *
  • Codepages like SCSU and LMBCS (and UTF-16) provide direct representations only for BMP code points + * including surrogates. Code points in supplementary planes are represented with + * two sequences, each encoding a surrogate. + * For these codepages, matching pairs of surrogates will be combined into single + * code points for returning from this function. + * (Note that SCSU is actually a mix of these codepage types.)
  • + *

+ * + * @param converter an open UConverter + * @param source the address of a pointer to the codepage buffer, will be + * updated to point after the bytes consumed in the conversion call. + * @param sourceLimit points to the end of the input buffer + * @param err fills in error status (see ucnv_toUnicode) + * U_INDEX_OUTOFBOUNDS_ERROR will be set if the input + * is empty or does not convert to any output (e.g.: pure state-change + * codes SI/SO, escape sequences for ISO 2022, + * or if the callback did not output anything, ...). + * This function will not set a U_BUFFER_OVERFLOW_ERROR because + * the "buffer" is the return code. However, there might be subsequent output + * stored in the converter object + * that will be returned in following calls to this function. + * @return a UChar32 resulting from the partial conversion of source + * @see ucnv_toUnicode + * @see ucnv_toUChars + * @see ucnv_convert + * @stable ICU 2.0 + */ +U_STABLE UChar32 U_EXPORT2 +ucnv_getNextUChar(UConverter * converter, + const char **source, + const char * sourceLimit, + UErrorCode * err); + +/** + * Convert from one external charset to another using two existing UConverters. + * Internally, two conversions - ucnv_toUnicode() and ucnv_fromUnicode() - + * are used, "pivoting" through 16-bit Unicode. + * + * There is a similar function, ucnv_convert(), + * which has the following limitations: + * - it takes charset names, not converter objects, so that + * - two converters are opened for each call + * - only single-string conversion is possible, not streaming operation + * - it does not provide enough information to find out, + * in case of failure, whether the toUnicode or + * the fromUnicode conversion failed + * + * By contrast, ucnv_convertEx() + * - takes UConverter parameters instead of charset names + * - fully exposes the pivot buffer for complete error handling + * + * ucnv_convertEx() also provides further convenience: + * - an option to reset the converters at the beginning + * (if reset==TRUE, see parameters; + * also sets *pivotTarget=*pivotSource=pivotStart) + * - allow NUL-terminated input + * (only a single NUL byte, will not work for charsets with multi-byte NULs) + * (if sourceLimit==NULL, see parameters) + * - terminate with a NUL on output + * (only a single NUL byte, not useful for charsets with multi-byte NULs), + * or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills + * the target buffer + * - the pivot buffer can be provided internally; + * in this case, the caller will not be able to get details about where an + * error occurred + * (if pivotStart==NULL, see below) + * + * The function returns when one of the following is true: + * - the entire source text has been converted successfully to the target buffer + * - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR) + * - a conversion error occurred + * (other U_FAILURE(), see description of pErrorCode) + * + * Limitation compared to the direct use of + * ucnv_fromUnicode() and ucnv_toUnicode(): + * ucnv_convertEx() does not provide offset information. + * + * Limitation compared to ucnv_fromUChars() and ucnv_toUChars(): + * ucnv_convertEx() does not support preflighting directly. + * + * Sample code for converting a single string from + * one external charset to UTF-8, ignoring the location of errors: + * + * \code + * int32_t + * myToUTF8(UConverter *cnv, + * const char *s, int32_t length, + * char *u8, int32_t capacity, + * UErrorCode *pErrorCode) { + * UConverter *utf8Cnv; + * char *target; + * + * if(U_FAILURE(*pErrorCode)) { + * return 0; + * } + * + * utf8Cnv=myGetCachedUTF8Converter(pErrorCode); + * if(U_FAILURE(*pErrorCode)) { + * return 0; + * } + * + * target=u8; + * ucnv_convertEx(cnv, utf8Cnv, + * &target, u8+capacity, + * &s, length>=0 ? s+length : NULL, + * NULL, NULL, NULL, NULL, + * TRUE, TRUE, + * pErrorCode); + * + * myReleaseCachedUTF8Converter(utf8Cnv); + * + * // return the output string length, but without preflighting + * return (int32_t)(target-u8); + * } + * \endcode + * + * @param targetCnv Output converter, used to convert from the UTF-16 pivot + * to the target using ucnv_fromUnicode(). + * @param sourceCnv Input converter, used to convert from the source to + * the UTF-16 pivot using ucnv_toUnicode(). + * @param target I/O parameter, same as for ucnv_fromUChars(). + * Input: *target points to the beginning of the target buffer. + * Output: *target points to the first unit after the last char written. + * @param targetLimit Pointer to the first unit after the target buffer. + * @param source I/O parameter, same as for ucnv_toUChars(). + * Input: *source points to the beginning of the source buffer. + * Output: *source points to the first unit after the last char read. + * @param sourceLimit Pointer to the first unit after the source buffer. + * @param pivotStart Pointer to the UTF-16 pivot buffer. If pivotStart==NULL, + * then an internal buffer is used and the other pivot + * arguments are ignored and can be NULL as well. + * @param pivotSource I/O parameter, same as source in ucnv_fromUChars() for + * conversion from the pivot buffer to the target buffer. + * @param pivotTarget I/O parameter, same as target in ucnv_toUChars() for + * conversion from the source buffer to the pivot buffer. + * It must be pivotStart<=*pivotSource<=*pivotTarget<=pivotLimit + * and pivotStart[0..ucnv_countAvaiable()]) + * @return a pointer a string (library owned), or NULL if the index is out of bounds. + * @see ucnv_countAvailable + * @stable ICU 2.0 + */ +U_STABLE const char* U_EXPORT2 +ucnv_getAvailableName(int32_t n); + +/** + * Returns a UEnumeration to enumerate all of the canonical converter + * names, as per the alias file, regardless of the ability to open each + * converter. + * + * @return A UEnumeration object for getting all the recognized canonical + * converter names. + * @see ucnv_getAvailableName + * @see uenum_close + * @see uenum_next + * @stable ICU 2.4 + */ +U_STABLE UEnumeration * U_EXPORT2 +ucnv_openAllNames(UErrorCode *pErrorCode); + +/** + * Gives the number of aliases for a given converter or alias name. + * If the alias is ambiguous, then the preferred converter is used + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. + * This method only enumerates the listed entries in the alias file. + * @param alias alias name + * @param pErrorCode error status + * @return number of names on alias list for given alias + * @stable ICU 2.0 + */ +U_STABLE uint16_t U_EXPORT2 +ucnv_countAliases(const char *alias, UErrorCode *pErrorCode); + +/** + * Gives the name of the alias at given index of alias list. + * This method only enumerates the listed entries in the alias file. + * If the alias is ambiguous, then the preferred converter is used + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. + * @param alias alias name + * @param n index in alias list + * @param pErrorCode result of operation + * @return returns the name of the alias at given index + * @see ucnv_countAliases + * @stable ICU 2.0 + */ +U_STABLE const char * U_EXPORT2 +ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode); + +/** + * Fill-up the list of alias names for the given alias. + * This method only enumerates the listed entries in the alias file. + * If the alias is ambiguous, then the preferred converter is used + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. + * @param alias alias name + * @param aliases fill-in list, aliases is a pointer to an array of + * ucnv_countAliases() string-pointers + * (const char *) that will be filled in. + * The strings themselves are owned by the library. + * @param pErrorCode result of operation + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode); + +/** + * Return a new UEnumeration object for enumerating all the + * alias names for a given converter that are recognized by a standard. + * This method only enumerates the listed entries in the alias file. + * The convrtrs.txt file can be modified to change the results of + * this function. + * The first result in this list is the same result given by + * ucnv_getStandardName, which is the default alias for + * the specified standard name. The returned object must be closed with + * uenum_close when you are done with the object. + * + * @param convName original converter name + * @param standard name of the standard governing the names; MIME and IANA + * are such standards + * @param pErrorCode The error code + * @return A UEnumeration object for getting all aliases that are recognized + * by a standard. If any of the parameters are invalid, NULL + * is returned. + * @see ucnv_getStandardName + * @see uenum_close + * @see uenum_next + * @stable ICU 2.2 + */ +U_STABLE UEnumeration * U_EXPORT2 +ucnv_openStandardNames(const char *convName, + const char *standard, + UErrorCode *pErrorCode); + +/** + * Gives the number of standards associated to converter names. + * @return number of standards + * @stable ICU 2.0 + */ +U_STABLE uint16_t U_EXPORT2 +ucnv_countStandards(void); + +/** + * Gives the name of the standard at given index of standard list. + * @param n index in standard list + * @param pErrorCode result of operation + * @return returns the name of the standard at given index. Owned by the library. + * @stable ICU 2.0 + */ +U_STABLE const char * U_EXPORT2 +ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode); + +/** + * Returns a standard name for a given converter name. + *

+ * Example alias table:
+ * conv alias1 { STANDARD1 } alias2 { STANDARD1* } + *

+ * Result of ucnv_getStandardName("conv", "STANDARD1") from example + * alias table:
+ * "alias2" + * + * @param name original converter name + * @param standard name of the standard governing the names; MIME and IANA + * are such standards + * @param pErrorCode result of operation + * @return returns the standard converter name; + * if a standard converter name cannot be determined, + * then NULL is returned. Owned by the library. + * @stable ICU 2.0 + */ +U_STABLE const char * U_EXPORT2 +ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode); + +/** + * This function will return the internal canonical converter name of the + * tagged alias. This is the opposite of ucnv_openStandardNames, which + * returns the tagged alias given the canonical name. + *

+ * Example alias table:
+ * conv alias1 { STANDARD1 } alias2 { STANDARD1* } + *

+ * Result of ucnv_getStandardName("alias1", "STANDARD1") from example + * alias table:
+ * "conv" + * + * @return returns the canonical converter name; + * if a standard or alias name cannot be determined, + * then NULL is returned. The returned string is + * owned by the library. + * @see ucnv_getStandardName + * @stable ICU 2.4 + */ +U_STABLE const char * U_EXPORT2 +ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode); + +/** + * returns the current default converter name. + * + * @return returns the current default converter name; + * if a default converter name cannot be determined, + * then NULL is returned. + * Storage owned by the library + * @see ucnv_setDefaultName + * @stable ICU 2.0 + */ +U_STABLE const char * U_EXPORT2 +ucnv_getDefaultName(void); + +/** + * sets the current default converter name. Caller must own the storage for 'name' + * and preserve it indefinitely. + * @param name the converter name to be the default (must exist). + * @see ucnv_getDefaultName + * @system SYSTEM API + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_setDefaultName(const char *name); + +/** + * Fixes the backslash character mismapping. For example, in SJIS, the backslash + * character in the ASCII portion is also used to represent the yen currency sign. + * When mapping from Unicode character 0x005C, it's unclear whether to map the + * character back to yen or backslash in SJIS. This function will take the input + * buffer and replace all the yen sign characters with backslash. This is necessary + * when the user tries to open a file with the input buffer on Windows. + * This function will test the converter to see whether such mapping is + * required. You can sometimes avoid using this function by using the correct version + * of Shift-JIS. + * + * @param cnv The converter representing the target codepage. + * @param source the input buffer to be fixed + * @param sourceLen the length of the input buffer + * @see ucnv_isAmbiguous + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen); + +/** + * Determines if the converter contains ambiguous mappings of the same + * character or not. + * @param cnv the converter to be tested + * @return TRUE if the converter contains ambiguous mapping of the same + * character, FALSE otherwise. + * @stable ICU 2.0 + */ +U_STABLE UBool U_EXPORT2 +ucnv_isAmbiguous(const UConverter *cnv); + +/** + * Sets the converter to use fallback mapping or not. + * @param cnv The converter to set the fallback mapping usage on. + * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback + * mapping, FALSE otherwise. + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +ucnv_setFallback(UConverter *cnv, UBool usesFallback); + +/** + * Determines if the converter uses fallback mappings or not. + * @param cnv The converter to be tested + * @return TRUE if the converter uses fallback, FALSE otherwise. + * @stable ICU 2.0 + */ +U_STABLE UBool U_EXPORT2 +ucnv_usesFallback(const UConverter *cnv); + +/** + * Detects Unicode signature byte sequences at the start of the byte stream + * and returns the charset name of the indicated Unicode charset. + * NULL is returned when no Unicode signature is recognized. + * The number of bytes in the signature is output as well. + * + * The caller can ucnv_open() a converter using the charset name. + * The first code unit (UChar) from the start of the stream will be U+FEFF + * (the Unicode BOM/signature character) and can usually be ignored. + * + * For most Unicode charsets it is also possible to ignore the indicated + * number of initial stream bytes and start converting after them. + * However, there are stateful Unicode charsets (UTF-7 and BOCU-1) for which + * this will not work. Therefore, it is best to ignore the first output UChar + * instead of the input signature bytes. + *

+ * Usage: + * @code + * UErrorCode err = U_ZERO_ERROR; + * char input[] = { '\xEF','\xBB', '\xBF','\x41','\x42','\x43' }; + * int32_t signatureLength = 0; + * char *encoding = ucnv_detectUnicodeSignatures(input,sizeof(input),&signatureLength,&err); + * UConverter *conv = NULL; + * UChar output[100]; + * UChar *target = output, *out; + * char *source = input; + * if(encoding!=NULL && U_SUCCESS(err)){ + * // should signature be discarded ? + * conv = ucnv_open(encoding, &err); + * // do the conversion + * ucnv_toUnicode(conv, + * target, output + sizeof(output)/U_SIZEOF_UCHAR, + * source, input + sizeof(input), + * NULL, TRUE, &err); + * out = output; + * if (discardSignature){ + * ++out; // ignore initial U+FEFF + * } + * while(out != target) { + * printf("%04x ", *out++); + * } + * puts(""); + * } + * + * @endcode + * + * @param source The source string in which the signature should be detected. + * @param sourceLength Length of the input string, or -1 if terminated with a NUL byte. + * @param signatureLength A pointer to int32_t to receive the number of bytes that make up the signature + * of the detected UTF. 0 if not detected. + * Can be a NULL pointer. + * @param pErrorCode A pointer to receive information about any errors that may occur during detection. + * Must be a valid pointer to an error code value, which must not indicate a failure + * before the function call. + * @return The name of the encoding detected. NULL if encoding is not detected. + * @stable ICU 2.4 + */ +U_STABLE const char* U_EXPORT2 +ucnv_detectUnicodeSignature(const char* source, + int32_t sourceLength, + int32_t *signatureLength, + UErrorCode *pErrorCode); + +#endif + +#endif +/*_UCNV*/ diff --git a/icu/unicode/ucnv_err.h b/icu/unicode/ucnv_err.h new file mode 100644 index 0000000..2a6104c --- /dev/null +++ b/icu/unicode/ucnv_err.h @@ -0,0 +1,456 @@ +/* +********************************************************************** +* Copyright (C) 1999-2004, International Business Machines +* Corporation and others. All Rights Reserved. +********************************************************************** + * + * + * ucnv_err.h: + */ + +/** + * \file + * \brief C UConverter predefined error callbacks + * + *

Error Behaviour Functions

+ * Defines some error behaviour functions called by ucnv_{from,to}Unicode + * These are provided as part of ICU and many are stable, but they + * can also be considered only as an example of what can be done with + * callbacks. You may of course write your own. + * + * If you want to write your own, you may also find the functions from + * ucnv_cb.h useful when writing your own callbacks. + * + * These functions, although public, should NEVER be called directly. + * They should be used as parameters to the ucnv_setFromUCallback + * and ucnv_setToUCallback functions, to set the behaviour of a converter + * when it encounters ILLEGAL/UNMAPPED/INVALID sequences. + * + * usage example: 'STOP' doesn't need any context, but newContext + * could be set to something other than 'NULL' if needed. The available + * contexts in this header can modify the default behavior of the callback. + * + * \code + * UErrorCode err = U_ZERO_ERROR; + * UConverter *myConverter = ucnv_open("ibm-949", &err); + * const void *oldContext; + * UConverterFromUCallback oldAction; + * + * + * if (U_SUCCESS(err)) + * { + * ucnv_setFromUCallBack(myConverter, + * UCNV_FROM_U_CALLBACK_STOP, + * NULL, + * &oldAction, + * &oldContext, + * &status); + * } + * \endcode + * + * The code above tells "myConverter" to stop when it encounters an + * ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from + * Unicode -> Codepage. The behavior from Codepage to Unicode is not changed, + * and ucnv_setToUCallBack would need to be called in order to change + * that behavior too. + * + * Here is an example with a context: + * + * \code + * UErrorCode err = U_ZERO_ERROR; + * UConverter *myConverter = ucnv_open("ibm-949", &err); + * const void *oldContext; + * UConverterFromUCallback oldAction; + * + * + * if (U_SUCCESS(err)) + * { + * ucnv_setToUCallBack(myConverter, + * UCNV_TO_U_CALLBACK_SUBSTITUTE, + * UCNV_SUB_STOP_ON_ILLEGAL, + * &oldAction, + * &oldContext, + * &status); + * } + * \endcode + * + * The code above tells "myConverter" to stop when it encounters an + * ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from + * Codepage -> Unicode. Any unmapped and legal characters will be + * substituted to be the default substitution character. + */ + +#ifndef UCNV_ERR_H +#define UCNV_ERR_H + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_CONVERSION + +/** Forward declaring the UConverter structure. @stable ICU 2.0 */ +struct UConverter; + +/** @stable ICU 2.0 */ +typedef struct UConverter UConverter; + +/** + * FROM_U, TO_U context options for sub callback + * @stable ICU 2.0 + */ +#define UCNV_SUB_STOP_ON_ILLEGAL "i" + +/** + * FROM_U, TO_U context options for skip callback + * @stable ICU 2.0 + */ +#define UCNV_SKIP_STOP_ON_ILLEGAL "i" + +/** + * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (%UXXXX) + * @stable ICU 2.0 + */ +#define UCNV_ESCAPE_ICU NULL +/** + * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to JAVA (\\uXXXX) + * @stable ICU 2.0 + */ +#define UCNV_ESCAPE_JAVA "J" +/** + * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to C (\\uXXXX \\UXXXXXXXX) + * TO_U_CALLBACK_ESCAPE option to escape the character value accoding to C (\\xXXXX) + * @stable ICU 2.0 + */ +#define UCNV_ESCAPE_C "C" +/** + * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Decimal escape (&#DDDD;) + * TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Decimal escape (&#DDDD;) + * @stable ICU 2.0 + */ +#define UCNV_ESCAPE_XML_DEC "D" +/** + * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Hex escape (&#xXXXX;) + * TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Hex escape (&#xXXXX;) + * @stable ICU 2.0 + */ +#define UCNV_ESCAPE_XML_HEX "X" +/** + * FROM_U_CALLBACK_ESCAPE context option to escape teh code unit according to Unicode (U+XXXXX) + * @stable ICU 2.0 + */ +#define UCNV_ESCAPE_UNICODE "U" + +/** + * The process condition code to be used with the callbacks. + * Codes which are greater than UCNV_IRREGULAR should be + * passed on to any chained callbacks. + * @stable ICU 2.0 + */ +typedef enum { + UCNV_UNASSIGNED = 0, /**< The code point is unassigned. + The error code U_INVALID_CHAR_FOUND will be set. */ + UCNV_ILLEGAL = 1, /**< The code point is illegal. For example, + \\x81\\x2E is illegal in SJIS because \\x2E + is not a valid trail byte for the \\x81 + lead byte. + Also, starting with Unicode 3.0.1, non-shortest byte sequences + in UTF-8 (like \\xC1\\xA1 instead of \\x61 for U+0061) + are also illegal, not just irregular. + The error code U_ILLEGAL_CHAR_FOUND will be set. */ + UCNV_IRREGULAR = 2, /**< The codepoint is not a regular sequence in + the encoding. For example, \\xED\\xA0\\x80..\\xED\\xBF\\xBF + are irregular UTF-8 byte sequences for single surrogate + code points. + The error code U_INVALID_CHAR_FOUND will be set. */ + UCNV_RESET = 3, /**< The callback is called with this reason when a + 'reset' has occured. Callback should reset all + state. */ + UCNV_CLOSE = 4, /**< Called when the converter is closed. The + callback should release any allocated memory.*/ + UCNV_CLONE = 5 /**< Called when ucnv_safeClone() is called on the + converter. the pointer available as the + 'context' is an alias to the original converters' + context pointer. If the context must be owned + by the new converter, the callback must clone + the data and call ucnv_setFromUCallback + (or setToUCallback) with the correct pointer. + @stable ICU 2.2 + */ +} UConverterCallbackReason; + + +/** + * The structure for the fromUnicode callback function parameter. + * @stable ICU 2.0 + */ +typedef struct { + uint16_t size; /**< The size of this struct. @stable ICU 2.0 */ + UBool flush; /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0 */ + UConverter *converter; /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */ + const UChar *source; /**< Pointer to the source source buffer. @stable ICU 2.0 */ + const UChar *sourceLimit; /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0 */ + char *target; /**< Pointer to the target buffer. @stable ICU 2.0 */ + const char *targetLimit; /**< Pointer to the limit (end + 1) of target buffer. @stable ICU 2.0 */ + int32_t *offsets; /**< Pointer to the buffer that recieves the offsets. *offset = blah ; offset++;. @stable ICU 2.0 */ +} UConverterFromUnicodeArgs; + + +/** + * The structure for the toUnicode callback function parameter. + * @stable ICU 2.0 + */ +typedef struct { + uint16_t size; /**< The size of this struct @stable ICU 2.0 */ + UBool flush; /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0 */ + UConverter *converter; /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */ + const char *source; /**< Pointer to the source source buffer. @stable ICU 2.0 */ + const char *sourceLimit; /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0 */ + UChar *target; /**< Pointer to the target buffer. @stable ICU 2.0 */ + const UChar *targetLimit; /**< Pointer to the limit (end + 1) of target buffer. @stable ICU 2.0 */ + int32_t *offsets; /**< Pointer to the buffer that recieves the offsets. *offset = blah ; offset++;. @stable ICU 2.0 */ +} UConverterToUnicodeArgs; + + +/** + * DO NOT CALL THIS FUNCTION DIRECTLY! + * This From Unicode callback STOPS at the ILLEGAL_SEQUENCE, + * returning the error code back to the caller immediately. + * + * @param context Pointer to the callback's private data + * @param fromUArgs Information about the conversion in progress + * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. + * @param reason Defines the reason the callback was invoked + * @param err This should always be set to a failure status prior to calling. + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP ( + const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + + + +/** + * DO NOT CALL THIS FUNCTION DIRECTLY! + * This To Unicode callback STOPS at the ILLEGAL_SEQUENCE, + * returning the error code back to the caller immediately. + * + * @param context Pointer to the callback's private data + * @param toUArgs Information about the conversion in progress + * @param codeUnits Points to 'length' bytes of the concerned codepage sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param reason Defines the reason the callback was invoked + * @param err This should always be set to a failure status prior to calling. + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP ( + const void *context, + UConverterToUnicodeArgs *toUArgs, + const char* codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err); + +/** + * DO NOT CALL THIS FUNCTION DIRECTLY! + * This From Unicode callback skips any ILLEGAL_SEQUENCE, or + * skips only UNASSINGED_SEQUENCE depending on the context parameter + * simply ignoring those characters. + * + * @param context The function currently recognizes the callback options: + * UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, + * returning the error code back to the caller immediately. + * NULL: Skips any ILLEGAL_SEQUENCE + * @param fromUArgs Information about the conversion in progress + * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. + * @param reason Defines the reason the callback was invoked + * @param err Return value will be set to success if the callback was handled, + * otherwise this value will be set to a failure status. + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP ( + const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + +/** + * DO NOT CALL THIS FUNCTION DIRECTLY! + * This From Unicode callback will Substitute the ILLEGAL SEQUENCE, or + * UNASSIGNED_SEQUENCE depending on context parameter, with the + * current substitution string for the converter. This is the default + * callback. + * + * @param context The function currently recognizes the callback options: + * UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, + * returning the error code back to the caller immediately. + * NULL: Substitutes any ILLEGAL_SEQUENCE + * @param fromUArgs Information about the conversion in progress + * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. + * @param reason Defines the reason the callback was invoked + * @param err Return value will be set to success if the callback was handled, + * otherwise this value will be set to a failure status. + * @see ucnv_setSubstChars + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE ( + const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + +/** + * DO NOT CALL THIS FUNCTION DIRECTLY! + * This From Unicode callback will Substitute the ILLEGAL SEQUENCE with the + * hexadecimal representation of the illegal codepoints + * + * @param context The function currently recognizes the callback options: + *
    + *
  • UCNV_ESCAPE_ICU: Substitues the ILLEGAL SEQUENCE with the hexadecimal + * representation in the format %UXXXX, e.g. "%uFFFE%u00AC%uC8FE"). + * In the Event the converter doesn't support the characters {%,U}[A-F][0-9], + * it will substitute the illegal sequence with the substitution characters. + * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as + * %UD84D%UDC56
  • + *
  • UCNV_ESCAPE_JAVA: Substitues the ILLEGAL SEQUENCE with the hexadecimal + * representation in the format \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). + * In the Event the converter doesn't support the characters {\,u}[A-F][0-9], + * it will substitute the illegal sequence with the substitution characters. + * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as + * \\uD84D\\uDC56
  • + *
  • UCNV_ESCAPE_C: Substitues the ILLEGAL SEQUENCE with the hexadecimal + * representation in the format \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). + * In the Event the converter doesn't support the characters {\,u,U}[A-F][0-9], + * it will substitute the illegal sequence with the substitution characters. + * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as + * \\U00023456
  • + *
  • UCNV_ESCAPE_XML_DEC: Substitues the ILLEGAL SEQUENCE with the decimal + * representation in the format &#DDDDDDDD;, e.g. "&#65534;&#172;&#51454;"). + * In the Event the converter doesn't support the characters {&,#}[0-9], + * it will substitute the illegal sequence with the substitution characters. + * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as + * &#144470; and Zero padding is ignored.
  • + *
  • UCNV_ESCAPE_XML_HEX:Substitues the ILLEGAL SEQUENCE with the decimal + * representation in the format &#xXXXX, e.g. "&#xFFFE;&#x00AC;&#xC8FE;"). + * In the Event the converter doesn't support the characters {&,#,x}[0-9], + * it will substitute the illegal sequence with the substitution characters. + * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as + * &#x23456;
  • + *
+ * @param fromUArgs Information about the conversion in progress + * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. + * @param reason Defines the reason the callback was invoked + * @param err Return value will be set to success if the callback was handled, + * otherwise this value will be set to a failure status. + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE ( + const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + + +/** + * DO NOT CALL THIS FUNCTION DIRECTLY! + * This To Unicode callback skips any ILLEGAL_SEQUENCE, or + * skips only UNASSINGED_SEQUENCE depending on the context parameter + * simply ignoring those characters. + * + * @param context The function currently recognizes the callback options: + * UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, + * returning the error code back to the caller immediately. + * NULL: Skips any ILLEGAL_SEQUENCE + * @param toUArgs Information about the conversion in progress + * @param codeUnits Points to 'length' bytes of the concerned codepage sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param reason Defines the reason the callback was invoked + * @param err Return value will be set to success if the callback was handled, + * otherwise this value will be set to a failure status. + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP ( + const void *context, + UConverterToUnicodeArgs *toUArgs, + const char* codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err); + +/** + * DO NOT CALL THIS FUNCTION DIRECTLY! + * This To Unicode callback will Substitute the ILLEGAL SEQUENCE,or + * UNASSIGNED_SEQUENCE depending on context parameter, with the + * Unicode substitution character, U+FFFD. + * + * @param context The function currently recognizes the callback options: + * UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, + * returning the error code back to the caller immediately. + * NULL: Substitutes any ILLEGAL_SEQUENCE + * @param toUArgs Information about the conversion in progress + * @param codeUnits Points to 'length' bytes of the concerned codepage sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param reason Defines the reason the callback was invoked + * @param err Return value will be set to success if the callback was handled, + * otherwise this value will be set to a failure status. + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE ( + const void *context, + UConverterToUnicodeArgs *toUArgs, + const char* codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err); + +/** + * DO NOT CALL THIS FUNCTION DIRECTLY! + * This To Unicode callback will Substitute the ILLEGAL SEQUENCE with the + * hexadecimal representation of the illegal bytes + * (in the format %XNN, e.g. "%XFF%X0A%XC8%X03"). + * + * @param context This function currently recognizes the callback options: + * UCNV_ESCAPE_ICU, UCNV_ESCAPE_JAVA, UCNV_ESCAPE_C, UCNV_ESCAPE_XML_DEC, + * UCNV_ESCAPE_XML_HEX and UCNV_ESCAPE_UNICODE. + * @param toUArgs Information about the conversion in progress + * @param codeUnits Points to 'length' bytes of the concerned codepage sequence + * @param length Size (in bytes) of the concerned codepage sequence + * @param reason Defines the reason the callback was invoked + * @param err Return value will be set to success if the callback was handled, + * otherwise this value will be set to a failure status. + * @stable ICU 2.0 + */ + +U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE ( + const void *context, + UConverterToUnicodeArgs *toUArgs, + const char* codeUnits, + int32_t length, + UConverterCallbackReason reason, + UErrorCode * err); + +#endif + +#endif + +/*UCNV_ERR_H*/ diff --git a/icu/unicode/uconfig.h b/icu/unicode/uconfig.h new file mode 100644 index 0000000..997cf68 --- /dev/null +++ b/icu/unicode/uconfig.h @@ -0,0 +1,186 @@ +/* +********************************************************************** +* Copyright (C) 2002-2004, International Business Machines +* Corporation and others. All Rights Reserved. +********************************************************************** +* file name: uconfig.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2002sep19 +* created by: Markus W. Scherer +*/ + +#ifndef __UCONFIG_H__ +#define __UCONFIG_H__ + +/*! + * \file + * \brief Switches for excluding parts of ICU library code modules. + * + * Allows to build partial, smaller libraries for special purposes. + * By default, all modules are built. + * The switches are fairly coarse, controlling large modules. + * Basic services cannot be turned off. + * + * @stable ICU 2.4 + */ + +/** + * \def UCONFIG_ONLY_COLLATION + * This switch turns off modules that are not needed for collation. + * + * It does not turn off legacy conversion because that is necessary + * for ICU to work on EBCDIC platforms (for the default converter). + * If you want "only collation" and do not build for EBCDIC, + * then you can #define UCONFIG_NO_LEGACY_CONVERSION 1 as well. + * + * @stable ICU 2.4 + */ +#ifndef UCONFIG_ONLY_COLLATION +# define UCONFIG_ONLY_COLLATION 0 +#endif + +#if UCONFIG_ONLY_COLLATION + /* common library */ +# define UCONFIG_NO_BREAK_ITERATION 1 +# define UCONFIG_NO_IDNA 1 + + /* i18n library */ +# if UCONFIG_NO_COLLATION +# error Contradictory collation switches in uconfig.h. +# endif +# define UCONFIG_NO_FORMATTING 1 +# define UCONFIG_NO_TRANSLITERATION 1 +# define UCONFIG_NO_REGULAR_EXPRESSIONS 1 +#endif + +/* common library switches -------------------------------------------------- */ + +/** + * \def UCONFIG_NO_CONVERSION + * ICU will not completely build with this switch turned on. + * This switch turns off all converters. + * + * @draft ICU 3.2 + */ +#ifndef UCONFIG_NO_CONVERSION +# define UCONFIG_NO_CONVERSION 0 +#endif + +#if UCONFIG_NO_CONVERSION +# define UCONFIG_NO_LEGACY_CONVERSION 1 +#endif + +/** + * \def UCONFIG_NO_LEGACY_CONVERSION + * This switch turns off all converters except for + * - Unicode charsets (UTF-7/8/16/32, CESU-8, SCSU, BOCU-1) + * - US-ASCII + * - ISO-8859-1 + * + * Turning off legacy conversion is not possible on EBCDIC platforms + * because they need ibm-37 or ibm-1047 default converters. + * + * @stable ICU 2.4 + */ +#ifndef UCONFIG_NO_LEGACY_CONVERSION +# define UCONFIG_NO_LEGACY_CONVERSION 0 +#endif + +/** + * \def UCONFIG_NO_NORMALIZATION + * This switch turns off normalization. + * It implies turning off several other services as well, for example + * collation and IDNA. + * + * @stable ICU 2.6 + */ +#ifndef UCONFIG_NO_NORMALIZATION +# define UCONFIG_NO_NORMALIZATION 0 +#elif UCONFIG_NO_NORMALIZATION + /* common library */ +# define UCONFIG_NO_IDNA 1 + + /* i18n library */ +# if UCONFIG_ONLY_COLLATION +# error Contradictory collation switches in uconfig.h. +# endif +# define UCONFIG_NO_COLLATION 1 +# define UCONFIG_NO_TRANSLITERATION 1 +#endif + +/** + * \def UCONFIG_NO_BREAK_ITERATION + * This switch turns off break iteration. + * + * @stable ICU 2.4 + */ +#ifndef UCONFIG_NO_BREAK_ITERATION +# define UCONFIG_NO_BREAK_ITERATION 0 +#endif + +/** + * \def UCONFIG_NO_IDNA + * This switch turns off IDNA. + * + * @stable ICU 2.6 + */ +#ifndef UCONFIG_NO_IDNA +# define UCONFIG_NO_IDNA 0 +#endif + +/* i18n library switches ---------------------------------------------------- */ + +/** + * \def UCONFIG_NO_COLLATION + * This switch turns off collation and collation-based string search. + * + * @stable ICU 2.4 + */ +#ifndef UCONFIG_NO_COLLATION +# define UCONFIG_NO_COLLATION 0 +#endif + +/** + * \def UCONFIG_NO_FORMATTING + * This switch turns off formatting and calendar/timezone services. + * + * @stable ICU 2.4 + */ +#ifndef UCONFIG_NO_FORMATTING +# define UCONFIG_NO_FORMATTING 0 +#endif + +/** + * \def UCONFIG_NO_TRANSLITERATION + * This switch turns off transliteration. + * + * @stable ICU 2.4 + */ +#ifndef UCONFIG_NO_TRANSLITERATION +# define UCONFIG_NO_TRANSLITERATION 0 +#endif + +/** + * \def UCONFIG_NO_REGULAR_EXPRESSIONS + * This switch turns off regular expressions. + * + * @stable ICU 2.4 + */ +#ifndef UCONFIG_NO_REGULAR_EXPRESSIONS +# define UCONFIG_NO_REGULAR_EXPRESSIONS 0 +#endif + +/** + * \def UCONFIG_NO_SERVICE + * This switch turns off service registration. + * + * @draft ICU 3.2 + */ +#ifndef UCONFIG_NO_SERVICE +# define UCONFIG_NO_SERVICE 0 +#endif + +#endif diff --git a/icu/unicode/uenum.h b/icu/unicode/uenum.h new file mode 100644 index 0000000..63690f8 --- /dev/null +++ b/icu/unicode/uenum.h @@ -0,0 +1,129 @@ +/* +******************************************************************************* +* +* Copyright (C) 2002-2004, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: uenum.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:2 +* +* created on: 2002jul08 +* created by: Vladimir Weinstein +*/ + +#ifndef __UENUM_H +#define __UENUM_H + +#include "unicode/utypes.h" + +/** + * An enumeration object. + * For usage in C programs. + * @stable ICU 2.2 + */ +struct UEnumeration; +/** structure representing an enumeration object instance @stable ICU 2.2 */ +typedef struct UEnumeration UEnumeration; + +/** + * Disposes of resources in use by the iterator. If en is NULL, + * does nothing. After this call, any char* or UChar* pointer + * returned by uenum_unext() or uenum_next() is invalid. + * @param en UEnumeration structure pointer + * @stable ICU 2.2 + */ +U_STABLE void U_EXPORT2 +uenum_close(UEnumeration* en); + +/** + * Returns the number of elements that the iterator traverses. If + * the iterator is out-of-sync with its service, status is set to + * U_ENUM_OUT_OF_SYNC_ERROR. + * This is a convenience function. It can end up being very + * expensive as all the items might have to be pre-fetched (depending + * on the type of data being traversed). Use with caution and only + * when necessary. + * @param en UEnumeration structure pointer + * @param status error code, can be U_ENUM_OUT_OF_SYNC_ERROR if the + * iterator is out of sync. + * @return number of elements in the iterator + * @stable ICU 2.2 + */ +U_STABLE int32_t U_EXPORT2 +uenum_count(UEnumeration* en, UErrorCode* status); + +/** + * Returns the next element in the iterator's list. If there are + * no more elements, returns NULL. If the iterator is out-of-sync + * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and + * NULL is returned. If the native service string is a char* string, + * it is converted to UChar* with the invariant converter. + * The result is terminated by (UChar)0. + * @param en the iterator object + * @param resultLength pointer to receive the length of the result + * (not including the terminating \\0). + * If the pointer is NULL it is ignored. + * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if + * the iterator is out of sync with its service. + * @return a pointer to the string. The string will be + * zero-terminated. The return pointer is owned by this iterator + * and must not be deleted by the caller. The pointer is valid + * until the next call to any uenum_... method, including + * uenum_next() or uenum_unext(). When all strings have been + * traversed, returns NULL. + * @stable ICU 2.2 + */ +U_STABLE const UChar* U_EXPORT2 +uenum_unext(UEnumeration* en, + int32_t* resultLength, + UErrorCode* status); + +/** + * Returns the next element in the iterator's list. If there are + * no more elements, returns NULL. If the iterator is out-of-sync + * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and + * NULL is returned. If the native service string is a UChar* + * string, it is converted to char* with the invariant converter. + * The result is terminated by (char)0. If the conversion fails + * (because a character cannot be converted) then status is set to + * U_INVARIANT_CONVERSION_ERROR and the return value is undefined + * (but non-NULL). + * @param en the iterator object + * @param resultLength pointer to receive the length of the result + * (not including the terminating \\0). + * If the pointer is NULL it is ignored. + * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if + * the iterator is out of sync with its service. Set to + * U_INVARIANT_CONVERSION_ERROR if the underlying native string is + * UChar* and conversion to char* with the invariant converter + * fails. This error pertains only to current string, so iteration + * might be able to continue successfully. + * @return a pointer to the string. The string will be + * zero-terminated. The return pointer is owned by this iterator + * and must not be deleted by the caller. The pointer is valid + * until the next call to any uenum_... method, including + * uenum_next() or uenum_unext(). When all strings have been + * traversed, returns NULL. + * @stable ICU 2.2 + */ +U_STABLE const char* U_EXPORT2 +uenum_next(UEnumeration* en, + int32_t* resultLength, + UErrorCode* status); + +/** + * Resets the iterator to the current list of service IDs. This + * re-establishes sync with the service and rewinds the iterator + * to start at the first element. + * @param en the iterator object + * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if + * the iterator is out of sync with its service. + * @stable ICU 2.2 + */ +U_STABLE void U_EXPORT2 +uenum_reset(UEnumeration* en, UErrorCode* status); + +#endif diff --git a/icu/unicode/uiter.h b/icu/unicode/uiter.h new file mode 100644 index 0000000..963df5c --- /dev/null +++ b/icu/unicode/uiter.h @@ -0,0 +1,707 @@ +/* +******************************************************************************* +* +* Copyright (C) 2002-2004, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: uiter.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2002jan18 +* created by: Markus W. Scherer +*/ + +#ifndef __UITER_H__ +#define __UITER_H__ + +/** + * \file + * \brief C API: Unicode Character Iteration + * + * @see UCharIterator + */ + +#include "unicode/utypes.h" + +#ifdef XP_CPLUSPLUS + U_NAMESPACE_BEGIN + + class CharacterIterator; + class Replaceable; + + U_NAMESPACE_END +#endif + +U_CDECL_BEGIN + +struct UCharIterator; +typedef struct UCharIterator UCharIterator; /**< C typedef for struct UCharIterator. @stable ICU 2.1 */ + +/** + * Origin constants for UCharIterator.getIndex() and UCharIterator.move(). + * @see UCharIteratorMove + * @see UCharIterator + * @stable ICU 2.1 + */ +typedef enum UCharIteratorOrigin { + UITER_START, UITER_CURRENT, UITER_LIMIT, UITER_ZERO, UITER_LENGTH +} UCharIteratorOrigin; + +/** Constants for UCharIterator. @stable ICU 2.6 */ +enum { + /** + * Constant value that may be returned by UCharIteratorMove + * indicating that the final UTF-16 index is not known, but that the move succeeded. + * This can occur when moving relative to limit or length, or + * when moving relative to the current index after a setState() + * when the current UTF-16 index is not known. + * + * It would be very inefficient to have to count from the beginning of the text + * just to get the current/limit/length index after moving relative to it. + * The actual index can be determined with getIndex(UITER_CURRENT) + * which will count the UChars if necessary. + * + * @stable ICU 2.6 + */ + UITER_UNKNOWN_INDEX=-2 +}; + + +/** + * Constant for UCharIterator getState() indicating an error or + * an unknown state. + * Returned by uiter_getState()/UCharIteratorGetState + * when an error occurs. + * Also, some UCharIterator implementations may not be able to return + * a valid state for each position. This will be clearly documented + * for each such iterator (none of the public ones here). + * + * @stable ICU 2.6 + */ +#define UITER_NO_STATE ((uint32_t)0xffffffff) + +/** + * Function type declaration for UCharIterator.getIndex(). + * + * Gets the current position, or the start or limit of the + * iteration range. + * + * This function may perform slowly for UITER_CURRENT after setState() was called, + * or for UITER_LENGTH, because an iterator implementation may have to count + * UChars if the underlying storage is not UTF-16. + * + * @param iter the UCharIterator structure ("this pointer") + * @param origin get the 0, start, limit, length, or current index + * @return the requested index, or U_SENTINEL in an error condition + * + * @see UCharIteratorOrigin + * @see UCharIterator + * @stable ICU 2.1 + */ +typedef int32_t U_CALLCONV +UCharIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin); + +/** + * Function type declaration for UCharIterator.move(). + * + * Use iter->move(iter, index, UITER_ZERO) like CharacterIterator::setIndex(index). + * + * Moves the current position relative to the start or limit of the + * iteration range, or relative to the current position itself. + * The movement is expressed in numbers of code units forward + * or backward by specifying a positive or negative delta. + * Out of bounds movement will be pinned to the start or limit. + * + * This function may perform slowly for moving relative to UITER_LENGTH + * because an iterator implementation may have to count the rest of the + * UChars if the native storage is not UTF-16. + * + * When moving relative to the limit or length, or + * relative to the current position after setState() was called, + * move() may return UITER_UNKNOWN_INDEX (-2) to avoid an inefficient + * determination of the actual UTF-16 index. + * The actual index can be determined with getIndex(UITER_CURRENT) + * which will count the UChars if necessary. + * See UITER_UNKNOWN_INDEX for details. + * + * @param iter the UCharIterator structure ("this pointer") + * @param delta can be positive, zero, or negative + * @param origin move relative to the 0, start, limit, length, or current index + * @return the new index, or U_SENTINEL on an error condition, + * or UITER_UNKNOWN_INDEX when the index is not known. + * + * @see UCharIteratorOrigin + * @see UCharIterator + * @see UITER_UNKNOWN_INDEX + * @stable ICU 2.1 + */ +typedef int32_t U_CALLCONV +UCharIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin); + +/** + * Function type declaration for UCharIterator.hasNext(). + * + * Check if current() and next() can still + * return another code unit. + * + * @param iter the UCharIterator structure ("this pointer") + * @return boolean value for whether current() and next() can still return another code unit + * + * @see UCharIterator + * @stable ICU 2.1 + */ +typedef UBool U_CALLCONV +UCharIteratorHasNext(UCharIterator *iter); + +/** + * Function type declaration for UCharIterator.hasPrevious(). + * + * Check if previous() can still return another code unit. + * + * @param iter the UCharIterator structure ("this pointer") + * @return boolean value for whether previous() can still return another code unit + * + * @see UCharIterator + * @stable ICU 2.1 + */ +typedef UBool U_CALLCONV +UCharIteratorHasPrevious(UCharIterator *iter); + +/** + * Function type declaration for UCharIterator.current(). + * + * Return the code unit at the current position, + * or U_SENTINEL if there is none (index is at the limit). + * + * @param iter the UCharIterator structure ("this pointer") + * @return the current code unit + * + * @see UCharIterator + * @stable ICU 2.1 + */ +typedef UChar32 U_CALLCONV +UCharIteratorCurrent(UCharIterator *iter); + +/** + * Function type declaration for UCharIterator.next(). + * + * Return the code unit at the current index and increment + * the index (post-increment, like s[i++]), + * or return U_SENTINEL if there is none (index is at the limit). + * + * @param iter the UCharIterator structure ("this pointer") + * @return the current code unit (and post-increment the current index) + * + * @see UCharIterator + * @stable ICU 2.1 + */ +typedef UChar32 U_CALLCONV +UCharIteratorNext(UCharIterator *iter); + +/** + * Function type declaration for UCharIterator.previous(). + * + * Decrement the index and return the code unit from there + * (pre-decrement, like s[--i]), + * or return U_SENTINEL if there is none (index is at the start). + * + * @param iter the UCharIterator structure ("this pointer") + * @return the previous code unit (after pre-decrementing the current index) + * + * @see UCharIterator + * @stable ICU 2.1 + */ +typedef UChar32 U_CALLCONV +UCharIteratorPrevious(UCharIterator *iter); + +/** + * Function type declaration for UCharIterator.reservedFn(). + * Reserved for future use. + * + * @param iter the UCharIterator structure ("this pointer") + * @param something some integer argument + * @return some integer + * + * @see UCharIterator + * @stable ICU 2.1 + */ +typedef int32_t U_CALLCONV +UCharIteratorReserved(UCharIterator *iter, int32_t something); + +/** + * Function type declaration for UCharIterator.getState(). + * + * Get the "state" of the iterator in the form of a single 32-bit word. + * It is recommended that the state value be calculated to be as small as + * is feasible. For strings with limited lengths, fewer than 32 bits may + * be sufficient. + * + * This is used together with setState()/UCharIteratorSetState + * to save and restore the iterator position more efficiently than with + * getIndex()/move(). + * + * The iterator state is defined as a uint32_t value because it is designed + * for use in ucol_nextSortKeyPart() which provides 32 bits to store the state + * of the character iterator. + * + * With some UCharIterator implementations (e.g., UTF-8), + * getting and setting the UTF-16 index with existing functions + * (getIndex(UITER_CURRENT) followed by move(pos, UITER_ZERO)) is possible but + * relatively slow because the iterator has to "walk" from a known index + * to the requested one. + * This takes more time the farther it needs to go. + * + * An opaque state value allows an iterator implementation to provide + * an internal index (UTF-8: the source byte array index) for + * fast, constant-time restoration. + * + * After calling setState(), a getIndex(UITER_CURRENT) may be slow because + * the UTF-16 index may not be restored as well, but the iterator can deliver + * the correct text contents and move relative to the current position + * without performance degradation. + * + * Some UCharIterator implementations may not be able to return + * a valid state for each position, in which case they return UITER_NO_STATE instead. + * This will be clearly documented for each such iterator (none of the public ones here). + * + * @param iter the UCharIterator structure ("this pointer") + * @return the state word + * + * @see UCharIterator + * @see UCharIteratorSetState + * @see UITER_NO_STATE + * @stable ICU 2.6 + */ +typedef uint32_t U_CALLCONV +UCharIteratorGetState(const UCharIterator *iter); + +/** + * Function type declaration for UCharIterator.setState(). + * + * Restore the "state" of the iterator using a state word from a getState() call. + * The iterator object need not be the same one as for which getState() was called, + * but it must be of the same type (set up using the same uiter_setXYZ function) + * and it must iterate over the same string + * (binary identical regardless of memory address). + * For more about the state word see UCharIteratorGetState. + * + * After calling setState(), a getIndex(UITER_CURRENT) may be slow because + * the UTF-16 index may not be restored as well, but the iterator can deliver + * the correct text contents and move relative to the current position + * without performance degradation. + * + * @param iter the UCharIterator structure ("this pointer") + * @param state the state word from a getState() call + * on a same-type, same-string iterator + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * + * @see UCharIterator + * @see UCharIteratorGetState + * @stable ICU 2.6 + */ +typedef void U_CALLCONV +UCharIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode); + + +/** + * C API for code unit iteration. + * This can be used as a C wrapper around + * CharacterIterator, Replaceable, or implemented using simple strings, etc. + * + * There are two roles for using UCharIterator: + * + * A "provider" sets the necessary function pointers and controls the "protected" + * fields of the UCharIterator structure. A "provider" passes a UCharIterator + * into C APIs that need a UCharIterator as an abstract, flexible string interface. + * + * Implementations of such C APIs are "callers" of UCharIterator functions; + * they only use the "public" function pointers and never access the "protected" + * fields directly. + * + * The current() and next() functions only check the current index against the + * limit, and previous() only checks the current index against the start, + * to see if the iterator already reached the end of the iteration range. + * + * The assumption - in all iterators - is that the index is moved via the API, + * which means it won't go out of bounds, or the index is modified by + * user code that knows enough about the iterator implementation to set valid + * index values. + * + * UCharIterator functions return code unit values 0..0xffff, + * or U_SENTINEL if the iteration bounds are reached. + * + * @stable ICU 2.1 + */ +struct UCharIterator { + /** + * (protected) Pointer to string or wrapped object or similar. + * Not used by caller. + * @stable ICU 2.1 + */ + const void *context; + + /** + * (protected) Length of string or similar. + * Not used by caller. + * @stable ICU 2.1 + */ + int32_t length; + + /** + * (protected) Start index or similar. + * Not used by caller. + * @stable ICU 2.1 + */ + int32_t start; + + /** + * (protected) Current index or similar. + * Not used by caller. + * @stable ICU 2.1 + */ + int32_t index; + + /** + * (protected) Limit index or similar. + * Not used by caller. + * @stable ICU 2.1 + */ + int32_t limit; + + /** + * (protected) Used by UTF-8 iterators and possibly others. + * @stable ICU 2.1 + */ + int32_t reservedField; + + /** + * (public) Returns the current position or the + * start or limit index of the iteration range. + * + * @see UCharIteratorGetIndex + * @stable ICU 2.1 + */ + UCharIteratorGetIndex *getIndex; + + /** + * (public) Moves the current position relative to the start or limit of the + * iteration range, or relative to the current position itself. + * The movement is expressed in numbers of code units forward + * or backward by specifying a positive or negative delta. + * + * @see UCharIteratorMove + * @stable ICU 2.1 + */ + UCharIteratorMove *move; + + /** + * (public) Check if current() and next() can still + * return another code unit. + * + * @see UCharIteratorHasNext + * @stable ICU 2.1 + */ + UCharIteratorHasNext *hasNext; + + /** + * (public) Check if previous() can still return another code unit. + * + * @see UCharIteratorHasPrevious + * @stable ICU 2.1 + */ + UCharIteratorHasPrevious *hasPrevious; + + /** + * (public) Return the code unit at the current position, + * or U_SENTINEL if there is none (index is at the limit). + * + * @see UCharIteratorCurrent + * @stable ICU 2.1 + */ + UCharIteratorCurrent *current; + + /** + * (public) Return the code unit at the current index and increment + * the index (post-increment, like s[i++]), + * or return U_SENTINEL if there is none (index is at the limit). + * + * @see UCharIteratorNext + * @stable ICU 2.1 + */ + UCharIteratorNext *next; + + /** + * (public) Decrement the index and return the code unit from there + * (pre-decrement, like s[--i]), + * or return U_SENTINEL if there is none (index is at the start). + * + * @see UCharIteratorPrevious + * @stable ICU 2.1 + */ + UCharIteratorPrevious *previous; + + /** + * (public) Reserved for future use. Currently NULL. + * + * @see UCharIteratorReserved + * @stable ICU 2.1 + */ + UCharIteratorReserved *reservedFn; + + /** + * (public) Return the state of the iterator, to be restored later with setState(). + * This function pointer is NULL if the iterator does not implement it. + * + * @see UCharIteratorGet + * @stable ICU 2.6 + */ + UCharIteratorGetState *getState; + + /** + * (public) Restore the iterator state from the state word from a call + * to getState(). + * This function pointer is NULL if the iterator does not implement it. + * + * @see UCharIteratorSet + * @stable ICU 2.6 + */ + UCharIteratorSetState *setState; +}; + +/** + * Helper function for UCharIterator to get the code point + * at the current index. + * + * Return the code point that includes the code unit at the current position, + * or U_SENTINEL if there is none (index is at the limit). + * If the current code unit is a lead or trail surrogate, + * then the following or preceding surrogate is used to form + * the code point value. + * + * @param iter the UCharIterator structure ("this pointer") + * @return the current code point + * + * @see UCharIterator + * @see U16_GET + * @see UnicodeString::char32At() + * @stable ICU 2.1 + */ +U_STABLE UChar32 U_EXPORT2 +uiter_current32(UCharIterator *iter); + +/** + * Helper function for UCharIterator to get the next code point. + * + * Return the code point at the current index and increment + * the index (post-increment, like s[i++]), + * or return U_SENTINEL if there is none (index is at the limit). + * + * @param iter the UCharIterator structure ("this pointer") + * @return the current code point (and post-increment the current index) + * + * @see UCharIterator + * @see U16_NEXT + * @stable ICU 2.1 + */ +U_STABLE UChar32 U_EXPORT2 +uiter_next32(UCharIterator *iter); + +/** + * Helper function for UCharIterator to get the previous code point. + * + * Decrement the index and return the code point from there + * (pre-decrement, like s[--i]), + * or return U_SENTINEL if there is none (index is at the start). + * + * @param iter the UCharIterator structure ("this pointer") + * @return the previous code point (after pre-decrementing the current index) + * + * @see UCharIterator + * @see U16_PREV + * @stable ICU 2.1 + */ +U_STABLE UChar32 U_EXPORT2 +uiter_previous32(UCharIterator *iter); + +/** + * Get the "state" of the iterator in the form of a single 32-bit word. + * This is a convenience function that calls iter->getState(iter) + * if iter->getState is not NULL; + * if it is NULL or any other error occurs, then UITER_NO_STATE is returned. + * + * Some UCharIterator implementations may not be able to return + * a valid state for each position, in which case they return UITER_NO_STATE instead. + * This will be clearly documented for each such iterator (none of the public ones here). + * + * @param iter the UCharIterator structure ("this pointer") + * @return the state word + * + * @see UCharIterator + * @see UCharIteratorGetState + * @see UITER_NO_STATE + * @stable ICU 2.6 + */ +U_STABLE uint32_t U_EXPORT2 +uiter_getState(const UCharIterator *iter); + +/** + * Restore the "state" of the iterator using a state word from a getState() call. + * This is a convenience function that calls iter->setState(iter, state, pErrorCode) + * if iter->setState is not NULL; if it is NULL, then U_UNSUPPORTED_ERROR is set. + * + * @param iter the UCharIterator structure ("this pointer") + * @param state the state word from a getState() call + * on a same-type, same-string iterator + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * + * @see UCharIterator + * @see UCharIteratorSetState + * @stable ICU 2.6 + */ +U_STABLE void U_EXPORT2 +uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode); + +/** + * Set up a UCharIterator to iterate over a string. + * + * Sets the UCharIterator function pointers for iteration over the string s + * with iteration boundaries start=index=0 and length=limit=string length. + * The "provider" may set the start, index, and limit values at any time + * within the range 0..length. + * The length field will be ignored. + * + * The string pointer s is set into UCharIterator.context without copying + * or reallocating the string contents. + * + * getState() simply returns the current index. + * move() will always return the final index. + * + * @param iter UCharIterator structure to be set for iteration + * @param s String to iterate over + * @param length Length of s, or -1 if NUL-terminated + * + * @see UCharIterator + * @stable ICU 2.1 + */ +U_STABLE void U_EXPORT2 +uiter_setString(UCharIterator *iter, const UChar *s, int32_t length); + +/** + * Set up a UCharIterator to iterate over a UTF-16BE string + * (byte vector with a big-endian pair of bytes per UChar). + * + * Everything works just like with a normal UChar iterator (uiter_setString), + * except that UChars are assembled from byte pairs, + * and that the length argument here indicates an even number of bytes. + * + * getState() simply returns the current index. + * move() will always return the final index. + * + * @param iter UCharIterator structure to be set for iteration + * @param s UTF-16BE string to iterate over + * @param length Length of s as an even number of bytes, or -1 if NUL-terminated + * (NUL means pair of 0 bytes at even index from s) + * + * @see UCharIterator + * @see uiter_setString + * @stable ICU 2.6 + */ +U_STABLE void U_EXPORT2 +uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length); + +/** + * Set up a UCharIterator to iterate over a UTF-8 string. + * + * Sets the UCharIterator function pointers for iteration over the UTF-8 string s + * with UTF-8 iteration boundaries 0 and length. + * The implementation counts the UTF-16 index on the fly and + * lazily evaluates the UTF-16 length of the text. + * + * The start field is used as the UTF-8 offset, the limit field as the UTF-8 length. + * When the reservedField is not 0, then it contains a supplementary code point + * and the UTF-16 index is between the two corresponding surrogates. + * At that point, the UTF-8 index is behind that code point. + * + * The UTF-8 string pointer s is set into UCharIterator.context without copying + * or reallocating the string contents. + * + * getState() returns a state value consisting of + * - the current UTF-8 source byte index (bits 31..1) + * - a flag (bit 0) that indicates whether the UChar position is in the middle + * of a surrogate pair + * (from a 4-byte UTF-8 sequence for the corresponding supplementary code point) + * + * getState() cannot also encode the UTF-16 index in the state value. + * move(relative to limit or length), or + * move(relative to current) after setState(), may return UITER_UNKNOWN_INDEX. + * + * @param iter UCharIterator structure to be set for iteration + * @param s UTF-8 string to iterate over + * @param length Length of s in bytes, or -1 if NUL-terminated + * + * @see UCharIterator + * @stable ICU 2.6 + */ +U_STABLE void U_EXPORT2 +uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length); + +#ifdef XP_CPLUSPLUS + +/** + * Set up a UCharIterator to wrap around a C++ CharacterIterator. + * + * Sets the UCharIterator function pointers for iteration using the + * CharacterIterator charIter. + * + * The CharacterIterator pointer charIter is set into UCharIterator.context + * without copying or cloning the CharacterIterator object. + * The other "protected" UCharIterator fields are set to 0 and will be ignored. + * The iteration index and boundaries are controlled by the CharacterIterator. + * + * getState() simply returns the current index. + * move() will always return the final index. + * + * @param iter UCharIterator structure to be set for iteration + * @param charIter CharacterIterator to wrap + * + * @see UCharIterator + * @stable ICU 2.1 + */ +U_STABLE void U_EXPORT2 +uiter_setCharacterIterator(UCharIterator *iter, CharacterIterator *charIter); + +/** + * Set up a UCharIterator to iterate over a C++ Replaceable. + * + * Sets the UCharIterator function pointers for iteration over the + * Replaceable rep with iteration boundaries start=index=0 and + * length=limit=rep->length(). + * The "provider" may set the start, index, and limit values at any time + * within the range 0..length=rep->length(). + * The length field will be ignored. + * + * The Replaceable pointer rep is set into UCharIterator.context without copying + * or cloning/reallocating the Replaceable object. + * + * getState() simply returns the current index. + * move() will always return the final index. + * + * @param iter UCharIterator structure to be set for iteration + * @param rep Replaceable to iterate over + * + * @see UCharIterator + * @stable ICU 2.1 + */ +U_STABLE void U_EXPORT2 +uiter_setReplaceable(UCharIterator *iter, const Replaceable *rep); + +#endif + +U_CDECL_END + +#endif diff --git a/icu/unicode/umachine.h b/icu/unicode/umachine.h new file mode 100644 index 0000000..d841f53 --- /dev/null +++ b/icu/unicode/umachine.h @@ -0,0 +1,371 @@ +/* +****************************************************************************** +* +* Copyright (C) 1999-2004, International Business Machines +* Corporation and others. All Rights Reserved. +* +****************************************************************************** +* file name: umachine.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 1999sep13 +* created by: Markus W. Scherer +* +* This file defines basic types and constants for utf.h to be +* platform-independent. umachine.h and utf.h are included into +* utypes.h to provide all the general definitions for ICU. +* All of these definitions used to be in utypes.h before +* the UTF-handling macros made this unmaintainable. +*/ + +#ifndef __UMACHINE_H__ +#define __UMACHINE_H__ + + +/** + * \file + * \brief Basic types and constants for UTF + * + *

Basic types and constants for UTF

+ * This file defines basic types and constants for utf.h to be + * platform-independent. umachine.h and utf.h are included into + * utypes.h to provide all the general definitions for ICU. + * All of these definitions used to be in utypes.h before + * the UTF-handling macros made this unmaintainable. + * + */ +/*==========================================================================*/ +/* Include platform-dependent definitions */ +/* which are contained in the platform-specific file platform.h */ +/*==========================================================================*/ + +#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +# include "unicode/pwin32.h" +#else +# include "unicode/platform.h" +#endif + +/* + * ANSI C headers: + * stddef.h defines wchar_t + */ +#include + +/*==========================================================================*/ +/* XP_CPLUSPLUS is a cross-platform symbol which should be defined when */ +/* using C++. It should not be defined when compiling under C. */ +/*==========================================================================*/ + +#ifdef __cplusplus +# ifndef XP_CPLUSPLUS +# define XP_CPLUSPLUS +# endif +#else +# undef XP_CPLUSPLUS +#endif + +/*==========================================================================*/ +/* For C wrappers, we use the symbol U_STABLE. */ +/* This works properly if the includer is C or C++. */ +/* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */ +/*==========================================================================*/ + +/** + * \def U_CFUNC + * This is used in a declaration of a library private ICU C function. + * @stable ICU 2.4 + */ + +/** + * \def U_CDECL_BEGIN + * This is used to begin a declaration of a library private ICU C API. + * @stable ICU 2.4 + */ + +/** + * \def U_CDECL_END + * This is used to end a declaration of a library private ICU C API + * @stable ICU 2.4 + */ + +#ifdef XP_CPLUSPLUS +# define U_CFUNC extern "C" +# define U_CDECL_BEGIN extern "C" { +# define U_CDECL_END } +#else +# define U_CFUNC extern +# define U_CDECL_BEGIN +# define U_CDECL_END +#endif + +/** + * \def U_NAMESPACE_BEGIN + * This is used to begin a declaration of a public ICU C++ API. + * If the compiler doesn't support namespaces, this does nothing. + * @stable ICU 2.4 + */ + +/** + * \def U_NAMESPACE_END + * This is used to end a declaration of a public ICU C++ API + * If the compiler doesn't support namespaces, this does nothing. + * @stable ICU 2.4 + */ + +/** + * \def U_NAMESPACE_USE + * This is used to specify that the rest of the code uses the + * public ICU C++ API namespace. + * If the compiler doesn't support namespaces, this does nothing. + * @stable ICU 2.4 + */ + +/** + * \def U_NAMESPACE_QUALIFIER + * This is used to qualify that a function or class is part of + * the public ICU C++ API namespace. + * If the compiler doesn't support namespaces, this does nothing. + * @stable ICU 2.4 + */ + +/* Define namespace symbols if the compiler supports it. */ +#if U_HAVE_NAMESPACE +# define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE { +# define U_NAMESPACE_END } +# define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE; +# define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE:: +#else +# define U_NAMESPACE_BEGIN +# define U_NAMESPACE_END +# define U_NAMESPACE_USE +# define U_NAMESPACE_QUALIFIER +#endif + +/** This is used to declare a function as a public ICU C API @stable ICU 2.0*/ +#define U_CAPI U_CFUNC U_EXPORT +#define U_STABLE U_CAPI +#define U_DRAFT U_CAPI +#define U_DEPRECATED U_CAPI +#define U_OBSOLETE U_CAPI +#define U_INTERNAL U_CAPI + +/*==========================================================================*/ +/* limits for int32_t etc., like in POSIX inttypes.h */ +/*==========================================================================*/ + +#ifndef INT8_MIN +/** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */ +# define INT8_MIN ((int8_t)(-128)) +#endif +#ifndef INT16_MIN +/** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */ +# define INT16_MIN ((int16_t)(-32767-1)) +#endif +#ifndef INT32_MIN +/** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */ +# define INT32_MIN ((int32_t)(-2147483647-1)) +#endif + +#ifndef INT8_MAX +/** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */ +# define INT8_MAX ((int8_t)(127)) +#endif +#ifndef INT16_MAX +/** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */ +# define INT16_MAX ((int16_t)(32767)) +#endif +#ifndef INT32_MAX +/** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */ +# define INT32_MAX ((int32_t)(2147483647)) +#endif + +#ifndef UINT8_MAX +/** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */ +# define UINT8_MAX ((uint8_t)(255U)) +#endif +#ifndef UINT16_MAX +/** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */ +# define UINT16_MAX ((uint16_t)(65535U)) +#endif +#ifndef UINT32_MAX +/** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */ +# define UINT32_MAX ((uint32_t)(4294967295U)) +#endif + +#if defined(U_INT64_T_UNAVAILABLE) +# error int64_t is required for decimal format and rule-based number format. +#else +# ifndef INT64_C +/** + * Provides a platform independent way to specify a signed 64-bit integer constant. + * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C + * @draft ICU 2.8 + */ +# define INT64_C(c) c ## LL +# endif +# ifndef UINT64_C +/** + * Provides a platform independent way to specify an unsigned 64-bit integer constant. + * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C + * @draft ICU 2.8 + */ +# define UINT64_C(c) c ## ULL +# endif +# ifndef U_INT64_MIN +/** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */ +# define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1)) +# endif +# ifndef U_INT64_MAX +/** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */ +# define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807))) +# endif +# ifndef U_UINT64_MAX +/** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */ +# define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615))) +# endif +#endif + +/*==========================================================================*/ +/* Boolean data type */ +/*==========================================================================*/ + +/** The ICU boolean type @stable ICU 2.0 */ +typedef int8_t UBool; + +#ifndef TRUE +/** The TRUE value of a UBool @stable ICU 2.0 */ +# define TRUE 1 +#endif +#ifndef FALSE +/** The FALSE value of a UBool @stable ICU 2.0 */ +# define FALSE 0 +#endif + + +/*==========================================================================*/ +/* Unicode data types */ +/*==========================================================================*/ + +/* wchar_t-related definitions -------------------------------------------- */ + +/** + * \def U_HAVE_WCHAR_H + * Indicates whether is available (1) or not (0). Set to 1 by default. + * + * @stable ICU 2.0 + */ +#ifndef U_HAVE_WCHAR_H +# define U_HAVE_WCHAR_H 1 +#endif + +/** + * \def U_SIZEOF_WCHAR_T + * U_SIZEOF_WCHAR_T==sizeof(wchar_t) (0 means it is not defined or autoconf could not set it) + * + * @stable ICU 2.0 + */ +#if U_SIZEOF_WCHAR_T==0 +# undef U_SIZEOF_WCHAR_T +# define U_SIZEOF_WCHAR_T 4 +#endif + +/* + * \def U_WCHAR_IS_UTF16 + * Defined if wchar_t uses UTF-16. + * + * @stable ICU 2.0 + */ +/* + * \def U_WCHAR_IS_UTF32 + * Defined if wchar_t uses UTF-32. + * + * @stable ICU 2.0 + */ +#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32) +# ifdef __STDC_ISO_10646__ +# if (U_SIZEOF_WCHAR_T==2) +# define U_WCHAR_IS_UTF16 +# elif (U_SIZEOF_WCHAR_T==4) +# define U_WCHAR_IS_UTF32 +# endif +# elif defined __UCS2__ +# if (__OS390__ || __OS400__) && (U_SIZEOF_WCHAR_T==2) +# define U_WCHAR_IS_UTF16 +# endif +# elif defined __UCS4__ +# if (U_SIZEOF_WCHAR_T==4) +# define U_WCHAR_IS_UTF32 +# endif +# elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +# define U_WCHAR_IS_UTF16 +# endif +#endif + +/* UChar and UChar32 definitions -------------------------------------------- */ + +/** Number of bytes in a UChar. @stable ICU 2.0 */ +#define U_SIZEOF_UCHAR 2 + +/** + * \var UChar + * Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned. + * If wchar_t is not 16 bits wide, then define UChar to be uint16_t. + * This makes the definition of UChar platform-dependent + * but allows direct string type compatibility with platforms with + * 16-bit wchar_t types. + * + * @stable ICU 2.0 + */ + +/* Define UChar to be compatible with wchar_t if possible. */ +#if U_SIZEOF_WCHAR_T==2 + typedef wchar_t UChar; +#else + typedef uint16_t UChar; +#endif + +/** + * Define UChar32 as a type for single Unicode code points. + * UChar32 is a signed 32-bit integer (same as int32_t). + * + * The Unicode code point range is 0..0x10ffff. + * All other values (negative or >=0x110000) are illegal as Unicode code points. + * They may be used as sentinel values to indicate "done", "error" + * or similar non-code point conditions. + * + * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined + * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned) + * or else to be uint32_t. + * That is, the definition of UChar32 was platform-dependent. + * + * @see U_SENTINEL + * @stable ICU 2.4 + */ +typedef int32_t UChar32; + +/*==========================================================================*/ +/* U_INLINE and U_ALIGN_CODE Set default values if these are not already */ +/* defined. Definitions normally are in */ +/* platform.h or the corresponding file for */ +/* the OS in use. */ +/*==========================================================================*/ + +/** + * \def U_ALIGN_CODE + * This is used to align code fragments to a specific byte boundary. + * This is useful for getting consistent performance test results. + * @internal + */ +#ifndef U_ALIGN_CODE +# define U_ALIGN_CODE(n) +#endif + +#ifndef U_INLINE +# define U_INLINE +#endif + +#include "unicode/urename.h" + +#endif diff --git a/icu/unicode/urename.h b/icu/unicode/urename.h new file mode 100644 index 0000000..5562592 --- /dev/null +++ b/icu/unicode/urename.h @@ -0,0 +1,1468 @@ +/* +******************************************************************************* +* Copyright (C) 2002-2004, International Business Machines +* Corporation and others. All Rights Reserved. +******************************************************************************* +* +* file name: urename.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* Created by: Perl script written by Vladimir Weinstein +* +* Contains data for renaming ICU exports. +* Gets included by umachine.h +* +* THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT +* YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN! +*/ + +#ifndef URENAME_H +#define URENAME_H + +/* Uncomment the following line to disable renaming on platforms + that do not use Autoconf. */ +/* #define U_DISABLE_RENAMING 1 */ + +#if !U_DISABLE_RENAMING + +/* C exports renaming data */ + +#define T_CString_int64ToString T_CString_int64ToString_3_2 +#define T_CString_integerToString T_CString_integerToString_3_2 +#define T_CString_stricmp T_CString_stricmp_3_2 +#define T_CString_stringToInteger T_CString_stringToInteger_3_2 +#define T_CString_strnicmp T_CString_strnicmp_3_2 +#define T_CString_toLowerCase T_CString_toLowerCase_3_2 +#define T_CString_toUpperCase T_CString_toUpperCase_3_2 +#define T_FileStream_close T_FileStream_close_3_2 +#define T_FileStream_eof T_FileStream_eof_3_2 +#define T_FileStream_error T_FileStream_error_3_2 +#define T_FileStream_file_exists T_FileStream_file_exists_3_2 +#define T_FileStream_getc T_FileStream_getc_3_2 +#define T_FileStream_open T_FileStream_open_3_2 +#define T_FileStream_peek T_FileStream_peek_3_2 +#define T_FileStream_putc T_FileStream_putc_3_2 +#define T_FileStream_read T_FileStream_read_3_2 +#define T_FileStream_readLine T_FileStream_readLine_3_2 +#define T_FileStream_remove T_FileStream_remove_3_2 +#define T_FileStream_rewind T_FileStream_rewind_3_2 +#define T_FileStream_size T_FileStream_size_3_2 +#define T_FileStream_stderr T_FileStream_stderr_3_2 +#define T_FileStream_stdin T_FileStream_stdin_3_2 +#define T_FileStream_stdout T_FileStream_stdout_3_2 +#define T_FileStream_ungetc T_FileStream_ungetc_3_2 +#define T_FileStream_write T_FileStream_write_3_2 +#define T_FileStream_writeLine T_FileStream_writeLine_3_2 +#define UCNV_FROM_U_CALLBACK_ESCAPE UCNV_FROM_U_CALLBACK_ESCAPE_3_2 +#define UCNV_FROM_U_CALLBACK_SKIP UCNV_FROM_U_CALLBACK_SKIP_3_2 +#define UCNV_FROM_U_CALLBACK_STOP UCNV_FROM_U_CALLBACK_STOP_3_2 +#define UCNV_FROM_U_CALLBACK_SUBSTITUTE UCNV_FROM_U_CALLBACK_SUBSTITUTE_3_2 +#define UCNV_TO_U_CALLBACK_ESCAPE UCNV_TO_U_CALLBACK_ESCAPE_3_2 +#define UCNV_TO_U_CALLBACK_SKIP UCNV_TO_U_CALLBACK_SKIP_3_2 +#define UCNV_TO_U_CALLBACK_STOP UCNV_TO_U_CALLBACK_STOP_3_2 +#define UCNV_TO_U_CALLBACK_SUBSTITUTE UCNV_TO_U_CALLBACK_SUBSTITUTE_3_2 +#define UDataMemory_createNewInstance UDataMemory_createNewInstance_3_2 +#define UDataMemory_init UDataMemory_init_3_2 +#define UDataMemory_isLoaded UDataMemory_isLoaded_3_2 +#define UDataMemory_normalizeDataPointer UDataMemory_normalizeDataPointer_3_2 +#define UDataMemory_setData UDataMemory_setData_3_2 +#define UDatamemory_assign UDatamemory_assign_3_2 +#define _ASCIIData _ASCIIData_3_2 +#define _Bocu1Data _Bocu1Data_3_2 +#define _CESU8Data _CESU8Data_3_2 +#define _HZData _HZData_3_2 +#define _IMAPData _IMAPData_3_2 +#define _ISCIIData _ISCIIData_3_2 +#define _ISO2022Data _ISO2022Data_3_2 +#define _LMBCSData1 _LMBCSData1_3_2 +#define _LMBCSData11 _LMBCSData11_3_2 +#define _LMBCSData16 _LMBCSData16_3_2 +#define _LMBCSData17 _LMBCSData17_3_2 +#define _LMBCSData18 _LMBCSData18_3_2 +#define _LMBCSData19 _LMBCSData19_3_2 +#define _LMBCSData2 _LMBCSData2_3_2 +#define _LMBCSData3 _LMBCSData3_3_2 +#define _LMBCSData4 _LMBCSData4_3_2 +#define _LMBCSData5 _LMBCSData5_3_2 +#define _LMBCSData6 _LMBCSData6_3_2 +#define _LMBCSData8 _LMBCSData8_3_2 +#define _Latin1Data _Latin1Data_3_2 +#define _MBCSData _MBCSData_3_2 +#define _SCSUData _SCSUData_3_2 +#define _UTF16BEData _UTF16BEData_3_2 +#define _UTF16Data _UTF16Data_3_2 +#define _UTF16LEData _UTF16LEData_3_2 +#define _UTF32BEData _UTF32BEData_3_2 +#define _UTF32Data _UTF32Data_3_2 +#define _UTF32LEData _UTF32LEData_3_2 +#define _UTF7Data _UTF7Data_3_2 +#define _UTF8Data _UTF8Data_3_2 +#define cmemory_cleanup cmemory_cleanup_3_2 +#define cmemory_inUse cmemory_inUse_3_2 +#define locale_getKeywords locale_getKeywords_3_2 +#define locale_get_default locale_get_default_3_2 +#define locale_set_default locale_set_default_3_2 +#define res_countArrayItems res_countArrayItems_3_2 +#define res_findResource res_findResource_3_2 +#define res_getAlias res_getAlias_3_2 +#define res_getArrayItem res_getArrayItem_3_2 +#define res_getBinary res_getBinary_3_2 +#define res_getIntVector res_getIntVector_3_2 +#define res_getResource res_getResource_3_2 +#define res_getString res_getString_3_2 +#define res_getTableItemByIndex res_getTableItemByIndex_3_2 +#define res_getTableItemByKey res_getTableItemByKey_3_2 +#define res_load res_load_3_2 +#define res_unload res_unload_3_2 +#define transliterator_cleanup transliterator_cleanup_3_2 +#define u_UCharsToChars u_UCharsToChars_3_2 +#define u_austrcpy u_austrcpy_3_2 +#define u_austrncpy u_austrncpy_3_2 +#define u_catclose u_catclose_3_2 +#define u_catgets u_catgets_3_2 +#define u_catopen u_catopen_3_2 +#define u_charAge u_charAge_3_2 +#define u_charDigitValue u_charDigitValue_3_2 +#define u_charDirection u_charDirection_3_2 +#define u_charFromName u_charFromName_3_2 +#define u_charMirror u_charMirror_3_2 +#define u_charName u_charName_3_2 +#define u_charType u_charType_3_2 +#define u_charsToUChars u_charsToUChars_3_2 +#define u_cleanup u_cleanup_3_2 +#define u_countChar32 u_countChar32_3_2 +#define u_digit u_digit_3_2 +#define u_enumCharNames u_enumCharNames_3_2 +#define u_enumCharTypes u_enumCharTypes_3_2 +#define u_errorName u_errorName_3_2 +#define u_fclose u_fclose_3_2 +#define u_feof u_feof_3_2 +#define u_fflush u_fflush_3_2 +#define u_fgetConverter u_fgetConverter_3_2 +#define u_fgetc u_fgetc_3_2 +#define u_fgetcodepage u_fgetcodepage_3_2 +#define u_fgetcx u_fgetcx_3_2 +#define u_fgetfile u_fgetfile_3_2 +#define u_fgetlocale u_fgetlocale_3_2 +#define u_fgets u_fgets_3_2 +#define u_file_read u_file_read_3_2 +#define u_file_write u_file_write_3_2 +#define u_file_write_flush u_file_write_flush_3_2 +#define u_finit u_finit_3_2 +#define u_foldCase u_foldCase_3_2 +#define u_fopen u_fopen_3_2 +#define u_forDigit u_forDigit_3_2 +#define u_formatMessage u_formatMessage_3_2 +#define u_formatMessageWithError u_formatMessageWithError_3_2 +#define u_fprintf u_fprintf_3_2 +#define u_fprintf_u u_fprintf_u_3_2 +#define u_fputc u_fputc_3_2 +#define u_fputs u_fputs_3_2 +#define u_frewind u_frewind_3_2 +#define u_fscanf u_fscanf_3_2 +#define u_fscanf_u u_fscanf_u_3_2 +#define u_fsetcodepage u_fsetcodepage_3_2 +#define u_fsetlocale u_fsetlocale_3_2 +#define u_fsettransliterator u_fsettransliterator_3_2 +#define u_fstropen u_fstropen_3_2 +#define u_fungetc u_fungetc_3_2 +#define u_getCombiningClass u_getCombiningClass_3_2 +#define u_getDataDirectory u_getDataDirectory_3_2 +#define u_getDefaultConverter u_getDefaultConverter_3_2 +#define u_getFC_NFKC_Closure u_getFC_NFKC_Closure_3_2 +#define u_getISOComment u_getISOComment_3_2 +#define u_getIntPropertyMaxValue u_getIntPropertyMaxValue_3_2 +#define u_getIntPropertyMinValue u_getIntPropertyMinValue_3_2 +#define u_getIntPropertyValue u_getIntPropertyValue_3_2 +#define u_getNumericValue u_getNumericValue_3_2 +#define u_getPropertyEnum u_getPropertyEnum_3_2 +#define u_getPropertyName u_getPropertyName_3_2 +#define u_getPropertyValueEnum u_getPropertyValueEnum_3_2 +#define u_getPropertyValueName u_getPropertyValueName_3_2 +#define u_getUnicodeProperties u_getUnicodeProperties_3_2 +#define u_getUnicodeVersion u_getUnicodeVersion_3_2 +#define u_getVersion u_getVersion_3_2 +#define u_growBufferFromStatic u_growBufferFromStatic_3_2 +#define u_hasBinaryProperty u_hasBinaryProperty_3_2 +#define u_init u_init_3_2 +#define u_isIDIgnorable u_isIDIgnorable_3_2 +#define u_isIDPart u_isIDPart_3_2 +#define u_isIDStart u_isIDStart_3_2 +#define u_isISOControl u_isISOControl_3_2 +#define u_isJavaIDPart u_isJavaIDPart_3_2 +#define u_isJavaIDStart u_isJavaIDStart_3_2 +#define u_isJavaSpaceChar u_isJavaSpaceChar_3_2 +#define u_isMirrored u_isMirrored_3_2 +#define u_isUAlphabetic u_isUAlphabetic_3_2 +#define u_isULowercase u_isULowercase_3_2 +#define u_isUUppercase u_isUUppercase_3_2 +#define u_isUWhiteSpace u_isUWhiteSpace_3_2 +#define u_isWhitespace u_isWhitespace_3_2 +#define u_isalnum u_isalnum_3_2 +#define u_isalpha u_isalpha_3_2 +#define u_isbase u_isbase_3_2 +#define u_isblank u_isblank_3_2 +#define u_iscntrl u_iscntrl_3_2 +#define u_isdefined u_isdefined_3_2 +#define u_isdigit u_isdigit_3_2 +#define u_isgraph u_isgraph_3_2 +#define u_islower u_islower_3_2 +#define u_isprint u_isprint_3_2 +#define u_ispunct u_ispunct_3_2 +#define u_isspace u_isspace_3_2 +#define u_istitle u_istitle_3_2 +#define u_isupper u_isupper_3_2 +#define u_isxdigit u_isxdigit_3_2 +#define u_lengthOfIdenticalLevelRun u_lengthOfIdenticalLevelRun_3_2 +#define u_locbund_close u_locbund_close_3_2 +#define u_locbund_getNumberFormat u_locbund_getNumberFormat_3_2 +#define u_locbund_init u_locbund_init_3_2 +#define u_memcasecmp u_memcasecmp_3_2 +#define u_memchr u_memchr_3_2 +#define u_memchr32 u_memchr32_3_2 +#define u_memcmp u_memcmp_3_2 +#define u_memcmpCodePointOrder u_memcmpCodePointOrder_3_2 +#define u_memcpy u_memcpy_3_2 +#define u_memmove u_memmove_3_2 +#define u_memrchr u_memrchr_3_2 +#define u_memrchr32 u_memrchr32_3_2 +#define u_memset u_memset_3_2 +#define u_parseMessage u_parseMessage_3_2 +#define u_parseMessageWithError u_parseMessageWithError_3_2 +#define u_printf_parse u_printf_parse_3_2 +#define u_releaseDefaultConverter u_releaseDefaultConverter_3_2 +#define u_scanf_parse u_scanf_parse_3_2 +#define u_setAtomicIncDecFunctions u_setAtomicIncDecFunctions_3_2 +#define u_setDataDirectory u_setDataDirectory_3_2 +#define u_setMemoryFunctions u_setMemoryFunctions_3_2 +#define u_setMutexFunctions u_setMutexFunctions_3_2 +#define u_shapeArabic u_shapeArabic_3_2 +#define u_snprintf u_snprintf_3_2 +#define u_snprintf_u u_snprintf_u_3_2 +#define u_sprintf u_sprintf_3_2 +#define u_sprintf_u u_sprintf_u_3_2 +#define u_sscanf u_sscanf_3_2 +#define u_sscanf_u u_sscanf_u_3_2 +#define u_strCaseCompare u_strCaseCompare_3_2 +#define u_strCompare u_strCompare_3_2 +#define u_strCompareIter u_strCompareIter_3_2 +#define u_strFindFirst u_strFindFirst_3_2 +#define u_strFindLast u_strFindLast_3_2 +#define u_strFoldCase u_strFoldCase_3_2 +#define u_strFromPunycode u_strFromPunycode_3_2 +#define u_strFromUTF32 u_strFromUTF32_3_2 +#define u_strFromUTF8 u_strFromUTF8_3_2 +#define u_strFromWCS u_strFromWCS_3_2 +#define u_strHasMoreChar32Than u_strHasMoreChar32Than_3_2 +#define u_strToLower u_strToLower_3_2 +#define u_strToPunycode u_strToPunycode_3_2 +#define u_strToTitle u_strToTitle_3_2 +#define u_strToUTF32 u_strToUTF32_3_2 +#define u_strToUTF8 u_strToUTF8_3_2 +#define u_strToUpper u_strToUpper_3_2 +#define u_strToWCS u_strToWCS_3_2 +#define u_strcasecmp u_strcasecmp_3_2 +#define u_strcat u_strcat_3_2 +#define u_strchr u_strchr_3_2 +#define u_strchr32 u_strchr32_3_2 +#define u_strcmp u_strcmp_3_2 +#define u_strcmpCodePointOrder u_strcmpCodePointOrder_3_2 +#define u_strcmpFold u_strcmpFold_3_2 +#define u_strcpy u_strcpy_3_2 +#define u_strcspn u_strcspn_3_2 +#define u_strlen u_strlen_3_2 +#define u_strncasecmp u_strncasecmp_3_2 +#define u_strncat u_strncat_3_2 +#define u_strncmp u_strncmp_3_2 +#define u_strncmpCodePointOrder u_strncmpCodePointOrder_3_2 +#define u_strncpy u_strncpy_3_2 +#define u_strpbrk u_strpbrk_3_2 +#define u_strrchr u_strrchr_3_2 +#define u_strrchr32 u_strrchr32_3_2 +#define u_strrstr u_strrstr_3_2 +#define u_strspn u_strspn_3_2 +#define u_strstr u_strstr_3_2 +#define u_strtok_r u_strtok_r_3_2 +#define u_terminateChars u_terminateChars_3_2 +#define u_terminateUChar32s u_terminateUChar32s_3_2 +#define u_terminateUChars u_terminateUChars_3_2 +#define u_terminateWChars u_terminateWChars_3_2 +#define u_tolower u_tolower_3_2 +#define u_totitle u_totitle_3_2 +#define u_toupper u_toupper_3_2 +#define u_uastrcpy u_uastrcpy_3_2 +#define u_uastrncpy u_uastrncpy_3_2 +#define u_unescape u_unescape_3_2 +#define u_unescapeAt u_unescapeAt_3_2 +#define u_versionFromString u_versionFromString_3_2 +#define u_versionToString u_versionToString_3_2 +#define u_vformatMessage u_vformatMessage_3_2 +#define u_vformatMessageWithError u_vformatMessageWithError_3_2 +#define u_vfprintf u_vfprintf_3_2 +#define u_vfprintf_u u_vfprintf_u_3_2 +#define u_vfscanf u_vfscanf_3_2 +#define u_vfscanf_u u_vfscanf_u_3_2 +#define u_vparseMessage u_vparseMessage_3_2 +#define u_vparseMessageWithError u_vparseMessageWithError_3_2 +#define u_vsnprintf u_vsnprintf_3_2 +#define u_vsnprintf_u u_vsnprintf_u_3_2 +#define u_vsprintf u_vsprintf_3_2 +#define u_vsprintf_u u_vsprintf_u_3_2 +#define u_vsscanf u_vsscanf_3_2 +#define u_vsscanf_u u_vsscanf_u_3_2 +#define u_writeDiff u_writeDiff_3_2 +#define u_writeIdenticalLevelRun u_writeIdenticalLevelRun_3_2 +#define u_writeIdenticalLevelRunTwoChars u_writeIdenticalLevelRunTwoChars_3_2 +#define ubidi_close ubidi_close_3_2 +#define ubidi_countRuns ubidi_countRuns_3_2 +#define ubidi_getDirection ubidi_getDirection_3_2 +#define ubidi_getLength ubidi_getLength_3_2 +#define ubidi_getLevelAt ubidi_getLevelAt_3_2 +#define ubidi_getLevels ubidi_getLevels_3_2 +#define ubidi_getLogicalIndex ubidi_getLogicalIndex_3_2 +#define ubidi_getLogicalMap ubidi_getLogicalMap_3_2 +#define ubidi_getLogicalRun ubidi_getLogicalRun_3_2 +#define ubidi_getMemory ubidi_getMemory_3_2 +#define ubidi_getParaLevel ubidi_getParaLevel_3_2 +#define ubidi_getRuns ubidi_getRuns_3_2 +#define ubidi_getText ubidi_getText_3_2 +#define ubidi_getVisualIndex ubidi_getVisualIndex_3_2 +#define ubidi_getVisualMap ubidi_getVisualMap_3_2 +#define ubidi_getVisualRun ubidi_getVisualRun_3_2 +#define ubidi_invertMap ubidi_invertMap_3_2 +#define ubidi_isInverse ubidi_isInverse_3_2 +#define ubidi_open ubidi_open_3_2 +#define ubidi_openSized ubidi_openSized_3_2 +#define ubidi_reorderLogical ubidi_reorderLogical_3_2 +#define ubidi_reorderVisual ubidi_reorderVisual_3_2 +#define ubidi_setInverse ubidi_setInverse_3_2 +#define ubidi_setLine ubidi_setLine_3_2 +#define ubidi_setPara ubidi_setPara_3_2 +#define ubidi_writeReordered ubidi_writeReordered_3_2 +#define ubidi_writeReverse ubidi_writeReverse_3_2 +#define ublock_getCode ublock_getCode_3_2 +#define ubrk_close ubrk_close_3_2 +#define ubrk_countAvailable ubrk_countAvailable_3_2 +#define ubrk_current ubrk_current_3_2 +#define ubrk_first ubrk_first_3_2 +#define ubrk_following ubrk_following_3_2 +#define ubrk_getAvailable ubrk_getAvailable_3_2 +#define ubrk_getLocaleByType ubrk_getLocaleByType_3_2 +#define ubrk_getRuleStatus ubrk_getRuleStatus_3_2 +#define ubrk_getRuleStatusVec ubrk_getRuleStatusVec_3_2 +#define ubrk_isBoundary ubrk_isBoundary_3_2 +#define ubrk_last ubrk_last_3_2 +#define ubrk_next ubrk_next_3_2 +#define ubrk_open ubrk_open_3_2 +#define ubrk_openRules ubrk_openRules_3_2 +#define ubrk_preceding ubrk_preceding_3_2 +#define ubrk_previous ubrk_previous_3_2 +#define ubrk_safeClone ubrk_safeClone_3_2 +#define ubrk_setText ubrk_setText_3_2 +#define ubrk_swap ubrk_swap_3_2 +#define ucal_add ucal_add_3_2 +#define ucal_clear ucal_clear_3_2 +#define ucal_clearField ucal_clearField_3_2 +#define ucal_close ucal_close_3_2 +#define ucal_countAvailable ucal_countAvailable_3_2 +#define ucal_equivalentTo ucal_equivalentTo_3_2 +#define ucal_get ucal_get_3_2 +#define ucal_getAttribute ucal_getAttribute_3_2 +#define ucal_getAvailable ucal_getAvailable_3_2 +#define ucal_getDSTSavings ucal_getDSTSavings_3_2 +#define ucal_getDefaultTimeZone ucal_getDefaultTimeZone_3_2 +#define ucal_getLimit ucal_getLimit_3_2 +#define ucal_getLocaleByType ucal_getLocaleByType_3_2 +#define ucal_getMillis ucal_getMillis_3_2 +#define ucal_getNow ucal_getNow_3_2 +#define ucal_getTimeZoneDisplayName ucal_getTimeZoneDisplayName_3_2 +#define ucal_inDaylightTime ucal_inDaylightTime_3_2 +#define ucal_isSet ucal_isSet_3_2 +#define ucal_open ucal_open_3_2 +#define ucal_openCountryTimeZones ucal_openCountryTimeZones_3_2 +#define ucal_openTimeZones ucal_openTimeZones_3_2 +#define ucal_roll ucal_roll_3_2 +#define ucal_set ucal_set_3_2 +#define ucal_setAttribute ucal_setAttribute_3_2 +#define ucal_setDate ucal_setDate_3_2 +#define ucal_setDateTime ucal_setDateTime_3_2 +#define ucal_setDefaultTimeZone ucal_setDefaultTimeZone_3_2 +#define ucal_setMillis ucal_setMillis_3_2 +#define ucal_setTimeZone ucal_setTimeZone_3_2 +#define ucase_addPropertyStarts ucase_addPropertyStarts_3_2 +#define ucase_close ucase_close_3_2 +#define ucase_fold ucase_fold_3_2 +#define ucase_getSingleton ucase_getSingleton_3_2 +#define ucase_getType ucase_getType_3_2 +#define ucase_getTypeOrIgnorable ucase_getTypeOrIgnorable_3_2 +#define ucase_isCaseSensitive ucase_isCaseSensitive_3_2 +#define ucase_isSoftDotted ucase_isSoftDotted_3_2 +#define ucase_open ucase_open_3_2 +#define ucase_openBinary ucase_openBinary_3_2 +#define ucase_swap ucase_swap_3_2 +#define ucase_toFullFolding ucase_toFullFolding_3_2 +#define ucase_toFullLower ucase_toFullLower_3_2 +#define ucase_toFullTitle ucase_toFullTitle_3_2 +#define ucase_toFullUpper ucase_toFullUpper_3_2 +#define ucase_tolower ucase_tolower_3_2 +#define ucase_totitle ucase_totitle_3_2 +#define ucase_toupper ucase_toupper_3_2 +#define uchar_addPropertyStarts uchar_addPropertyStarts_3_2 +#define uchar_getHST uchar_getHST_3_2 +#define uchar_swapNames uchar_swapNames_3_2 +#define ucln_common_lib_cleanup ucln_common_lib_cleanup_3_2 +#define ucln_common_registerCleanup ucln_common_registerCleanup_3_2 +#define ucln_i18n_registerCleanup ucln_i18n_registerCleanup_3_2 +#define ucln_registerCleanup ucln_registerCleanup_3_2 +#define ucmp8_close ucmp8_close_3_2 +#define ucmp8_compact ucmp8_compact_3_2 +#define ucmp8_expand ucmp8_expand_3_2 +#define ucmp8_flattenMem ucmp8_flattenMem_3_2 +#define ucmp8_getArray ucmp8_getArray_3_2 +#define ucmp8_getCount ucmp8_getCount_3_2 +#define ucmp8_getIndex ucmp8_getIndex_3_2 +#define ucmp8_getkBlockCount ucmp8_getkBlockCount_3_2 +#define ucmp8_getkUnicodeCount ucmp8_getkUnicodeCount_3_2 +#define ucmp8_init ucmp8_init_3_2 +#define ucmp8_initAdopt ucmp8_initAdopt_3_2 +#define ucmp8_initAlias ucmp8_initAlias_3_2 +#define ucmp8_initBogus ucmp8_initBogus_3_2 +#define ucmp8_initFromData ucmp8_initFromData_3_2 +#define ucmp8_isBogus ucmp8_isBogus_3_2 +#define ucmp8_open ucmp8_open_3_2 +#define ucmp8_openAdopt ucmp8_openAdopt_3_2 +#define ucmp8_openAlias ucmp8_openAlias_3_2 +#define ucmp8_set ucmp8_set_3_2 +#define ucmp8_setRange ucmp8_setRange_3_2 +#define ucnv_MBCSFromUChar32 ucnv_MBCSFromUChar32_3_2 +#define ucnv_MBCSFromUnicodeWithOffsets ucnv_MBCSFromUnicodeWithOffsets_3_2 +#define ucnv_MBCSGetType ucnv_MBCSGetType_3_2 +#define ucnv_MBCSGetUnicodeSetForBytes ucnv_MBCSGetUnicodeSetForBytes_3_2 +#define ucnv_MBCSGetUnicodeSetForUnicode ucnv_MBCSGetUnicodeSetForUnicode_3_2 +#define ucnv_MBCSIsLeadByte ucnv_MBCSIsLeadByte_3_2 +#define ucnv_MBCSSimpleGetNextUChar ucnv_MBCSSimpleGetNextUChar_3_2 +#define ucnv_MBCSToUnicodeWithOffsets ucnv_MBCSToUnicodeWithOffsets_3_2 +#define ucnv_cbFromUWriteBytes ucnv_cbFromUWriteBytes_3_2 +#define ucnv_cbFromUWriteSub ucnv_cbFromUWriteSub_3_2 +#define ucnv_cbFromUWriteUChars ucnv_cbFromUWriteUChars_3_2 +#define ucnv_cbToUWriteSub ucnv_cbToUWriteSub_3_2 +#define ucnv_cbToUWriteUChars ucnv_cbToUWriteUChars_3_2 +#define ucnv_close ucnv_close_3_2 +#define ucnv_compareNames ucnv_compareNames_3_2 +#define ucnv_convert ucnv_convert_3_2 +#define ucnv_convertEx ucnv_convertEx_3_2 +#define ucnv_copyPlatformString ucnv_copyPlatformString_3_2 +#define ucnv_countAliases ucnv_countAliases_3_2 +#define ucnv_countAvailable ucnv_countAvailable_3_2 +#define ucnv_countStandards ucnv_countStandards_3_2 +#define ucnv_createAlgorithmicConverter ucnv_createAlgorithmicConverter_3_2 +#define ucnv_createConverter ucnv_createConverter_3_2 +#define ucnv_createConverterFromPackage ucnv_createConverterFromPackage_3_2 +#define ucnv_createConverterFromSharedData ucnv_createConverterFromSharedData_3_2 +#define ucnv_detectUnicodeSignature ucnv_detectUnicodeSignature_3_2 +#define ucnv_extContinueMatchFromU ucnv_extContinueMatchFromU_3_2 +#define ucnv_extContinueMatchToU ucnv_extContinueMatchToU_3_2 +#define ucnv_extGetUnicodeSet ucnv_extGetUnicodeSet_3_2 +#define ucnv_extInitialMatchFromU ucnv_extInitialMatchFromU_3_2 +#define ucnv_extInitialMatchToU ucnv_extInitialMatchToU_3_2 +#define ucnv_extSimpleMatchFromU ucnv_extSimpleMatchFromU_3_2 +#define ucnv_extSimpleMatchToU ucnv_extSimpleMatchToU_3_2 +#define ucnv_fixFileSeparator ucnv_fixFileSeparator_3_2 +#define ucnv_flushCache ucnv_flushCache_3_2 +#define ucnv_fromAlgorithmic ucnv_fromAlgorithmic_3_2 +#define ucnv_fromUChars ucnv_fromUChars_3_2 +#define ucnv_fromUWriteBytes ucnv_fromUWriteBytes_3_2 +#define ucnv_fromUnicode ucnv_fromUnicode_3_2 +#define ucnv_fromUnicode_UTF8 ucnv_fromUnicode_UTF8_3_2 +#define ucnv_fromUnicode_UTF8_OFFSETS_LOGIC ucnv_fromUnicode_UTF8_OFFSETS_LOGIC_3_2 +#define ucnv_getAlias ucnv_getAlias_3_2 +#define ucnv_getAliases ucnv_getAliases_3_2 +#define ucnv_getAvailableName ucnv_getAvailableName_3_2 +#define ucnv_getCCSID ucnv_getCCSID_3_2 +#define ucnv_getCanonicalName ucnv_getCanonicalName_3_2 +#define ucnv_getCompleteUnicodeSet ucnv_getCompleteUnicodeSet_3_2 +#define ucnv_getDefaultName ucnv_getDefaultName_3_2 +#define ucnv_getDisplayName ucnv_getDisplayName_3_2 +#define ucnv_getFromUCallBack ucnv_getFromUCallBack_3_2 +#define ucnv_getInvalidChars ucnv_getInvalidChars_3_2 +#define ucnv_getInvalidUChars ucnv_getInvalidUChars_3_2 +#define ucnv_getMaxCharSize ucnv_getMaxCharSize_3_2 +#define ucnv_getMinCharSize ucnv_getMinCharSize_3_2 +#define ucnv_getName ucnv_getName_3_2 +#define ucnv_getNextUChar ucnv_getNextUChar_3_2 +#define ucnv_getNonSurrogateUnicodeSet ucnv_getNonSurrogateUnicodeSet_3_2 +#define ucnv_getPlatform ucnv_getPlatform_3_2 +#define ucnv_getStandard ucnv_getStandard_3_2 +#define ucnv_getStandardName ucnv_getStandardName_3_2 +#define ucnv_getStarters ucnv_getStarters_3_2 +#define ucnv_getSubstChars ucnv_getSubstChars_3_2 +#define ucnv_getToUCallBack ucnv_getToUCallBack_3_2 +#define ucnv_getType ucnv_getType_3_2 +#define ucnv_getUnicodeSet ucnv_getUnicodeSet_3_2 +#define ucnv_incrementRefCount ucnv_incrementRefCount_3_2 +#define ucnv_io_countAliases ucnv_io_countAliases_3_2 +#define ucnv_io_countAvailableAliases ucnv_io_countAvailableAliases_3_2 +#define ucnv_io_countAvailableConverters ucnv_io_countAvailableConverters_3_2 +#define ucnv_io_countStandards ucnv_io_countStandards_3_2 +#define ucnv_io_flushAvailableConverterCache ucnv_io_flushAvailableConverterCache_3_2 +#define ucnv_io_getAlias ucnv_io_getAlias_3_2 +#define ucnv_io_getAliases ucnv_io_getAliases_3_2 +#define ucnv_io_getAvailableConverter ucnv_io_getAvailableConverter_3_2 +#define ucnv_io_getConverterName ucnv_io_getConverterName_3_2 +#define ucnv_io_getDefaultConverterName ucnv_io_getDefaultConverterName_3_2 +#define ucnv_io_setDefaultConverterName ucnv_io_setDefaultConverterName_3_2 +#define ucnv_io_stripASCIIForCompare ucnv_io_stripASCIIForCompare_3_2 +#define ucnv_io_stripEBCDICForCompare ucnv_io_stripEBCDICForCompare_3_2 +#define ucnv_isAmbiguous ucnv_isAmbiguous_3_2 +#define ucnv_load ucnv_load_3_2 +#define ucnv_loadSharedData ucnv_loadSharedData_3_2 +#define ucnv_open ucnv_open_3_2 +#define ucnv_openAllNames ucnv_openAllNames_3_2 +#define ucnv_openCCSID ucnv_openCCSID_3_2 +#define ucnv_openPackage ucnv_openPackage_3_2 +#define ucnv_openStandardNames ucnv_openStandardNames_3_2 +#define ucnv_openU ucnv_openU_3_2 +#define ucnv_reset ucnv_reset_3_2 +#define ucnv_resetFromUnicode ucnv_resetFromUnicode_3_2 +#define ucnv_resetToUnicode ucnv_resetToUnicode_3_2 +#define ucnv_safeClone ucnv_safeClone_3_2 +#define ucnv_setDefaultName ucnv_setDefaultName_3_2 +#define ucnv_setFallback ucnv_setFallback_3_2 +#define ucnv_setFromUCallBack ucnv_setFromUCallBack_3_2 +#define ucnv_setSubstChars ucnv_setSubstChars_3_2 +#define ucnv_setToUCallBack ucnv_setToUCallBack_3_2 +#define ucnv_swap ucnv_swap_3_2 +#define ucnv_swapAliases ucnv_swapAliases_3_2 +#define ucnv_toAlgorithmic ucnv_toAlgorithmic_3_2 +#define ucnv_toUChars ucnv_toUChars_3_2 +#define ucnv_toUWriteCodePoint ucnv_toUWriteCodePoint_3_2 +#define ucnv_toUWriteUChars ucnv_toUWriteUChars_3_2 +#define ucnv_toUnicode ucnv_toUnicode_3_2 +#define ucnv_unload ucnv_unload_3_2 +#define ucnv_unloadSharedDataIfReady ucnv_unloadSharedDataIfReady_3_2 +#define ucnv_usesFallback ucnv_usesFallback_3_2 +#define ucol_allocWeights ucol_allocWeights_3_2 +#define ucol_assembleTailoringTable ucol_assembleTailoringTable_3_2 +#define ucol_calcSortKey ucol_calcSortKey_3_2 +#define ucol_calcSortKeySimpleTertiary ucol_calcSortKeySimpleTertiary_3_2 +#define ucol_cloneBinary ucol_cloneBinary_3_2 +#define ucol_cloneRuleData ucol_cloneRuleData_3_2 +#define ucol_close ucol_close_3_2 +#define ucol_closeElements ucol_closeElements_3_2 +#define ucol_collatorToIdentifier ucol_collatorToIdentifier_3_2 +#define ucol_countAvailable ucol_countAvailable_3_2 +#define ucol_createElements ucol_createElements_3_2 +#define ucol_doCE ucol_doCE_3_2 +#define ucol_equal ucol_equal_3_2 +#define ucol_equals ucol_equals_3_2 +#define ucol_getAttribute ucol_getAttribute_3_2 +#define ucol_getAttributeOrDefault ucol_getAttributeOrDefault_3_2 +#define ucol_getAvailable ucol_getAvailable_3_2 +#define ucol_getBound ucol_getBound_3_2 +#define ucol_getCEGenerator ucol_getCEGenerator_3_2 +#define ucol_getCEStrengthDifference ucol_getCEStrengthDifference_3_2 +#define ucol_getContractions ucol_getContractions_3_2 +#define ucol_getDisplayName ucol_getDisplayName_3_2 +#define ucol_getFirstCE ucol_getFirstCE_3_2 +#define ucol_getFunctionalEquivalent ucol_getFunctionalEquivalent_3_2 +#define ucol_getKeywordValues ucol_getKeywordValues_3_2 +#define ucol_getKeywords ucol_getKeywords_3_2 +#define ucol_getLocale ucol_getLocale_3_2 +#define ucol_getLocaleByType ucol_getLocaleByType_3_2 +#define ucol_getMaxExpansion ucol_getMaxExpansion_3_2 +#define ucol_getNextCE ucol_getNextCE_3_2 +#define ucol_getNextGenerated ucol_getNextGenerated_3_2 +#define ucol_getOffset ucol_getOffset_3_2 +#define ucol_getPrevCE ucol_getPrevCE_3_2 +#define ucol_getRules ucol_getRules_3_2 +#define ucol_getRulesEx ucol_getRulesEx_3_2 +#define ucol_getShortDefinitionString ucol_getShortDefinitionString_3_2 +#define ucol_getSimpleCEGenerator ucol_getSimpleCEGenerator_3_2 +#define ucol_getSortKey ucol_getSortKey_3_2 +#define ucol_getSortKeySize ucol_getSortKeySize_3_2 +#define ucol_getSortKeyWithAllocation ucol_getSortKeyWithAllocation_3_2 +#define ucol_getStrength ucol_getStrength_3_2 +#define ucol_getTailoredSet ucol_getTailoredSet_3_2 +#define ucol_getUCAVersion ucol_getUCAVersion_3_2 +#define ucol_getUnsafeSet ucol_getUnsafeSet_3_2 +#define ucol_getVariableTop ucol_getVariableTop_3_2 +#define ucol_getVersion ucol_getVersion_3_2 +#define ucol_greater ucol_greater_3_2 +#define ucol_greaterOrEqual ucol_greaterOrEqual_3_2 +#define ucol_identifierToShortString ucol_identifierToShortString_3_2 +#define ucol_initBuffers ucol_initBuffers_3_2 +#define ucol_initCollator ucol_initCollator_3_2 +#define ucol_initInverseUCA ucol_initInverseUCA_3_2 +#define ucol_initUCA ucol_initUCA_3_2 +#define ucol_inv_getGapPositions ucol_inv_getGapPositions_3_2 +#define ucol_inv_getNextCE ucol_inv_getNextCE_3_2 +#define ucol_inv_getPrevCE ucol_inv_getPrevCE_3_2 +#define ucol_isTailored ucol_isTailored_3_2 +#define ucol_keyHashCode ucol_keyHashCode_3_2 +#define ucol_mergeSortkeys ucol_mergeSortkeys_3_2 +#define ucol_next ucol_next_3_2 +#define ucol_nextSortKeyPart ucol_nextSortKeyPart_3_2 +#define ucol_nextWeight ucol_nextWeight_3_2 +#define ucol_normalizeShortDefinitionString ucol_normalizeShortDefinitionString_3_2 +#define ucol_open ucol_open_3_2 +#define ucol_openAvailableLocales ucol_openAvailableLocales_3_2 +#define ucol_openBinary ucol_openBinary_3_2 +#define ucol_openElements ucol_openElements_3_2 +#define ucol_openFromIdentifier ucol_openFromIdentifier_3_2 +#define ucol_openFromShortString ucol_openFromShortString_3_2 +#define ucol_openRules ucol_openRules_3_2 +#define ucol_open_internal ucol_open_internal_3_2 +#define ucol_previous ucol_previous_3_2 +#define ucol_primaryOrder ucol_primaryOrder_3_2 +#define ucol_prv_getSpecialCE ucol_prv_getSpecialCE_3_2 +#define ucol_prv_getSpecialPrevCE ucol_prv_getSpecialPrevCE_3_2 +#define ucol_reset ucol_reset_3_2 +#define ucol_restoreVariableTop ucol_restoreVariableTop_3_2 +#define ucol_safeClone ucol_safeClone_3_2 +#define ucol_secondaryOrder ucol_secondaryOrder_3_2 +#define ucol_setAttribute ucol_setAttribute_3_2 +#define ucol_setOffset ucol_setOffset_3_2 +#define ucol_setOptionsFromHeader ucol_setOptionsFromHeader_3_2 +#define ucol_setReqValidLocales ucol_setReqValidLocales_3_2 +#define ucol_setStrength ucol_setStrength_3_2 +#define ucol_setText ucol_setText_3_2 +#define ucol_setVariableTop ucol_setVariableTop_3_2 +#define ucol_shortStringToIdentifier ucol_shortStringToIdentifier_3_2 +#define ucol_sortKeyToString ucol_sortKeyToString_3_2 +#define ucol_strcoll ucol_strcoll_3_2 +#define ucol_strcollIter ucol_strcollIter_3_2 +#define ucol_swap ucol_swap_3_2 +#define ucol_swapBinary ucol_swapBinary_3_2 +#define ucol_swapInverseUCA ucol_swapInverseUCA_3_2 +#define ucol_tertiaryOrder ucol_tertiaryOrder_3_2 +#define ucol_tok_assembleTokenList ucol_tok_assembleTokenList_3_2 +#define ucol_tok_closeTokenList ucol_tok_closeTokenList_3_2 +#define ucol_tok_getNextArgument ucol_tok_getNextArgument_3_2 +#define ucol_tok_initTokenList ucol_tok_initTokenList_3_2 +#define ucol_tok_parseNextToken ucol_tok_parseNextToken_3_2 +#define ucol_updateInternalState ucol_updateInternalState_3_2 +#define ucurr_forLocale ucurr_forLocale_3_2 +#define ucurr_getDefaultFractionDigits ucurr_getDefaultFractionDigits_3_2 +#define ucurr_getName ucurr_getName_3_2 +#define ucurr_getRoundingIncrement ucurr_getRoundingIncrement_3_2 +#define ucurr_register ucurr_register_3_2 +#define ucurr_unregister ucurr_unregister_3_2 +#define udat_applyPattern udat_applyPattern_3_2 +#define udat_clone udat_clone_3_2 +#define udat_close udat_close_3_2 +#define udat_countAvailable udat_countAvailable_3_2 +#define udat_countSymbols udat_countSymbols_3_2 +#define udat_format udat_format_3_2 +#define udat_get2DigitYearStart udat_get2DigitYearStart_3_2 +#define udat_getAvailable udat_getAvailable_3_2 +#define udat_getCalendar udat_getCalendar_3_2 +#define udat_getLocaleByType udat_getLocaleByType_3_2 +#define udat_getNumberFormat udat_getNumberFormat_3_2 +#define udat_getSymbols udat_getSymbols_3_2 +#define udat_isLenient udat_isLenient_3_2 +#define udat_open udat_open_3_2 +#define udat_parse udat_parse_3_2 +#define udat_parseCalendar udat_parseCalendar_3_2 +#define udat_set2DigitYearStart udat_set2DigitYearStart_3_2 +#define udat_setCalendar udat_setCalendar_3_2 +#define udat_setLenient udat_setLenient_3_2 +#define udat_setNumberFormat udat_setNumberFormat_3_2 +#define udat_setSymbols udat_setSymbols_3_2 +#define udat_toPattern udat_toPattern_3_2 +#define udata_checkCommonData udata_checkCommonData_3_2 +#define udata_close udata_close_3_2 +#define udata_closeSwapper udata_closeSwapper_3_2 +#define udata_getHeaderSize udata_getHeaderSize_3_2 +#define udata_getInfo udata_getInfo_3_2 +#define udata_getInfoSize udata_getInfoSize_3_2 +#define udata_getLength udata_getLength_3_2 +#define udata_getMemory udata_getMemory_3_2 +#define udata_getRawMemory udata_getRawMemory_3_2 +#define udata_open udata_open_3_2 +#define udata_openChoice udata_openChoice_3_2 +#define udata_openSwapper udata_openSwapper_3_2 +#define udata_openSwapperForInputData udata_openSwapperForInputData_3_2 +#define udata_printError udata_printError_3_2 +#define udata_readInt16 udata_readInt16_3_2 +#define udata_readInt32 udata_readInt32_3_2 +#define udata_setAppData udata_setAppData_3_2 +#define udata_setCommonData udata_setCommonData_3_2 +#define udata_swapDataHeader udata_swapDataHeader_3_2 +#define udata_swapInvStringBlock udata_swapInvStringBlock_3_2 +#define uenum_close uenum_close_3_2 +#define uenum_count uenum_count_3_2 +#define uenum_next uenum_next_3_2 +#define uenum_nextDefault uenum_nextDefault_3_2 +#define uenum_openCharStringsEnumeration uenum_openCharStringsEnumeration_3_2 +#define uenum_openStringEnumeration uenum_openStringEnumeration_3_2 +#define uenum_reset uenum_reset_3_2 +#define uenum_unext uenum_unext_3_2 +#define uenum_unextDefault uenum_unextDefault_3_2 +#define ufile_close_translit ufile_close_translit_3_2 +#define ufile_fill_uchar_buffer ufile_fill_uchar_buffer_3_2 +#define ufile_flush_translit ufile_flush_translit_3_2 +#define ufile_getch ufile_getch_3_2 +#define ufile_getch32 ufile_getch32_3_2 +#define ufmt_64tou ufmt_64tou_3_2 +#define ufmt_defaultCPToUnicode ufmt_defaultCPToUnicode_3_2 +#define ufmt_digitvalue ufmt_digitvalue_3_2 +#define ufmt_isdigit ufmt_isdigit_3_2 +#define ufmt_ptou ufmt_ptou_3_2 +#define ufmt_uto64 ufmt_uto64_3_2 +#define ufmt_utop ufmt_utop_3_2 +#define uhash_close uhash_close_3_2 +#define uhash_compareCaselessUnicodeString uhash_compareCaselessUnicodeString_3_2 +#define uhash_compareChars uhash_compareChars_3_2 +#define uhash_compareIChars uhash_compareIChars_3_2 +#define uhash_compareLong uhash_compareLong_3_2 +#define uhash_compareUChars uhash_compareUChars_3_2 +#define uhash_compareUnicodeString uhash_compareUnicodeString_3_2 +#define uhash_count uhash_count_3_2 +#define uhash_deleteHashtable uhash_deleteHashtable_3_2 +#define uhash_deleteUVector uhash_deleteUVector_3_2 +#define uhash_deleteUnicodeString uhash_deleteUnicodeString_3_2 +#define uhash_find uhash_find_3_2 +#define uhash_freeBlock uhash_freeBlock_3_2 +#define uhash_get uhash_get_3_2 +#define uhash_geti uhash_geti_3_2 +#define uhash_hashCaselessUnicodeString uhash_hashCaselessUnicodeString_3_2 +#define uhash_hashChars uhash_hashChars_3_2 +#define uhash_hashIChars uhash_hashIChars_3_2 +#define uhash_hashLong uhash_hashLong_3_2 +#define uhash_hashUChars uhash_hashUChars_3_2 +#define uhash_hashUCharsN uhash_hashUCharsN_3_2 +#define uhash_hashUnicodeString uhash_hashUnicodeString_3_2 +#define uhash_iget uhash_iget_3_2 +#define uhash_igeti uhash_igeti_3_2 +#define uhash_iput uhash_iput_3_2 +#define uhash_iputi uhash_iputi_3_2 +#define uhash_iremove uhash_iremove_3_2 +#define uhash_iremovei uhash_iremovei_3_2 +#define uhash_nextElement uhash_nextElement_3_2 +#define uhash_open uhash_open_3_2 +#define uhash_openSize uhash_openSize_3_2 +#define uhash_put uhash_put_3_2 +#define uhash_puti uhash_puti_3_2 +#define uhash_remove uhash_remove_3_2 +#define uhash_removeAll uhash_removeAll_3_2 +#define uhash_removeElement uhash_removeElement_3_2 +#define uhash_removei uhash_removei_3_2 +#define uhash_setKeyComparator uhash_setKeyComparator_3_2 +#define uhash_setKeyDeleter uhash_setKeyDeleter_3_2 +#define uhash_setKeyHasher uhash_setKeyHasher_3_2 +#define uhash_setResizePolicy uhash_setResizePolicy_3_2 +#define uhash_setValueDeleter uhash_setValueDeleter_3_2 +#define uhash_toki uhash_toki_3_2 +#define uhash_tokp uhash_tokp_3_2 +#define uhst_addPropertyStarts uhst_addPropertyStarts_3_2 +#define uidna_IDNToASCII uidna_IDNToASCII_3_2 +#define uidna_IDNToUnicode uidna_IDNToUnicode_3_2 +#define uidna_compare uidna_compare_3_2 +#define uidna_toASCII uidna_toASCII_3_2 +#define uidna_toUnicode uidna_toUnicode_3_2 +#define uiter_current32 uiter_current32_3_2 +#define uiter_getState uiter_getState_3_2 +#define uiter_next32 uiter_next32_3_2 +#define uiter_previous32 uiter_previous32_3_2 +#define uiter_setCharacterIterator uiter_setCharacterIterator_3_2 +#define uiter_setReplaceable uiter_setReplaceable_3_2 +#define uiter_setState uiter_setState_3_2 +#define uiter_setString uiter_setString_3_2 +#define uiter_setUTF16BE uiter_setUTF16BE_3_2 +#define uiter_setUTF8 uiter_setUTF8_3_2 +#define uloc_acceptLanguage uloc_acceptLanguage_3_2 +#define uloc_acceptLanguageFromHTTP uloc_acceptLanguageFromHTTP_3_2 +#define uloc_canonicalize uloc_canonicalize_3_2 +#define uloc_countAvailable uloc_countAvailable_3_2 +#define uloc_getAvailable uloc_getAvailable_3_2 +#define uloc_getBaseName uloc_getBaseName_3_2 +#define uloc_getCountry uloc_getCountry_3_2 +#define uloc_getDefault uloc_getDefault_3_2 +#define uloc_getDisplayCountry uloc_getDisplayCountry_3_2 +#define uloc_getDisplayKeyword uloc_getDisplayKeyword_3_2 +#define uloc_getDisplayKeywordValue uloc_getDisplayKeywordValue_3_2 +#define uloc_getDisplayLanguage uloc_getDisplayLanguage_3_2 +#define uloc_getDisplayName uloc_getDisplayName_3_2 +#define uloc_getDisplayScript uloc_getDisplayScript_3_2 +#define uloc_getDisplayVariant uloc_getDisplayVariant_3_2 +#define uloc_getISO3Country uloc_getISO3Country_3_2 +#define uloc_getISO3Language uloc_getISO3Language_3_2 +#define uloc_getISOCountries uloc_getISOCountries_3_2 +#define uloc_getISOLanguages uloc_getISOLanguages_3_2 +#define uloc_getKeywordValue uloc_getKeywordValue_3_2 +#define uloc_getLCID uloc_getLCID_3_2 +#define uloc_getLanguage uloc_getLanguage_3_2 +#define uloc_getName uloc_getName_3_2 +#define uloc_getParent uloc_getParent_3_2 +#define uloc_getScript uloc_getScript_3_2 +#define uloc_getVariant uloc_getVariant_3_2 +#define uloc_openKeywordList uloc_openKeywordList_3_2 +#define uloc_openKeywords uloc_openKeywords_3_2 +#define uloc_setDefault uloc_setDefault_3_2 +#define uloc_setKeywordValue uloc_setKeywordValue_3_2 +#define ulocdata_getExemplarSet ulocdata_getExemplarSet_3_2 +#define ulocdata_getMeasurementSystem ulocdata_getMeasurementSystem_3_2 +#define ulocdata_getPaperSize ulocdata_getPaperSize_3_2 +#define umsg_applyPattern umsg_applyPattern_3_2 +#define umsg_clone umsg_clone_3_2 +#define umsg_close umsg_close_3_2 +#define umsg_format umsg_format_3_2 +#define umsg_getLocale umsg_getLocale_3_2 +#define umsg_getLocaleByType umsg_getLocaleByType_3_2 +#define umsg_open umsg_open_3_2 +#define umsg_parse umsg_parse_3_2 +#define umsg_setLocale umsg_setLocale_3_2 +#define umsg_toPattern umsg_toPattern_3_2 +#define umsg_vformat umsg_vformat_3_2 +#define umsg_vparse umsg_vparse_3_2 +#define umtx_atomic_dec umtx_atomic_dec_3_2 +#define umtx_atomic_inc umtx_atomic_inc_3_2 +#define umtx_cleanup umtx_cleanup_3_2 +#define umtx_destroy umtx_destroy_3_2 +#define umtx_init umtx_init_3_2 +#define umtx_lock umtx_lock_3_2 +#define umtx_unlock umtx_unlock_3_2 +#define unorm_addPropertyStarts unorm_addPropertyStarts_3_2 +#define unorm_closeIter unorm_closeIter_3_2 +#define unorm_compare unorm_compare_3_2 +#define unorm_compose unorm_compose_3_2 +#define unorm_concatenate unorm_concatenate_3_2 +#define unorm_decompose unorm_decompose_3_2 +#define unorm_getCanonStartSet unorm_getCanonStartSet_3_2 +#define unorm_getCanonicalDecomposition unorm_getCanonicalDecomposition_3_2 +#define unorm_getDecomposition unorm_getDecomposition_3_2 +#define unorm_getFCD16FromCodePoint unorm_getFCD16FromCodePoint_3_2 +#define unorm_getFCDTrie unorm_getFCDTrie_3_2 +#define unorm_getNX unorm_getNX_3_2 +#define unorm_getQuickCheck unorm_getQuickCheck_3_2 +#define unorm_getUnicodeVersion unorm_getUnicodeVersion_3_2 +#define unorm_haveData unorm_haveData_3_2 +#define unorm_internalIsFullCompositionExclusion unorm_internalIsFullCompositionExclusion_3_2 +#define unorm_internalNormalize unorm_internalNormalize_3_2 +#define unorm_internalNormalizeWithNX unorm_internalNormalizeWithNX_3_2 +#define unorm_internalQuickCheck unorm_internalQuickCheck_3_2 +#define unorm_isCanonSafeStart unorm_isCanonSafeStart_3_2 +#define unorm_isNFSkippable unorm_isNFSkippable_3_2 +#define unorm_isNormalized unorm_isNormalized_3_2 +#define unorm_isNormalizedWithOptions unorm_isNormalizedWithOptions_3_2 +#define unorm_next unorm_next_3_2 +#define unorm_normalize unorm_normalize_3_2 +#define unorm_openIter unorm_openIter_3_2 +#define unorm_previous unorm_previous_3_2 +#define unorm_quickCheck unorm_quickCheck_3_2 +#define unorm_quickCheckWithOptions unorm_quickCheckWithOptions_3_2 +#define unorm_setIter unorm_setIter_3_2 +#define unorm_swap unorm_swap_3_2 +#define unum_applyPattern unum_applyPattern_3_2 +#define unum_clone unum_clone_3_2 +#define unum_close unum_close_3_2 +#define unum_countAvailable unum_countAvailable_3_2 +#define unum_format unum_format_3_2 +#define unum_formatDouble unum_formatDouble_3_2 +#define unum_formatDoubleCurrency unum_formatDoubleCurrency_3_2 +#define unum_formatInt64 unum_formatInt64_3_2 +#define unum_getAttribute unum_getAttribute_3_2 +#define unum_getAvailable unum_getAvailable_3_2 +#define unum_getDoubleAttribute unum_getDoubleAttribute_3_2 +#define unum_getLocaleByType unum_getLocaleByType_3_2 +#define unum_getSymbol unum_getSymbol_3_2 +#define unum_getTextAttribute unum_getTextAttribute_3_2 +#define unum_open unum_open_3_2 +#define unum_parse unum_parse_3_2 +#define unum_parseDouble unum_parseDouble_3_2 +#define unum_parseDoubleCurrency unum_parseDoubleCurrency_3_2 +#define unum_parseInt64 unum_parseInt64_3_2 +#define unum_setAttribute unum_setAttribute_3_2 +#define unum_setDoubleAttribute unum_setDoubleAttribute_3_2 +#define unum_setSymbol unum_setSymbol_3_2 +#define unum_setTextAttribute unum_setTextAttribute_3_2 +#define unum_toPattern unum_toPattern_3_2 +#define upname_swap upname_swap_3_2 +#define uprops_getSource uprops_getSource_3_2 +#define uprops_swap uprops_swap_3_2 +#define uprv_asciiFromEbcdic uprv_asciiFromEbcdic_3_2 +#define uprv_asciitolower uprv_asciitolower_3_2 +#define uprv_ceil uprv_ceil_3_2 +#define uprv_cnttab_addContraction uprv_cnttab_addContraction_3_2 +#define uprv_cnttab_changeContraction uprv_cnttab_changeContraction_3_2 +#define uprv_cnttab_changeLastCE uprv_cnttab_changeLastCE_3_2 +#define uprv_cnttab_clone uprv_cnttab_clone_3_2 +#define uprv_cnttab_close uprv_cnttab_close_3_2 +#define uprv_cnttab_constructTable uprv_cnttab_constructTable_3_2 +#define uprv_cnttab_findCE uprv_cnttab_findCE_3_2 +#define uprv_cnttab_findCP uprv_cnttab_findCP_3_2 +#define uprv_cnttab_getCE uprv_cnttab_getCE_3_2 +#define uprv_cnttab_insertContraction uprv_cnttab_insertContraction_3_2 +#define uprv_cnttab_isTailored uprv_cnttab_isTailored_3_2 +#define uprv_cnttab_open uprv_cnttab_open_3_2 +#define uprv_cnttab_setContraction uprv_cnttab_setContraction_3_2 +#define uprv_compareASCIIPropertyNames uprv_compareASCIIPropertyNames_3_2 +#define uprv_compareEBCDICPropertyNames uprv_compareEBCDICPropertyNames_3_2 +#define uprv_compareInvAscii uprv_compareInvAscii_3_2 +#define uprv_compareInvEbcdic uprv_compareInvEbcdic_3_2 +#define uprv_convertToLCID uprv_convertToLCID_3_2 +#define uprv_convertToPosix uprv_convertToPosix_3_2 +#define uprv_copyAscii uprv_copyAscii_3_2 +#define uprv_copyEbcdic uprv_copyEbcdic_3_2 +#define uprv_dtostr uprv_dtostr_3_2 +#define uprv_ebcdicFromAscii uprv_ebcdicFromAscii_3_2 +#define uprv_ebcdictolower uprv_ebcdictolower_3_2 +#define uprv_fabs uprv_fabs_3_2 +#define uprv_floor uprv_floor_3_2 +#define uprv_fmax uprv_fmax_3_2 +#define uprv_fmin uprv_fmin_3_2 +#define uprv_fmod uprv_fmod_3_2 +#define uprv_free uprv_free_3_2 +#define uprv_getCharNameCharacters uprv_getCharNameCharacters_3_2 +#define uprv_getDefaultCodepage uprv_getDefaultCodepage_3_2 +#define uprv_getDefaultLocaleID uprv_getDefaultLocaleID_3_2 +#define uprv_getInfinity uprv_getInfinity_3_2 +#define uprv_getMaxCharNameLength uprv_getMaxCharNameLength_3_2 +#define uprv_getMaxValues uprv_getMaxValues_3_2 +#define uprv_getNaN uprv_getNaN_3_2 +#define uprv_getStaticCurrencyName uprv_getStaticCurrencyName_3_2 +#define uprv_getUTCtime uprv_getUTCtime_3_2 +#define uprv_haveProperties uprv_haveProperties_3_2 +#define uprv_init_collIterate uprv_init_collIterate_3_2 +#define uprv_int32Comparator uprv_int32Comparator_3_2 +#define uprv_isInfinite uprv_isInfinite_3_2 +#define uprv_isInvariantString uprv_isInvariantString_3_2 +#define uprv_isInvariantUString uprv_isInvariantUString_3_2 +#define uprv_isNaN uprv_isNaN_3_2 +#define uprv_isNegativeInfinity uprv_isNegativeInfinity_3_2 +#define uprv_isPositiveInfinity uprv_isPositiveInfinity_3_2 +#define uprv_isRuleWhiteSpace uprv_isRuleWhiteSpace_3_2 +#define uprv_itou uprv_itou_3_2 +#define uprv_loadPropsData uprv_loadPropsData_3_2 +#define uprv_log uprv_log_3_2 +#define uprv_log10 uprv_log10_3_2 +#define uprv_malloc uprv_malloc_3_2 +#define uprv_mapFile uprv_mapFile_3_2 +#define uprv_max uprv_max_3_2 +#define uprv_maxMantissa uprv_maxMantissa_3_2 +#define uprv_min uprv_min_3_2 +#define uprv_modf uprv_modf_3_2 +#define uprv_openRuleWhiteSpaceSet uprv_openRuleWhiteSpaceSet_3_2 +#define uprv_pathIsAbsolute uprv_pathIsAbsolute_3_2 +#define uprv_pow uprv_pow_3_2 +#define uprv_pow10 uprv_pow10_3_2 +#define uprv_realloc uprv_realloc_3_2 +#define uprv_round uprv_round_3_2 +#define uprv_sortArray uprv_sortArray_3_2 +#define uprv_strCompare uprv_strCompare_3_2 +#define uprv_strdup uprv_strdup_3_2 +#define uprv_strndup uprv_strndup_3_2 +#define uprv_syntaxError uprv_syntaxError_3_2 +#define uprv_timezone uprv_timezone_3_2 +#define uprv_toupper uprv_toupper_3_2 +#define uprv_trunc uprv_trunc_3_2 +#define uprv_tzname uprv_tzname_3_2 +#define uprv_tzset uprv_tzset_3_2 +#define uprv_uca_addAnElement uprv_uca_addAnElement_3_2 +#define uprv_uca_assembleTable uprv_uca_assembleTable_3_2 +#define uprv_uca_canonicalClosure uprv_uca_canonicalClosure_3_2 +#define uprv_uca_cloneTempTable uprv_uca_cloneTempTable_3_2 +#define uprv_uca_closeTempTable uprv_uca_closeTempTable_3_2 +#define uprv_uca_getCodePointFromRaw uprv_uca_getCodePointFromRaw_3_2 +#define uprv_uca_getImplicitFromRaw uprv_uca_getImplicitFromRaw_3_2 +#define uprv_uca_getImplicitPrimary uprv_uca_getImplicitPrimary_3_2 +#define uprv_uca_getRawFromCodePoint uprv_uca_getRawFromCodePoint_3_2 +#define uprv_uca_getRawFromImplicit uprv_uca_getRawFromImplicit_3_2 +#define uprv_uca_initImplicitConstants uprv_uca_initImplicitConstants_3_2 +#define uprv_uca_initTempTable uprv_uca_initTempTable_3_2 +#define uprv_uint16Comparator uprv_uint16Comparator_3_2 +#define uprv_uint32Comparator uprv_uint32Comparator_3_2 +#define uprv_unmapFile uprv_unmapFile_3_2 +#define uregex_appendReplacement uregex_appendReplacement_3_2 +#define uregex_appendTail uregex_appendTail_3_2 +#define uregex_clone uregex_clone_3_2 +#define uregex_close uregex_close_3_2 +#define uregex_end uregex_end_3_2 +#define uregex_find uregex_find_3_2 +#define uregex_findNext uregex_findNext_3_2 +#define uregex_flags uregex_flags_3_2 +#define uregex_getText uregex_getText_3_2 +#define uregex_group uregex_group_3_2 +#define uregex_groupCount uregex_groupCount_3_2 +#define uregex_lookingAt uregex_lookingAt_3_2 +#define uregex_matches uregex_matches_3_2 +#define uregex_open uregex_open_3_2 +#define uregex_openC uregex_openC_3_2 +#define uregex_pattern uregex_pattern_3_2 +#define uregex_replaceAll uregex_replaceAll_3_2 +#define uregex_replaceFirst uregex_replaceFirst_3_2 +#define uregex_reset uregex_reset_3_2 +#define uregex_setText uregex_setText_3_2 +#define uregex_split uregex_split_3_2 +#define uregex_start uregex_start_3_2 +#define ures_appendResPath ures_appendResPath_3_2 +#define ures_close ures_close_3_2 +#define ures_copyResb ures_copyResb_3_2 +#define ures_countArrayItems ures_countArrayItems_3_2 +#define ures_findResource ures_findResource_3_2 +#define ures_findSubResource ures_findSubResource_3_2 +#define ures_freeResPath ures_freeResPath_3_2 +#define ures_getBinary ures_getBinary_3_2 +#define ures_getByIndex ures_getByIndex_3_2 +#define ures_getByKey ures_getByKey_3_2 +#define ures_getByKeyWithFallback ures_getByKeyWithFallback_3_2 +#define ures_getFunctionalEquivalent ures_getFunctionalEquivalent_3_2 +#define ures_getInt ures_getInt_3_2 +#define ures_getIntVector ures_getIntVector_3_2 +#define ures_getKey ures_getKey_3_2 +#define ures_getKeywordValues ures_getKeywordValues_3_2 +#define ures_getLocale ures_getLocale_3_2 +#define ures_getLocaleByType ures_getLocaleByType_3_2 +#define ures_getName ures_getName_3_2 +#define ures_getNextResource ures_getNextResource_3_2 +#define ures_getNextString ures_getNextString_3_2 +#define ures_getPath ures_getPath_3_2 +#define ures_getSize ures_getSize_3_2 +#define ures_getString ures_getString_3_2 +#define ures_getStringByIndex ures_getStringByIndex_3_2 +#define ures_getStringByKey ures_getStringByKey_3_2 +#define ures_getType ures_getType_3_2 +#define ures_getUInt ures_getUInt_3_2 +#define ures_getVersion ures_getVersion_3_2 +#define ures_getVersionNumber ures_getVersionNumber_3_2 +#define ures_hasNext ures_hasNext_3_2 +#define ures_initStackObject ures_initStackObject_3_2 +#define ures_open ures_open_3_2 +#define ures_openAvailableLocales ures_openAvailableLocales_3_2 +#define ures_openDirect ures_openDirect_3_2 +#define ures_openFillIn ures_openFillIn_3_2 +#define ures_openU ures_openU_3_2 +#define ures_resetIterator ures_resetIterator_3_2 +#define ures_swap ures_swap_3_2 +#define uscript_closeRun uscript_closeRun_3_2 +#define uscript_getCode uscript_getCode_3_2 +#define uscript_getName uscript_getName_3_2 +#define uscript_getScript uscript_getScript_3_2 +#define uscript_getShortName uscript_getShortName_3_2 +#define uscript_nextRun uscript_nextRun_3_2 +#define uscript_openRun uscript_openRun_3_2 +#define uscript_resetRun uscript_resetRun_3_2 +#define uscript_setRunText uscript_setRunText_3_2 +#define usearch_close usearch_close_3_2 +#define usearch_first usearch_first_3_2 +#define usearch_following usearch_following_3_2 +#define usearch_getAttribute usearch_getAttribute_3_2 +#define usearch_getBreakIterator usearch_getBreakIterator_3_2 +#define usearch_getCollator usearch_getCollator_3_2 +#define usearch_getMatchedLength usearch_getMatchedLength_3_2 +#define usearch_getMatchedStart usearch_getMatchedStart_3_2 +#define usearch_getMatchedText usearch_getMatchedText_3_2 +#define usearch_getOffset usearch_getOffset_3_2 +#define usearch_getPattern usearch_getPattern_3_2 +#define usearch_getText usearch_getText_3_2 +#define usearch_handleNextCanonical usearch_handleNextCanonical_3_2 +#define usearch_handleNextExact usearch_handleNextExact_3_2 +#define usearch_handlePreviousCanonical usearch_handlePreviousCanonical_3_2 +#define usearch_handlePreviousExact usearch_handlePreviousExact_3_2 +#define usearch_last usearch_last_3_2 +#define usearch_next usearch_next_3_2 +#define usearch_open usearch_open_3_2 +#define usearch_openFromCollator usearch_openFromCollator_3_2 +#define usearch_preceding usearch_preceding_3_2 +#define usearch_previous usearch_previous_3_2 +#define usearch_reset usearch_reset_3_2 +#define usearch_setAttribute usearch_setAttribute_3_2 +#define usearch_setBreakIterator usearch_setBreakIterator_3_2 +#define usearch_setCollator usearch_setCollator_3_2 +#define usearch_setOffset usearch_setOffset_3_2 +#define usearch_setPattern usearch_setPattern_3_2 +#define usearch_setText usearch_setText_3_2 +#define userv_deleteStringPair userv_deleteStringPair_3_2 +#define uset_add uset_add_3_2 +#define uset_addAll uset_addAll_3_2 +#define uset_addRange uset_addRange_3_2 +#define uset_addString uset_addString_3_2 +#define uset_applyIntPropertyValue uset_applyIntPropertyValue_3_2 +#define uset_applyPattern uset_applyPattern_3_2 +#define uset_applyPropertyAlias uset_applyPropertyAlias_3_2 +#define uset_charAt uset_charAt_3_2 +#define uset_clear uset_clear_3_2 +#define uset_close uset_close_3_2 +#define uset_compact uset_compact_3_2 +#define uset_complement uset_complement_3_2 +#define uset_complementAll uset_complementAll_3_2 +#define uset_contains uset_contains_3_2 +#define uset_containsAll uset_containsAll_3_2 +#define uset_containsNone uset_containsNone_3_2 +#define uset_containsRange uset_containsRange_3_2 +#define uset_containsSome uset_containsSome_3_2 +#define uset_containsString uset_containsString_3_2 +#define uset_equals uset_equals_3_2 +#define uset_getItem uset_getItem_3_2 +#define uset_getItemCount uset_getItemCount_3_2 +#define uset_getSerializedRange uset_getSerializedRange_3_2 +#define uset_getSerializedRangeCount uset_getSerializedRangeCount_3_2 +#define uset_getSerializedSet uset_getSerializedSet_3_2 +#define uset_indexOf uset_indexOf_3_2 +#define uset_isEmpty uset_isEmpty_3_2 +#define uset_open uset_open_3_2 +#define uset_openPattern uset_openPattern_3_2 +#define uset_openPatternOptions uset_openPatternOptions_3_2 +#define uset_remove uset_remove_3_2 +#define uset_removeAll uset_removeAll_3_2 +#define uset_removeRange uset_removeRange_3_2 +#define uset_removeString uset_removeString_3_2 +#define uset_resemblesPattern uset_resemblesPattern_3_2 +#define uset_retain uset_retain_3_2 +#define uset_retainAll uset_retainAll_3_2 +#define uset_serialize uset_serialize_3_2 +#define uset_serializedContains uset_serializedContains_3_2 +#define uset_set uset_set_3_2 +#define uset_setSerializedToOne uset_setSerializedToOne_3_2 +#define uset_size uset_size_3_2 +#define uset_toPattern uset_toPattern_3_2 +#define usprep_close usprep_close_3_2 +#define usprep_open usprep_open_3_2 +#define usprep_prepare usprep_prepare_3_2 +#define usprep_swap usprep_swap_3_2 +#define ustr_foldCase ustr_foldCase_3_2 +#define ustr_toLower ustr_toLower_3_2 +#define ustr_toTitle ustr_toTitle_3_2 +#define ustr_toUpper ustr_toUpper_3_2 +#define utf8_appendCharSafeBody utf8_appendCharSafeBody_3_2 +#define utf8_back1SafeBody utf8_back1SafeBody_3_2 +#define utf8_countTrailBytes utf8_countTrailBytes_3_2 +#define utf8_nextCharSafeBody utf8_nextCharSafeBody_3_2 +#define utf8_prevCharSafeBody utf8_prevCharSafeBody_3_2 +#define utmscale_fromInt64 utmscale_fromInt64_3_2 +#define utmscale_getTimeScaleValue utmscale_getTimeScaleValue_3_2 +#define utmscale_toInt64 utmscale_toInt64_3_2 +#define utrace_cleanup utrace_cleanup_3_2 +#define utrace_data utrace_data_3_2 +#define utrace_entry utrace_entry_3_2 +#define utrace_exit utrace_exit_3_2 +#define utrace_format utrace_format_3_2 +#define utrace_functionName utrace_functionName_3_2 +#define utrace_getFunctions utrace_getFunctions_3_2 +#define utrace_getLevel utrace_getLevel_3_2 +#define utrace_level utrace_level_3_2 +#define utrace_setFunctions utrace_setFunctions_3_2 +#define utrace_setLevel utrace_setLevel_3_2 +#define utrace_vformat utrace_vformat_3_2 +#define utrans_clone utrans_clone_3_2 +#define utrans_close utrans_close_3_2 +#define utrans_countAvailableIDs utrans_countAvailableIDs_3_2 +#define utrans_getAvailableID utrans_getAvailableID_3_2 +#define utrans_getID utrans_getID_3_2 +#define utrans_getUnicodeID utrans_getUnicodeID_3_2 +#define utrans_open utrans_open_3_2 +#define utrans_openIDs utrans_openIDs_3_2 +#define utrans_openInverse utrans_openInverse_3_2 +#define utrans_openU utrans_openU_3_2 +#define utrans_register utrans_register_3_2 +#define utrans_rep_caseContextIterator utrans_rep_caseContextIterator_3_2 +#define utrans_setFilter utrans_setFilter_3_2 +#define utrans_trans utrans_trans_3_2 +#define utrans_transIncremental utrans_transIncremental_3_2 +#define utrans_transIncrementalUChars utrans_transIncrementalUChars_3_2 +#define utrans_transUChars utrans_transUChars_3_2 +#define utrans_unregister utrans_unregister_3_2 +#define utrans_unregisterID utrans_unregisterID_3_2 +#define utrie_clone utrie_clone_3_2 +#define utrie_close utrie_close_3_2 +#define utrie_enum utrie_enum_3_2 +#define utrie_get32 utrie_get32_3_2 +#define utrie_getData utrie_getData_3_2 +#define utrie_open utrie_open_3_2 +#define utrie_serialize utrie_serialize_3_2 +#define utrie_set32 utrie_set32_3_2 +#define utrie_setRange32 utrie_setRange32_3_2 +#define utrie_swap utrie_swap_3_2 +#define utrie_unserialize utrie_unserialize_3_2 +/* C++ class names renaming defines */ + +#ifdef XP_CPLUSPLUS +#if !U_HAVE_NAMESPACE + +#define AbsoluteValueSubstitution AbsoluteValueSubstitution_3_2 +#define AlternateSubstitutionSubtable AlternateSubstitutionSubtable_3_2 +#define AnchorTable AnchorTable_3_2 +#define AnyTransliterator AnyTransliterator_3_2 +#define ArabicOpenTypeLayoutEngine ArabicOpenTypeLayoutEngine_3_2 +#define ArabicShaping ArabicShaping_3_2 +#define BasicCalendarFactory BasicCalendarFactory_3_2 +#define BinarySearchLookupTable BinarySearchLookupTable_3_2 +#define BreakDictionary BreakDictionary_3_2 +#define BreakIterator BreakIterator_3_2 +#define BuddhistCalendar BuddhistCalendar_3_2 +#define CFactory CFactory_3_2 +#define Calendar Calendar_3_2 +#define CalendarAstronomer CalendarAstronomer_3_2 +#define CalendarCache CalendarCache_3_2 +#define CalendarData CalendarData_3_2 +#define CalendarService CalendarService_3_2 +#define CanonShaping CanonShaping_3_2 +#define CanonicalIterator CanonicalIterator_3_2 +#define CaseMapTransliterator CaseMapTransliterator_3_2 +#define ChainingContextualSubstitutionFormat1Subtable ChainingContextualSubstitutionFormat1Subtable_3_2 +#define ChainingContextualSubstitutionFormat2Subtable ChainingContextualSubstitutionFormat2Subtable_3_2 +#define ChainingContextualSubstitutionFormat3Subtable ChainingContextualSubstitutionFormat3Subtable_3_2 +#define ChainingContextualSubstitutionSubtable ChainingContextualSubstitutionSubtable_3_2 +#define CharSubstitutionFilter CharSubstitutionFilter_3_2 +#define CharacterIterator CharacterIterator_3_2 +#define ChoiceFormat ChoiceFormat_3_2 +#define ClassDefFormat1Table ClassDefFormat1Table_3_2 +#define ClassDefFormat2Table ClassDefFormat2Table_3_2 +#define ClassDefinitionTable ClassDefinitionTable_3_2 +#define CollationElementIterator CollationElementIterator_3_2 +#define CollationKey CollationKey_3_2 +#define Collator Collator_3_2 +#define CollatorFactory CollatorFactory_3_2 +#define CompoundTransliterator CompoundTransliterator_3_2 +#define ContextualGlyphSubstitutionProcessor ContextualGlyphSubstitutionProcessor_3_2 +#define ContextualSubstitutionBase ContextualSubstitutionBase_3_2 +#define ContextualSubstitutionFormat1Subtable ContextualSubstitutionFormat1Subtable_3_2 +#define ContextualSubstitutionFormat2Subtable ContextualSubstitutionFormat2Subtable_3_2 +#define ContextualSubstitutionFormat3Subtable ContextualSubstitutionFormat3Subtable_3_2 +#define ContextualSubstitutionSubtable ContextualSubstitutionSubtable_3_2 +#define CoverageFormat1Table CoverageFormat1Table_3_2 +#define CoverageFormat2Table CoverageFormat2Table_3_2 +#define CoverageTable CoverageTable_3_2 +#define CurrencyAmount CurrencyAmount_3_2 +#define CurrencyFormat CurrencyFormat_3_2 +#define CurrencyUnit CurrencyUnit_3_2 +#define CursiveAttachmentSubtable CursiveAttachmentSubtable_3_2 +#define DateFormat DateFormat_3_2 +#define DateFormatSymbols DateFormatSymbols_3_2 +#define DecimalFormat DecimalFormat_3_2 +#define DecimalFormatSymbols DecimalFormatSymbols_3_2 +#define DefaultCalendarFactory DefaultCalendarFactory_3_2 +#define DefaultCharMapper DefaultCharMapper_3_2 +#define DeviceTable DeviceTable_3_2 +#define DictionaryBasedBreakIterator DictionaryBasedBreakIterator_3_2 +#define DictionaryBasedBreakIteratorTables DictionaryBasedBreakIteratorTables_3_2 +#define DigitList DigitList_3_2 +#define Entry Entry_3_2 +#define EnumToOffset EnumToOffset_3_2 +#define EscapeTransliterator EscapeTransliterator_3_2 +#define EventListener EventListener_3_2 +#define ExtensionSubtable ExtensionSubtable_3_2 +#define FeatureListTable FeatureListTable_3_2 +#define FieldPosition FieldPosition_3_2 +#define FontRuns FontRuns_3_2 +#define Format Format_3_2 +#define Format1AnchorTable Format1AnchorTable_3_2 +#define Format2AnchorTable Format2AnchorTable_3_2 +#define Format3AnchorTable Format3AnchorTable_3_2 +#define Formattable Formattable_3_2 +#define ForwardCharacterIterator ForwardCharacterIterator_3_2 +#define FractionalPartSubstitution FractionalPartSubstitution_3_2 +#define FunctionReplacer FunctionReplacer_3_2 +#define GDEFMarkFilter GDEFMarkFilter_3_2 +#define GXLayoutEngine GXLayoutEngine_3_2 +#define GlyphDefinitionTableHeader GlyphDefinitionTableHeader_3_2 +#define GlyphIterator GlyphIterator_3_2 +#define GlyphLookupTableHeader GlyphLookupTableHeader_3_2 +#define GlyphPositioningLookupProcessor GlyphPositioningLookupProcessor_3_2 +#define GlyphPositioningTableHeader GlyphPositioningTableHeader_3_2 +#define GlyphSubstitutionLookupProcessor GlyphSubstitutionLookupProcessor_3_2 +#define GlyphSubstitutionTableHeader GlyphSubstitutionTableHeader_3_2 +#define Grego Grego_3_2 +#define GregorianCalendar GregorianCalendar_3_2 +#define HanOpenTypeLayoutEngine HanOpenTypeLayoutEngine_3_2 +#define HebrewCalendar HebrewCalendar_3_2 +#define ICUBreakIteratorFactory ICUBreakIteratorFactory_3_2 +#define ICUBreakIteratorService ICUBreakIteratorService_3_2 +#define ICUCollatorFactory ICUCollatorFactory_3_2 +#define ICUCollatorService ICUCollatorService_3_2 +#define ICULayoutEngine ICULayoutEngine_3_2 +#define ICULocaleService ICULocaleService_3_2 +#define ICUNotifier ICUNotifier_3_2 +#define ICUNumberFormatFactory ICUNumberFormatFactory_3_2 +#define ICUNumberFormatService ICUNumberFormatService_3_2 +#define ICUResourceBundleFactory ICUResourceBundleFactory_3_2 +#define ICUService ICUService_3_2 +#define ICUServiceFactory ICUServiceFactory_3_2 +#define ICUServiceKey ICUServiceKey_3_2 +#define ICU_Utility ICU_Utility_3_2 +#define IndicClassTable IndicClassTable_3_2 +#define IndicOpenTypeLayoutEngine IndicOpenTypeLayoutEngine_3_2 +#define IndicRearrangementProcessor IndicRearrangementProcessor_3_2 +#define IndicReordering IndicReordering_3_2 +#define IntegralPartSubstitution IntegralPartSubstitution_3_2 +#define IslamicCalendar IslamicCalendar_3_2 +#define JapaneseCalendar JapaneseCalendar_3_2 +#define KeywordEnumeration KeywordEnumeration_3_2 +#define LECharMapper LECharMapper_3_2 +#define LEFontInstance LEFontInstance_3_2 +#define LEGlyphFilter LEGlyphFilter_3_2 +#define LEGlyphStorage LEGlyphStorage_3_2 +#define LEInsertionCallback LEInsertionCallback_3_2 +#define LEInsertionList LEInsertionList_3_2 +#define LXUtilities LXUtilities_3_2 +#define LayoutEngine LayoutEngine_3_2 +#define LigatureSubstitutionProcessor LigatureSubstitutionProcessor_3_2 +#define LigatureSubstitutionSubtable LigatureSubstitutionSubtable_3_2 +#define LocDataParser LocDataParser_3_2 +#define Locale Locale_3_2 +#define LocaleBased LocaleBased_3_2 +#define LocaleKey LocaleKey_3_2 +#define LocaleKeyFactory LocaleKeyFactory_3_2 +#define LocaleRuns LocaleRuns_3_2 +#define LocaleUtility LocaleUtility_3_2 +#define LocalizationInfo LocalizationInfo_3_2 +#define LookupListTable LookupListTable_3_2 +#define LookupProcessor LookupProcessor_3_2 +#define LookupSubtable LookupSubtable_3_2 +#define LookupTable LookupTable_3_2 +#define LowercaseTransliterator LowercaseTransliterator_3_2 +#define MPreFixups MPreFixups_3_2 +#define MarkArray MarkArray_3_2 +#define MarkToBasePositioningSubtable MarkToBasePositioningSubtable_3_2 +#define MarkToLigaturePositioningSubtable MarkToLigaturePositioningSubtable_3_2 +#define MarkToMarkPositioningSubtable MarkToMarkPositioningSubtable_3_2 +#define Math Math_3_2 +#define Measure Measure_3_2 +#define MeasureFormat MeasureFormat_3_2 +#define MeasureUnit MeasureUnit_3_2 +#define MessageFormat MessageFormat_3_2 +#define MessageFormatAdapter MessageFormatAdapter_3_2 +#define ModulusSubstitution ModulusSubstitution_3_2 +#define MoonRiseSetCoordFunc MoonRiseSetCoordFunc_3_2 +#define MoonTimeAngleFunc MoonTimeAngleFunc_3_2 +#define MorphSubtableHeader MorphSubtableHeader_3_2 +#define MorphTableHeader MorphTableHeader_3_2 +#define MultipleSubstitutionSubtable MultipleSubstitutionSubtable_3_2 +#define MultiplierSubstitution MultiplierSubstitution_3_2 +#define NFFactory NFFactory_3_2 +#define NFRule NFRule_3_2 +#define NFRuleSet NFRuleSet_3_2 +#define NFSubstitution NFSubstitution_3_2 +#define NameToEnum NameToEnum_3_2 +#define NameUnicodeTransliterator NameUnicodeTransliterator_3_2 +#define NonContextualGlyphSubstitutionProcessor NonContextualGlyphSubstitutionProcessor_3_2 +#define NonContiguousEnumToOffset NonContiguousEnumToOffset_3_2 +#define NormalizationTransliterator NormalizationTransliterator_3_2 +#define Normalizer Normalizer_3_2 +#define NullSubstitution NullSubstitution_3_2 +#define NullTransliterator NullTransliterator_3_2 +#define NumberFormat NumberFormat_3_2 +#define NumberFormatFactory NumberFormatFactory_3_2 +#define NumeratorSubstitution NumeratorSubstitution_3_2 +#define OlsonTimeZone OlsonTimeZone_3_2 +#define OpenTypeLayoutEngine OpenTypeLayoutEngine_3_2 +#define OpenTypeUtilities OpenTypeUtilities_3_2 +#define PairPositioningFormat1Subtable PairPositioningFormat1Subtable_3_2 +#define PairPositioningFormat2Subtable PairPositioningFormat2Subtable_3_2 +#define PairPositioningSubtable PairPositioningSubtable_3_2 +#define ParagraphLayout ParagraphLayout_3_2 +#define ParseData ParseData_3_2 +#define ParsePosition ParsePosition_3_2 +#define PropertyAliases PropertyAliases_3_2 +#define Quantifier Quantifier_3_2 +#define RBBIDataWrapper RBBIDataWrapper_3_2 +#define RBBINode RBBINode_3_2 +#define RBBIRuleBuilder RBBIRuleBuilder_3_2 +#define RBBIRuleScanner RBBIRuleScanner_3_2 +#define RBBISetBuilder RBBISetBuilder_3_2 +#define RBBIStateDescriptor RBBIStateDescriptor_3_2 +#define RBBISymbolTable RBBISymbolTable_3_2 +#define RBBISymbolTableEntry RBBISymbolTableEntry_3_2 +#define RBBITableBuilder RBBITableBuilder_3_2 +#define RangeDescriptor RangeDescriptor_3_2 +#define RegexCompile RegexCompile_3_2 +#define RegexMatcher RegexMatcher_3_2 +#define RegexPattern RegexPattern_3_2 +#define RegexStaticSets RegexStaticSets_3_2 +#define RemoveTransliterator RemoveTransliterator_3_2 +#define Replaceable Replaceable_3_2 +#define ReplaceableGlue ReplaceableGlue_3_2 +#define ResourceBundle ResourceBundle_3_2 +#define RiseSetCoordFunc RiseSetCoordFunc_3_2 +#define RuleBasedBreakIterator RuleBasedBreakIterator_3_2 +#define RuleBasedCollator RuleBasedCollator_3_2 +#define RuleBasedNumberFormat RuleBasedNumberFormat_3_2 +#define RuleBasedTransliterator RuleBasedTransliterator_3_2 +#define RuleCharacterIterator RuleCharacterIterator_3_2 +#define RuleHalf RuleHalf_3_2 +#define RunArray RunArray_3_2 +#define SameValueSubstitution SameValueSubstitution_3_2 +#define ScriptListTable ScriptListTable_3_2 +#define ScriptRunIterator ScriptRunIterator_3_2 +#define ScriptTable ScriptTable_3_2 +#define SearchIterator SearchIterator_3_2 +#define SegmentArrayProcessor SegmentArrayProcessor_3_2 +#define SegmentSingleProcessor SegmentSingleProcessor_3_2 +#define ServiceEnumeration ServiceEnumeration_3_2 +#define ServiceListener ServiceListener_3_2 +#define SimpleArrayProcessor SimpleArrayProcessor_3_2 +#define SimpleDateFormat SimpleDateFormat_3_2 +#define SimpleFactory SimpleFactory_3_2 +#define SimpleLocaleKeyFactory SimpleLocaleKeyFactory_3_2 +#define SimpleNumberFormatFactory SimpleNumberFormatFactory_3_2 +#define SimpleTimeZone SimpleTimeZone_3_2 +#define SinglePositioningFormat1Subtable SinglePositioningFormat1Subtable_3_2 +#define SinglePositioningFormat2Subtable SinglePositioningFormat2Subtable_3_2 +#define SinglePositioningSubtable SinglePositioningSubtable_3_2 +#define SingleSubstitutionFormat1Subtable SingleSubstitutionFormat1Subtable_3_2 +#define SingleSubstitutionFormat2Subtable SingleSubstitutionFormat2Subtable_3_2 +#define SingleSubstitutionSubtable SingleSubstitutionSubtable_3_2 +#define SingleTableProcessor SingleTableProcessor_3_2 +#define Spec Spec_3_2 +#define StateTableProcessor StateTableProcessor_3_2 +#define StringCharacterIterator StringCharacterIterator_3_2 +#define StringEnumeration StringEnumeration_3_2 +#define StringLocalizationInfo StringLocalizationInfo_3_2 +#define StringMatcher StringMatcher_3_2 +#define StringPair StringPair_3_2 +#define StringReplacer StringReplacer_3_2 +#define StringSearch StringSearch_3_2 +#define StyleRuns StyleRuns_3_2 +#define SubstitutionLookup SubstitutionLookup_3_2 +#define SubtableProcessor SubtableProcessor_3_2 +#define SunTimeAngleFunc SunTimeAngleFunc_3_2 +#define SymbolTable SymbolTable_3_2 +#define TZEnumeration TZEnumeration_3_2 +#define ThaiLayoutEngine ThaiLayoutEngine_3_2 +#define ThaiShaping ThaiShaping_3_2 +#define TimeZone TimeZone_3_2 +#define TitlecaseTransliterator TitlecaseTransliterator_3_2 +#define TransliterationRule TransliterationRule_3_2 +#define TransliterationRuleData TransliterationRuleData_3_2 +#define TransliterationRuleSet TransliterationRuleSet_3_2 +#define Transliterator Transliterator_3_2 +#define TransliteratorAlias TransliteratorAlias_3_2 +#define TransliteratorIDParser TransliteratorIDParser_3_2 +#define TransliteratorParser TransliteratorParser_3_2 +#define TransliteratorRegistry TransliteratorRegistry_3_2 +#define TrimmedArrayProcessor TrimmedArrayProcessor_3_2 +#define UCharCharacterIterator UCharCharacterIterator_3_2 +#define UMemory UMemory_3_2 +#define UObject UObject_3_2 +#define UStack UStack_3_2 +#define UStringEnumeration UStringEnumeration_3_2 +#define UVector UVector_3_2 +#define UVector32 UVector32_3_2 +#define UnescapeTransliterator UnescapeTransliterator_3_2 +#define UnicodeArabicOpenTypeLayoutEngine UnicodeArabicOpenTypeLayoutEngine_3_2 +#define UnicodeFilter UnicodeFilter_3_2 +#define UnicodeFunctor UnicodeFunctor_3_2 +#define UnicodeMatcher UnicodeMatcher_3_2 +#define UnicodeNameTransliterator UnicodeNameTransliterator_3_2 +#define UnicodeReplacer UnicodeReplacer_3_2 +#define UnicodeSet UnicodeSet_3_2 +#define UnicodeSetIterator UnicodeSetIterator_3_2 +#define UnicodeString UnicodeString_3_2 +#define UppercaseTransliterator UppercaseTransliterator_3_2 +#define ValueRecord ValueRecord_3_2 +#define ValueRuns ValueRuns_3_2 +#define locale_set_default_internal locale_set_default_internal_3_2 +#define uprv_parseCurrency uprv_parseCurrency_3_2 +#define util64_fromDouble util64_fromDouble_3_2 +#define util64_pow util64_pow_3_2 +#define util64_tou util64_tou_3_2 +#define util64_utoi util64_utoi_3_2 + +#endif +#endif + +#endif + +#endif diff --git a/icu/unicode/ustring.h b/icu/unicode/ustring.h new file mode 100644 index 0000000..6ebb6fb --- /dev/null +++ b/icu/unicode/ustring.h @@ -0,0 +1,1320 @@ +/* +********************************************************************** +* Copyright (C) 1998-2004, International Business Machines +* Corporation and others. All Rights Reserved. +********************************************************************** +* +* File ustring.h +* +* Modification History: +* +* Date Name Description +* 12/07/98 bertrand Creation. +****************************************************************************** +*/ + +#ifndef USTRING_H +#define USTRING_H + +#include "unicode/utypes.h" +#include "unicode/putil.h" +#include "unicode/uiter.h" + +/** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. @stable ICU 2.1*/ +#ifndef UBRK_TYPEDEF_UBREAK_ITERATOR +# define UBRK_TYPEDEF_UBREAK_ITERATOR + typedef void UBreakIterator; +#endif + +/** + * \file + * \brief C API: Unicode string handling functions + * + * These C API functions provide general Unicode string handling. + * + * Some functions are equivalent in name, signature, and behavior to the ANSI C + * functions. (For example, they do not check for bad arguments like NULL string pointers.) + * In some cases, only the thread-safe variant of such a function is implemented here + * (see u_strtok_r()). + * + * Other functions provide more Unicode-specific functionality like locale-specific + * upper/lower-casing and string comparison in code point order. + * + * ICU uses 16-bit Unicode (UTF-16) in the form of arrays of UChar code units. + * UTF-16 encodes each Unicode code point with either one or two UChar code units. + * (This is the default form of Unicode, and a forward-compatible extension of the original, + * fixed-width form that was known as UCS-2. UTF-16 superseded UCS-2 with Unicode 2.0 + * in 1996.) + * + * Some APIs accept a 32-bit UChar32 value for a single code point. + * + * ICU also handles 16-bit Unicode text with unpaired surrogates. + * Such text is not well-formed UTF-16. + * Code-point-related functions treat unpaired surrogates as surrogate code points, + * i.e., as separate units. + * + * Although UTF-16 is a variable-width encoding form (like some legacy multi-byte encodings), + * it is much more efficient even for random access because the code unit values + * for single-unit characters vs. lead units vs. trail units are completely disjoint. + * This means that it is easy to determine character (code point) boundaries from + * random offsets in the string. + * + * Unicode (UTF-16) string processing is optimized for the single-unit case. + * Although it is important to support supplementary characters + * (which use pairs of lead/trail code units called "surrogates"), + * their occurrence is rare. Almost all characters in modern use require only + * a single UChar code unit (i.e., their code point values are <=0xffff). + * + * For more details see the User Guide Strings chapter (http://oss.software.ibm.com/icu/userguide/strings.html). + * For a discussion of the handling of unpaired surrogates see also + * Jitterbug 2145 and its icu mailing list proposal on 2002-sep-18. + */ + +/** + * Determine the length of an array of UChar. + * + * @param s The array of UChars, NULL (U+0000) terminated. + * @return The number of UChars in chars, minus the terminator. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strlen(const UChar *s); + +/** + * Count Unicode code points in the length UChar code units of the string. + * A code point may occupy either one or two UChar code units. + * Counting code points involves reading all code units. + * + * This functions is basically the inverse of the U16_FWD_N() macro (see utf.h). + * + * @param s The input string. + * @param length The number of UChar code units to be checked, or -1 to count all + * code points before the first NUL (U+0000). + * @return The number of code points in the specified code units. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_countChar32(const UChar *s, int32_t length); + +/** + * Check if the string contains more Unicode code points than a certain number. + * This is more efficient than counting all code points in the entire string + * and comparing that number with a threshold. + * This function may not need to scan the string at all if the length is known + * (not -1 for NUL-termination) and falls within a certain range, and + * never needs to count more than 'number+1' code points. + * Logically equivalent to (u_countChar32(s, length)>number). + * A Unicode code point may occupy either one or two UChar code units. + * + * @param s The input string. + * @param length The length of the string, or -1 if it is NUL-terminated. + * @param number The number of code points in the string is compared against + * the 'number' parameter. + * @return Boolean value for whether the string contains more Unicode code points + * than 'number'. Same as (u_countChar32(s, length)>number). + * @stable ICU 2.4 + */ +U_STABLE UBool U_EXPORT2 +u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number); + +/** + * Concatenate two ustrings. Appends a copy of src, + * including the null terminator, to dst. The initial copied + * character from src overwrites the null terminator in dst. + * + * @param dst The destination string. + * @param src The source string. + * @return A pointer to dst. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_strcat(UChar *dst, + const UChar *src); + +/** + * Concatenate two ustrings. + * Appends at most n characters from src to dst. + * Adds a terminating NUL. + * If src is too long, then only n-1 characters will be copied + * before the terminating NUL. + * If n<=0 then dst is not modified. + * + * @param dst The destination string. + * @param src The source string. + * @param n The maximum number of characters to compare. + * @return A pointer to dst. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_strncat(UChar *dst, + const UChar *src, + int32_t n); + +/** + * Find the first occurrence of a substring in a string. + * The substring is found at code point boundaries. + * That means that if the substring begins with + * a trail surrogate or ends with a lead surrogate, + * then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against + * halves of surrogate pairs. + * + * @param s The string to search (NUL-terminated). + * @param substring The substring to find (NUL-terminated). + * @return A pointer to the first occurrence of substring in s, + * or s itself if the substring is empty, + * or NULL if substring is not in s. + * @stable ICU 2.0 + * + * @see u_strrstr + * @see u_strFindFirst + * @see u_strFindLast + */ +U_STABLE UChar * U_EXPORT2 +u_strstr(const UChar *s, const UChar *substring); + +/** + * Find the first occurrence of a substring in a string. + * The substring is found at code point boundaries. + * That means that if the substring begins with + * a trail surrogate or ends with a lead surrogate, + * then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against + * halves of surrogate pairs. + * + * @param s The string to search. + * @param length The length of s (number of UChars), or -1 if it is NUL-terminated. + * @param substring The substring to find (NUL-terminated). + * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated. + * @return A pointer to the first occurrence of substring in s, + * or s itself if the substring is empty, + * or NULL if substring is not in s. + * @stable ICU 2.4 + * + * @see u_strstr + * @see u_strFindLast + */ +U_STABLE UChar * U_EXPORT2 +u_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t subLength); + +/** + * Find the first occurrence of a BMP code point in a string. + * A surrogate code point is found only if its match in the text is not + * part of a surrogate pair. + * A NUL character is found at the string terminator. + * + * @param s The string to search (NUL-terminated). + * @param c The BMP code point to find. + * @return A pointer to the first occurrence of c in s + * or NULL if c is not in s. + * @stable ICU 2.0 + * + * @see u_strchr32 + * @see u_memchr + * @see u_strstr + * @see u_strFindFirst + */ +U_STABLE UChar * U_EXPORT2 +u_strchr(const UChar *s, UChar c); + +/** + * Find the first occurrence of a code point in a string. + * A surrogate code point is found only if its match in the text is not + * part of a surrogate pair. + * A NUL character is found at the string terminator. + * + * @param s The string to search (NUL-terminated). + * @param c The code point to find. + * @return A pointer to the first occurrence of c in s + * or NULL if c is not in s. + * @stable ICU 2.0 + * + * @see u_strchr + * @see u_memchr32 + * @see u_strstr + * @see u_strFindFirst + */ +U_STABLE UChar * U_EXPORT2 +u_strchr32(const UChar *s, UChar32 c); + +/** + * Find the last occurrence of a substring in a string. + * The substring is found at code point boundaries. + * That means that if the substring begins with + * a trail surrogate or ends with a lead surrogate, + * then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against + * halves of surrogate pairs. + * + * @param s The string to search (NUL-terminated). + * @param substring The substring to find (NUL-terminated). + * @return A pointer to the last occurrence of substring in s, + * or s itself if the substring is empty, + * or NULL if substring is not in s. + * @stable ICU 2.4 + * + * @see u_strstr + * @see u_strFindFirst + * @see u_strFindLast + */ +U_STABLE UChar * U_EXPORT2 +u_strrstr(const UChar *s, const UChar *substring); + +/** + * Find the last occurrence of a substring in a string. + * The substring is found at code point boundaries. + * That means that if the substring begins with + * a trail surrogate or ends with a lead surrogate, + * then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against + * halves of surrogate pairs. + * + * @param s The string to search. + * @param length The length of s (number of UChars), or -1 if it is NUL-terminated. + * @param substring The substring to find (NUL-terminated). + * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated. + * @return A pointer to the last occurrence of substring in s, + * or s itself if the substring is empty, + * or NULL if substring is not in s. + * @stable ICU 2.4 + * + * @see u_strstr + * @see u_strFindLast + */ +U_STABLE UChar * U_EXPORT2 +u_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t subLength); + +/** + * Find the last occurrence of a BMP code point in a string. + * A surrogate code point is found only if its match in the text is not + * part of a surrogate pair. + * A NUL character is found at the string terminator. + * + * @param s The string to search (NUL-terminated). + * @param c The BMP code point to find. + * @return A pointer to the last occurrence of c in s + * or NULL if c is not in s. + * @stable ICU 2.4 + * + * @see u_strrchr32 + * @see u_memrchr + * @see u_strrstr + * @see u_strFindLast + */ +U_STABLE UChar * U_EXPORT2 +u_strrchr(const UChar *s, UChar c); + +/** + * Find the last occurrence of a code point in a string. + * A surrogate code point is found only if its match in the text is not + * part of a surrogate pair. + * A NUL character is found at the string terminator. + * + * @param s The string to search (NUL-terminated). + * @param c The code point to find. + * @return A pointer to the last occurrence of c in s + * or NULL if c is not in s. + * @stable ICU 2.4 + * + * @see u_strrchr + * @see u_memchr32 + * @see u_strrstr + * @see u_strFindLast + */ +U_STABLE UChar * U_EXPORT2 +u_strrchr32(const UChar *s, UChar32 c); + +/** + * Locates the first occurrence in the string string of any of the characters + * in the string matchSet. + * Works just like C's strpbrk but with Unicode. + * + * @param string The string in which to search, NUL-terminated. + * @param matchSet A NUL-terminated string defining a set of code points + * for which to search in the text string. + * @return A pointer to the character in string that matches one of the + * characters in matchSet, or NULL if no such character is found. + * @stable ICU 2.0 + */ +U_STABLE UChar * U_EXPORT2 +u_strpbrk(const UChar *string, const UChar *matchSet); + +/** + * Returns the number of consecutive characters in string, + * beginning with the first, that do not occur somewhere in matchSet. + * Works just like C's strcspn but with Unicode. + * + * @param string The string in which to search, NUL-terminated. + * @param matchSet A NUL-terminated string defining a set of code points + * for which to search in the text string. + * @return The number of initial characters in string that do not + * occur in matchSet. + * @see u_strspn + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strcspn(const UChar *string, const UChar *matchSet); + +/** + * Returns the number of consecutive characters in string, + * beginning with the first, that occur somewhere in matchSet. + * Works just like C's strspn but with Unicode. + * + * @param string The string in which to search, NUL-terminated. + * @param matchSet A NUL-terminated string defining a set of code points + * for which to search in the text string. + * @return The number of initial characters in string that do + * occur in matchSet. + * @see u_strcspn + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strspn(const UChar *string, const UChar *matchSet); + +/** + * The string tokenizer API allows an application to break a string into + * tokens. Unlike strtok(), the saveState (the current pointer within the + * original string) is maintained in saveState. In the first call, the + * argument src is a pointer to the string. In subsequent calls to + * return successive tokens of that string, src must be specified as + * NULL. The value saveState is set by this function to maintain the + * function's position within the string, and on each subsequent call + * you must give this argument the same variable. This function does + * handle surrogate pairs. This function is similar to the strtok_r() + * the POSIX Threads Extension (1003.1c-1995) version. + * + * @param src String containing token(s). This string will be modified. + * After the first call to u_strtok_r(), this argument must + * be NULL to get to the next token. + * @param delim Set of delimiter characters (Unicode code points). + * @param saveState The current pointer within the original string, + * which is set by this function. The saveState + * parameter should the address of a local variable of type + * UChar *. (i.e. defined "Uhar *myLocalSaveState" and use + * &myLocalSaveState for this parameter). + * @return A pointer to the next token found in src, or NULL + * when there are no more tokens. + * @stable ICU 2.0 + */ +U_STABLE UChar * U_EXPORT2 +u_strtok_r(UChar *src, + const UChar *delim, + UChar **saveState); + +/** + * Compare two Unicode strings for bitwise equality (code unit order). + * + * @param s1 A string to compare. + * @param s2 A string to compare. + * @return 0 if s1 and s2 are bitwise equal; a negative + * value if s1 is bitwise less than s2,; a positive + * value if s1 is bitwise greater than s2. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strcmp(const UChar *s1, + const UChar *s2); + +/** + * Compare two Unicode strings in code point order. + * See u_strCompare for details. + * + * @param s1 A string to compare. + * @param s2 A string to compare. + * @return a negative/zero/positive integer corresponding to whether + * the first string is less than/equal to/greater than the second one + * in code point order + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strcmpCodePointOrder(const UChar *s1, const UChar *s2); + +/** + * Compare two Unicode strings (binary order). + * + * The comparison can be done in code unit order or in code point order. + * They differ only in UTF-16 when + * comparing supplementary code points (U+10000..U+10ffff) + * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). + * In code unit order, high BMP code points sort after supplementary code points + * because they are stored as pairs of surrogates which are at U+d800..U+dfff. + * + * This functions works with strings of different explicitly specified lengths + * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. + * NUL-terminated strings are possible with length arguments of -1. + * + * @param s1 First source string. + * @param length1 Length of first source string, or -1 if NUL-terminated. + * + * @param s2 Second source string. + * @param length2 Length of second source string, or -1 if NUL-terminated. + * + * @param codePointOrder Choose between code unit order (FALSE) + * and code point order (TRUE). + * + * @return <0 or 0 or >0 as usual for string comparisons + * + * @stable ICU 2.2 + */ +U_STABLE int32_t U_EXPORT2 +u_strCompare(const UChar *s1, int32_t length1, + const UChar *s2, int32_t length2, + UBool codePointOrder); + +/** + * Compare two Unicode strings (binary order) + * as presented by UCharIterator objects. + * Works otherwise just like u_strCompare(). + * + * Both iterators are reset to their start positions. + * When the function returns, it is undefined where the iterators + * have stopped. + * + * @param iter1 First source string iterator. + * @param iter2 Second source string iterator. + * @param codePointOrder Choose between code unit order (FALSE) + * and code point order (TRUE). + * + * @return <0 or 0 or >0 as usual for string comparisons + * + * @see u_strCompare + * + * @stable ICU 2.6 + */ +U_STABLE int32_t U_EXPORT2 +u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrder); + +#ifndef U_COMPARE_CODE_POINT_ORDER +/* see also unistr.h and unorm.h */ +/** + * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc: + * Compare strings in code point order instead of code unit order. + * @stable ICU 2.2 + */ +#define U_COMPARE_CODE_POINT_ORDER 0x8000 +#endif + +/** + * Compare two strings case-insensitively using full case folding. + * This is equivalent to + * u_strCompare(u_strFoldCase(s1, options), + * u_strFoldCase(s2, options), + * (options&U_COMPARE_CODE_POINT_ORDER)!=0). + * + * The comparison can be done in UTF-16 code unit order or in code point order. + * They differ only when comparing supplementary code points (U+10000..U+10ffff) + * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). + * In code unit order, high BMP code points sort after supplementary code points + * because they are stored as pairs of surrogates which are at U+d800..U+dfff. + * + * This functions works with strings of different explicitly specified lengths + * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. + * NUL-terminated strings are possible with length arguments of -1. + * + * @param s1 First source string. + * @param length1 Length of first source string, or -1 if NUL-terminated. + * + * @param s2 Second source string. + * @param length2 Length of second source string, or -1 if NUL-terminated. + * + * @param options A bit set of options: + * - U_FOLD_CASE_DEFAULT or 0 is used for default options: + * Comparison in code unit order with default case folding. + * + * - U_COMPARE_CODE_POINT_ORDER + * Set to choose code point order instead of code unit order + * (see u_strCompare for details). + * + * - U_FOLD_CASE_EXCLUDE_SPECIAL_I + * + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * + * @return <0 or 0 or >0 as usual for string comparisons + * + * @stable ICU 2.2 + */ +U_STABLE int32_t U_EXPORT2 +u_strCaseCompare(const UChar *s1, int32_t length1, + const UChar *s2, int32_t length2, + uint32_t options, + UErrorCode *pErrorCode); + +/** + * Compare two ustrings for bitwise equality. + * Compares at most n characters. + * + * @param ucs1 A string to compare. + * @param ucs2 A string to compare. + * @param n The maximum number of characters to compare. + * @return 0 if s1 and s2 are bitwise equal; a negative + * value if s1 is bitwise less than s2; a positive + * value if s1 is bitwise greater than s2. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strncmp(const UChar *ucs1, + const UChar *ucs2, + int32_t n); + +/** + * Compare two Unicode strings in code point order. + * This is different in UTF-16 from u_strncmp() if supplementary characters are present. + * For details, see u_strCompare(). + * + * @param s1 A string to compare. + * @param s2 A string to compare. + * @param n The maximum number of characters to compare. + * @return a negative/zero/positive integer corresponding to whether + * the first string is less than/equal to/greater than the second one + * in code point order + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n); + +/** + * Compare two strings case-insensitively using full case folding. + * This is equivalent to u_strcmp(u_strFoldCase(s1, options), u_strFoldCase(s2, options)). + * + * @param s1 A string to compare. + * @param s2 A string to compare. + * @param options A bit set of options: + * - U_FOLD_CASE_DEFAULT or 0 is used for default options: + * Comparison in code unit order with default case folding. + * + * - U_COMPARE_CODE_POINT_ORDER + * Set to choose code point order instead of code unit order + * (see u_strCompare for details). + * + * - U_FOLD_CASE_EXCLUDE_SPECIAL_I + * + * @return A negative, zero, or positive integer indicating the comparison result. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options); + +/** + * Compare two strings case-insensitively using full case folding. + * This is equivalent to u_strcmp(u_strFoldCase(s1, at most n, options), + * u_strFoldCase(s2, at most n, options)). + * + * @param s1 A string to compare. + * @param s2 A string to compare. + * @param n The maximum number of characters each string to case-fold and then compare. + * @param options A bit set of options: + * - U_FOLD_CASE_DEFAULT or 0 is used for default options: + * Comparison in code unit order with default case folding. + * + * - U_COMPARE_CODE_POINT_ORDER + * Set to choose code point order instead of code unit order + * (see u_strCompare for details). + * + * - U_FOLD_CASE_EXCLUDE_SPECIAL_I + * + * @return A negative, zero, or positive integer indicating the comparison result. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options); + +/** + * Compare two strings case-insensitively using full case folding. + * This is equivalent to u_strcmp(u_strFoldCase(s1, n, options), + * u_strFoldCase(s2, n, options)). + * + * @param s1 A string to compare. + * @param s2 A string to compare. + * @param length The number of characters in each string to case-fold and then compare. + * @param options A bit set of options: + * - U_FOLD_CASE_DEFAULT or 0 is used for default options: + * Comparison in code unit order with default case folding. + * + * - U_COMPARE_CODE_POINT_ORDER + * Set to choose code point order instead of code unit order + * (see u_strCompare for details). + * + * - U_FOLD_CASE_EXCLUDE_SPECIAL_I + * + * @return A negative, zero, or positive integer indicating the comparison result. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options); + +/** + * Copy a ustring. Adds a null terminator. + * + * @param dst The destination string. + * @param src The source string. + * @return A pointer to dst. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_strcpy(UChar *dst, + const UChar *src); + +/** + * Copy a ustring. + * Copies at most n characters. The result will be null terminated + * if the length of src is less than n. + * + * @param dst The destination string. + * @param src The source string. + * @param n The maximum number of characters to copy. + * @return A pointer to dst. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_strncpy(UChar *dst, + const UChar *src, + int32_t n); + +#if !UCONFIG_NO_CONVERSION + +/** + * Copy a byte string encoded in the default codepage to a ustring. + * Adds a null terminator. + * Performs a host byte to UChar conversion + * + * @param dst The destination string. + * @param src The source string. + * @return A pointer to dst. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 u_uastrcpy(UChar *dst, + const char *src ); + +/** + * Copy a byte string encoded in the default codepage to a ustring. + * Copies at most n characters. The result will be null terminated + * if the length of src is less than n. + * Performs a host byte to UChar conversion + * + * @param dst The destination string. + * @param src The source string. + * @param n The maximum number of characters to copy. + * @return A pointer to dst. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 u_uastrncpy(UChar *dst, + const char *src, + int32_t n); + +/** + * Copy ustring to a byte string encoded in the default codepage. + * Adds a null terminator. + * Performs a UChar to host byte conversion + * + * @param dst The destination string. + * @param src The source string. + * @return A pointer to dst. + * @stable ICU 2.0 + */ +U_STABLE char* U_EXPORT2 u_austrcpy(char *dst, + const UChar *src ); + +/** + * Copy ustring to a byte string encoded in the default codepage. + * Copies at most n characters. The result will be null terminated + * if the length of src is less than n. + * Performs a UChar to host byte conversion + * + * @param dst The destination string. + * @param src The source string. + * @param n The maximum number of characters to copy. + * @return A pointer to dst. + * @stable ICU 2.0 + */ +U_STABLE char* U_EXPORT2 u_austrncpy(char *dst, + const UChar *src, + int32_t n ); + +#endif + +/** + * Synonym for memcpy(), but with UChars only. + * @param dest The destination string + * @param src The source string + * @param count The number of characters to copy + * @return A pointer to dest + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_memcpy(UChar *dest, const UChar *src, int32_t count); + +/** + * Synonym for memmove(), but with UChars only. + * @param dest The destination string + * @param src The source string + * @param count The number of characters to move + * @return A pointer to dest + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_memmove(UChar *dest, const UChar *src, int32_t count); + +/** + * Initialize count characters of dest to c. + * + * @param dest The destination string. + * @param c The character to initialize the string. + * @param count The maximum number of characters to set. + * @return A pointer to dest. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_memset(UChar *dest, UChar c, int32_t count); + +/** + * Compare the first count UChars of each buffer. + * + * @param buf1 The first string to compare. + * @param buf2 The second string to compare. + * @param count The maximum number of UChars to compare. + * @return When buf1 < buf2, a negative number is returned. + * When buf1 == buf2, 0 is returned. + * When buf1 > buf2, a positive number is returned. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count); + +/** + * Compare two Unicode strings in code point order. + * This is different in UTF-16 from u_memcmp() if supplementary characters are present. + * For details, see u_strCompare(). + * + * @param s1 A string to compare. + * @param s2 A string to compare. + * @param count The maximum number of characters to compare. + * @return a negative/zero/positive integer corresponding to whether + * the first string is less than/equal to/greater than the second one + * in code point order + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count); + +/** + * Find the first occurrence of a BMP code point in a string. + * A surrogate code point is found only if its match in the text is not + * part of a surrogate pair. + * A NUL character is found at the string terminator. + * + * @param s The string to search (contains count UChars). + * @param c The BMP code point to find. + * @param count The length of the string. + * @return A pointer to the first occurrence of c in s + * or NULL if c is not in s. + * @stable ICU 2.0 + * + * @see u_strchr + * @see u_memchr32 + * @see u_strFindFirst + */ +U_STABLE UChar* U_EXPORT2 +u_memchr(const UChar *s, UChar c, int32_t count); + +/** + * Find the first occurrence of a code point in a string. + * A surrogate code point is found only if its match in the text is not + * part of a surrogate pair. + * A NUL character is found at the string terminator. + * + * @param s The string to search (contains count UChars). + * @param c The code point to find. + * @param count The length of the string. + * @return A pointer to the first occurrence of c in s + * or NULL if c is not in s. + * @stable ICU 2.0 + * + * @see u_strchr32 + * @see u_memchr + * @see u_strFindFirst + */ +U_STABLE UChar* U_EXPORT2 +u_memchr32(const UChar *s, UChar32 c, int32_t count); + +/** + * Find the last occurrence of a BMP code point in a string. + * A surrogate code point is found only if its match in the text is not + * part of a surrogate pair. + * A NUL character is found at the string terminator. + * + * @param s The string to search (contains count UChars). + * @param c The BMP code point to find. + * @param count The length of the string. + * @return A pointer to the last occurrence of c in s + * or NULL if c is not in s. + * @stable ICU 2.4 + * + * @see u_strrchr + * @see u_memrchr32 + * @see u_strFindLast + */ +U_STABLE UChar* U_EXPORT2 +u_memrchr(const UChar *s, UChar c, int32_t count); + +/** + * Find the last occurrence of a code point in a string. + * A surrogate code point is found only if its match in the text is not + * part of a surrogate pair. + * A NUL character is found at the string terminator. + * + * @param s The string to search (contains count UChars). + * @param c The code point to find. + * @param count The length of the string. + * @return A pointer to the last occurrence of c in s + * or NULL if c is not in s. + * @stable ICU 2.4 + * + * @see u_strrchr32 + * @see u_memrchr + * @see u_strFindLast + */ +U_STABLE UChar* U_EXPORT2 +u_memrchr32(const UChar *s, UChar32 c, int32_t count); + +/** + * Unicode String literals in C. + * We need one macro to declare a variable for the string + * and to statically preinitialize it if possible, + * and a second macro to dynamically intialize such a string variable if necessary. + * + * The macros are defined for maximum performance. + * They work only for strings that contain "invariant characters", i.e., + * only latin letters, digits, and some punctuation. + * See utypes.h for details. + * + * A pair of macros for a single string must be used with the same + * parameters. + * The string parameter must be a C string literal. + * The length of the string, not including the terminating + * NUL, must be specified as a constant. + * The U_STRING_DECL macro should be invoked exactly once for one + * such string variable before it is used. + * + * Usage: + *
+ *     U_STRING_DECL(ustringVar1, "Quick-Fox 2", 11);
+ *     U_STRING_DECL(ustringVar2, "jumps 5%", 8);
+ *     static UBool didInit=FALSE;
+ *  
+ *     int32_t function() {
+ *         if(!didInit) {
+ *             U_STRING_INIT(ustringVar1, "Quick-Fox 2", 11);
+ *             U_STRING_INIT(ustringVar2, "jumps 5%", 8);
+ *             didInit=TRUE;
+ *         }
+ *         return u_strcmp(ustringVar1, ustringVar2);
+ *     }
+ * 
+ * @stable ICU 2.0 + */ +#if U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && U_CHARSET_FAMILY==U_ASCII_FAMILY +# define U_STRING_DECL(var, cs, length) static const wchar_t var[(length)+1]={ L ## cs } + /**@stable ICU 2.0 */ +# define U_STRING_INIT(var, cs, length) +#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY +# define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]={ (const UChar *)cs } + /**@stable ICU 2.0 */ +# define U_STRING_INIT(var, cs, length) +#else +# define U_STRING_DECL(var, cs, length) static UChar var[(length)+1] + /**@stable ICU 2.0 */ +# define U_STRING_INIT(var, cs, length) u_charsToUChars(cs, var, length+1) +#endif + +/** + * Unescape a string of characters and write the resulting + * Unicode characters to the destination buffer. The following escape + * sequences are recognized: + * + * \\uhhhh 4 hex digits; h in [0-9A-Fa-f] + * \\Uhhhhhhhh 8 hex digits + * \\xhh 1-2 hex digits + * \\x{h...} 1-8 hex digits + * \\ooo 1-3 octal digits; o in [0-7] + * \\cX control-X; X is masked with 0x1F + * + * as well as the standard ANSI C escapes: + * + * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A, + * \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B, + * \\" => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C + * + * Anything else following a backslash is generically escaped. For + * example, "[a\\-z]" returns "[a-z]". + * + * If an escape sequence is ill-formed, this method returns an empty + * string. An example of an ill-formed sequence is "\\u" followed by + * fewer than 4 hex digits. + * + * The above characters are recognized in the compiler's codepage, + * that is, they are coded as 'u', '\\', etc. Characters that are + * not parts of escape sequences are converted using u_charsToUChars(). + * + * This function is similar to UnicodeString::unescape() but not + * identical to it. The latter takes a source UnicodeString, so it + * does escape recognition but no conversion. + * + * @param src a zero-terminated string of invariant characters + * @param dest pointer to buffer to receive converted and unescaped + * text and, if there is room, a zero terminator. May be NULL for + * preflighting, in which case no UChars will be written, but the + * return value will still be valid. On error, an empty string is + * stored here (if possible). + * @param destCapacity the number of UChars that may be written at + * dest. Ignored if dest == NULL. + * @return the length of unescaped string. + * @see u_unescapeAt + * @see UnicodeString#unescape() + * @see UnicodeString#unescapeAt() + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_unescape(const char *src, + UChar *dest, int32_t destCapacity); + +U_CDECL_BEGIN +/** + * Callback function for u_unescapeAt() that returns a character of + * the source text given an offset and a context pointer. The context + * pointer will be whatever is passed into u_unescapeAt(). + * + * @param offset pointer to the offset that will be passed to u_unescapeAt(). + * @param context an opaque pointer passed directly into u_unescapeAt() + * @return the character represented by the escape sequence at + * offset + * @see u_unescapeAt + * @stable ICU 2.0 + */ +typedef UChar (U_CALLCONV *UNESCAPE_CHAR_AT)(int32_t offset, void *context); +U_CDECL_END + +/** + * Unescape a single sequence. The character at offset-1 is assumed + * (without checking) to be a backslash. This method takes a callback + * pointer to a function that returns the UChar at a given offset. By + * varying this callback, ICU functions are able to unescape char* + * strings, UnicodeString objects, and UFILE pointers. + * + * If offset is out of range, or if the escape sequence is ill-formed, + * (UChar32)0xFFFFFFFF is returned. See documentation of u_unescape() + * for a list of recognized sequences. + * + * @param charAt callback function that returns a UChar of the source + * text given an offset and a context pointer. + * @param offset pointer to the offset that will be passed to charAt. + * The offset value will be updated upon return to point after the + * last parsed character of the escape sequence. On error the offset + * is unchanged. + * @param length the number of characters in the source text. The + * last character of the source text is considered to be at offset + * length-1. + * @param context an opaque pointer passed directly into charAt. + * @return the character represented by the escape sequence at + * offset, or (UChar32)0xFFFFFFFF on error. + * @see u_unescape() + * @see UnicodeString#unescape() + * @see UnicodeString#unescapeAt() + * @stable ICU 2.0 + */ +U_STABLE UChar32 U_EXPORT2 +u_unescapeAt(UNESCAPE_CHAR_AT charAt, + int32_t *offset, + int32_t length, + void *context); + +/** + * Uppercase the characters in a string. + * Casing is locale-dependent and context-sensitive. + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of UChars). If it is 0, then + * dest may be NULL and the function will only return the length of the result + * without writing any of the result string. + * @param src The original string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param locale The locale to consider, or "" for the root locale or NULL for the default locale. + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strToUpper(UChar *dest, int32_t destCapacity, + const UChar *src, int32_t srcLength, + const char *locale, + UErrorCode *pErrorCode); + +/** + * Lowercase the characters in a string. + * Casing is locale-dependent and context-sensitive. + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of UChars). If it is 0, then + * dest may be NULL and the function will only return the length of the result + * without writing any of the result string. + * @param src The original string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param locale The locale to consider, or "" for the root locale or NULL for the default locale. + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strToLower(UChar *dest, int32_t destCapacity, + const UChar *src, int32_t srcLength, + const char *locale, + UErrorCode *pErrorCode); + +#if !UCONFIG_NO_BREAK_ITERATION + +/** + * Titlecase a string. + * Casing is locale-dependent and context-sensitive. + * Titlecasing uses a break iterator to find the first characters of words + * that are to be titlecased. It titlecases those characters and lowercases + * all others. + * + * The titlecase break iterator can be provided to customize for arbitrary + * styles, using rules and dictionaries beyond the standard iterators. + * It may be more efficient to always provide an iterator to avoid + * opening and closing one for each string. + * The standard titlecase iterator for the root locale implements the + * algorithm of Unicode TR 21. + * + * This function uses only the first() and next() methods of the + * provided break iterator. + * + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of UChars). If it is 0, then + * dest may be NULL and the function will only return the length of the result + * without writing any of the result string. + * @param src The original string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param titleIter A break iterator to find the first characters of words + * that are to be titlecased. + * If none is provided (NULL), then a standard titlecase + * break iterator is opened. + * @param locale The locale to consider, or "" for the root locale or NULL for the default locale. + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @stable ICU 2.1 + */ +U_STABLE int32_t U_EXPORT2 +u_strToTitle(UChar *dest, int32_t destCapacity, + const UChar *src, int32_t srcLength, + UBreakIterator *titleIter, + const char *locale, + UErrorCode *pErrorCode); + +#endif + +/** + * Case-fold the characters in a string. + * Case-folding is locale-independent and not context-sensitive, + * but there is an option for whether to include or exclude mappings for dotted I + * and dotless i that are marked with 'I' in CaseFolding.txt. + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of UChars). If it is 0, then + * dest may be NULL and the function will only return the length of the result + * without writing any of the result string. + * @param src The original string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @stable ICU 2.0 + */ +U_STABLE int32_t U_EXPORT2 +u_strFoldCase(UChar *dest, int32_t destCapacity, + const UChar *src, int32_t srcLength, + uint32_t options, + UErrorCode *pErrorCode); + +/** + * Converts a sequence of UChars to wchar_t units. + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of wchar_t's). If it is 0, then + * dest may be NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param src The original source string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @stable ICU 2.0 + */ +U_STABLE wchar_t* U_EXPORT2 +u_strToWCS(wchar_t *dest, + int32_t destCapacity, + int32_t *pDestLength, + const UChar *src, + int32_t srcLength, + UErrorCode *pErrorCode); +/** + * Converts a sequence of wchar_t units to UChars + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of UChars). If it is 0, then + * dest may be NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param src The original source string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_strFromWCS(UChar *dest, + int32_t destCapacity, + int32_t *pDestLength, + const wchar_t *src, + int32_t srcLength, + UErrorCode *pErrorCode); +/** + * Converts a sequence of UChars (UTF-16) to UTF-8 bytes + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of chars). If it is 0, then + * dest may be NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param src The original source string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @stable ICU 2.0 + */ +U_STABLE char* U_EXPORT2 +u_strToUTF8(char *dest, + int32_t destCapacity, + int32_t *pDestLength, + const UChar *src, + int32_t srcLength, + UErrorCode *pErrorCode); + +/** + * Converts a sequence of UTF-8 bytes to UChars (UTF-16). + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of UChars). If it is 0, then + * dest may be NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param src The original source string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_strFromUTF8(UChar *dest, + int32_t destCapacity, + int32_t *pDestLength, + const char *src, + int32_t srcLength, + UErrorCode *pErrorCode); + +/** + * Converts a sequence of UChars (UTF-16) to UTF32 units. + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of UChar32s). If it is 0, then + * dest may be NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param src The original source string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @stable ICU 2.0 + */ +U_STABLE UChar32* U_EXPORT2 +u_strToUTF32(UChar32 *dest, + int32_t destCapacity, + int32_t *pDestLength, + const UChar *src, + int32_t srcLength, + UErrorCode *pErrorCode); + +/** + * Converts a sequence of UTF32 units to UChars (UTF-16) + * + * @param dest A buffer for the result string. The result will be zero-terminated if + * the buffer is large enough. + * @param destCapacity The size of the buffer (number of UChars). If it is 0, then + * dest may be NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param pDestLength A pointer to receive the number of units written to the destination. If + * pDestLength!=NULL then *pDestLength is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param src The original source string + * @param srcLength The length of the original string. If -1, then src must be zero-terminated. + * @param pErrorCode Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @stable ICU 2.0 + */ +U_STABLE UChar* U_EXPORT2 +u_strFromUTF32(UChar *dest, + int32_t destCapacity, + int32_t *pDestLength, + const UChar32 *src, + int32_t srcLength, + UErrorCode *pErrorCode); + +#endif diff --git a/icu/unicode/utf.h b/icu/unicode/utf.h new file mode 100644 index 0000000..201691d --- /dev/null +++ b/icu/unicode/utf.h @@ -0,0 +1,221 @@ +/* +******************************************************************************* +* +* Copyright (C) 1999-2004, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: utf.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 1999sep09 +* created by: Markus W. Scherer +*/ + +/** + * \file + * \brief C API: Code point macros + * + * This file defines macros for checking whether a code point is + * a surrogate or a non-character etc. + * + * The UChar and UChar32 data types for Unicode code units and code points + * are defined in umachines.h because they can be machine-dependent. + * + * utf.h is included by utypes.h and itself includes utf8.h and utf16.h after some + * common definitions. Those files define macros for efficiently getting code points + * in and out of UTF-8/16 strings. + * utf16.h macros have "U16_" prefixes. + * utf8.h defines similar macros with "U8_" prefixes for UTF-8 string handling. + * + * ICU processes 16-bit Unicode strings. + * Most of the time, such strings are well-formed UTF-16. + * Single, unpaired surrogates must be handled as well, and are treated in ICU + * like regular code points where possible. + * (Pairs of surrogate code points are indistinguishable from supplementary + * code points encoded as pairs of supplementary code units.) + * + * In fact, almost all Unicode code points in normal text (>99%) + * are on the BMP (<=U+ffff) and even <=U+d7ff. + * ICU functions handle supplementary code points (U+10000..U+10ffff) + * but are optimized for the much more frequently occurring BMP code points. + * + * utf.h defines UChar to be an unsigned 16-bit integer. If this matches wchar_t, then + * UChar is defined to be exactly wchar_t, otherwise uint16_t. + * + * UChar32 is defined to be a signed 32-bit integer (int32_t), large enough for a 21-bit + * Unicode code point (Unicode scalar value, 0..0x10ffff). + * Before ICU 2.4, the definition of UChar32 was similarly platform-dependent as + * the definition of UChar. For details see the documentation for UChar32 itself. + * + * utf.h also defines a small number of C macros for single Unicode code points. + * These are simple checks for surrogates and non-characters. + * For actual Unicode character properties see uchar.h. + * + * By default, string operations must be done with error checking in case + * a string is not well-formed UTF-16. + * The macros will detect if a surrogate code unit is unpaired + * (lead unit without trail unit or vice versa) and just return the unit itself + * as the code point. + * (It is an accidental property of Unicode and UTF-16 that all + * malformed sequences can be expressed unambiguously with a distinct subrange + * of Unicode code points.) + * + * When it is safe to assume that text is well-formed UTF-16 + * (does not contain single, unpaired surrogates), then one can use + * U16_..._UNSAFE macros. + * These do not check for proper code unit sequences or truncated text and may + * yield wrong results or even cause a crash if they are used with "malformed" + * text. + * In practice, U16_..._UNSAFE macros will produce slightly less code but + * should not be faster because the processing is only different when a + * surrogate code unit is detected, which will be rare. + * + * Similarly for UTF-8, there are "safe" macros without a suffix, + * and U8_..._UNSAFE versions. + * The performance differences are much larger here because UTF-8 provides so + * many opportunities for malformed sequences. + * The unsafe UTF-8 macros are entirely implemented inside the macro definitions + * and are fast, while the safe UTF-8 macros call functions for all but the + * trivial (ASCII) cases. + * + * Unlike with UTF-16, malformed sequences cannot be expressed with distinct + * code point values (0..U+10ffff). They are indicated with negative values instead. + * + * For more information see the ICU User Guide Strings chapter + * (http://oss.software.ibm.com/icu/userguide/). + * + * Usage: + * ICU coding guidelines for if() statements should be followed when using these macros. + * Compound statements (curly braces {}) must be used for if-else-while... + * bodies and all macro statements should be terminated with semicolon. + * + * @stable ICU 2.4 + */ + +#ifndef __UTF_H__ +#define __UTF_H__ + +#include "unicode/utypes.h" +/* include the utfXX.h after the following definitions */ + +/* single-code point definitions -------------------------------------------- */ + +/** + * This value is intended for sentinel values for APIs that + * (take or) return single code points (UChar32). + * It is outside of the Unicode code point range 0..0x10ffff. + * + * For example, a "done" or "error" value in a new API + * could be indicated with U_SENTINEL. + * + * ICU APIs designed before ICU 2.4 usually define service-specific "done" + * values, mostly 0xffff. + * Those may need to be distinguished from + * actual U+ffff text contents by calling functions like + * CharacterIterator::hasNext() or UnicodeString::length(). + * + * @return -1 + * @see UChar32 + * @stable ICU 2.4 + */ +#define U_SENTINEL (-1) + +/** + * Is this code point a Unicode noncharacter? + * @param c 32-bit code point + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U_IS_UNICODE_NONCHAR(c) \ + ((c)>=0xfdd0 && \ + ((uint32_t)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \ + (uint32_t)(c)<=0x10ffff) + +/** + * Is c a Unicode code point value (0..U+10ffff) + * that can be assigned a character? + * + * Code points that are not characters include: + * - single surrogate code points (U+d800..U+dfff, 2048 code points) + * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points) + * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points) + * - the highest Unicode code point value is U+10ffff + * + * This means that all code points below U+d800 are character code points, + * and that boundary is tested first for performance. + * + * @param c 32-bit code point + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U_IS_UNICODE_CHAR(c) \ + ((uint32_t)(c)<0xd800 || \ + ((uint32_t)(c)>0xdfff && \ + (uint32_t)(c)<=0x10ffff && \ + !U_IS_UNICODE_NONCHAR(c))) + +#ifndef U_HIDE_DRAFT_API + +/** + * Is this code point a BMP code point (U+0000..U+ffff)? + * @param c 32-bit code point + * @return TRUE or FALSE + * @draft ICU 2.8 + */ +#define U_IS_BMP(c) ((uint32_t)(c)<=0xffff) + +/** + * Is this code point a supplementary code point (U+10000..U+10ffff)? + * @param c 32-bit code point + * @return TRUE or FALSE + * @draft ICU 2.8 + */ +#define U_IS_SUPPLEMENTARY(c) ((uint32_t)((c)-0x10000)<=0xfffff) + +#endif /*U_HIDE_DRAFT_API*/ + +/** + * Is this code point a lead surrogate (U+d800..U+dbff)? + * @param c 32-bit code point + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U_IS_LEAD(c) (((c)&0xfffffc00)==0xd800) + +/** + * Is this code point a trail surrogate (U+dc00..U+dfff)? + * @param c 32-bit code point + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00) + +/** + * Is this code point a surrogate (U+d800..U+dfff)? + * @param c 32-bit code point + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U_IS_SURROGATE(c) (((c)&0xfffff800)==0xd800) + +/** + * Assuming c is a surrogate code point (U_IS_SURROGATE(c)), + * is it a lead surrogate? + * @param c 32-bit code point + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U_IS_SURROGATE_LEAD(c) (((c)&0x400)==0) + +/* include the utfXX.h ------------------------------------------------------ */ + +#include "unicode/utf8.h" +#include "unicode/utf16.h" + +/* utf_old.h contains deprecated, pre-ICU 2.4 definitions */ +#include "unicode/utf_old.h" + +#endif diff --git a/icu/unicode/utf16.h b/icu/unicode/utf16.h new file mode 100644 index 0000000..7bf3872 --- /dev/null +++ b/icu/unicode/utf16.h @@ -0,0 +1,605 @@ +/* +******************************************************************************* +* +* Copyright (C) 1999-2004, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: utf16.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 1999sep09 +* created by: Markus W. Scherer +*/ + +/** + * \file + * \brief C API: 16-bit Unicode handling macros + * + * This file defines macros to deal with 16-bit Unicode (UTF-16) code units and strings. + * utf16.h is included by utf.h after unicode/umachine.h + * and some common definitions. + * + * For more information see utf.h and the ICU User Guide Strings chapter + * (http://oss.software.ibm.com/icu/userguide/). + * + * Usage: + * ICU coding guidelines for if() statements should be followed when using these macros. + * Compound statements (curly braces {}) must be used for if-else-while... + * bodies and all macro statements should be terminated with semicolon. + */ + +#ifndef __UTF16_H__ +#define __UTF16_H__ + +/* utf.h must be included first. */ +#ifndef __UTF_H__ +# include "unicode/utf.h" +#endif + +/* single-code point definitions -------------------------------------------- */ + +/** + * Does this code unit alone encode a code point (BMP, not a surrogate)? + * @param c 16-bit code unit + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U16_IS_SINGLE(c) !U_IS_SURROGATE(c) + +/** + * Is this code unit a lead surrogate (U+d800..U+dbff)? + * @param c 16-bit code unit + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800) + +/** + * Is this code unit a trail surrogate (U+dc00..U+dfff)? + * @param c 16-bit code unit + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00) + +/** + * Is this code unit a surrogate (U+d800..U+dfff)? + * @param c 16-bit code unit + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U16_IS_SURROGATE(c) U_IS_SURROGATE(c) + +/** + * Assuming c is a surrogate code point (U16_IS_SURROGATE(c)), + * is it a lead surrogate? + * @param c 16-bit code unit + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0) + +/** + * Helper constant for U16_GET_SUPPLEMENTARY. + * @internal + */ +#define U16_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000) + +/** + * Get a supplementary code point value (U+10000..U+10ffff) + * from its lead and trail surrogates. + * The result is undefined if the input values are not + * lead and trail surrogates. + * + * @param lead lead surrogate (U+d800..U+dbff) + * @param trail trail surrogate (U+dc00..U+dfff) + * @return supplementary code point (U+10000..U+10ffff) + * @stable ICU 2.4 + */ +#define U16_GET_SUPPLEMENTARY(lead, trail) \ + (((UChar32)(lead)<<10UL)+(UChar32)(trail)-U16_SURROGATE_OFFSET) + + +/** + * Get the lead surrogate (0xd800..0xdbff) for a + * supplementary code point (0x10000..0x10ffff). + * @param supplementary 32-bit code point (U+10000..U+10ffff) + * @return lead surrogate (U+d800..U+dbff) for supplementary + * @stable ICU 2.4 + */ +#define U16_LEAD(supplementary) (UChar)(((supplementary)>>10)+0xd7c0) + +/** + * Get the trail surrogate (0xdc00..0xdfff) for a + * supplementary code point (0x10000..0x10ffff). + * @param supplementary 32-bit code point (U+10000..U+10ffff) + * @return trail surrogate (U+dc00..U+dfff) for supplementary + * @stable ICU 2.4 + */ +#define U16_TRAIL(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00) + +/** + * How many 16-bit code units are used to encode this Unicode code point? (1 or 2) + * The result is not defined if c is not a Unicode code point (U+0000..U+10ffff). + * @param c 32-bit code point + * @return 1 or 2 + * @stable ICU 2.4 + */ +#define U16_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2) + +/** + * The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff). + * @return 2 + * @stable ICU 2.4 + */ +#define U16_MAX_LENGTH 2 + +/** + * Get a code point from a string at a random-access offset, + * without changing the offset. + * "Unsafe" macro, assumes well-formed UTF-16. + * + * The offset may point to either the lead or trail surrogate unit + * for a supplementary code point, in which case the macro will read + * the adjacent matching surrogate as well. + * The result is undefined if the offset points to a single, unpaired surrogate. + * Iteration through a string is more efficient with U16_NEXT_UNSAFE or U16_NEXT. + * + * @param s const UChar * string + * @param i string offset + * @param c output UChar32 variable + * @see U16_GET + * @stable ICU 2.4 + */ +#define U16_GET_UNSAFE(s, i, c) { \ + (c)=(s)[i]; \ + if(U16_IS_SURROGATE(c)) { \ + if(U16_IS_SURROGATE_LEAD(c)) { \ + (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)+1]); \ + } else { \ + (c)=U16_GET_SUPPLEMENTARY((s)[(i)-1], (c)); \ + } \ + } \ +} + +/** + * Get a code point from a string at a random-access offset, + * without changing the offset. + * "Safe" macro, handles unpaired surrogates and checks for string boundaries. + * + * The offset may point to either the lead or trail surrogate unit + * for a supplementary code point, in which case the macro will read + * the adjacent matching surrogate as well. + * If the offset points to a single, unpaired surrogate, then that itself + * will be returned as the code point. + * Iteration through a string is more efficient with U16_NEXT_UNSAFE or U16_NEXT. + * + * @param s const UChar * string + * @param start starting string offset (usually 0) + * @param i string offset, start<=i=(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \ + (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \ + } \ + } \ + } \ +} + +/* definitions with forward iteration --------------------------------------- */ + +/** + * Get a code point from a string at a code point boundary offset, + * and advance the offset to the next code point boundary. + * (Post-incrementing forward iteration.) + * "Unsafe" macro, assumes well-formed UTF-16. + * + * The offset may point to the lead surrogate unit + * for a supplementary code point, in which case the macro will read + * the following trail surrogate as well. + * If the offset points to a trail surrogate, then that itself + * will be returned as the code point. + * The result is undefined if the offset points to a single, unpaired lead surrogate. + * + * @param s const UChar * string + * @param i string offset + * @param c output UChar32 variable + * @see U16_NEXT + * @stable ICU 2.4 + */ +#define U16_NEXT_UNSAFE(s, i, c) { \ + (c)=(s)[(i)++]; \ + if(U16_IS_LEAD(c)) { \ + (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)++]); \ + } \ +} + +/** + * Get a code point from a string at a code point boundary offset, + * and advance the offset to the next code point boundary. + * (Post-incrementing forward iteration.) + * "Safe" macro, handles unpaired surrogates and checks for string boundaries. + * + * The offset may point to the lead surrogate unit + * for a supplementary code point, in which case the macro will read + * the following trail surrogate as well. + * If the offset points to a trail surrogate or + * to a single, unpaired lead surrogate, then that itself + * will be returned as the code point. + * + * @param s const UChar * string + * @param i string offset, i>10)+0xd7c0); \ + (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \ + } \ +} + +/** + * Append a code point to a string, overwriting 1 or 2 code units. + * The offset points to the current end of the string contents + * and is advanced (post-increment). + * "Safe" macro, checks for a valid code point. + * If a surrogate pair is written, checks for sufficient space in the string. + * If the code point is not valid or a trail surrogate does not fit, + * then isError is set to TRUE. + * + * @param s const UChar * string buffer + * @param i string offset, i>10)+0xd7c0); \ + (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \ + } else /* c>0x10ffff or not enough space */ { \ + (isError)=TRUE; \ + } \ +} + +/** + * Advance the string offset from one code point boundary to the next. + * (Post-incrementing iteration.) + * "Unsafe" macro, assumes well-formed UTF-16. + * + * @param s const UChar * string + * @param i string offset + * @see U16_FWD_1 + * @stable ICU 2.4 + */ +#define U16_FWD_1_UNSAFE(s, i) { \ + if(U16_IS_LEAD((s)[(i)++])) { \ + ++(i); \ + } \ +} + +/** + * Advance the string offset from one code point boundary to the next. + * (Post-incrementing iteration.) + * "Safe" macro, handles unpaired surrogates and checks for string boundaries. + * + * @param s const UChar * string + * @param i string offset, i0) { \ + U16_FWD_1_UNSAFE(s, i); \ + --__N; \ + } \ +} + +/** + * Advance the string offset from one code point boundary to the n-th next one, + * i.e., move forward by n code points. + * (Post-incrementing iteration.) + * "Safe" macro, handles unpaired surrogates and checks for string boundaries. + * + * @param s const UChar * string + * @param i string offset, i0 && (i)<(length)) { \ + U16_FWD_1(s, i, length); \ + --__N; \ + } \ +} + +/** + * Adjust a random-access offset to a code point boundary + * at the start of a code point. + * If the offset points to the trail surrogate of a surrogate pair, + * then the offset is decremented. + * Otherwise, it is not modified. + * "Unsafe" macro, assumes well-formed UTF-16. + * + * @param s const UChar * string + * @param i string offset + * @see U16_SET_CP_START + * @stable ICU 2.4 + */ +#define U16_SET_CP_START_UNSAFE(s, i) { \ + if(U16_IS_TRAIL((s)[i])) { \ + --(i); \ + } \ +} + +/** + * Adjust a random-access offset to a code point boundary + * at the start of a code point. + * If the offset points to the trail surrogate of a surrogate pair, + * then the offset is decremented. + * Otherwise, it is not modified. + * "Safe" macro, handles unpaired surrogates and checks for string boundaries. + * + * @param s const UChar * string + * @param start starting string offset (usually 0) + * @param i string offset, start<=i + * @see U16_SET_CP_START_UNSAFE + * @stable ICU 2.4 + */ +#define U16_SET_CP_START(s, start, i) { \ + if(U16_IS_TRAIL((s)[i]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \ + --(i); \ + } \ +} + +/* definitions with backward iteration -------------------------------------- */ + +/** + * Move the string offset from one code point boundary to the previous one + * and get the code point between them. + * (Pre-decrementing backward iteration.) + * "Unsafe" macro, assumes well-formed UTF-16. + * + * The input offset may be the same as the string length. + * If the offset is behind a trail surrogate unit + * for a supplementary code point, then the macro will read + * the preceding lead surrogate as well. + * If the offset is behind a lead surrogate, then that itself + * will be returned as the code point. + * The result is undefined if the offset is behind a single, unpaired trail surrogate. + * + * @param s const UChar * string + * @param i string offset + * @param c output UChar32 variable + * @see U16_PREV + * @stable ICU 2.4 + */ +#define U16_PREV_UNSAFE(s, i, c) { \ + (c)=(s)[--(i)]; \ + if(U16_IS_TRAIL(c)) { \ + (c)=U16_GET_SUPPLEMENTARY((s)[--(i)], (c)); \ + } \ +} + +/** + * Move the string offset from one code point boundary to the previous one + * and get the code point between them. + * (Pre-decrementing backward iteration.) + * "Safe" macro, handles unpaired surrogates and checks for string boundaries. + * + * The input offset may be the same as the string length. + * If the offset is behind a trail surrogate unit + * for a supplementary code point, then the macro will read + * the preceding lead surrogate as well. + * If the offset is behind a lead surrogate or behind a single, unpaired + * trail surrogate, then that itself + * will be returned as the code point. + * + * @param s const UChar * string + * @param start starting string offset (usually 0) + * @param i string offset, start<=i + * @param c output UChar32 variable + * @see U16_PREV_UNSAFE + * @stable ICU 2.4 + */ +#define U16_PREV(s, start, i, c) { \ + (c)=(s)[--(i)]; \ + if(U16_IS_TRAIL(c)) { \ + uint16_t __c2; \ + if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \ + --(i); \ + (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \ + } \ + } \ +} + +/** + * Move the string offset from one code point boundary to the previous one. + * (Pre-decrementing backward iteration.) + * The input offset may be the same as the string length. + * "Unsafe" macro, assumes well-formed UTF-16. + * + * @param s const UChar * string + * @param i string offset + * @see U16_BACK_1 + * @stable ICU 2.4 + */ +#define U16_BACK_1_UNSAFE(s, i) { \ + if(U16_IS_TRAIL((s)[--(i)])) { \ + --(i); \ + } \ +} + +/** + * Move the string offset from one code point boundary to the previous one. + * (Pre-decrementing backward iteration.) + * The input offset may be the same as the string length. + * "Safe" macro, handles unpaired surrogates and checks for string boundaries. + * + * @param s const UChar * string + * @param start starting string offset (usually 0) + * @param i string offset, start<=i + * @see U16_BACK_1_UNSAFE + * @stable ICU 2.4 + */ +#define U16_BACK_1(s, start, i) { \ + if(U16_IS_TRAIL((s)[--(i)]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \ + --(i); \ + } \ +} + +/** + * Move the string offset from one code point boundary to the n-th one before it, + * i.e., move backward by n code points. + * (Pre-decrementing backward iteration.) + * The input offset may be the same as the string length. + * "Unsafe" macro, assumes well-formed UTF-16. + * + * @param s const UChar * string + * @param i string offset + * @param n number of code points to skip + * @see U16_BACK_N + * @stable ICU 2.4 + */ +#define U16_BACK_N_UNSAFE(s, i, n) { \ + int32_t __N=(n); \ + while(__N>0) { \ + U16_BACK_1_UNSAFE(s, i); \ + --__N; \ + } \ +} + +/** + * Move the string offset from one code point boundary to the n-th one before it, + * i.e., move backward by n code points. + * (Pre-decrementing backward iteration.) + * The input offset may be the same as the string length. + * "Safe" macro, handles unpaired surrogates and checks for string boundaries. + * + * @param s const UChar * string + * @param start start of string + * @param i string offset, i0 && (i)>(start)) { \ + U16_BACK_1(s, start, i); \ + --__N; \ + } \ +} + +/** + * Adjust a random-access offset to a code point boundary after a code point. + * If the offset is behind the lead surrogate of a surrogate pair, + * then the offset is incremented. + * Otherwise, it is not modified. + * The input offset may be the same as the string length. + * "Unsafe" macro, assumes well-formed UTF-16. + * + * @param s const UChar * string + * @param i string offset + * @see U16_SET_CP_LIMIT + * @stable ICU 2.4 + */ +#define U16_SET_CP_LIMIT_UNSAFE(s, i) { \ + if(U16_IS_LEAD((s)[(i)-1])) { \ + ++(i); \ + } \ +} + +/** + * Adjust a random-access offset to a code point boundary after a code point. + * If the offset is behind the lead surrogate of a surrogate pair, + * then the offset is incremented. + * Otherwise, it is not modified. + * The input offset may be the same as the string length. + * "Safe" macro, handles unpaired surrogates and checks for string boundaries. + * + * @param s const UChar * string + * @param start starting string offset (usually 0) + * @param i string offset, start<=i<=length + * @param length string length + * @see U16_SET_CP_LIMIT_UNSAFE + * @stable ICU 2.4 + */ +#define U16_SET_CP_LIMIT(s, start, i, length) { \ + if((start)<(i) && (i)<(length) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \ + ++(i); \ + } \ +} + +#endif diff --git a/icu/unicode/utf8.h b/icu/unicode/utf8.h new file mode 100644 index 0000000..f83662b --- /dev/null +++ b/icu/unicode/utf8.h @@ -0,0 +1,627 @@ +/* +******************************************************************************* +* +* Copyright (C) 1999-2004, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: utf8.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 1999sep13 +* created by: Markus W. Scherer +*/ + +/** + * \file + * \brief C API: 8-bit Unicode handling macros + * + * This file defines macros to deal with 8-bit Unicode (UTF-8) code units (bytes) and strings. + * utf8.h is included by utf.h after unicode/umachine.h + * and some common definitions. + * + * For more information see utf.h and the ICU User Guide Strings chapter + * (http://oss.software.ibm.com/icu/userguide/). + * + * Usage: + * ICU coding guidelines for if() statements should be followed when using these macros. + * Compound statements (curly braces {}) must be used for if-else-while... + * bodies and all macro statements should be terminated with semicolon. + */ + +#ifndef __UTF8_H__ +#define __UTF8_H__ + +/* utf.h must be included first. */ +#ifndef __UTF_H__ +# include "unicode/utf.h" +#endif + +/* internal definitions ----------------------------------------------------- */ + +/** + * \var utf8_countTrailBytes + * Internal array with numbers of trail bytes for any given byte used in + * lead byte position. + * @internal + */ +#ifdef U_UTF8_IMPL +U_INTERNAL const uint8_t +#elif defined(U_STATIC_IMPLEMENTATION) +U_CFUNC const uint8_t +#else +U_CFUNC U_IMPORT const uint8_t /* U_IMPORT2? */ /*U_IMPORT*/ +#endif +utf8_countTrailBytes[256]; + +/** + * Count the trail bytes for a UTF-8 lead byte. + * @internal + */ +#define U8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[(uint8_t)leadByte]) + +/** + * Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value. + * @internal + */ +#define U8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1) + +/** + * Function for handling "next code point" with error-checking. + * @internal + */ +U_INTERNAL UChar32 U_EXPORT2 +utf8_nextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict); + +/** + * Function for handling "append code point" with error-checking. + * @internal + */ +U_INTERNAL int32_t U_EXPORT2 +utf8_appendCharSafeBody(uint8_t *s, int32_t i, int32_t length, UChar32 c, UBool *pIsError); + +/** + * Function for handling "previous code point" with error-checking. + * @internal + */ +U_INTERNAL UChar32 U_EXPORT2 +utf8_prevCharSafeBody(const uint8_t *s, int32_t start, int32_t *pi, UChar32 c, UBool strict); + +/** + * Function for handling "skip backward one code point" with error-checking. + * @internal + */ +U_INTERNAL int32_t U_EXPORT2 +utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i); + +/* single-code point definitions -------------------------------------------- */ + +/** + * Does this code unit (byte) encode a code point by itself (US-ASCII 0..0x7f)? + * @param c 8-bit code unit (byte) + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U8_IS_SINGLE(c) (((c)&0x80)==0) + +/** + * Is this code unit (byte) a UTF-8 lead byte? + * @param c 8-bit code unit (byte) + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U8_IS_LEAD(c) ((uint8_t)((c)-0xc0)<0x3e) + +/** + * Is this code unit (byte) a UTF-8 trail byte? + * @param c 8-bit code unit (byte) + * @return TRUE or FALSE + * @stable ICU 2.4 + */ +#define U8_IS_TRAIL(c) (((c)&0xc0)==0x80) + +/** + * How many code units (bytes) are used for the UTF-8 encoding + * of this Unicode code point? + * @param c 32-bit code point + * @return 1..4, or 0 if c is a surrogate or not a Unicode code point + * @stable ICU 2.4 + */ +#define U8_LENGTH(c) \ + ((uint32_t)(c)<=0x7f ? 1 : \ + ((uint32_t)(c)<=0x7ff ? 2 : \ + ((uint32_t)(c)<=0xd7ff ? 3 : \ + ((uint32_t)(c)<=0xdfff || (uint32_t)(c)>0x10ffff ? 0 : \ + ((uint32_t)(c)<=0xffff ? 3 : 4)\ + ) \ + ) \ + ) \ + ) + +/** + * The maximum number of UTF-8 code units (bytes) per Unicode code point (U+0000..U+10ffff). + * @return 4 + * @stable ICU 2.4 + */ +#define U8_MAX_LENGTH 4 + +/** + * Get a code point from a string at a random-access offset, + * without changing the offset. + * The offset may point to either the lead byte or one of the trail bytes + * for a code point, in which case the macro will read all of the bytes + * for the code point. + * The result is undefined if the offset points to an illegal UTF-8 + * byte sequence. + * Iteration through a string is more efficient with U8_NEXT_UNSAFE or U8_NEXT. + * + * @param s const uint8_t * string + * @param i string offset + * @param c output UChar32 variable + * @see U8_GET + * @stable ICU 2.4 + */ +#define U8_GET_UNSAFE(s, i, c) { \ + int32_t _u8_get_unsafe_index=(int32_t)(i); \ + U8_SET_CP_START_UNSAFE(s, _u8_get_unsafe_index); \ + U8_NEXT_UNSAFE(s, _u8_get_unsafe_index, c); \ +} + +/** + * Get a code point from a string at a random-access offset, + * without changing the offset. + * The offset may point to either the lead byte or one of the trail bytes + * for a code point, in which case the macro will read all of the bytes + * for the code point. + * If the offset points to an illegal UTF-8 byte sequence, then + * c is set to a negative value. + * Iteration through a string is more efficient with U8_NEXT_UNSAFE or U8_NEXT. + * + * @param s const uint8_t * string + * @param start starting string offset + * @param i string offset, start<=i=0x80) { \ + if(U8_IS_LEAD(c)) { \ + (c)=utf8_nextCharSafeBody((const uint8_t *)s, &(i), (int32_t)(length), c, -1); \ + } else { \ + (c)=U_SENTINEL; \ + } \ + } \ +} + +/** + * Append a code point to a string, overwriting 1 to 4 bytes. + * The offset points to the current end of the string contents + * and is advanced (post-increment). + * "Unsafe" macro, assumes a valid code point and sufficient space in the string. + * Otherwise, the result is undefined. + * + * @param s const uint8_t * string buffer + * @param i string offset + * @param c code point to append + * @see U8_APPEND + * @stable ICU 2.4 + */ +#define U8_APPEND_UNSAFE(s, i, c) { \ + if((uint32_t)(c)<=0x7f) { \ + (s)[(i)++]=(uint8_t)(c); \ + } else { \ + if((uint32_t)(c)<=0x7ff) { \ + (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \ + } else { \ + if((uint32_t)(c)<=0xffff) { \ + (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \ + } else { \ + (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \ + (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \ + } \ + (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \ + } \ + (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \ + } \ +} + +/** + * Append a code point to a string, overwriting 1 or 2 code units. + * The offset points to the current end of the string contents + * and is advanced (post-increment). + * "Safe" macro, checks for a valid code point. + * If a non-ASCII code point is written, checks for sufficient space in the string. + * If the code point is not valid or trail bytes do not fit, + * then isError is set to TRUE. + * + * @param s const uint8_t * string buffer + * @param i string offset, i(length)) { \ + __count=(uint8_t)((length)-(i)); \ + } \ + while(__count>0 && U8_IS_TRAIL((s)[i])) { \ + ++(i); \ + --__count; \ + } \ + } \ +} + +/** + * Advance the string offset from one code point boundary to the n-th next one, + * i.e., move forward by n code points. + * (Post-incrementing iteration.) + * "Unsafe" macro, assumes well-formed UTF-8. + * + * @param s const uint8_t * string + * @param i string offset + * @param n number of code points to skip + * @see U8_FWD_N + * @stable ICU 2.4 + */ +#define U8_FWD_N_UNSAFE(s, i, n) { \ + int32_t __N=(n); \ + while(__N>0) { \ + U8_FWD_1_UNSAFE(s, i); \ + --__N; \ + } \ +} + +/** + * Advance the string offset from one code point boundary to the n-th next one, + * i.e., move forward by n code points. + * (Post-incrementing iteration.) + * "Safe" macro, checks for illegal sequences and for string boundaries. + * + * @param s const uint8_t * string + * @param i string offset, i0 && (i)<(length)) { \ + U8_FWD_1(s, i, length); \ + --__N; \ + } \ +} + +/** + * Adjust a random-access offset to a code point boundary + * at the start of a code point. + * If the offset points to a UTF-8 trail byte, + * then the offset is moved backward to the corresponding lead byte. + * Otherwise, it is not modified. + * "Unsafe" macro, assumes well-formed UTF-8. + * + * @param s const uint8_t * string + * @param i string offset + * @see U8_SET_CP_START + * @stable ICU 2.4 + */ +#define U8_SET_CP_START_UNSAFE(s, i) { \ + while(U8_IS_TRAIL((s)[i])) { --(i); } \ +} + +/** + * Adjust a random-access offset to a code point boundary + * at the start of a code point. + * If the offset points to a UTF-8 trail byte, + * then the offset is moved backward to the corresponding lead byte. + * Otherwise, it is not modified. + * "Safe" macro, checks for illegal sequences and for string boundaries. + * + * @param s const uint8_t * string + * @param start starting string offset (usually 0) + * @param i string offset, start<=i + * @see U8_SET_CP_START_UNSAFE + * @stable ICU 2.4 + */ +#define U8_SET_CP_START(s, start, i) { \ + if(U8_IS_TRAIL((s)[(i)])) { \ + (i)=utf8_back1SafeBody(s, start, (int32_t)(i)); \ + } \ +} + +/* definitions with backward iteration -------------------------------------- */ + +/** + * Move the string offset from one code point boundary to the previous one + * and get the code point between them. + * (Pre-decrementing backward iteration.) + * "Unsafe" macro, assumes well-formed UTF-8. + * + * The input offset may be the same as the string length. + * If the offset is behind a multi-byte sequence, then the macro will read + * the whole sequence. + * If the offset is behind a lead byte, then that itself + * will be returned as the code point. + * The result is undefined if the offset is behind an illegal UTF-8 sequence. + * + * @param s const uint8_t * string + * @param i string offset + * @param c output UChar32 variable + * @see U8_PREV + * @stable ICU 2.4 + */ +#define U8_PREV_UNSAFE(s, i, c) { \ + (c)=(s)[--(i)]; \ + if(U8_IS_TRAIL(c)) { \ + uint8_t __b, __count=1, __shift=6; \ +\ + /* c is a trail byte */ \ + (c)&=0x3f; \ + for(;;) { \ + __b=(s)[--(i)]; \ + if(__b>=0xc0) { \ + U8_MASK_LEAD_BYTE(__b, __count); \ + (c)|=(UChar32)__b<<__shift; \ + break; \ + } else { \ + (c)|=(UChar32)(__b&0x3f)<<__shift; \ + ++__count; \ + __shift+=6; \ + } \ + } \ + } \ +} + +/** + * Move the string offset from one code point boundary to the previous one + * and get the code point between them. + * (Pre-decrementing backward iteration.) + * "Safe" macro, checks for illegal sequences and for string boundaries. + * + * The input offset may be the same as the string length. + * If the offset is behind a multi-byte sequence, then the macro will read + * the whole sequence. + * If the offset is behind a lead byte, then that itself + * will be returned as the code point. + * If the offset is behind an illegal UTF-8 sequence, then c is set to a negative value. + * + * @param s const uint8_t * string + * @param start starting string offset (usually 0) + * @param i string offset, start<=i + * @param c output UChar32 variable, set to <0 in case of an error + * @see U8_PREV_UNSAFE + * @stable ICU 2.4 + */ +#define U8_PREV(s, start, i, c) { \ + (c)=(s)[--(i)]; \ + if((c)>=0x80) { \ + if((c)<=0xbf) { \ + (c)=utf8_prevCharSafeBody(s, start, &(i), c, -1); \ + } else { \ + (c)=U_SENTINEL; \ + } \ + } \ +} + +/** + * Move the string offset from one code point boundary to the previous one. + * (Pre-decrementing backward iteration.) + * The input offset may be the same as the string length. + * "Unsafe" macro, assumes well-formed UTF-8. + * + * @param s const uint8_t * string + * @param i string offset + * @see U8_BACK_1 + * @stable ICU 2.4 + */ +#define U8_BACK_1_UNSAFE(s, i) { \ + while(U8_IS_TRAIL((s)[--(i)])) {} \ +} + +/** + * Move the string offset from one code point boundary to the previous one. + * (Pre-decrementing backward iteration.) + * The input offset may be the same as the string length. + * "Safe" macro, checks for illegal sequences and for string boundaries. + * + * @param s const uint8_t * string + * @param start starting string offset (usually 0) + * @param i string offset, start<=i + * @see U8_BACK_1_UNSAFE + * @stable ICU 2.4 + */ +#define U8_BACK_1(s, start, i) { \ + if(U8_IS_TRAIL((s)[--(i)])) { \ + (i)=utf8_back1SafeBody(s, start, (int32_t)(i)); \ + } \ +} + +/** + * Move the string offset from one code point boundary to the n-th one before it, + * i.e., move backward by n code points. + * (Pre-decrementing backward iteration.) + * The input offset may be the same as the string length. + * "Unsafe" macro, assumes well-formed UTF-8. + * + * @param s const uint8_t * string + * @param i string offset + * @param n number of code points to skip + * @see U8_BACK_N + * @stable ICU 2.4 + */ +#define U8_BACK_N_UNSAFE(s, i, n) { \ + int32_t __N=(n); \ + while(__N>0) { \ + U8_BACK_1_UNSAFE(s, i); \ + --__N; \ + } \ +} + +/** + * Move the string offset from one code point boundary to the n-th one before it, + * i.e., move backward by n code points. + * (Pre-decrementing backward iteration.) + * The input offset may be the same as the string length. + * "Safe" macro, checks for illegal sequences and for string boundaries. + * + * @param s const uint8_t * string + * @param start index of the start of the string + * @param i string offset, i0 && (i)>(start)) { \ + U8_BACK_1(s, start, i); \ + --__N; \ + } \ +} + +/** + * Adjust a random-access offset to a code point boundary after a code point. + * If the offset is behind a partial multi-byte sequence, + * then the offset is incremented to behind the whole sequence. + * Otherwise, it is not modified. + * The input offset may be the same as the string length. + * "Unsafe" macro, assumes well-formed UTF-8. + * + * @param s const uint8_t * string + * @param i string offset + * @see U8_SET_CP_LIMIT + * @stable ICU 2.4 + */ +#define U8_SET_CP_LIMIT_UNSAFE(s, i) { \ + U8_BACK_1_UNSAFE(s, i); \ + U8_FWD_1_UNSAFE(s, i); \ +} + +/** + * Adjust a random-access offset to a code point boundary after a code point. + * If the offset is behind a partial multi-byte sequence, + * then the offset is incremented to behind the whole sequence. + * Otherwise, it is not modified. + * The input offset may be the same as the string length. + * "Safe" macro, checks for illegal sequences and for string boundaries. + * + * @param s const uint8_t * string + * @param start starting string offset (usually 0) + * @param i string offset, start<=i<=length + * @param length string length + * @see U8_SET_CP_LIMIT_UNSAFE + * @stable ICU 2.4 + */ +#define U8_SET_CP_LIMIT(s, start, i, length) { \ + if((start)<(i) && (i)<(length)) { \ + U8_BACK_1(s, start, i); \ + U8_FWD_1(s, i, length); \ + } \ +} + +#endif diff --git a/icu/unicode/utf_old.h b/icu/unicode/utf_old.h new file mode 100644 index 0000000..e69de29 diff --git a/icu/unicode/utypes.h b/icu/unicode/utypes.h new file mode 100644 index 0000000..e20cd79 --- /dev/null +++ b/icu/unicode/utypes.h @@ -0,0 +1,745 @@ +/* +********************************************************************** +* Copyright (C) 1996-2004, International Business Machines +* Corporation and others. All Rights Reserved. +********************************************************************** +* +* FILE NAME : UTYPES.H (formerly ptypes.h) +* +* Date Name Description +* 12/11/96 helena Creation. +* 02/27/97 aliu Added typedefs for UClassID, int8, int16, int32, +* uint8, uint16, and uint32. +* 04/01/97 aliu Added XP_CPLUSPLUS and modified to work under C as +* well as C++. +* Modified to use memcpy() for uprv_arrayCopy() fns. +* 04/14/97 aliu Added TPlatformUtilities. +* 05/07/97 aliu Added import/export specifiers (replacing the old +* broken EXT_CLASS). Added version number for our +* code. Cleaned up header. +* 6/20/97 helena Java class name change. +* 08/11/98 stephen UErrorCode changed from typedef to enum +* 08/12/98 erm Changed T_ANALYTIC_PACKAGE_VERSION to 3 +* 08/14/98 stephen Added uprv_arrayCopy() for int8_t, int16_t, int32_t +* 12/09/98 jfitz Added BUFFER_OVERFLOW_ERROR (bug 1100066) +* 04/20/99 stephen Cleaned up & reworked for autoconf. +* Renamed to utypes.h. +* 05/05/99 stephen Changed to use +* 12/07/99 helena Moved copyright notice string from ucnv_bld.h here. +******************************************************************************* +*/ + +#ifndef UTYPES_H +#define UTYPES_H + + +#include "unicode/umachine.h" +#include "unicode/utf.h" +#include "unicode/uversion.h" +#include "unicode/uconfig.h" + +#ifdef U_HIDE_DRAFT_API +#include "unicode/udraft.h" +#endif + +#ifdef U_HIDE_DEPRECATED_API +#include "unicode/udeprctd.h" +#endif + +#ifdef U_HIDE_DEPRECATED_API +#include "unicode/uobslete.h" +#endif + + +/*! + * \file + * \brief Basic definitions for ICU, for both C and C++ APIs + * + * This file defines basic types, constants, and enumerations directly or + * indirectly by including other header files, especially utf.h for the + * basic character and string definitions and umachine.h for consistent + * integer and other types. + */ + +/*===========================================================================*/ +/* char Character set family */ +/*===========================================================================*/ + +/** + * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform. + * @stable ICU 2.0 + */ +#define U_ASCII_FAMILY 0 + +/** + * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform. + * @stable ICU 2.0 + */ +#define U_EBCDIC_FAMILY 1 + +/** + * \def U_CHARSET_FAMILY + * + *

These definitions allow to specify the encoding of text + * in the char data type as defined by the platform and the compiler. + * It is enough to determine the code point values of "invariant characters", + * which are the ones shared by all encodings that are in use + * on a given platform.

+ * + *

Those "invariant characters" should be all the uppercase and lowercase + * latin letters, the digits, the space, and "basic punctuation". + * Also, '\\n', '\\r', '\\t' should be available.

+ * + *

The list of "invariant characters" is:
+ * \code + * A-Z a-z 0-9 SPACE " % & ' ( ) * + , - . / : ; < = > ? _ + * \endcode + *
+ * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)

+ * + *

This matches the IBM Syntactic Character Set (CS 640).

+ * + *

In other words, all the graphic characters in 7-bit ASCII should + * be safely accessible except the following:

+ * + * \code + * '\' + * '[' + * ']' + * '{' + * '}' + * '^' + * '~' + * '!' + * '#' + * '|' + * '$' + * '@' + * '`' + * \endcode + * @stable ICU 2.0 + */ + +#ifndef U_CHARSET_FAMILY +# define U_CHARSET_FAMILY 0 +#endif + +/*===========================================================================*/ +/* ICUDATA naming scheme */ +/*===========================================================================*/ + +/** + * \def U_ICUDATA_TYPE_LETTER + * + * This is a platform-dependent string containing one letter: + * - b for big-endian, ASCII-family platforms + * - l for little-endian, ASCII-family platforms + * - e for big-endian, EBCDIC-family platforms + * This letter is part of the common data file name. + * @stable ICU 2.0 + */ + +/** + * \def U_ICUDATA_TYPE_LITLETTER + * The non-string form of U_ICUDATA_TYPE_LETTER + * @stable ICU 2.0 + */ +#if U_CHARSET_FAMILY +# if U_IS_BIG_ENDIAN + /* EBCDIC - should always be BE */ +# define U_ICUDATA_TYPE_LETTER "e" +# define U_ICUDATA_TYPE_LITLETTER e +# else +# error "Don't know what to do with little endian EBCDIC!" +# define U_ICUDATA_TYPE_LETTER "x" +# define U_ICUDATA_TYPE_LITLETTER x +# endif +#else +# if U_IS_BIG_ENDIAN + /* Big-endian ASCII */ +# define U_ICUDATA_TYPE_LETTER "b" +# define U_ICUDATA_TYPE_LITLETTER b +# else + /* Little-endian ASCII */ +# define U_ICUDATA_TYPE_LETTER "l" +# define U_ICUDATA_TYPE_LITLETTER l +# endif +#endif + +/** + * A single string literal containing the icudata stub name. i.e. 'icudt18e' for + * ICU 1.8.x on EBCDIC, etc.. + * @stable ICU 2.0 + */ +#define U_ICUDATA_NAME "icudt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER + + +/** + * U_ICU_ENTRY_POINT is the name of the DLL entry point to the ICU data library. + * Defined as a literal, not a string. + * Tricky Preprocessor use - ## operator replaces macro paramters with the literal string + * from the corresponding macro invocation, _before_ other macro substitutions. + * Need a nested #defines to get the actual version numbers rather than + * the literal text U_ICU_VERSION_MAJOR_NUM into the name. + * The net result will be something of the form + * #define U_ICU_ENTRY_POINT icudt19_dat + * @stable ICU 2.4 + */ +#define U_ICUDATA_ENTRY_POINT U_DEF2_ICUDATA_ENTRY_POINT(U_ICU_VERSION_MAJOR_NUM, U_ICU_VERSION_MINOR_NUM) +/** + * @internal + */ +#define U_DEF2_ICUDATA_ENTRY_POINT(major, minor) U_DEF_ICUDATA_ENTRY_POINT(major, minor) +/** + * @internal + */ +#define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt##major##minor##_dat + +/** + * \def U_CALLCONV + * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary + * in callback function typedefs to make sure that the calling convention + * is compatible. + * + * This is only used for non-ICU-API functions. + * When a function is a public ICU API, + * you must use the U_CAPI and U_EXPORT2 qualifiers. + * @stable ICU 2.0 + */ +#if defined(OS390) && (__COMPILER_VER__ < 0x41020000) && defined(XP_CPLUSPLUS) +# define U_CALLCONV __cdecl +#else +# define U_CALLCONV U_EXPORT2 +#endif + +/** + * \def NULL + * Define NULL if necessary, to 0 for C++ and to ((void *)0) for C. + * @stable ICU 2.0 + */ +#ifndef NULL +#ifdef XP_CPLUSPLUS +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +/*===========================================================================*/ +/* Calendar/TimeZone data types */ +/*===========================================================================*/ + +/** + * Date and Time data type. + * This is a primitive data type that holds the date and time + * as the number of milliseconds since 1970-jan-01, 00:00 UTC. + * UTC leap seconds are ignored. + * @stable ICU 2.0 + */ +typedef double UDate; + +/** The number of milliseconds per second @stable ICU 2.0 */ +#define U_MILLIS_PER_SECOND (1000) +/** The number of milliseconds per minute @stable ICU 2.0 */ +#define U_MILLIS_PER_MINUTE (60000) +/** The number of milliseconds per hour @stable ICU 2.0 */ +#define U_MILLIS_PER_HOUR (3600000) +/** The number of milliseconds per day @stable ICU 2.0 */ +#define U_MILLIS_PER_DAY (86400000) + + +/*===========================================================================*/ +/* UClassID-based RTTI */ +/*===========================================================================*/ + +/** + * UClassID is used to identify classes without using RTTI, since RTTI + * is not yet supported by all C++ compilers. Each class hierarchy which needs + * to implement polymorphic clone() or operator==() defines two methods, + * described in detail below. UClassID values can be compared using + * operator==(). Nothing else should be done with them. + * + * \par + * getDynamicClassID() is declared in the base class of the hierarchy as + * a pure virtual. Each concrete subclass implements it in the same way: + * + * \code + * class Base { + * public: + * virtual UClassID getDynamicClassID() const = 0; + * } + * + * class Derived { + * public: + * virtual UClassID getDynamicClassID() const + * { return Derived::getStaticClassID(); } + * } + * \endcode + * + * Each concrete class implements getStaticClassID() as well, which allows + * clients to test for a specific type. + * + * \code + * class Derived { + * public: + * static UClassID U_EXPORT2 getStaticClassID(); + * private: + * static char fgClassID; + * } + * + * // In Derived.cpp: + * UClassID Derived::getStaticClassID() + * { return (UClassID)&Derived::fgClassID; } + * char Derived::fgClassID = 0; // Value is irrelevant + * \endcode + * @stable ICU 2.0 + */ +typedef void* UClassID; + +/*===========================================================================*/ +/* Shared library/DLL import-export API control */ +/*===========================================================================*/ + +/* + * Control of symbol import/export. + * ICU is separated into three libraries. + */ + +/* + * \def U_COMBINED_IMPLEMENTATION + * Set to export library symbols from inside the ICU library + * when all of ICU is in a single library. + * This can be set as a compiler option while building ICU, and it + * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc. + * @stable ICU 2.0 + */ + +/** + * \def U_DATA_API + * Set to export library symbols from inside the stubdata library, + * and to import them from outside. + * @draft ICU 3.0 + */ + +/** + * \def U_COMMON_API + * Set to export library symbols from inside the common library, + * and to import them from outside. + * @stable ICU 2.0 + */ + +/** + * \def U_I18N_API + * Set to export library symbols from inside the i18n library, + * and to import them from outside. + * @stable ICU 2.0 + */ + +/** + * \def U_LAYOUT_API + * Set to export library symbols from inside the layout engine library, + * and to import them from outside. + * @stable ICU 2.0 + */ + +/** + * \def U_LAYOUTEX_API + * Set to export library symbols from inside the layout extensions library, + * and to import them from outside. + * @stable ICU 2.6 + */ + +/** + * \def U_IO_API + * Set to export library symbols from inside the ustdio library, + * and to import them from outside. + * @stable ICU 2.0 + */ + +#if defined(U_COMBINED_IMPLEMENTATION) +#define U_DATA_API U_EXPORT +#define U_COMMON_API U_EXPORT +#define U_I18N_API U_EXPORT +#define U_LAYOUT_API U_EXPORT +#define U_LAYOUTEX_API U_EXPORT +#define U_IO_API U_EXPORT +#elif defined(U_STATIC_IMPLEMENTATION) +#define U_DATA_API +#define U_COMMON_API +#define U_I18N_API +#define U_LAYOUT_API +#define U_LAYOUTEX_API +#define U_IO_API +#elif defined(U_COMMON_IMPLEMENTATION) +#define U_DATA_API U_IMPORT +#define U_COMMON_API U_EXPORT +#define U_I18N_API U_IMPORT +#define U_LAYOUT_API U_IMPORT +#define U_LAYOUTEX_API U_IMPORT +#define U_IO_API U_IMPORT +#elif defined(U_I18N_IMPLEMENTATION) +#define U_DATA_API U_IMPORT +#define U_COMMON_API U_IMPORT +#define U_I18N_API U_EXPORT +#define U_LAYOUT_API U_IMPORT +#define U_LAYOUTEX_API U_IMPORT +#define U_IO_API U_IMPORT +#elif defined(U_LAYOUT_IMPLEMENTATION) +#define U_DATA_API U_IMPORT +#define U_COMMON_API U_IMPORT +#define U_I18N_API U_IMPORT +#define U_LAYOUT_API U_EXPORT +#define U_LAYOUTEX_API U_IMPORT +#define U_IO_API U_IMPORT +#elif defined(U_LAYOUTEX_IMPLEMENTATION) +#define U_DATA_API U_IMPORT +#define U_COMMON_API U_IMPORT +#define U_I18N_API U_IMPORT +#define U_LAYOUT_API U_IMPORT +#define U_LAYOUTEX_API U_EXPORT +#define U_IO_API U_IMPORT +#elif defined(U_IO_IMPLEMENTATION) +#define U_DATA_API U_IMPORT +#define U_COMMON_API U_IMPORT +#define U_I18N_API U_IMPORT +#define U_LAYOUT_API U_IMPORT +#define U_LAYOUTEX_API U_IMPORT +#define U_IO_API U_EXPORT +#else +#define U_DATA_API U_IMPORT +#define U_COMMON_API U_IMPORT +#define U_I18N_API U_IMPORT +#define U_LAYOUT_API U_IMPORT +#define U_LAYOUTEX_API U_IMPORT +#define U_IO_API U_IMPORT +#endif + +/** + * \def U_STANDARD_CPP_NAMESPACE + * Control of C++ Namespace + * @stable ICU 2.0 + */ +#ifdef __cplusplus +#define U_STANDARD_CPP_NAMESPACE :: +#else +#define U_STANDARD_CPP_NAMESPACE +#endif + + +/*===========================================================================*/ +/* Global delete operator */ +/*===========================================================================*/ + +/* + * The ICU4C library must not use the global new and delete operators. + * These operators here are defined to enable testing for this. + * See Jitterbug 2581 for details of why this is necessary. + * + * Verification that ICU4C's memory usage is correct, i.e., + * that global new/delete are not used: + * + * a) Check for imports of global new/delete (see uobject.cpp for details) + * b) Verify that new is never imported. + * c) Verify that delete is only imported from object code for interface/mixin classes. + * d) Add global delete and delete[] only for the ICU4C library itself + * and define them in a way that crashes or otherwise easily shows a problem. + * + * The following implements d). + * The operator implementations crash; this is intentional and used for library debugging. + * + * Note: This is currently only done on Windows because + * some Linux/Unix compilers have problems with defining global new/delete. + * On Windows, WIN32 is defined, and it is _MSC_Ver>=1200 for MSVC 6.0 and higher. + */ +#if defined(XP_CPLUSPLUS) && defined(WIN32) && (_MSC_Ver>=1200) && (defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_LAYOUT_IMPLEMENTATION) || defined(U_USTDIO_IMPLEMENTATION)) + +/** + * Global operator new, defined only inside ICU4C, must not be used. + * Crashes intentionally. + * @internal + */ +inline void * +operator new(size_t /*size*/) { + char *q=NULL; + *q=5; /* break it */ + return q; +} + +/** + * Global operator new[], defined only inside ICU4C, must not be used. + * Crashes intentionally. + * @internal + */ +inline void * +operator new[](size_t /*size*/) { + char *q=NULL; + *q=5; /* break it */ + return q; +} + +/** + * Global operator delete, defined only inside ICU4C, must not be used. + * Crashes intentionally. + * @internal + */ +inline void +operator delete(void * /*p*/) { + char *q=NULL; + *q=5; /* break it */ +} + +/** + * Global operator delete[], defined only inside ICU4C, must not be used. + * Crashes intentionally. + * @internal + */ +inline void +operator delete[](void * /*p*/) { + char *q=NULL; + *q=5; /* break it */ +} + +#endif + +/*===========================================================================*/ +/* UErrorCode */ +/*===========================================================================*/ + +/** + * Error code to replace exception handling, so that the code is compatible with all C++ compilers, + * and to use the same mechanism for C and C++. + * + * \par + * ICU functions that take a reference (C++) or a pointer (C) to a UErrorCode + * first test if(U_FAILURE(errorCode)) { return immediately; } + * so that in a chain of such functions the first one that sets an error code + * causes the following ones to not perform any operations. + * + * \par + * Error codes should be tested using U_FAILURE() and U_SUCCESS(). + * @stable ICU 2.0 + */ +typedef enum UErrorCode { + /* The ordering of U_ERROR_INFO_START Vs U_USING_FALLBACK_WARNING looks weird + * and is that way because VC++ debugger displays first encountered constant, + * which is not the what the code is used for + */ + + U_USING_FALLBACK_WARNING = -128, /**< A resource bundle lookup returned a fallback result (not an error) */ + + U_ERROR_WARNING_START = -128, /**< Start of information results (semantically successful) */ + + U_USING_DEFAULT_WARNING = -127, /**< A resource bundle lookup returned a result from the root locale (not an error) */ + + U_SAFECLONE_ALLOCATED_WARNING = -126, /**< A SafeClone operation required allocating memory (informational only) */ + + U_STATE_OLD_WARNING = -125, /**< ICU has to use compatibility layer to construct the service. Expect performance/memory usage degradation. Consider upgrading */ + + U_STRING_NOT_TERMINATED_WARNING = -124,/**< An output string could not be NUL-terminated because output length==destCapacity. */ + + U_SORT_KEY_TOO_SHORT_WARNING = -123, /**< Number of levels requested in getBound is higher than the number of levels in the sort key */ + + U_AMBIGUOUS_ALIAS_WARNING = -122, /**< This converter alias can go to different converter implementations */ + + U_DIFFERENT_UCA_VERSION = -121, /**< ucol_open encountered a mismatch between UCA version and collator image version, so the collator was constructed from rules. No impact to further function */ + + U_ERROR_WARNING_LIMIT, /**< This must always be the last warning value to indicate the limit for UErrorCode warnings (last warning code +1) */ + + + U_ZERO_ERROR = 0, /**< No error, no warning. */ + + U_ILLEGAL_ARGUMENT_ERROR = 1, /**< Start of codes indicating failure */ + U_MISSING_RESOURCE_ERROR = 2, /**< The requested resource cannot be found */ + U_INVALID_FORMAT_ERROR = 3, /**< Data format is not what is expected */ + U_FILE_ACCESS_ERROR = 4, /**< The requested file cannot be found */ + U_INTERNAL_PROGRAM_ERROR = 5, /**< Indicates a bug in the library code */ + U_MESSAGE_PARSE_ERROR = 6, /**< Unable to parse a message (message format) */ + U_MEMORY_ALLOCATION_ERROR = 7, /**< Memory allocation error */ + U_INDEX_OUTOFBOUNDS_ERROR = 8, /**< Trying to access the index that is out of bounds */ + U_PARSE_ERROR = 9, /**< Equivalent to Java ParseException */ + U_INVALID_CHAR_FOUND = 10, /**< Character conversion: Unmappable input sequence. In other APIs: Invalid character. */ + U_TRUNCATED_CHAR_FOUND = 11, /**< Character conversion: Incomplete input sequence. */ + U_ILLEGAL_CHAR_FOUND = 12, /**< Character conversion: Illegal input sequence/combination of input units.. */ + U_INVALID_TABLE_FORMAT = 13, /**< Conversion table file found, but corrupted */ + U_INVALID_TABLE_FILE = 14, /**< Conversion table file not found */ + U_BUFFER_OVERFLOW_ERROR = 15, /**< A result would not fit in the supplied buffer */ + U_UNSUPPORTED_ERROR = 16, /**< Requested operation not supported in current context */ + U_RESOURCE_TYPE_MISMATCH = 17, /**< an operation is requested over a resource that does not support it */ + U_ILLEGAL_ESCAPE_SEQUENCE = 18, /**< ISO-2022 illlegal escape sequence */ + U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, /**< ISO-2022 unsupported escape sequence */ + U_NO_SPACE_AVAILABLE = 20, /**< No space available for in-buffer expansion for Arabic shaping */ + U_CE_NOT_FOUND_ERROR = 21, /**< Currently used only while setting variable top, but can be used generally */ + U_PRIMARY_TOO_LONG_ERROR = 22, /**< User tried to set variable top to a primary that is longer than two bytes */ + U_STATE_TOO_OLD_ERROR = 23, /**< ICU cannot construct a service from this state, as it is no longer supported */ + U_TOO_MANY_ALIASES_ERROR = 24, /**< There are too many aliases in the path to the requested resource. + It is very possible that a circular alias definition has occured */ + U_ENUM_OUT_OF_SYNC_ERROR = 25, /**< UEnumeration out of sync with underlying collection */ + U_INVARIANT_CONVERSION_ERROR = 26, /**< Unable to convert a UChar* string to char* with the invariant converter. */ + U_INVALID_STATE_ERROR = 27, /**< Requested operation can not be completed with ICU in its current state */ + U_COLLATOR_VERSION_MISMATCH = 28, /**< Collator version is not compatible with the base version */ + U_USELESS_COLLATOR_ERROR = 29, /**< Collator is options only and no base is specified */ + + U_STANDARD_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for standard errors */ + /* + * the error code range 0x10000 0x10100 are reserved for Transliterator + */ + U_BAD_VARIABLE_DEFINITION=0x10000,/**< Missing '$' or duplicate variable name */ + U_PARSE_ERROR_START = 0x10000, /**< Start of Transliterator errors */ + U_MALFORMED_RULE, /**< Elements of a rule are misplaced */ + U_MALFORMED_SET, /**< A UnicodeSet pattern is invalid*/ + U_MALFORMED_SYMBOL_REFERENCE, /**< UNUSED as of ICU 2.4 */ + U_MALFORMED_UNICODE_ESCAPE, /**< A Unicode escape pattern is invalid*/ + U_MALFORMED_VARIABLE_DEFINITION, /**< A variable definition is invalid */ + U_MALFORMED_VARIABLE_REFERENCE, /**< A variable reference is invalid */ + U_MISMATCHED_SEGMENT_DELIMITERS, /**< UNUSED as of ICU 2.4 */ + U_MISPLACED_ANCHOR_START, /**< A start anchor appears at an illegal position */ + U_MISPLACED_CURSOR_OFFSET, /**< A cursor offset occurs at an illegal position */ + U_MISPLACED_QUANTIFIER, /**< A quantifier appears after a segment close delimiter */ + U_MISSING_OPERATOR, /**< A rule contains no operator */ + U_MISSING_SEGMENT_CLOSE, /**< UNUSED as of ICU 2.4 */ + U_MULTIPLE_ANTE_CONTEXTS, /**< More than one ante context */ + U_MULTIPLE_CURSORS, /**< More than one cursor */ + U_MULTIPLE_POST_CONTEXTS, /**< More than one post context */ + U_TRAILING_BACKSLASH, /**< A dangling backslash */ + U_UNDEFINED_SEGMENT_REFERENCE, /**< A segment reference does not correspond to a defined segment */ + U_UNDEFINED_VARIABLE, /**< A variable reference does not correspond to a defined variable */ + U_UNQUOTED_SPECIAL, /**< A special character was not quoted or escaped */ + U_UNTERMINATED_QUOTE, /**< A closing single quote is missing */ + U_RULE_MASK_ERROR, /**< A rule is hidden by an earlier more general rule */ + U_MISPLACED_COMPOUND_FILTER, /**< A compound filter is in an invalid location */ + U_MULTIPLE_COMPOUND_FILTERS, /**< More than one compound filter */ + U_INVALID_RBT_SYNTAX, /**< A "::id" rule was passed to the RuleBasedTransliterator parser */ + U_INVALID_PROPERTY_PATTERN, /**< UNUSED as of ICU 2.4 */ + U_MALFORMED_PRAGMA, /**< A 'use' pragma is invlalid */ + U_UNCLOSED_SEGMENT, /**< A closing ')' is missing */ + U_ILLEGAL_CHAR_IN_SEGMENT, /**< UNUSED as of ICU 2.4 */ + U_VARIABLE_RANGE_EXHAUSTED, /**< Too many stand-ins generated for the given variable range */ + U_VARIABLE_RANGE_OVERLAP, /**< The variable range overlaps characters used in rules */ + U_ILLEGAL_CHARACTER, /**< A special character is outside its allowed context */ + U_INTERNAL_TRANSLITERATOR_ERROR, /**< Internal transliterator system error */ + U_INVALID_ID, /**< A "::id" rule specifies an unknown transliterator */ + U_INVALID_FUNCTION, /**< A "&fn()" rule specifies an unknown transliterator */ + U_PARSE_ERROR_LIMIT, /**< The limit for Transliterator errors */ + + /* + * the error code range 0x10100 0x10200 are reserved for formatting API parsing error + */ + U_UNEXPECTED_TOKEN=0x10100, /**< Syntax error in format pattern */ + U_FMT_PARSE_ERROR_START=0x10100, /**< Start of format library errors */ + U_MULTIPLE_DECIMAL_SEPARATORS, /**< More than one decimal separator in number pattern */ + U_MULTIPLE_DECIMAL_SEPERATORS = U_MULTIPLE_DECIMAL_SEPARATORS, /**< Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS */ + U_MULTIPLE_EXPONENTIAL_SYMBOLS, /**< More than one exponent symbol in number pattern */ + U_MALFORMED_EXPONENTIAL_PATTERN, /**< Grouping symbol in exponent pattern */ + U_MULTIPLE_PERCENT_SYMBOLS, /**< More than one percent symbol in number pattern */ + U_MULTIPLE_PERMILL_SYMBOLS, /**< More than one permill symbol in number pattern */ + U_MULTIPLE_PAD_SPECIFIERS, /**< More than one pad symbol in number pattern */ + U_PATTERN_SYNTAX_ERROR, /**< Syntax error in format pattern */ + U_ILLEGAL_PAD_POSITION, /**< Pad symbol misplaced in number pattern */ + U_UNMATCHED_BRACES, /**< Braces do not match in message pattern */ + U_UNSUPPORTED_PROPERTY, /**< UNUSED as of ICU 2.4 */ + U_UNSUPPORTED_ATTRIBUTE, /**< UNUSED as of ICU 2.4 */ + U_FMT_PARSE_ERROR_LIMIT, /**< The limit for format library errors */ + + /* + * the error code range 0x10200 0x102ff are reserved for Break Iterator related error + */ + U_BRK_ERROR_START=0x10200, /**< Start of codes indicating Break Iterator failures */ + U_BRK_INTERNAL_ERROR, /**< An internal error (bug) was detected. */ + U_BRK_HEX_DIGITS_EXPECTED, /**< Hex digits expected as part of a escaped char in a rule. */ + U_BRK_SEMICOLON_EXPECTED, /**< Missing ';' at the end of a RBBI rule. */ + U_BRK_RULE_SYNTAX, /**< Syntax error in RBBI rule. */ + U_BRK_UNCLOSED_SET, /**< UnicodeSet witing an RBBI rule missing a closing ']'. */ + U_BRK_ASSIGN_ERROR, /**< Syntax error in RBBI rule assignment statement. */ + U_BRK_VARIABLE_REDFINITION, /**< RBBI rule $Variable redefined. */ + U_BRK_MISMATCHED_PAREN, /**< Mis-matched parentheses in an RBBI rule. */ + U_BRK_NEW_LINE_IN_QUOTED_STRING, /**< Missing closing quote in an RBBI rule. */ + U_BRK_UNDEFINED_VARIABLE, /**< Use of an undefined $Variable in an RBBI rule. */ + U_BRK_INIT_ERROR, /**< Initialization failure. Probable missing ICU Data. */ + U_BRK_RULE_EMPTY_SET, /**< Rule contains an empty Unicode Set. */ + U_BRK_UNRECOGNIZED_OPTION, /**< !!option in RBBI rules not recognized. */ + U_BRK_MALFORMED_RULE_TAG, /**< The {nnn} tag on a rule is mal formed */ + U_BRK_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for Break Iterator failures */ + + /* + * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs + */ + U_REGEX_ERROR_START=0x10300, /**< Start of codes indicating Regexp failures */ + U_REGEX_INTERNAL_ERROR, /**< An internal error (bug) was detected. */ + U_REGEX_RULE_SYNTAX, /**< Syntax error in regexp pattern. */ + U_REGEX_INVALID_STATE, /**< RegexMatcher in invalid state for requested operation */ + U_REGEX_BAD_ESCAPE_SEQUENCE, /**< Unrecognized backslash escape sequence in pattern */ + U_REGEX_PROPERTY_SYNTAX, /**< Incorrect Unicode property */ + U_REGEX_UNIMPLEMENTED, /**< Use of regexp feature that is not yet implemented. */ + U_REGEX_MISMATCHED_PAREN, /**< Incorrectly nested parentheses in regexp pattern. */ + U_REGEX_NUMBER_TOO_BIG, /**< Decimal number is too large. */ + U_REGEX_BAD_INTERVAL, /**< Error in {min,max} interval */ + U_REGEX_MAX_LT_MIN, /**< In {min,max}, max is less than min. */ + U_REGEX_INVALID_BACK_REF, /**< Back-reference to a non-existent capture group. */ + U_REGEX_INVALID_FLAG, /**< Invalid value for match mode flags. */ + U_REGEX_LOOK_BEHIND_LIMIT, /**< Look-Behind pattern matches must have a bounded maximum length. */ + U_REGEX_SET_CONTAINS_STRING, /**< Regexps cannot have UnicodeSets containing strings.*/ + U_REGEX_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for regexp errors */ + + /* + * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes + */ + U_IDNA_ERROR_START=0x10400, + U_IDNA_PROHIBITED_ERROR, + U_IDNA_UNASSIGNED_ERROR, + U_IDNA_CHECK_BIDI_ERROR, + U_IDNA_STD3_ASCII_RULES_ERROR, + U_IDNA_ACE_PREFIX_ERROR, + U_IDNA_VERIFICATION_ERROR, + U_IDNA_LABEL_TOO_LONG_ERROR, + U_IDNA_ERROR_LIMIT, + /* + * Aliases for StringPrep + */ + U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR, + U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR, + U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR, + + + U_ERROR_LIMIT=U_IDNA_ERROR_LIMIT /**< This must always be the last value to indicate the limit for UErrorCode (last error code +1) */ +} UErrorCode; + +/* Use the following to determine if an UErrorCode represents */ +/* operational success or failure. */ + +#ifdef XP_CPLUSPLUS + /** + * Does the error code indicate success? + * @stable ICU 2.0 + */ + static + inline UBool U_SUCCESS(UErrorCode code) { return (UBool)(code<=U_ZERO_ERROR); } + /** + * Does the error code indicate a failure? + * @stable ICU 2.0 + */ + static + inline UBool U_FAILURE(UErrorCode code) { return (UBool)(code>U_ZERO_ERROR); } +#else + /** + * Does the error code indicate success? + * @stable ICU 2.0 + */ +# define U_SUCCESS(x) ((x)<=U_ZERO_ERROR) + /** + * Does the error code indicate a failure? + * @stable ICU 2.0 + */ +# define U_FAILURE(x) ((x)>U_ZERO_ERROR) +#endif + +/** + * Return a string for a UErrorCode value. + * The string will be the same as the name of the error code constant + * in the UErrorCode enum above. + * @stable ICU 2.0 + */ +U_STABLE const char * U_EXPORT2 +u_errorName(UErrorCode code); + + +#endif /* _UTYPES */ diff --git a/icu/unicode/uversion.h b/icu/unicode/uversion.h new file mode 100644 index 0000000..f9a7755 --- /dev/null +++ b/icu/unicode/uversion.h @@ -0,0 +1,216 @@ +/* +******************************************************************************* +* Copyright (C) 2000-2004, International Business Machines +* Corporation and others. All Rights Reserved. +******************************************************************************* +* +* file name: uversion.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* Created by: Vladimir Weinstein +* +* Contains all the important version numbers for ICU. +* Gets included by utypes.h and Windows .rc files +*/ + +/*===========================================================================*/ +/* Main ICU version information */ +/*===========================================================================*/ + +#ifndef UVERSION_H +#define UVERSION_H + +/** IMPORTANT: When updating version, the following things need to be done: */ +/** source/common/unicode/uversion.h - this file: update major, minor, */ +/** patchlevel, suffix, version, short version constants, namespace, */ +/** and copyright */ +/** source/common/common.dsp - update 'Output file name' on the link tab so */ +/** that it contains the new major/minor combination */ +/** source/i18n/i18n.dsp - same as for the common.dsp */ +/** source/layout/layout.dsp - same as for the common.dsp */ +/** source/stubdata/stubdata.dsp - same as for the common.dsp */ +/** source/extra/ustdio/ustdio.dsp - same as for the common.dsp */ +/** source/data/makedata.mak - change U_ICUDATA_NAME so that it contains */ +/** the new major/minor combination */ +/** source/tools/genren/genren.pl - use this script according to the README */ +/** in that folder */ + +#include "unicode/umachine.h" + +/** The standard copyright notice that gets compiled into each library. + * This value will change in the subsequent releases of ICU + * @stable ICU 2.4 + */ +#define U_COPYRIGHT_STRING \ + " Copyright (C) 2004, International Business Machines Corporation and others. All Rights Reserved. " + +/** Maximum length of the copyright string. + * @stable ICU 2.4 + */ +#define U_COPYRIGHT_STRING_LENGTH 128 + +/** The current ICU major version as an integer. + * This value will change in the subsequent releases of ICU + * @stable ICU 2.4 + */ +#define U_ICU_VERSION_MAJOR_NUM 3 + +/** The current ICU minor version as an integer. + * This value will change in the subsequent releases of ICU + * @stable ICU 2.6 + */ +#define U_ICU_VERSION_MINOR_NUM 2 + +/** The current ICU patchlevel version as an integer. + * This value will change in the subsequent releases of ICU + * @stable ICU 2.4 + */ +#define U_ICU_VERSION_PATCHLEVEL_NUM 0 + +/** Glued version suffix for renamers + * This value will change in the subsequent releases of ICU + * @stable ICU 2.6 + */ +#define U_ICU_VERSION_SUFFIX _3_2 + +/** The current ICU library version as a dotted-decimal string. The patchlevel + * only appears in this string if it non-zero. + * This value will change in the subsequent releases of ICU + * @stable ICU 2.4 + */ +#define U_ICU_VERSION "3.2" + +/** The current ICU library major/minor version as a string without dots, for library name suffixes. + * This value will change in the subsequent releases of ICU + * @stable ICU 2.6 + */ +#define U_ICU_VERSION_SHORT "32" + +/** An ICU version consists of up to 4 numbers from 0..255. + * @stable ICU 2.4 + */ +#define U_MAX_VERSION_LENGTH 4 + +/** In a string, ICU version fields are delimited by dots. + * @stable ICU 2.4 + */ +#define U_VERSION_DELIMITER '.' + +/** The maximum length of an ICU version string. + * @stable ICU 2.4 + */ +#define U_MAX_VERSION_STRING_LENGTH 20 + +/** The binary form of a version on ICU APIs is an array of 4 uint8_t. + * @stable ICU 2.4 + */ +typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; + +#if U_HAVE_NAMESPACE && defined(XP_CPLUSPLUS) +#if U_DISABLE_RENAMING +#define U_ICU_NAMESPACE icu +namespace U_ICU_NAMESPACE { } +#else +#define U_ICU_NAMESPACE icu_3_2 +namespace U_ICU_NAMESPACE { } +namespace icu = U_ICU_NAMESPACE; +#endif +U_NAMESPACE_USE +#endif + + +/*===========================================================================*/ +/* General version helper functions. Definitions in putil.c */ +/*===========================================================================*/ + +/** + * Parse a string with dotted-decimal version information and + * fill in a UVersionInfo structure with the result. + * Definition of this function lives in putil.c + * + * @param versionArray The destination structure for the version information. + * @param versionString A string with dotted-decimal version information, + * with up to four non-negative number fields with + * values of up to 255 each. + * @stable ICU 2.4 + */ +U_STABLE void U_EXPORT2 +u_versionFromString(UVersionInfo versionArray, const char *versionString); + +/** + * Write a string with dotted-decimal version information according + * to the input UVersionInfo. + * Definition of this function lives in putil.c + * + * @param versionArray The version information to be written as a string. + * @param versionString A string buffer that will be filled in with + * a string corresponding to the numeric version + * information in versionArray. + * The buffer size must be at least U_MAX_VERSION_STRING_LENGTH. + * @stable ICU 2.4 + */ +U_STABLE void U_EXPORT2 +u_versionToString(UVersionInfo versionArray, char *versionString); + +/** + * Gets the ICU release version. The version array stores the version information + * for ICU. For example, release "1.3.31.2" is then represented as 0x01031F02. + * Definition of this function lives in putil.c + * + * @param versionArray the version # information, the result will be filled in + * @stable ICU 2.0 + */ +U_STABLE void U_EXPORT2 +u_getVersion(UVersionInfo versionArray); + + +/*=========================================================================== + * ICU collation framework version information + * Version info that can be obtained from a collator is affected by these + * numbers in a secret and magic way. Please use collator version as whole + *=========================================================================== + */ + +/** Collation runtime version (sort key generator, strcoll). + * If the version is different, sortkeys for the same string could be different + * version 2 was in ICU 1.8.1. changed is: compression intervals, French secondary + * compression, generating quad level always when strength is quad or more + * version 4 - ICU 2.2 - tracking UCA changes, ignore completely ignorables + * in contractions, ignore primary ignorables after shifted + * version 5 - ICU 2.8 - changed implicit generation code + * This value may change in the subsequent releases of ICU + * @stable ICU 2.4 + */ +#define UCOL_RUNTIME_VERSION 5 + +/** Builder code version. When this is different, same tailoring might result + * in assigning different collation elements to code points + * version 2 was in ICU 1.8.1. added support for prefixes, tweaked canonical + * closure. However, the tailorings should probably get same CEs assigned + * version 5 - ICU 2.2 - fixed some bugs, renamed some indirect values. + * version 6 - ICU 2.8 - fixed bug in builder that allowed 0xFF in primary values + * Backward compatible with the old rules. + * This value may change in the subsequent releases of ICU + * @stable ICU 2.4 + */ +#define UCOL_BUILDER_VERSION 6 + +/** *** Removed *** Instead we use the data we read from FractionalUCA.txt + * This is the version of FractionalUCA.txt tailoring rules + * Version 1 was in ICU 1.8.1. Version two contains canonical closure for + * supplementary code points + * Version 4 in ICU 2.2, following UCA=3.1.1d6, UCD=3.2.0 + * This value may change in the subsequent releases of ICU + * @stable ICU 2.4 + */ +/*#define UCOL_FRACTIONAL_UCA_VERSION 4*/ + +/** This is the version of the tailorings + * This value may change in the subsequent releases of ICU + * @stable ICU 2.4 + */ +#define UCOL_TAILORINGS_VERSION 1 + +#endif diff --git a/jscore.bkl b/jscore.bkl new file mode 100644 index 0000000..2339691 --- /dev/null +++ b/jscore.bkl @@ -0,0 +1,114 @@ + + + + + . + + + + + obj-$(FORMAT) + + + + + off + off + on + jscore + $(SRCDIR) + $(WK_ROOT)/JavaScriptCore + $(WK_ROOT)/JavaScriptCore/kjs + $(WK_ROOT)/JavaScriptCore/pcre + $(WK_ROOT)/JavaScriptCore/wtf + $(WKOUTPUTDIR) + $(SRCDIR)/kjs/testkjs.cpp + + $(WKOUTPUTDIR)/libjscore.a + + + $(WK_ROOT)/WebKitLibraries/win/include + jscore + winmm + $(WKOUTPUTDIR) + $(WK_ROOT)/WebKitLibraries/win/lib + + + + + + + bash make-generated-sources.sh + + + + + + diff --git a/kjs/Activation.h b/kjs/Activation.h new file mode 100644 index 0000000..0fdd2cc --- /dev/null +++ b/kjs/Activation.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) + * Copyright (C) 2007 Maks Orlovich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef Activation_h +#define Activation_h + +#include "ExecState.h" +#include "JSVariableObject.h" +#include "object.h" + +namespace KJS { + + class Arguments; + class FunctionImp; + + class ActivationImp : public JSVariableObject { + friend class JSGlobalObject; + friend struct StackActivation; + private: + struct ActivationData : public JSVariableObjectData { + ActivationData() : isOnStack(true), leftRelic(false) { } + ActivationData(const ActivationData&); + + ExecState* exec; + FunctionImp* function; + Arguments* argumentsObject; + + bool isOnStack : 1; + bool leftRelic : 1; + }; + + public: + ActivationImp() { } + ActivationImp(const ActivationData&, bool); + + virtual ~ActivationImp(); + + void init(ExecState*); + + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None); + virtual bool deleteProperty(ExecState*, const Identifier& propertyName); + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + + virtual void mark(); + void markChildren(); + + virtual bool isActivationObject() { return true; } + + bool isOnStack() const { return d()->isOnStack; } + bool needsPop() const { return d()->isOnStack || d()->leftRelic; } + + private: + static PropertySlot::GetValueFunc getArgumentsGetter(); + static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + void createArgumentsObject(ExecState*); + ActivationData* d() const { return static_cast(JSVariableObject::d); } + }; + + const size_t activationStackNodeSize = 32; + + struct StackActivation { + StackActivation() { activationStorage.JSVariableObject::d = &activationDataStorage; } + StackActivation(const StackActivation&); + + ActivationImp activationStorage; + ActivationImp::ActivationData activationDataStorage; + }; + + struct ActivationStackNode { + ActivationStackNode* prev; + StackActivation data[activationStackNodeSize]; + }; + +} // namespace + +#endif diff --git a/kjs/AllInOneFile.cpp b/kjs/AllInOneFile.cpp new file mode 100644 index 0000000..8c19f80 --- /dev/null +++ b/kjs/AllInOneFile.cpp @@ -0,0 +1,73 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +// This file exists to help compile the essential code of +// JavaScriptCore all as one file, for compilers and build systems +// that see a significant speed gain from this. + +#define KDE_USE_FINAL 1 +#include "config.h" + +#include "function.cpp" +#include "debugger.cpp" +#include "array_instance.cpp" +#include "array_object.cpp" +#include "bool_object.cpp" +#include "collector.cpp" +#if PLATFORM(DARWIN) +#include "CollectorHeapIntrospector.cpp" +#endif +#include "CommonIdentifiers.cpp" +#include "date_object.cpp" +#include "DateMath.cpp" +#include "dtoa.cpp" +#include "error_object.cpp" +#include "ExecState.cpp" +#include "function_object.cpp" +#include "grammar.cpp" +#include "identifier.cpp" +#include "internal.cpp" +#include "interpreter.cpp" +#include "JSImmediate.cpp" +#include "JSLock.cpp" +#include "JSWrapperObject.cpp" +#include "lexer.cpp" +#include "list.cpp" +#include "lookup.cpp" +#include "math_object.cpp" +#include "nodes.cpp" +#include "nodes2string.cpp" +#include "number_object.cpp" +#include "object.cpp" +#include "object_object.cpp" +#include "operations.cpp" +#include "Parser.cpp" +#include "property_map.cpp" +#include "property_slot.cpp" +#include "PropertyNameArray.cpp" +#include "regexp.cpp" +#include "regexp_object.cpp" +#include "scope_chain.cpp" +#include "string_object.cpp" +#include "ustring.cpp" +#include "value.cpp" +#include "wtf/FastMalloc.cpp" +#include "wtf/TCSystemAlloc.cpp" diff --git a/kjs/CollectorHeapIntrospector.cpp b/kjs/CollectorHeapIntrospector.cpp new file mode 100644 index 0000000..6941b58 --- /dev/null +++ b/kjs/CollectorHeapIntrospector.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "CollectorHeapIntrospector.h" + +#include "collector.h" +#include "MallocZoneSupport.h" + +namespace KJS { + +extern "C" { +malloc_introspection_t jscore_collector_introspection = { &CollectorHeapIntrospector::enumerate, &CollectorHeapIntrospector::goodSize, &CollectorHeapIntrospector::check, &CollectorHeapIntrospector::print, + &CollectorHeapIntrospector::log, &CollectorHeapIntrospector::forceLock, &CollectorHeapIntrospector::forceUnlock, &CollectorHeapIntrospector::statistics }; +} + +void CollectorHeapIntrospector::init(CollectorHeap* primaryHeap, CollectorHeap* numberHeap) +{ + static CollectorHeapIntrospector zone(primaryHeap, numberHeap); +} + +CollectorHeapIntrospector::CollectorHeapIntrospector(CollectorHeap* primaryHeap, CollectorHeap* numberHeap) + : m_primaryHeap(primaryHeap) + , m_numberHeap(numberHeap) +{ + memset(&m_zone, 0, sizeof(m_zone)); + m_zone.zone_name = "JavaScriptCore Collector"; + m_zone.size = &CollectorHeapIntrospector::size; + m_zone.malloc = &CollectorHeapIntrospector::zoneMalloc; + m_zone.calloc = &CollectorHeapIntrospector::zoneCalloc; + m_zone.realloc = &CollectorHeapIntrospector::zoneRealloc; + m_zone.free = &CollectorHeapIntrospector::zoneFree; + m_zone.valloc = &CollectorHeapIntrospector::zoneValloc; + m_zone.destroy = &CollectorHeapIntrospector::zoneDestroy; + m_zone.introspect = &jscore_collector_introspection; + malloc_zone_register(&m_zone); +} + +kern_return_t CollectorHeapIntrospector::enumerate(task_t task, void* context, unsigned typeMask, vm_address_t zoneAddress, memory_reader_t reader, vm_range_recorder_t recorder) +{ + RemoteMemoryReader memoryReader(task, reader); + CollectorHeapIntrospector* zone = memoryReader(reinterpret_cast(zoneAddress)); + CollectorHeap* heaps[2] = {memoryReader(zone->m_primaryHeap), memoryReader(zone->m_numberHeap)}; + + if (!heaps[0]->blocks && !heaps[1]->blocks) + return 0; + + for (int currentHeap = 0; currentHeap < 2; currentHeap++) { + CollectorHeap* heap = heaps[currentHeap]; + CollectorBlock** blocks = memoryReader(heap->blocks); + for (unsigned i = 0; i < heap->usedBlocks; i++) { + vm_address_t remoteBlockAddress = reinterpret_cast(blocks[i]); + vm_range_t ptrRange = { remoteBlockAddress, sizeof(CollectorBlock) }; + + if (typeMask & (MALLOC_PTR_REGION_RANGE_TYPE | MALLOC_ADMIN_REGION_RANGE_TYPE)) + (*recorder)(task, context, MALLOC_PTR_REGION_RANGE_TYPE, &ptrRange, 1); + + // Recording individual cells causes frequent false-positives. Any garbage cells + // which have yet to be collected are labeled as leaks. Recording on a per-block + // basis provides less detail but avoids these false-positives. + if (memoryReader(blocks[i])->usedCells && (typeMask & MALLOC_PTR_IN_USE_RANGE_TYPE)) + (*recorder)(task, context, MALLOC_PTR_IN_USE_RANGE_TYPE, &ptrRange, 1); + } + } + + return 0; +} + +} // namespace KJS diff --git a/kjs/CollectorHeapIntrospector.h b/kjs/CollectorHeapIntrospector.h new file mode 100644 index 0000000..76ba324 --- /dev/null +++ b/kjs/CollectorHeapIntrospector.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CollectorHeapIntrospector_h +#define CollectorHeapIntrospector_h + +#include +#include "Assertions.h" + +namespace KJS { + +struct CollectorHeap; + +class CollectorHeapIntrospector { +public: + static void init(CollectorHeap*, CollectorHeap*); + static kern_return_t enumerate(task_t, void* context, unsigned typeMask, vm_address_t zoneAddress, memory_reader_t, vm_range_recorder_t); + static size_t goodSize(malloc_zone_t*, size_t size) { return size; } + static boolean_t check(malloc_zone_t*) { return true; } + static void print(malloc_zone_t*, boolean_t) { } + static void log(malloc_zone_t*, void*) { } + static void forceLock(malloc_zone_t*) { } + static void forceUnlock(malloc_zone_t*) { } + static void statistics(malloc_zone_t*, malloc_statistics_t*) { } + +private: + CollectorHeapIntrospector(CollectorHeap*, CollectorHeap*); + static size_t size(malloc_zone_t*, const void*) { return 0; } + static void* zoneMalloc(malloc_zone_t*, size_t) { LOG_ERROR("malloc is not supported"); return 0; } + static void* zoneCalloc(malloc_zone_t*, size_t, size_t) { LOG_ERROR("calloc is not supported"); return 0; } + static void* zoneRealloc(malloc_zone_t*, void*, size_t) { LOG_ERROR("realloc is not supported"); return 0; } + static void* zoneValloc(malloc_zone_t*, size_t) { LOG_ERROR("valloc is not supported"); return 0; } + static void zoneDestroy(malloc_zone_t*) { } + + static void zoneFree(malloc_zone_t*, void* ptr) + { + // Due to zoneFree may be called by the system free even if the pointer + // is not in this zone. When this happens, the pointer being freed was not allocated by any + // zone so we need to print a useful error for the application developer. + malloc_printf("*** error for object %p: pointer being freed was not allocated\n", ptr); + } + + malloc_zone_t m_zone; + CollectorHeap* m_primaryHeap; + CollectorHeap* m_numberHeap; +}; + +} + +#endif // CollectorHeapIntrospector_h diff --git a/kjs/CommonIdentifiers.cpp b/kjs/CommonIdentifiers.cpp new file mode 100644 index 0000000..5f673b8 --- /dev/null +++ b/kjs/CommonIdentifiers.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "CommonIdentifiers.h" + +namespace KJS { + +const char* const nullCString = 0; + +#define INITIALIZE_PROPERTY_NAME(name) , name ( #name ) + +CommonIdentifiers::CommonIdentifiers() + : nullIdentifier(nullCString) + , underscoreProto("__proto__") + KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PROPERTY_NAME) +{ +} + +CommonIdentifiers* CommonIdentifiers::shared() +{ + static CommonIdentifiers* sharedInstance; + if (!sharedInstance) { + JSLock lock; + sharedInstance = new CommonIdentifiers; + } + return sharedInstance; +} + +} // namespace KJS diff --git a/kjs/CommonIdentifiers.h b/kjs/CommonIdentifiers.h new file mode 100644 index 0000000..ae5c778 --- /dev/null +++ b/kjs/CommonIdentifiers.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2003,2007 Apple Computer, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_COMMON_IDENTIFIERS_H +#define KJS_COMMON_IDENTIFIERS_H + +#include "identifier.h" +#include + +// List of property names, passed to a macro so we can do set them up various +// ways without repeating the list. +#define KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \ + macro(arguments) \ + macro(callee) \ + macro(caller) \ + macro(constructor) \ + macro(fromCharCode) \ + macro(global) \ + macro(ignoreCase) \ + macro(index) \ + macro(input) \ + macro(length) \ + macro(message) \ + macro(multiline) \ + macro(name) \ + macro(prototype) \ + macro(source) \ + macro(toExponential) \ + macro(toFixed) \ + macro(toLocaleString) \ + macro(toPrecision) \ + macro(toString) \ + macro(valueOf) + +namespace KJS { + + class CommonIdentifiers : Noncopyable { + + private: + CommonIdentifiers(); + + public: + static CommonIdentifiers* shared(); + + const Identifier nullIdentifier; + const Identifier underscoreProto; + +#define KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name; + KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL) +#undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL + }; +} // namespace KJS + +#endif // KJS_COMMON_IDENTIFIERS_H + diff --git a/kjs/DateMath.cpp b/kjs/DateMath.cpp new file mode 100644 index 0000000..22816b3 --- /dev/null +++ b/kjs/DateMath.cpp @@ -0,0 +1,506 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Alternatively, the contents of this file may be used under the terms + * of either the Mozilla Public License Version 1.1, found at + * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public + * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html + * (the "GPL"), in which case the provisions of the MPL or the GPL are + * applicable instead of those above. If you wish to allow use of your + * version of this file only under the terms of one of those two + * licenses (the MPL or the GPL) and not to allow others to use your + * version of this file under the LGPL, indicate your decision by + * deletingthe provisions above and replace them with the notice and + * other provisions required by the MPL or the GPL, as the case may be. + * If you do not delete the provisions above, a recipient may use your + * version of this file under any of the LGPL, the MPL or the GPL. + */ + +#include "config.h" +#include "DateMath.h" + +#include +#include +#include + +#include + +#if PLATFORM(DARWIN) +#include +#endif + +#if HAVE(SYS_TIME_H) +#include +#endif + +#if HAVE(SYS_TIMEB_H) +#include +#endif + +namespace KJS { + +/* Constants */ + +static const double minutesPerDay = 24.0 * 60.0; +static const double secondsPerDay = 24.0 * 60.0 * 60.0; +static const double secondsPerYear = 24.0 * 60.0 * 60.0 * 365.0; + +static const double usecPerSec = 1000000.0; + +static const double maxUnixTime = 2145859200.0; // 12/31/2037 + +// Day of year for the first day of each month, where index 0 is January, and day 0 is January 1. +// First for non-leap years, then for leap years. +static const int firstDayOfMonth[2][12] = { + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335} +}; + +static inline bool isLeapYear(int year) +{ + if (year % 4 != 0) + return false; + if (year % 400 == 0) + return true; + if (year % 100 == 0) + return false; + return true; +} + +static inline int daysInYear(int year) +{ + return 365 + isLeapYear(year); +} + +static inline double daysFrom1970ToYear(int year) +{ + // The Gregorian Calendar rules for leap years: + // Every fourth year is a leap year. 2004, 2008, and 2012 are leap years. + // However, every hundredth year is not a leap year. 1900 and 2100 are not leap years. + // Every four hundred years, there's a leap year after all. 2000 and 2400 are leap years. + + static const int leapDaysBefore1971By4Rule = 1970 / 4; + static const int excludedLeapDaysBefore1971By100Rule = 1970 / 100; + static const int leapDaysBefore1971By400Rule = 1970 / 400; + + const double yearMinusOne = year - 1; + const double yearsToAddBy4Rule = floor(yearMinusOne / 4.0) - leapDaysBefore1971By4Rule; + const double yearsToExcludeBy100Rule = floor(yearMinusOne / 100.0) - excludedLeapDaysBefore1971By100Rule; + const double yearsToAddBy400Rule = floor(yearMinusOne / 400.0) - leapDaysBefore1971By400Rule; + + return 365.0 * (year - 1970) + yearsToAddBy4Rule - yearsToExcludeBy100Rule + yearsToAddBy400Rule; +} + +static inline double msToDays(double ms) +{ + return floor(ms / msPerDay); +} + +static inline int msToYear(double ms) +{ + int approxYear = static_cast(floor(ms / (msPerDay * 365.2425)) + 1970); + double msFromApproxYearTo1970 = msPerDay * daysFrom1970ToYear(approxYear); + if (msFromApproxYearTo1970 > ms) + return approxYear - 1; + if (msFromApproxYearTo1970 + msPerDay * daysInYear(approxYear) <= ms) + return approxYear + 1; + return approxYear; +} + +static inline int dayInYear(double ms, int year) +{ + return static_cast(msToDays(ms) - daysFrom1970ToYear(year)); +} + +static inline double msToMilliseconds(double ms) +{ + double result = fmod(ms, msPerDay); + if (result < 0) + result += msPerDay; + return result; +} + +// 0: Sunday, 1: Monday, etc. +static inline int msToWeekDay(double ms) +{ + int wd = (static_cast(msToDays(ms)) + 4) % 7; + if (wd < 0) + wd += 7; + return wd; +} + +static inline int msToSeconds(double ms) +{ + double result = fmod(floor(ms / msPerSecond), secondsPerMinute); + if (result < 0) + result += secondsPerMinute; + return static_cast(result); +} + +static inline int msToMinutes(double ms) +{ + double result = fmod(floor(ms / msPerMinute), minutesPerHour); + if (result < 0) + result += minutesPerHour; + return static_cast(result); +} + +static inline int msToHours(double ms) +{ + double result = fmod(floor(ms/msPerHour), hoursPerDay); + if (result < 0) + result += hoursPerDay; + return static_cast(result); +} + +static inline int monthFromDayInYear(int dayInYear, bool leapYear) +{ + const int d = dayInYear; + int step; + + if (d < (step = 31)) + return 0; + step += (leapYear ? 29 : 28); + if (d < step) + return 1; + if (d < (step += 31)) + return 2; + if (d < (step += 30)) + return 3; + if (d < (step += 31)) + return 4; + if (d < (step += 30)) + return 5; + if (d < (step += 31)) + return 6; + if (d < (step += 31)) + return 7; + if (d < (step += 30)) + return 8; + if (d < (step += 31)) + return 9; + if (d < (step += 30)) + return 10; + return 11; +} + +static inline bool checkMonth(int dayInYear, int& startDayOfThisMonth, int& startDayOfNextMonth, int daysInThisMonth) +{ + startDayOfThisMonth = startDayOfNextMonth; + startDayOfNextMonth += daysInThisMonth; + return (dayInYear <= startDayOfNextMonth); +} + +static inline int dayInMonthFromDayInYear(int dayInYear, bool leapYear) +{ + const int d = dayInYear; + int step; + int next = 30; + + if (d <= next) + return d + 1; + const int daysInFeb = (leapYear ? 29 : 28); + if (checkMonth(d, step, next, daysInFeb)) + return d - step; + if (checkMonth(d, step, next, 31)) + return d - step; + if (checkMonth(d, step, next, 30)) + return d - step; + if (checkMonth(d, step, next, 31)) + return d - step; + if (checkMonth(d, step, next, 30)) + return d - step; + if (checkMonth(d, step, next, 31)) + return d - step; + if (checkMonth(d, step, next, 31)) + return d - step; + if (checkMonth(d, step, next, 30)) + return d - step; + if (checkMonth(d, step, next, 31)) + return d - step; + if (checkMonth(d, step, next, 30)) + return d - step; + step = next; + return d - step; +} + +static inline int monthToDayInYear(int month, bool isLeapYear) +{ + return firstDayOfMonth[isLeapYear][month]; +} + +static inline double timeToMS(double hour, double min, double sec, double ms) +{ + return (((hour * minutesPerHour + min) * secondsPerMinute + sec) * msPerSecond + ms); +} + +static int dateToDayInYear(int year, int month, int day) +{ + year += month / 12; + + month %= 12; + if (month < 0) { + month += 12; + --year; + } + + int yearday = static_cast(floor(daysFrom1970ToYear(year))); + int monthday = monthToDayInYear(month, isLeapYear(year)); + + return yearday + monthday + day - 1; +} + +double getCurrentUTCTime() +{ +#if PLATFORM(WIN_OS) +#if COMPILER(BORLAND) + struct timeb timebuffer; + ftime(&timebuffer); +#else + struct _timeb timebuffer; + _ftime(&timebuffer); +#endif + double utc = timebuffer.time * msPerSecond + timebuffer.millitm; +#else + struct timeval tv; + gettimeofday(&tv, 0); + double utc = floor(tv.tv_sec * msPerSecond + tv.tv_usec / 1000); +#endif + return utc; +} + +// There is a hard limit at 2038 that we currently do not have a workaround +// for (rdar://problem/5052975). +static inline int maximumYearForDST() +{ + return 2037; +} + +// It is ok if the cached year is not the current year (e.g. Dec 31st) +// so long as the rules for DST did not change between the two years, if it does +// the app would need to be restarted. +static int mimimumYearForDST() +{ + // Because of the 2038 issue (see maximumYearForDST) if the current year is + // greater than the max year minus 27 (2010), we want to use the max year + // minus 27 instead, to ensure there is a range of 28 years that all years + // can map to. + static int minYear = std::min(msToYear(getCurrentUTCTime()), maximumYearForDST() - 27) ; + return minYear; +} + +/* + * Find an equivalent year for the one given, where equivalence is deterined by + * the two years having the same leapness and the first day of the year, falling + * on the same day of the week. + * + * This function returns a year between this current year and 2037, however this + * function will potentially return incorrect results if the current year is after + * 2010, (rdar://problem/5052975), if the year passed in is before 1900 or after + * 2100, (rdar://problem/5055038). + */ +int equivalentYearForDST(int year) +{ + static int minYear = mimimumYearForDST(); + static int maxYear = maximumYearForDST(); + + int difference; + if (year > maxYear) + difference = minYear - year; + else if (year < minYear) + difference = maxYear - year; + else + return year; + + int quotient = difference / 28; + int product = (quotient) * 28; + + year += product; + ASSERT((year >= minYear && year <= maxYear) || (product - year == static_cast(NaN))); + return year; +} + +/* + * Get the difference in milliseconds between this time zone and UTC (GMT) + * NOT including DST. + */ +double getUTCOffset() +{ +#if PLATFORM(DARWIN) + // Register for a notification whenever the time zone changes. + static bool triedToRegister = false; + static bool haveNotificationToken = false; + static int notificationToken; + if (!triedToRegister) { + triedToRegister = true; + uint32_t status = notify_register_check("com.apple.system.timezone", ¬ificationToken); + if (status == NOTIFY_STATUS_OK) + haveNotificationToken = true; + } + + // If we can verify that we have not received a time zone notification, + // then use the cached offset from the last time this function was called. + static bool haveCachedOffset = false; + static double cachedOffset; + if (haveNotificationToken && haveCachedOffset) { + int notified; + uint32_t status = notify_check(notificationToken, ¬ified); + if (status == NOTIFY_STATUS_OK && !notified) + return cachedOffset; + } +#endif + + tm localt; + + memset(&localt, 0, sizeof(localt)); + + // get the difference between this time zone and UTC on Jan 01, 2000 12:00:00 AM + localt.tm_mday = 1; + localt.tm_year = 100; + double utcOffset = 946684800.0 - mktime(&localt); + + utcOffset *= msPerSecond; + +#if PLATFORM(DARWIN) + haveCachedOffset = true; + cachedOffset = utcOffset; +#endif + + return utcOffset; +} + +/* + * Get the DST offset for the time passed in. Takes + * seconds (not milliseconds) and cannot handle dates before 1970 + * on some OS' + */ +static double getDSTOffsetSimple(double localTimeSeconds, double utcOffset) +{ + if (localTimeSeconds > maxUnixTime) + localTimeSeconds = maxUnixTime; + else if (localTimeSeconds < 0) // Go ahead a day to make localtime work (does not work with 0) + localTimeSeconds += secondsPerDay; + + //input is UTC so we have to shift back to local time to determine DST thus the + getUTCOffset() + double offsetTime = (localTimeSeconds * msPerSecond) + utcOffset; + + // Offset from UTC but doesn't include DST obviously + int offsetHour = msToHours(offsetTime); + int offsetMinute = msToMinutes(offsetTime); + + // FIXME: time_t has a potential problem in 2038 + time_t localTime = static_cast(localTimeSeconds); + + tm localTM; +#if PLATFORM(QT) + // ### this is not threadsafe but we don't use multiple threads anyway + // in the Qt build +#if USE(MULTIPLE_THREADS) +#error Mulitple threads are currently not supported in the Qt/mingw build +#endif + localTM = *localtime(&localTime); +#elif PLATFORM(WIN_OS) + #if COMPILER(MSVC7) + localTM = *localtime(&localTime); + #else + localtime_s(&localTM, &localTime); + #endif +#else + localtime_r(&localTime, &localTM); +#endif + + double diff = ((localTM.tm_hour - offsetHour) * secondsPerHour) + ((localTM.tm_min - offsetMinute) * 60); + + if (diff < 0) + diff += secondsPerDay; + + return (diff * msPerSecond); +} + +// Get the DST offset, given a time in UTC +static double getDSTOffset(double ms, double utcOffset) +{ + // On Mac OS X, the call to localtime (see getDSTOffsetSimple) will return historically accurate + // DST information (e.g. New Zealand did not have DST from 1946 to 1974) however the JavaScript + // standard explicitly dictates that historical information should not be considered when + // determining DST. For this reason we shift away from years that localtime can handle but would + // return historically accurate information. + int year = msToYear(ms); + int equivalentYear = equivalentYearForDST(year); + if (year != equivalentYear) { + bool leapYear = isLeapYear(year); + int dayInYearLocal = dayInYear(ms, year); + int dayInMonth = dayInMonthFromDayInYear(dayInYearLocal, leapYear); + int month = monthFromDayInYear(dayInYearLocal, leapYear); + int day = dateToDayInYear(equivalentYear, month, dayInMonth); + ms = (day * msPerDay) + msToMilliseconds(ms); + } + + return getDSTOffsetSimple(ms / msPerSecond, utcOffset); +} + +double gregorianDateTimeToMS(const GregorianDateTime& t, double milliSeconds, bool inputIsUTC) +{ + int day = dateToDayInYear(t.year + 1900, t.month, t.monthDay); + double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds); + double result = (day * msPerDay) + ms; + + if (!inputIsUTC) { // convert to UTC + double utcOffset = getUTCOffset(); + result -= utcOffset; + result -= getDSTOffset(result, utcOffset); + } + + return result; +} + +void msToGregorianDateTime(double ms, bool outputIsUTC, GregorianDateTime& tm) +{ + // input is UTC + double dstOff = 0.0; + const double utcOff = getUTCOffset(); + + if (!outputIsUTC) { // convert to local time + dstOff = getDSTOffset(ms, utcOff); + ms += dstOff + utcOff; + } + + const int year = msToYear(ms); + tm.second = msToSeconds(ms); + tm.minute = msToMinutes(ms); + tm.hour = msToHours(ms); + tm.weekDay = msToWeekDay(ms); + tm.yearDay = dayInYear(ms, year); + tm.monthDay = dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year)); + tm.month = monthFromDayInYear(tm.yearDay, isLeapYear(year)); + tm.year = year - 1900; + tm.isDST = dstOff != 0.0; + + tm.utcOffset = static_cast((dstOff + utcOff) / msPerSecond); + tm.timeZone = NULL; +} + +} // namespace KJS diff --git a/kjs/DateMath.h b/kjs/DateMath.h new file mode 100644 index 0000000..6fdad0b --- /dev/null +++ b/kjs/DateMath.h @@ -0,0 +1,154 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + */ + +#ifndef DateMath_h +#define DateMath_h + +#include +#include +#include + +namespace KJS { + +struct GregorianDateTime; + +void msToGregorianDateTime(double, bool outputIsUTC, GregorianDateTime&); +double gregorianDateTimeToMS(const GregorianDateTime&, double, bool inputIsUTC); +double getUTCOffset(); +int equivalentYearForDST(int year); +double getCurrentUTCTime(); + +const char * const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; +const char * const monthName[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + +const double hoursPerDay = 24.0; +const double minutesPerHour = 60.0; +const double secondsPerHour = 60.0 * 60.0; +const double secondsPerMinute = 60.0; +const double msPerSecond = 1000.0; +const double msPerMinute = 60.0 * 1000.0; +const double msPerHour = 60.0 * 60.0 * 1000.0; +const double msPerDay = 24.0 * 60.0 * 60.0 * 1000.0; + +// Intentionally overridding the default tm of the system +// Tee members of tm differ on various operating systems. +struct GregorianDateTime : Noncopyable { + GregorianDateTime() + : second(0) + , minute(0) + , hour(0) + , weekDay(0) + , monthDay(0) + , yearDay(0) + , month(0) + , year(0) + , isDST(0) + , utcOffset(0) + , timeZone(0) + { + } + + ~GregorianDateTime() + { + delete [] timeZone; + } + + GregorianDateTime(const tm& inTm) + : second(inTm.tm_sec) + , minute(inTm.tm_min) + , hour(inTm.tm_hour) + , weekDay(inTm.tm_wday) + , monthDay(inTm.tm_mday) + , yearDay(inTm.tm_yday) + , month(inTm.tm_mon) + , year(inTm.tm_year) + , isDST(inTm.tm_isdst) + { +#if !PLATFORM(WIN_OS) && !PLATFORM(SOLARIS) + utcOffset = static_cast(inTm.tm_gmtoff); + + int inZoneSize = strlen(inTm.tm_zone) + 1; + timeZone = new char[inZoneSize]; + strncpy(timeZone, inTm.tm_zone, inZoneSize); +#else + utcOffset = static_cast(getUTCOffset() / msPerSecond + (isDST ? secondsPerHour : 0)); + timeZone = 0; +#endif + } + + operator tm() const + { + tm ret; + memset(&ret, 0, sizeof(ret)); + + ret.tm_sec = second; + ret.tm_min = minute; + ret.tm_hour = hour; + ret.tm_wday = weekDay; + ret.tm_mday = monthDay; + ret.tm_yday = yearDay; + ret.tm_mon = month; + ret.tm_year = year; + ret.tm_isdst = isDST; + +#if !PLATFORM(WIN_OS) && !PLATFORM(SOLARIS) + ret.tm_gmtoff = static_cast(utcOffset); + ret.tm_zone = timeZone; +#endif + + return ret; + } + + int second; + int minute; + int hour; + int weekDay; + int monthDay; + int yearDay; + int month; + int year; + int isDST; + int utcOffset; + char* timeZone; +}; + +} //namespace KJS + +#endif // DateMath_h diff --git a/kjs/ExecState.cpp b/kjs/ExecState.cpp new file mode 100644 index 0000000..b37523e --- /dev/null +++ b/kjs/ExecState.cpp @@ -0,0 +1,215 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "ExecState.h" + +#include "Activation.h" +#include "JSGlobalObject.h" +#include "function.h" +#include "internal.h" +#include "scope_chain_mark.h" + +namespace KJS { + +static inline List* globalEmptyList() +{ + static List staticEmptyList; + return &staticEmptyList; +} + +// ECMA 10.2 + +// The constructor for the globalExec pseudo-ExecState +inline ExecState::ExecState(JSGlobalObject* globalObject) + : m_globalObject(globalObject) + , m_exception(0) + , m_propertyNames(CommonIdentifiers::shared()) + , m_emptyList(globalEmptyList()) + , m_callingExec(0) + , m_scopeNode(0) + , m_function(0) + , m_arguments(0) + , m_activation(0) + , m_localStorage(&globalObject->localStorage()) + , m_variableObject(globalObject) + , m_thisValue(globalObject) + , m_iterationDepth(0) + , m_switchDepth(0) + , m_codeType(GlobalCode) +{ + m_scopeChain.push(globalObject); +} + +inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* /*thisObject*/, ProgramNode* programNode) + : m_globalObject(globalObject) + , m_exception(0) + , m_propertyNames(CommonIdentifiers::shared()) + , m_emptyList(globalEmptyList()) + , m_callingExec(0) + , m_scopeNode(programNode) + , m_function(0) + , m_arguments(0) + , m_activation(0) + , m_localStorage(&globalObject->localStorage()) + , m_variableObject(globalObject) + , m_thisValue(globalObject) + , m_iterationDepth(0) + , m_switchDepth(0) + , m_codeType(GlobalCode) +{ + // FIXME: This function ignores the "thisObject" parameter, which means that the API for evaluating + // a script with a this object that's not the same as the global object is broken, and probably + // has been for some time. + ASSERT(m_scopeNode); + m_scopeChain.push(globalObject); +} + +inline ExecState::ExecState(JSGlobalObject* globalObject, EvalNode* evalNode, ExecState* callingExec) + : m_globalObject(globalObject) + , m_exception(0) + , m_propertyNames(callingExec->m_propertyNames) + , m_emptyList(callingExec->m_emptyList) + , m_callingExec(callingExec) + , m_scopeNode(evalNode) + , m_function(0) + , m_arguments(0) + , m_activation(0) + , m_localStorage(callingExec->m_localStorage) + , m_scopeChain(callingExec->m_scopeChain) + , m_variableObject(callingExec->m_variableObject) + , m_thisValue(callingExec->m_thisValue) + , m_iterationDepth(0) + , m_switchDepth(0) + , m_codeType(EvalCode) +{ + ASSERT(m_scopeNode); +} + +inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisObject, + FunctionBodyNode* functionBodyNode, ExecState* callingExec, + FunctionImp* func, const List& args) + : m_globalObject(globalObject) + , m_exception(0) + , m_propertyNames(callingExec->m_propertyNames) + , m_emptyList(callingExec->m_emptyList) + , m_callingExec(callingExec) + , m_scopeNode(functionBodyNode) + , m_function(func) + , m_arguments(&args) + , m_scopeChain(func->scope()) + , m_thisValue(thisObject) + , m_iterationDepth(0) + , m_switchDepth(0) + , m_codeType(FunctionCode) +{ + ASSERT(m_scopeNode); + + ActivationImp* activation = globalObject->pushActivation(this); + m_activation = activation; + m_localStorage = &activation->localStorage(); + m_variableObject = activation; + m_scopeChain.push(activation); +} + +inline ExecState::~ExecState() +{ +} + +JSGlobalObject* ExecState::lexicalGlobalObject() const +{ + JSObject* object = m_scopeChain.bottom(); + if (object && object->isGlobalObject()) + return static_cast(object); + return m_globalObject; +} + +void ExecState::markActiveExecStates() +{ + ExecStateStack::const_iterator end = activeExecStates().end(); + for (ExecStateStack::const_iterator it = activeExecStates().begin(); it != end; ++it) + (*it)->m_scopeChain.mark(); +} + +static inline ExecStateStack& inlineActiveExecStates() +{ + static ExecStateStack staticActiveExecStates; + return staticActiveExecStates; +} + +ExecStateStack& ExecState::activeExecStates() +{ + return inlineActiveExecStates(); +} + +GlobalExecState::GlobalExecState(JSGlobalObject* globalObject) + : ExecState(globalObject) +{ +} + +GlobalExecState::~GlobalExecState() +{ +} + +InterpreterExecState::InterpreterExecState(JSGlobalObject* globalObject, JSObject* thisObject, ProgramNode* programNode) + : ExecState(globalObject, thisObject, programNode) +{ + inlineActiveExecStates().append(this); +} + +InterpreterExecState::~InterpreterExecState() +{ + ASSERT(inlineActiveExecStates().last() == this); + inlineActiveExecStates().removeLast(); +} + +EvalExecState::EvalExecState(JSGlobalObject* globalObject, EvalNode* evalNode, ExecState* callingExec) + : ExecState(globalObject, evalNode, callingExec) +{ + inlineActiveExecStates().append(this); +} + +EvalExecState::~EvalExecState() +{ + ASSERT(inlineActiveExecStates().last() == this); + inlineActiveExecStates().removeLast(); +} + +FunctionExecState::FunctionExecState(JSGlobalObject* globalObject, JSObject* thisObject, + FunctionBodyNode* functionBodyNode, ExecState* callingExec, + FunctionImp* func, const List& args) + : ExecState(globalObject, thisObject, functionBodyNode, callingExec, func, args) +{ + inlineActiveExecStates().append(this); +} + +FunctionExecState::~FunctionExecState() +{ + ASSERT(inlineActiveExecStates().last() == this); + inlineActiveExecStates().removeLast(); + + if (m_activation->needsPop()) + m_globalObject->popActivation(); +} + +} // namespace KJS diff --git a/kjs/ExecState.h b/kjs/ExecState.h new file mode 100644 index 0000000..ed8b4d2 --- /dev/null +++ b/kjs/ExecState.h @@ -0,0 +1,241 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef ExecState_h +#define ExecState_h + +#include "LabelStack.h" +#include "LocalStorage.h" +#include "completion.h" +#include "list.h" +#include "scope_chain.h" + +namespace KJS { + + class ActivationImp; + class CommonIdentifiers; + class EvalNode; + class FunctionBodyNode; + class FunctionImp; + class GlobalFuncImp; + class Interpreter; + class JSGlobalObject; + class JSVariableObject; + class ProgramNode; + class ScopeNode; + + enum CodeType { GlobalCode, EvalCode, FunctionCode }; + + typedef Vector ExecStateStack; + + // Represents the current state of script execution. + // Passed as the first argument to most functions. + class ExecState : Noncopyable { + public: + // Global object that was in scope when the current script started executing. + JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; } + + // Global object that was in scope when the current body of code was defined. + JSGlobalObject* lexicalGlobalObject() const; + + void setException(JSValue* e) { m_exception = e; } + void clearException() { m_exception = 0; } + JSValue* exception() const { return m_exception; } + JSValue** exceptionSlot() { return &m_exception; } + bool hadException() const { return !!m_exception; } + + const ScopeChain& scopeChain() const { return m_scopeChain; } + void pushScope(JSObject* s) { m_scopeChain.push(s); } + void popScope() { m_scopeChain.pop(); } + void replaceScopeChainTop(JSObject* o) { m_scopeChain.replaceTop(o); } + + JSVariableObject* variableObject() const { return m_variableObject; } + void setVariableObject(JSVariableObject* v) { m_variableObject = v; } + + JSObject* thisValue() const { return m_thisValue; } + + ExecState* callingExecState() { return m_callingExec; } + + ActivationImp* activationObject() { return m_activation; } + void setActivationObject(ActivationImp* a) { m_activation = a; } + CodeType codeType() { return m_codeType; } + ScopeNode* scopeNode() { return m_scopeNode; } + FunctionImp* function() const { return m_function; } + const List* arguments() const { return m_arguments; } + + LabelStack& seenLabels() { return m_labelStack; } + + void pushIteration() { m_iterationDepth++; } + void popIteration() { m_iterationDepth--; } + bool inIteration() const { return (m_iterationDepth > 0); } + + void pushSwitch() { m_switchDepth++; } + void popSwitch() { m_switchDepth--; } + bool inSwitch() const { return (m_switchDepth > 0); } + + // These pointers are used to avoid accessing global variables for these, + // to avoid taking PIC branches in Mach-O binaries. + const CommonIdentifiers& propertyNames() const { return *m_propertyNames; } + const List& emptyList() const { return *m_emptyList; } + + LocalStorage& localStorage() { return *m_localStorage; } + void setLocalStorage(LocalStorage* s) { m_localStorage = s; } + + // These are only valid right after calling execute(). + ComplType completionType() const { return m_completionType; } + const Identifier& breakOrContinueTarget() const + { + ASSERT(m_completionType == Break || m_completionType == Continue); + return *m_breakOrContinueTarget; + } + + // Only for use in the implementation of execute(). + void setCompletionType(ComplType type) + { + ASSERT(type != Break); + ASSERT(type != Continue); + m_completionType = type; + } + JSValue* setNormalCompletion() + { + ASSERT(!hadException()); + m_completionType = Normal; + return 0; + } + JSValue* setNormalCompletion(JSValue* value) + { + ASSERT(!hadException()); + m_completionType = Normal; + return value; + } + JSValue* setBreakCompletion(const Identifier* target) + { + ASSERT(!hadException()); + m_completionType = Break; + m_breakOrContinueTarget = target; + return 0; + } + JSValue* setContinueCompletion(const Identifier* target) + { + ASSERT(!hadException()); + m_completionType = Continue; + m_breakOrContinueTarget = target; + return 0; + } + JSValue* setReturnValueCompletion(JSValue* returnValue) + { + ASSERT(!hadException()); + ASSERT(returnValue); + m_completionType = ReturnValue; + return returnValue; + } + JSValue* setThrowCompletion(JSValue* exception) + { + ASSERT(!hadException()); + ASSERT(exception); + m_completionType = Throw; + return exception; + } + JSValue* setInterruptedCompletion() + { + ASSERT(!hadException()); + m_completionType = Interrupted; + return 0; + } + JSValue* setInterruptedCompletion(JSValue* returnValue) + { + ASSERT(!hadException()); + ASSERT(returnValue); + m_completionType = Interrupted; + return returnValue; + } + + static void markActiveExecStates(); + static ExecStateStack& activeExecStates(); + + protected: + ExecState(JSGlobalObject*); + ExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*); + ExecState(JSGlobalObject*, EvalNode*, ExecState* callingExecState); + ExecState(JSGlobalObject*, JSObject* thisObject, FunctionBodyNode*, + ExecState* callingExecState, FunctionImp*, const List& args); + ~ExecState(); + + // ExecStates are always stack-allocated, and the garbage collector + // marks the stack, so we don't need to protect the objects below from GC. + + JSGlobalObject* m_globalObject; + JSValue* m_exception; + CommonIdentifiers* m_propertyNames; + const List* m_emptyList; + + ExecState* m_callingExec; + + ScopeNode* m_scopeNode; + + FunctionImp* m_function; + const List* m_arguments; + ActivationImp* m_activation; + LocalStorage* m_localStorage; + + ScopeChain m_scopeChain; + JSVariableObject* m_variableObject; + JSObject* m_thisValue; + + LabelStack m_labelStack; + int m_iterationDepth; + int m_switchDepth; + CodeType m_codeType; + + ComplType m_completionType; + const Identifier* m_breakOrContinueTarget; + }; + + class GlobalExecState : public ExecState { + public: + GlobalExecState(JSGlobalObject*); + ~GlobalExecState(); + }; + + class InterpreterExecState : public ExecState { + public: + InterpreterExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*); + ~InterpreterExecState(); + }; + + class EvalExecState : public ExecState { + public: + EvalExecState(JSGlobalObject*, EvalNode*, ExecState* callingExecState); + ~EvalExecState(); + }; + + class FunctionExecState : public ExecState { + public: + FunctionExecState(JSGlobalObject*, JSObject* thisObject, FunctionBodyNode*, + ExecState* callingExecState, FunctionImp*, const List& args); + ~FunctionExecState(); + }; + +} // namespace KJS + +#endif // ExecState_h diff --git a/kjs/JSGlobalObject.cpp b/kjs/JSGlobalObject.cpp new file mode 100644 index 0000000..75747d7 --- /dev/null +++ b/kjs/JSGlobalObject.cpp @@ -0,0 +1,568 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008 Cameron Zwarich (cwzwarich@uwaterloo.ca) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSGlobalObject.h" + +#include "Activation.h" +#include "array_object.h" +#include "bool_object.h" +#include "date_object.h" +#include "debugger.h" +#include "error_object.h" +#include "function_object.h" +#include "math_object.h" +#include "number_object.h" +#include "object_object.h" +#include "regexp_object.h" +#include "SavedBuiltins.h" +#include "string_object.h" + +#if HAVE(SYS_TIME_H) +#include +#endif + +#if PLATFORM(WIN_OS) +#include +#endif + +#if PLATFORM(QT) +#include +#endif + +namespace KJS { + +// Default number of ticks before a timeout check should be done. +static const int initialTickCountThreshold = 255; + +// Preferred number of milliseconds between each timeout check +static const int preferredScriptCheckTimeInterval = 1000; + +static inline void markIfNeeded(JSValue* v) +{ + if (v && !v->marked()) + v->mark(); +} + +// Returns the current time in milliseconds +// It doesn't matter what "current time" is here, just as long as +// it's possible to measure the time difference correctly. +static inline unsigned getCurrentTime() +{ +#if HAVE(SYS_TIME_H) + struct timeval tv; + gettimeofday(&tv, 0); + return tv.tv_sec * 1000 + tv.tv_usec / 1000; +#elif PLATFORM(QT) + QDateTime t = QDateTime::currentDateTime(); + return t.toTime_t() * 1000 + t.time().msec(); +#elif PLATFORM(WIN_OS) + return timeGetTime(); +#else +#error Platform does not have getCurrentTime function +#endif +} + +JSGlobalObject* JSGlobalObject::s_head = 0; + +void JSGlobalObject::deleteActivationStack() +{ + ActivationStackNode* prevNode = 0; + for (ActivationStackNode* currentNode = d()->activations; currentNode; currentNode = prevNode) { + prevNode = currentNode->prev; + delete currentNode; + } +} + +JSGlobalObject::~JSGlobalObject() +{ + ASSERT(JSLock::currentThreadIsHoldingLock()); + + if (d()->debugger) + d()->debugger->detach(this); + + d()->next->d()->prev = d()->prev; + d()->prev->d()->next = d()->next; + s_head = d()->next; + if (s_head == this) + s_head = 0; + + deleteActivationStack(); + + delete d(); +} + +void JSGlobalObject::init() +{ + ASSERT(JSLock::currentThreadIsHoldingLock()); + + if (s_head) { + d()->prev = s_head; + d()->next = s_head->d()->next; + s_head->d()->next->d()->prev = this; + s_head->d()->next = this; + } else + s_head = d()->next = d()->prev = this; + + d()->compatMode = NativeMode; + + resetTimeoutCheck(); + d()->timeoutTime = 0; + d()->timeoutCheckCount = 0; + + d()->recursion = 0; + d()->debugger = 0; + + ActivationStackNode* newStackNode = new ActivationStackNode; + newStackNode->prev = 0; + d()->activations = newStackNode; + d()->activationCount = 0; + + reset(prototype()); +} + +bool JSGlobalObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + if (symbolTableGet(propertyName, slot)) + return true; + return JSVariableObject::getOwnPropertySlot(exec, propertyName, slot); +} + +void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) +{ + if (symbolTablePut(propertyName, value, !(attr & ~DontDelete))) + return; + return JSVariableObject::put(exec, propertyName, value, attr); +} + +static inline JSObject* lastInPrototypeChain(JSObject* object) +{ + JSObject* o = object; + while (o->prototype()->isObject()) + o = static_cast(o->prototype()); + return o; +} + +void JSGlobalObject::reset(JSValue* prototype) +{ + // Clear before inititalizing, to avoid calling mark() on stale pointers -- + // which would be wasteful -- or uninitialized pointers -- which would be + // dangerous. (The allocations below may cause a GC.) + + _prop.clear(); + localStorage().clear(); + symbolTable().clear(); + + // Prototypes + d()->functionPrototype = 0; + d()->objectPrototype = 0; + + d()->arrayPrototype = 0; + d()->stringPrototype = 0; + d()->booleanPrototype = 0; + d()->numberPrototype = 0; + d()->datePrototype = 0; + d()->regExpPrototype = 0; + d()->errorPrototype = 0; + + d()->evalErrorPrototype = 0; + d()->rangeErrorPrototype = 0; + d()->referenceErrorPrototype = 0; + d()->syntaxErrorPrototype = 0; + d()->typeErrorPrototype = 0; + d()->URIErrorPrototype = 0; + + // Constructors + d()->objectConstructor = 0; + d()->functionConstructor = 0; + d()->arrayConstructor = 0; + d()->stringConstructor = 0; + d()->booleanConstructor = 0; + d()->numberConstructor = 0; + d()->dateConstructor = 0; + d()->regExpConstructor = 0; + d()->errorConstructor = 0; + + d()->evalErrorConstructor = 0; + d()->rangeErrorConstructor = 0; + d()->referenceErrorConstructor = 0; + d()->syntaxErrorConstructor = 0; + d()->typeErrorConstructor = 0; + d()->URIErrorConstructor = 0; + + ExecState* exec = &d()->globalExec; + + // Prototypes + d()->functionPrototype = new FunctionPrototype(exec); + d()->objectPrototype = new ObjectPrototype(exec, d()->functionPrototype); + d()->functionPrototype->setPrototype(d()->objectPrototype); + + d()->arrayPrototype = new ArrayPrototype(exec, d()->objectPrototype); + d()->stringPrototype = new StringPrototype(exec, d()->objectPrototype); + d()->booleanPrototype = new BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype); + d()->numberPrototype = new NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype); + d()->datePrototype = new DatePrototype(exec, d()->objectPrototype); + d()->regExpPrototype = new RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype); + d()->errorPrototype = new ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype); + + d()->evalErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "EvalError", "EvalError"); + d()->rangeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "RangeError", "RangeError"); + d()->referenceErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "ReferenceError", "ReferenceError"); + d()->syntaxErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "SyntaxError", "SyntaxError"); + d()->typeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "TypeError", "TypeError"); + d()->URIErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "URIError", "URIError"); + + // Constructors + d()->objectConstructor = new ObjectObjectImp(exec, d()->objectPrototype, d()->functionPrototype); + d()->functionConstructor = new FunctionObjectImp(exec, d()->functionPrototype); + d()->arrayConstructor = new ArrayObjectImp(exec, d()->functionPrototype, d()->arrayPrototype); + d()->stringConstructor = new StringObjectImp(exec, d()->functionPrototype, d()->stringPrototype); + d()->booleanConstructor = new BooleanObjectImp(exec, d()->functionPrototype, d()->booleanPrototype); + d()->numberConstructor = new NumberObjectImp(exec, d()->functionPrototype, d()->numberPrototype); + d()->dateConstructor = new DateObjectImp(exec, d()->functionPrototype, d()->datePrototype); + d()->regExpConstructor = new RegExpObjectImp(exec, d()->functionPrototype, d()->regExpPrototype); + d()->errorConstructor = new ErrorObjectImp(exec, d()->functionPrototype, d()->errorPrototype); + + d()->evalErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->evalErrorPrototype); + d()->rangeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->rangeErrorPrototype); + d()->referenceErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->referenceErrorPrototype); + d()->syntaxErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->syntaxErrorPrototype); + d()->typeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->typeErrorPrototype); + d()->URIErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->URIErrorPrototype); + + d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum); + + d()->objectPrototype->putDirect(exec->propertyNames().constructor, d()->objectConstructor, DontEnum | DontDelete | ReadOnly); + d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum | DontDelete | ReadOnly); + d()->arrayPrototype->putDirect(exec->propertyNames().constructor, d()->arrayConstructor, DontEnum | DontDelete | ReadOnly); + d()->booleanPrototype->putDirect(exec->propertyNames().constructor, d()->booleanConstructor, DontEnum | DontDelete | ReadOnly); + d()->stringPrototype->putDirect(exec->propertyNames().constructor, d()->stringConstructor, DontEnum | DontDelete | ReadOnly); + d()->numberPrototype->putDirect(exec->propertyNames().constructor, d()->numberConstructor, DontEnum | DontDelete | ReadOnly); + d()->datePrototype->putDirect(exec->propertyNames().constructor, d()->dateConstructor, DontEnum | DontDelete | ReadOnly); + d()->regExpPrototype->putDirect(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum | DontDelete | ReadOnly); + d()->errorPrototype->putDirect(exec->propertyNames().constructor, d()->errorConstructor, DontEnum | DontDelete | ReadOnly); + d()->evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum | DontDelete | ReadOnly); + d()->rangeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly); + d()->referenceErrorPrototype->putDirect(exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly); + d()->syntaxErrorPrototype->putDirect(exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly); + d()->typeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum | DontDelete | ReadOnly); + d()->URIErrorPrototype->putDirect(exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum | DontDelete | ReadOnly); + + // Set global constructors + + // FIXME: kjs_window.cpp checks Internal/DontEnum as a performance hack, to + // see that these values can be put directly without a check for override + // properties. + + // FIXME: These properties should be handled by a static hash table. + + putDirect("Object", d()->objectConstructor, DontEnum); + putDirect("Function", d()->functionConstructor, DontEnum); + putDirect("Array", d()->arrayConstructor, DontEnum); + putDirect("Boolean", d()->booleanConstructor, DontEnum); + putDirect("String", d()->stringConstructor, DontEnum); + putDirect("Number", d()->numberConstructor, DontEnum); + putDirect("Date", d()->dateConstructor, DontEnum); + putDirect("RegExp", d()->regExpConstructor, DontEnum); + putDirect("Error", d()->errorConstructor, DontEnum); + putDirect("EvalError", d()->evalErrorConstructor, Internal); + putDirect("RangeError", d()->rangeErrorConstructor, Internal); + putDirect("ReferenceError", d()->referenceErrorConstructor, Internal); + putDirect("SyntaxError", d()->syntaxErrorConstructor, Internal); + putDirect("TypeError", d()->typeErrorConstructor, Internal); + putDirect("URIError", d()->URIErrorConstructor, Internal); + + // Set global values. + + putDirect("Math", new MathObjectImp(exec, d()->objectPrototype), DontEnum); + + putDirect("NaN", jsNaN(), DontEnum | DontDelete); + putDirect("Infinity", jsNumber(Inf), DontEnum | DontDelete); + putDirect("undefined", jsUndefined(), DontEnum | DontDelete); + + // Set global functions. + + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "eval", globalFuncEval), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 2, "parseInt", globalFuncParseInt), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "parseFloat", globalFuncParseFloat), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "isNaN", globalFuncIsNaN), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "isFinite", globalFuncIsFinite), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "escape", globalFuncEscape), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "unescape", globalFuncUnescape), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "decodeURI", globalFuncDecodeURI), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "decodeURIComponent", globalFuncDecodeURIComponent), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "encodeURI", globalFuncEncodeURI), DontEnum); + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "encodeURIComponent", globalFuncEncodeURIComponent), DontEnum); +#ifndef NDEBUG + putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "kjsprint", globalFuncKJSPrint), DontEnum); +#endif + + // Set prototype, and also insert the object prototype at the end of the chain. + + setPrototype(prototype); + lastInPrototypeChain(this)->setPrototype(d()->objectPrototype); +} + +void JSGlobalObject::startTimeoutCheck() +{ + if (!d()->timeoutCheckCount) + resetTimeoutCheck(); + + ++d()->timeoutCheckCount; +} + +void JSGlobalObject::stopTimeoutCheck() +{ + --d()->timeoutCheckCount; +} + +void JSGlobalObject::resetTimeoutCheck() +{ + d()->tickCount = 0; + d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold; + d()->timeAtLastCheckTimeout = 0; + d()->timeExecuting = 0; +} + +bool JSGlobalObject::checkTimeout() +{ + d()->tickCount = 0; + + unsigned currentTime = getCurrentTime(); + + if (!d()->timeAtLastCheckTimeout) { + // Suspicious amount of looping in a script -- start timing it + d()->timeAtLastCheckTimeout = currentTime; + return false; + } + + unsigned timeDiff = currentTime - d()->timeAtLastCheckTimeout; + + if (timeDiff == 0) + timeDiff = 1; + + d()->timeExecuting += timeDiff; + d()->timeAtLastCheckTimeout = currentTime; + + // Adjust the tick threshold so we get the next checkTimeout call in the interval specified in + // preferredScriptCheckTimeInterval + d()->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d()->ticksUntilNextTimeoutCheck; + + // If the new threshold is 0 reset it to the default threshold. This can happen if the timeDiff is higher than the + // preferred script check time interval. + if (d()->ticksUntilNextTimeoutCheck == 0) + d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold; + + if (shouldInterruptScriptBeforeTimeout()) + return true; + + if (d()->timeoutTime && d()->timeExecuting > d()->timeoutTime) { + if (shouldInterruptScript()) + return true; + + resetTimeoutCheck(); + } + + return false; +} + +void JSGlobalObject::saveBuiltins(SavedBuiltins& builtins) const +{ + if (!builtins._internal) + builtins._internal = new SavedBuiltinsInternal; + + builtins._internal->objectConstructor = d()->objectConstructor; + builtins._internal->functionConstructor = d()->functionConstructor; + builtins._internal->arrayConstructor = d()->arrayConstructor; + builtins._internal->booleanConstructor = d()->booleanConstructor; + builtins._internal->stringConstructor = d()->stringConstructor; + builtins._internal->numberConstructor = d()->numberConstructor; + builtins._internal->dateConstructor = d()->dateConstructor; + builtins._internal->regExpConstructor = d()->regExpConstructor; + builtins._internal->errorConstructor = d()->errorConstructor; + builtins._internal->evalErrorConstructor = d()->evalErrorConstructor; + builtins._internal->rangeErrorConstructor = d()->rangeErrorConstructor; + builtins._internal->referenceErrorConstructor = d()->referenceErrorConstructor; + builtins._internal->syntaxErrorConstructor = d()->syntaxErrorConstructor; + builtins._internal->typeErrorConstructor = d()->typeErrorConstructor; + builtins._internal->URIErrorConstructor = d()->URIErrorConstructor; + + builtins._internal->objectPrototype = d()->objectPrototype; + builtins._internal->functionPrototype = d()->functionPrototype; + builtins._internal->arrayPrototype = d()->arrayPrototype; + builtins._internal->booleanPrototype = d()->booleanPrototype; + builtins._internal->stringPrototype = d()->stringPrototype; + builtins._internal->numberPrototype = d()->numberPrototype; + builtins._internal->datePrototype = d()->datePrototype; + builtins._internal->regExpPrototype = d()->regExpPrototype; + builtins._internal->errorPrototype = d()->errorPrototype; + builtins._internal->evalErrorPrototype = d()->evalErrorPrototype; + builtins._internal->rangeErrorPrototype = d()->rangeErrorPrototype; + builtins._internal->referenceErrorPrototype = d()->referenceErrorPrototype; + builtins._internal->syntaxErrorPrototype = d()->syntaxErrorPrototype; + builtins._internal->typeErrorPrototype = d()->typeErrorPrototype; + builtins._internal->URIErrorPrototype = d()->URIErrorPrototype; +} + +void JSGlobalObject::restoreBuiltins(const SavedBuiltins& builtins) +{ + if (!builtins._internal) + return; + + d()->objectConstructor = builtins._internal->objectConstructor; + d()->functionConstructor = builtins._internal->functionConstructor; + d()->arrayConstructor = builtins._internal->arrayConstructor; + d()->booleanConstructor = builtins._internal->booleanConstructor; + d()->stringConstructor = builtins._internal->stringConstructor; + d()->numberConstructor = builtins._internal->numberConstructor; + d()->dateConstructor = builtins._internal->dateConstructor; + d()->regExpConstructor = builtins._internal->regExpConstructor; + d()->errorConstructor = builtins._internal->errorConstructor; + d()->evalErrorConstructor = builtins._internal->evalErrorConstructor; + d()->rangeErrorConstructor = builtins._internal->rangeErrorConstructor; + d()->referenceErrorConstructor = builtins._internal->referenceErrorConstructor; + d()->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor; + d()->typeErrorConstructor = builtins._internal->typeErrorConstructor; + d()->URIErrorConstructor = builtins._internal->URIErrorConstructor; + + d()->objectPrototype = builtins._internal->objectPrototype; + d()->functionPrototype = builtins._internal->functionPrototype; + d()->arrayPrototype = builtins._internal->arrayPrototype; + d()->booleanPrototype = builtins._internal->booleanPrototype; + d()->stringPrototype = builtins._internal->stringPrototype; + d()->numberPrototype = builtins._internal->numberPrototype; + d()->datePrototype = builtins._internal->datePrototype; + d()->regExpPrototype = builtins._internal->regExpPrototype; + d()->errorPrototype = builtins._internal->errorPrototype; + d()->evalErrorPrototype = builtins._internal->evalErrorPrototype; + d()->rangeErrorPrototype = builtins._internal->rangeErrorPrototype; + d()->referenceErrorPrototype = builtins._internal->referenceErrorPrototype; + d()->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype; + d()->typeErrorPrototype = builtins._internal->typeErrorPrototype; + d()->URIErrorPrototype = builtins._internal->URIErrorPrototype; +} + +void JSGlobalObject::mark() +{ + JSVariableObject::mark(); + + markIfNeeded(d()->globalExec.exception()); + + markIfNeeded(d()->objectConstructor); + markIfNeeded(d()->functionConstructor); + markIfNeeded(d()->arrayConstructor); + markIfNeeded(d()->booleanConstructor); + markIfNeeded(d()->stringConstructor); + markIfNeeded(d()->numberConstructor); + markIfNeeded(d()->dateConstructor); + markIfNeeded(d()->regExpConstructor); + markIfNeeded(d()->errorConstructor); + markIfNeeded(d()->evalErrorConstructor); + markIfNeeded(d()->rangeErrorConstructor); + markIfNeeded(d()->referenceErrorConstructor); + markIfNeeded(d()->syntaxErrorConstructor); + markIfNeeded(d()->typeErrorConstructor); + markIfNeeded(d()->URIErrorConstructor); + + markIfNeeded(d()->objectPrototype); + markIfNeeded(d()->functionPrototype); + markIfNeeded(d()->arrayPrototype); + markIfNeeded(d()->booleanPrototype); + markIfNeeded(d()->stringPrototype); + markIfNeeded(d()->numberPrototype); + markIfNeeded(d()->datePrototype); + markIfNeeded(d()->regExpPrototype); + markIfNeeded(d()->errorPrototype); + markIfNeeded(d()->evalErrorPrototype); + markIfNeeded(d()->rangeErrorPrototype); + markIfNeeded(d()->referenceErrorPrototype); + markIfNeeded(d()->syntaxErrorPrototype); + markIfNeeded(d()->typeErrorPrototype); + markIfNeeded(d()->URIErrorPrototype); +} + +ExecState* JSGlobalObject::globalExec() +{ + return &d()->globalExec; +} + +ActivationImp* JSGlobalObject::pushActivation(ExecState* exec) +{ + if (d()->activationCount == activationStackNodeSize) { + ActivationStackNode* newNode = new ActivationStackNode; + newNode->prev = d()->activations; + d()->activations = newNode; + d()->activationCount = 0; + } + + StackActivation* stackEntry = &d()->activations->data[d()->activationCount++]; + stackEntry->activationStorage.init(exec); + return &stackEntry->activationStorage; +} + +inline void JSGlobalObject::checkActivationCount() +{ + if (!d()->activationCount) { + ActivationStackNode* prev = d()->activations->prev; + ASSERT(prev); + delete d()->activations; + d()->activations = prev; + d()->activationCount = activationStackNodeSize; + } +} + +void JSGlobalObject::popActivation() +{ + checkActivationCount(); + d()->activations->data[--d()->activationCount].activationDataStorage.localStorage.shrink(0); +} + +void JSGlobalObject::tearOffActivation(ExecState* exec, bool leaveRelic) +{ + ActivationImp* oldActivation = exec->activationObject(); + if (!oldActivation || !oldActivation->isOnStack()) + return; + + ASSERT(exec->codeType() == FunctionCode); + ActivationImp* newActivation = new ActivationImp(*oldActivation->d(), leaveRelic); + + if (!leaveRelic) { + checkActivationCount(); + d()->activationCount--; + } + + oldActivation->d()->localStorage.shrink(0); + + exec->setActivationObject(newActivation); + exec->setVariableObject(newActivation); + exec->setLocalStorage(&newActivation->localStorage()); + exec->replaceScopeChainTop(newActivation); +} + +} // namespace KJS diff --git a/kjs/JSGlobalObject.h b/kjs/JSGlobalObject.h new file mode 100644 index 0000000..87862dc --- /dev/null +++ b/kjs/JSGlobalObject.h @@ -0,0 +1,262 @@ +// -*- c-basic-offset: 4 -*- +/* + * Copyright (C) 2007 Eric Seidel + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_GlobalObject_h +#define KJS_GlobalObject_h + +#include "JSVariableObject.h" + +namespace KJS { + + class ActivationImp; + class ArrayObjectImp; + class ArrayPrototype; + class BooleanObjectImp; + class BooleanPrototype; + class DateObjectImp; + class DatePrototype; + class Debugger; + class ErrorObjectImp; + class ErrorPrototype; + class EvalError; + class EvalErrorPrototype; + class FunctionObjectImp; + class FunctionPrototype; + class JSGlobalObject; + class NativeErrorImp; + class NativeErrorPrototype; + class NumberObjectImp; + class NumberPrototype; + class ObjectObjectImp; + class ObjectPrototype; + class RangeError; + class RangeErrorPrototype; + class ReferenceError; + class ReferenceError; + class ReferenceErrorPrototype; + class RegExpObjectImp; + class RegExpPrototype; + class RuntimeMethod; + class SavedBuiltins; + class ScopeChain; + class StringObjectImp; + class StringPrototype; + class SyntaxErrorPrototype; + class TypeError; + class TypeErrorPrototype; + class UriError; + class UriErrorPrototype; + struct ActivationStackNode; + + enum CompatMode { NativeMode, IECompat, NetscapeCompat }; + + class JSGlobalObject : public JSVariableObject { + protected: + using JSVariableObject::JSVariableObjectData; + + struct JSGlobalObjectData : public JSVariableObjectData { + JSGlobalObjectData(JSGlobalObject* globalObject) + : JSVariableObjectData(&inlineSymbolTable) + , globalExec(globalObject) + { + } + + JSGlobalObject* next; + JSGlobalObject* prev; + + Debugger* debugger; + CompatMode compatMode; + + GlobalExecState globalExec; + int recursion; + + unsigned timeoutTime; + unsigned timeAtLastCheckTimeout; + unsigned timeExecuting; + unsigned timeoutCheckCount; + unsigned tickCount; + unsigned ticksUntilNextTimeoutCheck; + + ObjectObjectImp* objectConstructor; + FunctionObjectImp* functionConstructor; + ArrayObjectImp* arrayConstructor; + BooleanObjectImp* booleanConstructor; + StringObjectImp* stringConstructor; + NumberObjectImp* numberConstructor; + DateObjectImp* dateConstructor; + RegExpObjectImp* regExpConstructor; + ErrorObjectImp* errorConstructor; + NativeErrorImp* evalErrorConstructor; + NativeErrorImp* rangeErrorConstructor; + NativeErrorImp* referenceErrorConstructor; + NativeErrorImp* syntaxErrorConstructor; + NativeErrorImp* typeErrorConstructor; + NativeErrorImp* URIErrorConstructor; + + ObjectPrototype* objectPrototype; + FunctionPrototype* functionPrototype; + ArrayPrototype* arrayPrototype; + BooleanPrototype* booleanPrototype; + StringPrototype* stringPrototype; + NumberPrototype* numberPrototype; + DatePrototype* datePrototype; + RegExpPrototype* regExpPrototype; + ErrorPrototype* errorPrototype; + NativeErrorPrototype* evalErrorPrototype; + NativeErrorPrototype* rangeErrorPrototype; + NativeErrorPrototype* referenceErrorPrototype; + NativeErrorPrototype* syntaxErrorPrototype; + NativeErrorPrototype* typeErrorPrototype; + NativeErrorPrototype* URIErrorPrototype; + + SymbolTable inlineSymbolTable; + + ActivationStackNode* activations; + size_t activationCount; + }; + + public: + JSGlobalObject() + : JSVariableObject(new JSGlobalObjectData(this)) + { + init(); + } + + protected: + JSGlobalObject(JSValue* proto) + : JSVariableObject(proto, new JSGlobalObjectData(this)) + { + init(); + } + + public: + virtual ~JSGlobalObject(); + + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None); + + // Linked list of all global objects. + static JSGlobalObject* head() { return s_head; } + JSGlobalObject* next() { return d()->next; } + + // Resets the global object to contain only built-in properties, sets + // the global object's prototype to "prototype," then adds the + // default object prototype to the tail of the global object's + // prototype chain. + void reset(JSValue* prototype); + + // The following accessors return pristine values, even if a script + // replaces the global object's associated property. + + ObjectObjectImp* objectConstructor() const { return d()->objectConstructor; } + FunctionObjectImp* functionConstructor() const { return d()->functionConstructor; } + ArrayObjectImp* arrayConstructor() const { return d()->arrayConstructor; } + BooleanObjectImp* booleanConstructor() const { return d()->booleanConstructor; } + StringObjectImp* stringConstructor() const{ return d()->stringConstructor; } + NumberObjectImp* numberConstructor() const{ return d()->numberConstructor; } + DateObjectImp* dateConstructor() const{ return d()->dateConstructor; } + RegExpObjectImp* regExpConstructor() const { return d()->regExpConstructor; } + ErrorObjectImp* errorConstructor() const { return d()->errorConstructor; } + NativeErrorImp* evalErrorConstructor() const { return d()->evalErrorConstructor; } + NativeErrorImp* rangeErrorConstructor() const { return d()->rangeErrorConstructor; } + NativeErrorImp* referenceErrorConstructor() const { return d()->referenceErrorConstructor; } + NativeErrorImp* syntaxErrorConstructor() const { return d()->syntaxErrorConstructor; } + NativeErrorImp* typeErrorConstructor() const { return d()->typeErrorConstructor; } + NativeErrorImp* URIErrorConstructor() const { return d()->URIErrorConstructor; } + + ObjectPrototype* objectPrototype() const { return d()->objectPrototype; } + FunctionPrototype* functionPrototype() const { return d()->functionPrototype; } + ArrayPrototype* arrayPrototype() const { return d()->arrayPrototype; } + BooleanPrototype* booleanPrototype() const { return d()->booleanPrototype; } + StringPrototype* stringPrototype() const { return d()->stringPrototype; } + NumberPrototype* numberPrototype() const { return d()->numberPrototype; } + DatePrototype* datePrototype() const { return d()->datePrototype; } + RegExpPrototype* regExpPrototype() const { return d()->regExpPrototype; } + ErrorPrototype* errorPrototype() const { return d()->errorPrototype; } + NativeErrorPrototype* evalErrorPrototype() const { return d()->evalErrorPrototype; } + NativeErrorPrototype* rangeErrorPrototype() const { return d()->rangeErrorPrototype; } + NativeErrorPrototype* referenceErrorPrototype() const { return d()->referenceErrorPrototype; } + NativeErrorPrototype* syntaxErrorPrototype() const { return d()->syntaxErrorPrototype; } + NativeErrorPrototype* typeErrorPrototype() const { return d()->typeErrorPrototype; } + NativeErrorPrototype* URIErrorPrototype() const { return d()->URIErrorPrototype; } + + void saveBuiltins(SavedBuiltins&) const; + void restoreBuiltins(const SavedBuiltins&); + + void setTimeoutTime(unsigned timeoutTime) { d()->timeoutTime = timeoutTime; } + void startTimeoutCheck(); + void stopTimeoutCheck(); + bool timedOut(); + + Debugger* debugger() const { return d()->debugger; } + void setDebugger(Debugger* debugger) { d()->debugger = debugger; } + + // FIXME: Let's just pick one compatible behavior and go with it. + void setCompatMode(CompatMode mode) { d()->compatMode = mode; } + CompatMode compatMode() const { return d()->compatMode; } + + int recursion() { return d()->recursion; } + void incRecursion() { ++d()->recursion; } + void decRecursion() { --d()->recursion; } + + virtual void mark(); + + virtual bool isGlobalObject() const { return true; } + + virtual ExecState* globalExec(); + + virtual bool shouldInterruptScriptBeforeTimeout() const { return false; } + virtual bool shouldInterruptScript() const { return true; } + + virtual bool allowsAccessFrom(const JSGlobalObject*) const { return true; } + + ActivationImp* pushActivation(ExecState*); + void popActivation(); + void tearOffActivation(ExecState*, bool markAsRelic = false); + + private: + void init(); + + JSGlobalObjectData* d() const { return static_cast(JSVariableObject::d); } + + bool checkTimeout(); + void resetTimeoutCheck(); + + void deleteActivationStack(); + void checkActivationCount(); + + static JSGlobalObject* s_head; + }; + + inline bool JSGlobalObject::timedOut() + { + d()->tickCount++; + + if (d()->tickCount != d()->ticksUntilNextTimeoutCheck) + return false; + + return checkTimeout(); + } + +} // namespace KJS + +#endif // KJS_GlobalObject_h diff --git a/kjs/JSImmediate.cpp b/kjs/JSImmediate.cpp new file mode 100644 index 0000000..ded8ccb --- /dev/null +++ b/kjs/JSImmediate.cpp @@ -0,0 +1,82 @@ +/* + * This file is part of the KDE libraries + * Copyright (C) 2003-2006 Apple Computer, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "JSImmediate.h" + +#include "JSGlobalObject.h" +#include "bool_object.h" +#include "number_object.h" +#include "object.h" + +namespace KJS { + +JSObject *JSImmediate::toObject(const JSValue *v, ExecState *exec) +{ + ASSERT(isImmediate(v)); + if (v == jsNull()) + return throwError(exec, TypeError, "Null value"); + else if (v == jsUndefined()) + return throwError(exec, TypeError, "Undefined value"); + else if (isBoolean(v)) { + List args; + args.append(const_cast(v)); + return exec->lexicalGlobalObject()->booleanConstructor()->construct(exec, args); + } else { + ASSERT(isNumber(v)); + List args; + args.append(const_cast(v)); + return exec->lexicalGlobalObject()->numberConstructor()->construct(exec, args); + } +} + +UString JSImmediate::toString(const JSValue *v) +{ + ASSERT(isImmediate(v)); + + if (v == jsNull()) + return "null"; + else if (v == jsUndefined()) + return "undefined"; + else if (v == jsBoolean(true)) + return "true"; + else if (v == jsBoolean(false)) + return "false"; + else { + ASSERT(isNumber(v)); + double d = toDouble(v); + if (d == 0.0) // +0.0 or -0.0 + return "0"; + return UString::from(d); + } +} + +JSType JSImmediate::type(const JSValue *v) +{ + ASSERT(isImmediate(v)); + + uintptr_t tag = getTag(v); + if (tag == UndefinedType) + return v == jsUndefined() ? UndefinedType : NullType; + return static_cast(tag); +} + +} // namespace KJS diff --git a/kjs/JSImmediate.h b/kjs/JSImmediate.h new file mode 100644 index 0000000..bc0cb16 --- /dev/null +++ b/kjs/JSImmediate.h @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_JS_IMMEDIATE_H +#define KJS_JS_IMMEDIATE_H + +#include "JSType.h" +#include +#include +#include +#include +#include +#include +#include + +namespace KJS { + +class ExecState; +class JSObject; +class JSValue; +class UString; + +/* + * A JSValue* is either a pointer to a cell (a heap-allocated object) or an immediate (a type-tagged + * signed int masquerading as a pointer). The low two bits in a JSValue* are available + * for type tagging because allocator alignment guarantees they will be 00 in cell pointers. + * + * For example, on a 32 bit system: + * + * JSCell*: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 00 + * [ high 30 bits: pointer address ] [ low 2 bits -- always 0 ] + * + * JSImmediate: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX TT + * [ high 30 bits: signed int ] [ low 2 bits -- type tag ] + * + * The bit "payload" (the high 30 bits) is a 30 bit signed int for immediate numbers, a flag to distinguish true/false + * and undefined/null. + * + * Notice that the JSType value of NullType is 4, which requires 3 bits to encode. Since we only have 2 bits + * available for type tagging, we tag the null immediate with UndefinedType, and JSImmediate::type() has + * to sort them out. + */ + +class JSImmediate { +public: + static ALWAYS_INLINE bool isImmediate(const JSValue* v) + { + return getTag(v) != 0; + } + + static ALWAYS_INLINE bool isNumber(const JSValue* v) + { + return (getTag(v) == NumberType); + } + + static ALWAYS_INLINE bool isBoolean(const JSValue* v) + { + return (getTag(v) == BooleanType); + } + + // Since we have room for only 3 unique tags, null and undefined have to share. + static ALWAYS_INLINE bool isUndefinedOrNull(const JSValue* v) + { + return (getTag(v) == UndefinedType); + } + + static JSValue* from(char); + static JSValue* from(signed char); + static JSValue* from(unsigned char); + static JSValue* from(short); + static JSValue* from(unsigned short); + static JSValue* from(int); + static JSValue* from(unsigned); + static JSValue* from(long); + static JSValue* from(unsigned long); + static JSValue* from(long long); + static JSValue* from(unsigned long long); + static JSValue* from(double); + + static ALWAYS_INLINE bool areBothImmediateNumbers(const JSValue* v1, const JSValue* v2) + { + return (reinterpret_cast(v1) & reinterpret_cast(v2) & TagMask) == NumberType; + } + + static ALWAYS_INLINE JSValue* andImmediateNumbers(const JSValue* v1, const JSValue* v2) + { + ASSERT(areBothImmediateNumbers(v1, v2)); + return reinterpret_cast(reinterpret_cast(v1) & reinterpret_cast(v2)); + } + + static double toDouble(const JSValue*); + static bool toBoolean(const JSValue*); + static JSObject* toObject(const JSValue*, ExecState*); + static UString toString(const JSValue*); + static JSType type(const JSValue*); + + static bool getUInt32(const JSValue*, uint32_t&); + static bool getTruncatedInt32(const JSValue*, int32_t&); + static bool getTruncatedUInt32(const JSValue*, uint32_t&); + + static int32_t getTruncatedInt32(const JSValue*); + + static JSValue* trueImmediate(); + static JSValue* falseImmediate(); + static JSValue* undefinedImmediate(); + static JSValue* nullImmediate(); + +private: + static const uintptr_t TagMask = 3; // type tags are 2 bits long + + // Immediate values are restricted to a 30 bit signed value. + static const int minImmediateInt = -(1 << 29); + static const int maxImmediateInt = (1 << 29) - 1; + static const unsigned maxImmediateUInt = maxImmediateInt; + + static ALWAYS_INLINE JSValue* tag(uintptr_t bits, uintptr_t tag) + { + return reinterpret_cast(bits | tag); + } + + static ALWAYS_INLINE uintptr_t unTag(const JSValue* v) + { + return reinterpret_cast(v) & ~TagMask; + } + + static ALWAYS_INLINE uintptr_t getTag(const JSValue* v) + { + return reinterpret_cast(v) & TagMask; + } +}; + +ALWAYS_INLINE JSValue* JSImmediate::trueImmediate() { return tag(1 << 2, BooleanType); } +ALWAYS_INLINE JSValue* JSImmediate::falseImmediate() { return tag(0, BooleanType); } +ALWAYS_INLINE JSValue* JSImmediate::undefinedImmediate() { return tag(1 << 2, UndefinedType); } +ALWAYS_INLINE JSValue* JSImmediate::nullImmediate() { return tag(0, UndefinedType); } + +ALWAYS_INLINE bool JSImmediate::toBoolean(const JSValue* v) +{ + ASSERT(isImmediate(v)); + uintptr_t bits = unTag(v); + return (bits != 0) & (JSImmediate::getTag(v) != UndefinedType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(char i) +{ + return tag(i << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(signed char i) +{ + return tag(i << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(unsigned char i) +{ + return tag(i << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(short i) +{ + return tag(i << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(unsigned short i) +{ + return tag(i << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(int i) +{ + if ((i < minImmediateInt) | (i > maxImmediateInt)) + return 0; + return tag(i << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(unsigned i) +{ + if (i > maxImmediateUInt) + return 0; + return tag(i << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(long i) +{ + if ((i < minImmediateInt) | (i > maxImmediateInt)) + return 0; + return tag(i << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(unsigned long i) +{ + if (i > maxImmediateUInt) + return 0; + return tag(i << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(long long i) +{ + if ((i < minImmediateInt) | (i > maxImmediateInt)) + return 0; + return tag(static_cast(i) << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(unsigned long long i) +{ + if (i > maxImmediateUInt) + return 0; + return tag(static_cast(i) << 2, NumberType); +} + +ALWAYS_INLINE JSValue* JSImmediate::from(double d) +{ + const int intVal = static_cast(d); + + if ((intVal < minImmediateInt) | (intVal > maxImmediateInt)) + return 0; + + // Check for data loss from conversion to int. + if ((intVal != d) || (!intVal && signbit(d))) + return 0; + + return tag(intVal << 2, NumberType); +} + +ALWAYS_INLINE int32_t JSImmediate::getTruncatedInt32(const JSValue* v) +{ + ASSERT(isNumber(v)); + return static_cast(unTag(v)) >> 2; +} + +ALWAYS_INLINE double JSImmediate::toDouble(const JSValue* v) +{ + ASSERT(isImmediate(v)); + const int32_t i = static_cast(unTag(v)) >> 2; + if (JSImmediate::getTag(v) == UndefinedType && i) + return std::numeric_limits::quiet_NaN(); + return i; +} + +ALWAYS_INLINE bool JSImmediate::getUInt32(const JSValue* v, uint32_t& i) +{ + const int32_t si = static_cast(unTag(v)) >> 2; + i = si; + return isNumber(v) & (si >= 0); +} + +ALWAYS_INLINE bool JSImmediate::getTruncatedInt32(const JSValue* v, int32_t& i) +{ + i = static_cast(unTag(v)) >> 2; + return isNumber(v); +} + +ALWAYS_INLINE bool JSImmediate::getTruncatedUInt32(const JSValue* v, uint32_t& i) +{ + return getUInt32(v, i); +} + +} // namespace KJS + +#endif diff --git a/kjs/JSLock.cpp b/kjs/JSLock.cpp new file mode 100644 index 0000000..4439c48 --- /dev/null +++ b/kjs/JSLock.cpp @@ -0,0 +1,183 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2005 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + * + */ + +#include "config.h" +#include "JSLock.h" + +#include "collector.h" +#if USE(MULTIPLE_THREADS) +#include +#endif + +namespace KJS { + +#if USE(MULTIPLE_THREADS) + +// Acquire this mutex before accessing lock-related data. +static pthread_mutex_t JSMutex = PTHREAD_MUTEX_INITIALIZER; + +// Thread-specific key that tells whether a thread holds the JSMutex. +pthread_key_t didLockJSMutex; + +// Lock nesting count. +static int JSLockCount; + +static void createDidLockJSMutex() +{ + pthread_key_create(&didLockJSMutex, 0); +} +pthread_once_t createDidLockJSMutexOnce = PTHREAD_ONCE_INIT; + +void JSLock::lock() +{ + pthread_once(&createDidLockJSMutexOnce, createDidLockJSMutex); + + if (!pthread_getspecific(didLockJSMutex)) { + int result; + result = pthread_mutex_lock(&JSMutex); + ASSERT(!result); + pthread_setspecific(didLockJSMutex, &didLockJSMutex); + } + ++JSLockCount; +} + +void JSLock::unlock() +{ + ASSERT(JSLockCount); + ASSERT(!!pthread_getspecific(didLockJSMutex)); + + --JSLockCount; + if (!JSLockCount) { + pthread_setspecific(didLockJSMutex, 0); + int result; + result = pthread_mutex_unlock(&JSMutex); + ASSERT(!result); + } +} + +bool JSLock::currentThreadIsHoldingLock() +{ + pthread_once(&createDidLockJSMutexOnce, createDidLockJSMutex); + return !!pthread_getspecific(didLockJSMutex); +} + +void JSLock::registerThread() +{ + Collector::registerThread(); +} + +JSLock::DropAllLocks::DropAllLocks() + : m_lockCount(0) +{ + pthread_once(&createDidLockJSMutexOnce, createDidLockJSMutex); + + m_lockCount = !!pthread_getspecific(didLockJSMutex) ? JSLock::lockCount() : 0; + for (int i = 0; i < m_lockCount; i++) + JSLock::unlock(); +} + +JSLock::DropAllLocks::~DropAllLocks() +{ + for (int i = 0; i < m_lockCount; i++) + JSLock::lock(); + m_lockCount = 0; +} + +#else + +// If threading support is off, set the lock count to a constant value of 1 so assertions +// that the lock is held don't fail +const int JSLockCount = 1; + +bool JSLock::currentThreadIsHoldingLock() +{ + return true; +} + +void JSLock::lock() +{ +} + +void JSLock::unlock() +{ +} + +void JSLock::registerThread() +{ +} + +JSLock::DropAllLocks::DropAllLocks() +{ +} + +JSLock::DropAllLocks::~DropAllLocks() +{ +} + +#endif // USE(MULTIPLE_THREADS) + +int JSLock::lockCount() +{ + return JSLockCount; +} + +} + + +#include "JSLockC.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int JSLockDropAllLocks(void) +{ + KJS::JSLock::lock(); + int lockCount = KJS::JSLock::lockCount(); + for (int i = 0; i < lockCount; i++) + KJS::JSLock::unlock(); + return lockCount - 1; +} + +void JSLockRecoverAllLocks(int lockCount) +{ + ASSERT(KJS::JSLock::lockCount() == 0); + for (int i = 0; i < lockCount; i++) + KJS::JSLock::lock(); +} + +static pthread_t javaScriptCollectionThread = 0; + +void JSSetJavaScriptCollectionThread (pthread_t thread) +{ + javaScriptCollectionThread = thread; +} + +pthread_t JSJavaScriptCollectionThread (void) +{ + return javaScriptCollectionThread; +} + +#ifdef __cplusplus +} +#endif + diff --git a/kjs/JSLock.h b/kjs/JSLock.h new file mode 100644 index 0000000..f6cda5d --- /dev/null +++ b/kjs/JSLock.h @@ -0,0 +1,81 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2005 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_JSLock_h +#define KJS_JSLock_h + +#include +#include + +namespace KJS { + + // To make it safe to use JavaScript on multiple threads, it is + // important to lock before doing anything that allocates a + // JavaScript data structure or that interacts with shared state + // such as the protect count hash table. The simplest way to lock + // is to create a local JSLock object in the scope where the lock + // must be held. The lock is recursive so nesting is ok. The JSLock + // object also acts as a convenience short-hand for running important + // initialization routines. + + // To avoid deadlock, sometimes it is necessary to temporarily + // release the lock. Since it is recursive you actually have to + // release all locks held by your thread. This is safe to do if + // you are executing code that doesn't require the lock, and you + // reacquire the right number of locks at the end. You can do this + // by constructing a locally scoped JSLock::DropAllLocks object. The + // DropAllLocks object takes care to release the JSLock only if your + // thread acquired it to begin with. + + class JSLock : Noncopyable { + public: + JSLock() + { + lock(); + registerThread(); + } + + ~JSLock() + { + unlock(); + } + + static void lock(); + static void unlock(); + static int lockCount(); + static bool currentThreadIsHoldingLock(); + + static void registerThread(); + + class DropAllLocks : Noncopyable { + public: + DropAllLocks(); + ~DropAllLocks(); + + private: + int m_lockCount; + }; + }; + +} // namespace + +#endif // KJS_JSLock_h diff --git a/kjs/JSLockC.h b/kjs/JSLockC.h new file mode 100644 index 0000000..b3c181d --- /dev/null +++ b/kjs/JSLockC.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2006, 2007, Apple Inc. All rights reserved. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int JSLockDropAllLocks(void); +void JSLockRecoverAllLocks(int lockCount); +void JSSetJavaScriptCollectionThread (pthread_t thread); +pthread_t JSJavaScriptCollectionThread (void); + +#ifdef __cplusplus +} +#endif + diff --git a/kjs/JSType.h b/kjs/JSType.h new file mode 100644 index 0000000..1c9418c --- /dev/null +++ b/kjs/JSType.h @@ -0,0 +1,43 @@ +/* + * This file is part of the KDE libraries + * Copyright (C) 2006 Apple Computer, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_JSTYPE_H +#define KJS_JSTYPE_H + +namespace KJS { + +/** + * Primitive types + */ +enum JSType { + UnspecifiedType = 0, + UndefinedType = 1, + BooleanType = 2, + NumberType = 3, + NullType = 4, + StringType = 5, + ObjectType = 6, + GetterSetterType = 7 +}; + +} // namespace KJS + +#endif diff --git a/kjs/JSVariableObject.cpp b/kjs/JSVariableObject.cpp new file mode 100644 index 0000000..76d563d --- /dev/null +++ b/kjs/JSVariableObject.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSVariableObject.h" + +#include "PropertyNameArray.h" +#include "property_map.h" + +namespace KJS { + +UString::Rep* IdentifierRepHashTraits::nullRepPtr = &UString::Rep::null; // Didn't want to make a whole source file for just this. + +void JSVariableObject::saveLocalStorage(SavedProperties& p) const +{ + ASSERT(d->symbolTable); + ASSERT(static_cast(d->symbolTable->size()) == d->localStorage.size()); + + unsigned count = d->symbolTable->size(); + + p.properties.clear(); + p.count = count; + + if (!count) + return; + + p.properties.set(new SavedProperty[count]); + + SymbolTable::const_iterator end = d->symbolTable->end(); + for (SymbolTable::const_iterator it = d->symbolTable->begin(); it != end; ++it) { + size_t i = it->second; + const LocalStorageEntry& entry = d->localStorage[i]; + p.properties[i].init(it->first.get(), entry.value, entry.attributes); + } +} + +void JSVariableObject::restoreLocalStorage(const SavedProperties& p) +{ + unsigned count = p.count; + d->symbolTable->clear(); + d->localStorage.resize(count); + SavedProperty* property = p.properties.get(); + for (size_t i = 0; i < count; ++i, ++property) { + ASSERT(!d->symbolTable->contains(property->name())); + LocalStorageEntry& entry = d->localStorage[i]; + d->symbolTable->set(property->name(), i); + entry.value = property->value(); + entry.attributes = property->attributes(); + } +} + +bool JSVariableObject::deleteProperty(ExecState* exec, const Identifier& propertyName) +{ + if (symbolTable().contains(propertyName.ustring().rep())) + return false; + + return JSObject::deleteProperty(exec, propertyName); +} + +void JSVariableObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +{ + SymbolTable::const_iterator::Keys end = symbolTable().end().keys(); + for (SymbolTable::const_iterator::Keys it = symbolTable().begin().keys(); it != end; ++it) + propertyNames.add(Identifier(it->get())); + + JSObject::getPropertyNames(exec, propertyNames); +} + +void JSVariableObject::mark() +{ + JSObject::mark(); + + size_t size = d->localStorage.size(); + for (size_t i = 0; i < size; ++i) { + JSValue* value = d->localStorage[i].value; + if (!value->marked()) + value->mark(); + } +} + +} // namespace KJS diff --git a/kjs/JSVariableObject.h b/kjs/JSVariableObject.h new file mode 100644 index 0000000..e82013b --- /dev/null +++ b/kjs/JSVariableObject.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSVariableObject_h +#define JSVariableObject_h + +#include "LocalStorage.h" +#include "SymbolTable.h" +#include "object.h" + +namespace KJS { + + class JSVariableObject : public JSObject { + public: + SymbolTable& symbolTable() { return *d->symbolTable; } + LocalStorage& localStorage() { return d->localStorage; } + + void saveLocalStorage(SavedProperties&) const; + void restoreLocalStorage(const SavedProperties&); + + virtual bool deleteProperty(ExecState*, const Identifier&); + virtual void getPropertyNames(ExecState*, PropertyNameArray&); + + virtual void mark(); + + protected: + // Subclasses of JSVariableObject can subclass this struct to add data + // without increasing their own size (since there's a hard limit on the + // size of a JSCell). + struct JSVariableObjectData { + JSVariableObjectData() { } + JSVariableObjectData(SymbolTable* s) + : symbolTable(s) // Subclass owns this pointer. + { + } + + LocalStorage localStorage; // Storage for variables in the symbol table. + SymbolTable* symbolTable; // Maps name -> index in localStorage. + }; + + JSVariableObject() { } + + JSVariableObject(JSVariableObjectData* data) + : d(data) // Subclass owns this pointer. + { + } + + JSVariableObject(JSValue* proto, JSVariableObjectData* data) + : JSObject(proto) + , d(data) // Subclass owns this pointer. + { + } + + bool symbolTableGet(const Identifier&, PropertySlot&); + bool symbolTablePut(const Identifier&, JSValue*, bool checkReadOnly); + + JSVariableObjectData* d; + }; + + inline bool JSVariableObject::symbolTableGet(const Identifier& propertyName, PropertySlot& slot) + { + size_t index = symbolTable().get(propertyName.ustring().rep()); + if (index != missingSymbolMarker()) { +#ifndef NDEBUG + // During initialization, the variable object needs to advertise that it has certain + // properties, even if they're not ready for access yet. This check verifies that + // no one tries to access such a property. + + // In a release build, we optimize this check away and just return an invalid pointer. + // There's no harm in an invalid pointer, since no one dereferences it. + if (index >= d->localStorage.size()) { + slot.setUngettable(this); + return true; + } +#endif + slot.setValueSlot(this, &d->localStorage[index].value); + return true; + } + return false; + } + + inline bool JSVariableObject::symbolTablePut(const Identifier& propertyName, JSValue* value, bool checkReadOnly) + { + size_t index = symbolTable().get(propertyName.ustring().rep()); + if (index == missingSymbolMarker()) + return false; + LocalStorageEntry& entry = d->localStorage[index]; + if (checkReadOnly && (entry.attributes & ReadOnly)) + return true; + entry.value = value; + return true; + } + +} // namespace KJS + +#endif // JSVariableObject_h diff --git a/kjs/JSWrapperObject.cpp b/kjs/JSWrapperObject.cpp new file mode 100644 index 0000000..dd161f7 --- /dev/null +++ b/kjs/JSWrapperObject.cpp @@ -0,0 +1,34 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 2006 Maks Orlovich + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "JSWrapperObject.h" + +namespace KJS { + +void JSWrapperObject::mark() +{ + JSObject::mark(); + if (m_internalValue && !m_internalValue->marked()) + m_internalValue->mark(); +} + +} // namespace KJS diff --git a/kjs/JSWrapperObject.h b/kjs/JSWrapperObject.h new file mode 100644 index 0000000..0a06c9f --- /dev/null +++ b/kjs/JSWrapperObject.h @@ -0,0 +1,84 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Maks Orlovich + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_JSWrapperObject_h +#define KJS_JSWrapperObject_h + +#include "object.h" + +namespace KJS { + + /** + This class is used as a base for classes such as String, + Number, Boolean and Date which which are wrappers for primitive + types. These classes stores the internal value, which is the + actual value represented by the wrapper objects. + */ + class JSWrapperObject : public JSObject { + public: + JSWrapperObject(JSValue* proto); + + /** + * Returns the internal value of the object. This is used for objects such + * as String and Boolean which are wrappers for native types. The interal + * value is the actual value represented by the wrapper objects. + * + * @see ECMA 8.6.2 + * @return The internal value of the object + */ + JSValue* internalValue() const; + + /** + * Sets the internal value of the object + * + * @see internalValue() + * + * @param v The new internal value + */ + void setInternalValue(JSValue* v); + + virtual void mark(); + + private: + JSValue* m_internalValue; + }; + + inline JSWrapperObject::JSWrapperObject(JSValue* proto) + : JSObject(proto) + , m_internalValue(0) + { + } + + inline JSValue* JSWrapperObject::internalValue() const + { + return m_internalValue; + } + + inline void JSWrapperObject::setInternalValue(JSValue* v) + { + ASSERT(v); + m_internalValue = v; + } + +} // namespace KJS + +#endif // KJS_JSWrapperObject_h diff --git a/kjs/LabelStack.h b/kjs/LabelStack.h new file mode 100644 index 0000000..375edf1 --- /dev/null +++ b/kjs/LabelStack.h @@ -0,0 +1,84 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_LABEL_STACK_H +#define KJS_LABEL_STACK_H + +#include "identifier.h" +#include + +namespace KJS { + /** + * @short The "label set" in Ecma-262 spec + */ + class LabelStack : Noncopyable { + public: + LabelStack() + : tos(0) + { + } + ~LabelStack(); + + /** + * If id is not empty and is not in the stack already, puts it on top of + * the stack and returns true, otherwise returns false + */ + bool push(const Identifier &id); + /** + * Is the id in the stack? + */ + bool contains(const Identifier &id) const; + /** + * Removes from the stack the last pushed id (what else?) + */ + void pop(); + + private: + struct StackElem { + Identifier id; + StackElem *prev; + }; + + StackElem *tos; + }; + +inline LabelStack::~LabelStack() +{ + StackElem *prev; + for (StackElem *e = tos; e; e = prev) { + prev = e->prev; + delete e; + } +} + +inline void LabelStack::pop() +{ + if (StackElem *e = tos) { + tos = e->prev; + delete e; + } +} + +} + +#endif // KJS_LABEL_STACK_H diff --git a/kjs/LocalStorage.h b/kjs/LocalStorage.h new file mode 100644 index 0000000..87a54bb --- /dev/null +++ b/kjs/LocalStorage.h @@ -0,0 +1,56 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) + * Copyright (C) 2007 Maks Orlovich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_LOCAL_STORAGE_H +#define KJS_LOCAL_STORAGE_H + +#include +#include + +namespace KJS { + class JSValue; + + struct LocalStorageEntry { + LocalStorageEntry() + { + } + + LocalStorageEntry(JSValue* v, unsigned a) + : value(v) + , attributes(a) + { + } + + JSValue* value; + unsigned attributes; + }; + + typedef Vector LocalStorage; +} + +namespace WTF { + template<> struct VectorTraits : VectorTraitsBase { }; +} + +#endif // KJS_LOCAL_STORAGE_H diff --git a/kjs/NodeInfo.h b/kjs/NodeInfo.h new file mode 100644 index 0000000..60637f2 --- /dev/null +++ b/kjs/NodeInfo.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef NodeInfo_h +#define NodeInfo_h + +#include "nodes.h" +#include "Parser.h" + +namespace KJS { + +template struct NodeInfo { + T m_node; + ParserRefCountedData* m_varDeclarations; + ParserRefCountedData* m_funcDeclarations; +}; + +typedef NodeInfo StatementNodeInfo; +typedef NodeInfo CaseBlockNodeInfo; +typedef NodeInfo CaseClauseNodeInfo; +typedef NodeInfo SourceElementsInfo; +typedef NodeInfo ClauseListInfo; +typedef NodeInfo VarDeclListInfo; +typedef NodeInfo ConstDeclListInfo; + +} // namespace KJS + +#endif // NodeInfo_h diff --git a/kjs/Parser.cpp b/kjs/Parser.cpp new file mode 100644 index 0000000..c6d7265 --- /dev/null +++ b/kjs/Parser.cpp @@ -0,0 +1,91 @@ +// -*- c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2006, 2007 Apple Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "Parser.h" + +#include "lexer.h" +#include +#include + +extern int kjsyyparse(); + +namespace KJS { + +Parser::Parser() + : m_sourceId(0) +{ +} + +void Parser::parse(int startingLineNumber, + const UChar* code, unsigned length, + int* sourceId, int* errLine, UString* errMsg) +{ + ASSERT(!m_sourceElements); + + if (errLine) + *errLine = -1; + if (errMsg) + *errMsg = 0; + + Lexer& lexer = KJS::lexer(); + + lexer.setCode(startingLineNumber, code, length); + m_sourceId++; + if (sourceId) + *sourceId = m_sourceId; + + int parseError = kjsyyparse(); + bool lexError = lexer.sawError(); + lexer.clear(); + + ParserRefCounted::deleteNewObjects(); + + if (parseError || lexError) { + if (errLine) + *errLine = lexer.lineNo(); + if (errMsg) + *errMsg = "Parse error"; + m_sourceElements.clear(); + } +} + +void Parser::didFinishParsing(SourceElements* sourceElements, ParserRefCountedData* varStack, + ParserRefCountedData* funcStack, int lastLine) +{ + m_sourceElements = sourceElements ? sourceElements : new SourceElements; + m_varDeclarations = varStack; + m_funcDeclarations = funcStack; + m_lastLine = lastLine; +} + +Parser& parser() +{ + ASSERT(JSLock::currentThreadIsHoldingLock()); + + static Parser& staticParser = *new Parser; + return staticParser; +} + +} // namespace KJS diff --git a/kjs/Parser.h b/kjs/Parser.h new file mode 100644 index 0000000..92548fe --- /dev/null +++ b/kjs/Parser.h @@ -0,0 +1,99 @@ +// -*- c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2006, 2007 Apple Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef Parser_h +#define Parser_h + +#include +#include +#include +#include +#include "nodes.h" + +namespace KJS { + + class FunctionBodyNode; + class ProgramNode; + class UString; + + struct UChar; + + template struct ParserRefCountedData : ParserRefCounted { + T data; + }; + + class Parser : Noncopyable { + public: + template + PassRefPtr parse(const UString& sourceURL, int startingLineNumber, + const UChar* code, unsigned length, + int* sourceId = 0, int* errLine = 0, UString* errMsg = 0); + + UString sourceURL() const { return m_sourceURL; } + int sourceId() const { return m_sourceId; } + + void didFinishParsing(SourceElements*, ParserRefCountedData*, + ParserRefCountedData*, int lastLine); + + private: + friend Parser& parser(); + + Parser(); // Use parser() instead. + void parse(int startingLineNumber, const UChar* code, unsigned length, + int* sourceId, int* errLine, UString* errMsg); + + UString m_sourceURL; + int m_sourceId; + RefPtr m_sourceElements; + RefPtr > m_varDeclarations; + RefPtr > m_funcDeclarations; + int m_lastLine; + }; + + Parser& parser(); // Returns the singleton JavaScript parser. + + template + PassRefPtr Parser::parse(const UString& sourceURL, int startingLineNumber, + const UChar* code, unsigned length, + int* sourceId, int* errLine, UString* errMsg) + { + m_sourceURL = sourceURL; + parse(startingLineNumber, code, length, sourceId, errLine, errMsg); + if (!m_sourceElements) { + m_sourceURL = UString(); + return 0; + } + RefPtr node = ParsedNode::create(m_sourceElements.release().get(), + m_varDeclarations ? &m_varDeclarations->data : 0, + m_funcDeclarations ? &m_funcDeclarations->data : 0); + m_varDeclarations = 0; + m_funcDeclarations = 0; + m_sourceURL = UString(); + node->setLoc(startingLineNumber, m_lastLine); + return node.release(); + } + +} // namespace KJS + +#endif // Parser_h diff --git a/kjs/PropertyNameArray.cpp b/kjs/PropertyNameArray.cpp new file mode 100644 index 0000000..45dda3a --- /dev/null +++ b/kjs/PropertyNameArray.cpp @@ -0,0 +1,43 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "PropertyNameArray.h" + +namespace KJS { + +void PropertyNameArray::add(const Identifier& ident) +{ + if (!m_set.add(ident.ustring().rep()).second) + return; + + m_vector.append(ident); +} + +void PropertyNameArray::swap(PropertyNameArray& other) +{ + m_vector.swap(other.m_vector); + m_set.swap(other.m_set); +} + + +} // namespace KJS + diff --git a/kjs/PropertyNameArray.h b/kjs/PropertyNameArray.h new file mode 100644 index 0000000..b702d21 --- /dev/null +++ b/kjs/PropertyNameArray.h @@ -0,0 +1,56 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_PROPERTY_NAME_ARRAY_H +#define KJS_PROPERTY_NAME_ARRAY_H + +#include "identifier.h" + +#include +#include + +namespace KJS { + + class PropertyNameArray { + public: + typedef Identifier ValueType; + typedef Vector::const_iterator const_iterator; + + void add(const Identifier&); + const_iterator begin() const { return m_vector.begin(); } + const_iterator end() const { return m_vector.end(); } + size_t size() const { return m_vector.size(); } + + Identifier& operator[](unsigned i) { return m_vector[i]; } + const Identifier& operator[](unsigned i) const { return m_vector[i]; } + + void swap(PropertyNameArray&); + private: + typedef HashSet > IdentifierSet; + IdentifierSet m_set; + Vector m_vector; + }; + + +} // namespace KJS + + +#endif // KJS_PROPERTY_NAME_ARRAY_H diff --git a/kjs/SavedBuiltins.h b/kjs/SavedBuiltins.h new file mode 100644 index 0000000..9901e41 --- /dev/null +++ b/kjs/SavedBuiltins.h @@ -0,0 +1,94 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef SavedBuiltins_H +#define SavedBuiltins_H + +#include "protect.h" +#include "object_object.h" +#include "string_object.h" +#include "error_object.h" +#include "regexp_object.h" +#include "array_object.h" +#include "bool_object.h" +#include "date_object.h" +#include "number_object.h" +#include "math_object.h" + +namespace KJS { + +struct SavedBuiltinsInternal { + ProtectedPtr objectConstructor; + ProtectedPtr functionConstructor; + ProtectedPtr arrayConstructor; + ProtectedPtr booleanConstructor; + ProtectedPtr stringConstructor; + ProtectedPtr numberConstructor; + ProtectedPtr dateConstructor; + ProtectedPtr regExpConstructor; + ProtectedPtr errorConstructor; + ProtectedPtr evalErrorConstructor; + ProtectedPtr rangeErrorConstructor; + ProtectedPtr referenceErrorConstructor; + ProtectedPtr syntaxErrorConstructor; + ProtectedPtr typeErrorConstructor; + ProtectedPtr URIErrorConstructor; + + ProtectedPtr objectPrototype; + ProtectedPtr functionPrototype; + ProtectedPtr arrayPrototype; + ProtectedPtr booleanPrototype; + ProtectedPtr stringPrototype; + ProtectedPtr numberPrototype; + ProtectedPtr datePrototype; + ProtectedPtr regExpPrototype; + ProtectedPtr errorPrototype; + ProtectedPtr evalErrorPrototype; + ProtectedPtr rangeErrorPrototype; + ProtectedPtr referenceErrorPrototype; + ProtectedPtr syntaxErrorPrototype; + ProtectedPtr typeErrorPrototype; + ProtectedPtr URIErrorPrototype; +}; + +class SavedBuiltins { + friend class JSGlobalObject; +public: + SavedBuiltins() + : _internal(0) + { + } + + ~SavedBuiltins() + { + delete _internal; + } + +private: + SavedBuiltinsInternal* _internal; +}; + +} // namespace + +#endif // SavedBuiltins_H diff --git a/kjs/SymbolTable.h b/kjs/SymbolTable.h new file mode 100644 index 0000000..1c2b2e8 --- /dev/null +++ b/kjs/SymbolTable.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SymbolTable_h +#define SymbolTable_h + +#include "ustring.h" +#include + +namespace KJS { + + struct IdentifierRepHash { + static unsigned hash(const RefPtr& key) { return key->computedHash(); } + static bool equal(const RefPtr& a, const RefPtr& b) { return a == b; } + static const bool safeToCompareToEmptyOrDeleted = true; + }; + + struct IdentifierRepHashTraits : HashTraits > { + static const RefPtr& deletedValue() + { + return *reinterpret_cast*>(&nullRepPtr); + } + + private: + static UString::Rep* nullRepPtr; + }; + + static ALWAYS_INLINE size_t missingSymbolMarker() { return std::numeric_limits::max(); } + + struct SymbolTableIndexHashTraits { + typedef size_t TraitType; + typedef SymbolTableIndexHashTraits StorageTraits; + static size_t emptyValue() { return missingSymbolMarker(); } + static const bool emptyValueIsZero = false; + static const bool needsDestruction = false; + static const bool needsRef = false; + }; + + typedef HashMap, size_t, IdentifierRepHash, IdentifierRepHashTraits, SymbolTableIndexHashTraits> SymbolTable; + +} // namespace KJS + +#endif // SymbolTable_h diff --git a/kjs/array_instance.cpp b/kjs/array_instance.cpp new file mode 100644 index 0000000..fec5c09 --- /dev/null +++ b/kjs/array_instance.cpp @@ -0,0 +1,612 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2003 Peter Kelly (pmk@post.com) + * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "array_instance.h" + +#include "JSGlobalObject.h" +#include "PropertyNameArray.h" +#include + +using namespace std; + +namespace KJS { + +typedef HashMap SparseArrayValueMap; + +struct ArrayStorage { + unsigned m_numValuesInVector; + SparseArrayValueMap* m_sparseValueMap; + JSValue* m_vector[1]; +}; + +// 0xFFFFFFFF is a bit weird -- is not an array index even though it's an integer +static const unsigned maxArrayIndex = 0xFFFFFFFEU; + +// Our policy for when to use a vector and when to use a sparse map. +// For all array indices under sparseArrayCutoff, we always use a vector. +// When indices greater than sparseArrayCutoff are involved, we use a vector +// as long as it is 1/8 full. If more sparse than that, we use a map. +// This value has to be a macro to be used in max() and min() without introducing +// a PIC branch in Mach-O binaries, see . +#define sparseArrayCutoff 10000U +static const unsigned minDensityMultiplier = 8; + +static const unsigned copyingSortCutoff = 50000; + +const ClassInfo ArrayInstance::info = {"Array", 0, 0}; + +static inline size_t storageSize(unsigned vectorLength) +{ + return sizeof(ArrayStorage) - sizeof(JSValue*) + vectorLength * sizeof(JSValue*); +} + +static inline unsigned increasedVectorLength(unsigned newLength) +{ + return (newLength * 3 + 1) / 2; +} + +static inline bool isDenseEnoughForVector(unsigned length, unsigned numValues) +{ + return length / minDensityMultiplier <= numValues; +} + +ArrayInstance::ArrayInstance(JSObject* prototype, unsigned initialLength) + : JSObject(prototype) +{ + unsigned initialCapacity = min(initialLength, sparseArrayCutoff); + + m_length = initialLength; + m_vectorLength = initialCapacity; + m_storage = static_cast(fastZeroedMalloc(storageSize(initialCapacity))); + + Collector::reportExtraMemoryCost(initialCapacity * sizeof(JSValue*)); +} + +ArrayInstance::ArrayInstance(JSObject* prototype, const List& list) + : JSObject(prototype) +{ + unsigned length = list.size(); + + m_length = length; + m_vectorLength = length; + + ArrayStorage* storage = static_cast(fastMalloc(storageSize(length))); + + storage->m_numValuesInVector = length; + storage->m_sparseValueMap = 0; + + size_t i = 0; + List::const_iterator end = list.end(); + for (List::const_iterator it = list.begin(); it != end; ++it, ++i) + storage->m_vector[i] = *it; + + m_storage = storage; + + // When the array is created non-empty, its cells are filled, so it's really no worse than + // a property map. Therefore don't report extra memory cost. +} + +ArrayInstance::~ArrayInstance() +{ + delete m_storage->m_sparseValueMap; + fastFree(m_storage); +} + +JSValue* ArrayInstance::getItem(unsigned i) const +{ + ASSERT(i <= maxArrayIndex); + + ArrayStorage* storage = m_storage; + + if (i < m_vectorLength) { + JSValue* value = storage->m_vector[i]; + return value ? value : jsUndefined(); + } + + SparseArrayValueMap* map = storage->m_sparseValueMap; + if (!map) + return jsUndefined(); + + JSValue* value = map->get(i); + return value ? value : jsUndefined(); +} + +JSValue* ArrayInstance::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) +{ + return jsNumber(static_cast(slot.slotBase())->m_length); +} + +ALWAYS_INLINE bool ArrayInstance::inlineGetOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot& slot) +{ + ArrayStorage* storage = m_storage; + + if (i >= m_length) { + if (i > maxArrayIndex) + return getOwnPropertySlot(exec, Identifier::from(i), slot); + return false; + } + + if (i < m_vectorLength) { + JSValue*& valueSlot = storage->m_vector[i]; + if (valueSlot) { + slot.setValueSlot(this, &valueSlot); + return true; + } + } else if (SparseArrayValueMap* map = storage->m_sparseValueMap) { + if (i >= sparseArrayCutoff) { + SparseArrayValueMap::iterator it = map->find(i); + if (it != map->end()) { + slot.setValueSlot(this, &it->second); + return true; + } + } + } + + return false; +} + +bool ArrayInstance::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + if (propertyName == exec->propertyNames().length) { + slot.setCustom(this, lengthGetter); + return true; + } + + bool isArrayIndex; + unsigned i = propertyName.toArrayIndex(&isArrayIndex); + if (isArrayIndex) + return inlineGetOwnPropertySlot(exec, i, slot); + + return JSObject::getOwnPropertySlot(exec, propertyName, slot); +} + +bool ArrayInstance::getOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot& slot) +{ + return inlineGetOwnPropertySlot(exec, i, slot); +} + +// ECMA 15.4.5.1 +void ArrayInstance::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attributes) +{ + bool isArrayIndex; + unsigned i = propertyName.toArrayIndex(&isArrayIndex); + if (isArrayIndex) { + put(exec, i, value, attributes); + return; + } + + if (propertyName == exec->propertyNames().length) { + unsigned newLength = value->toUInt32(exec); + if (value->toNumber(exec) != static_cast(newLength)) { + throwError(exec, RangeError, "Invalid array length."); + return; + } + setLength(newLength); + return; + } + + JSObject::put(exec, propertyName, value, attributes); +} + +void ArrayInstance::put(ExecState* exec, unsigned i, JSValue* value, int attributes) +{ + if (i > maxArrayIndex) { + put(exec, Identifier::from(i), value, attributes); + return; + } + + ArrayStorage* storage = m_storage; + + unsigned length = m_length; + if (i >= length) { + length = i + 1; + m_length = length; + } + + if (i < m_vectorLength) { + JSValue*& valueSlot = storage->m_vector[i]; + storage->m_numValuesInVector += !valueSlot; + valueSlot = value; + return; + } + + SparseArrayValueMap* map = storage->m_sparseValueMap; + + if (i >= sparseArrayCutoff) { + // We miss some cases where we could compact the storage, such as a large array that is being filled from the end + // (which will only be compacted as we reach indices that are less than cutoff) - but this makes the check much faster. + if (!isDenseEnoughForVector(i + 1, storage->m_numValuesInVector + 1)) { + if (!map) { + map = new SparseArrayValueMap; + storage->m_sparseValueMap = map; + } + map->set(i, value); + return; + } + } + + // We have decided that we'll put the new item into the vector. + // Fast case is when there is no sparse map, so we can increase the vector size without moving values from it. + if (!map || map->isEmpty()) { + increaseVectorLength(i + 1); + storage = m_storage; + ++storage->m_numValuesInVector; + storage->m_vector[i] = value; + return; + } + + // Decide how many values it would be best to move from the map. + unsigned newNumValuesInVector = storage->m_numValuesInVector + 1; + unsigned newVectorLength = increasedVectorLength(i + 1); + for (unsigned j = max(m_vectorLength, sparseArrayCutoff); j < newVectorLength; ++j) + newNumValuesInVector += map->contains(j); + if (i >= sparseArrayCutoff) + newNumValuesInVector -= map->contains(i); + if (isDenseEnoughForVector(newVectorLength, newNumValuesInVector)) { + unsigned proposedNewNumValuesInVector = newNumValuesInVector; + while (true) { + unsigned proposedNewVectorLength = increasedVectorLength(newVectorLength + 1); + for (unsigned j = max(newVectorLength, sparseArrayCutoff); j < proposedNewVectorLength; ++j) + proposedNewNumValuesInVector += map->contains(j); + if (!isDenseEnoughForVector(proposedNewVectorLength, proposedNewNumValuesInVector)) + break; + newVectorLength = proposedNewVectorLength; + newNumValuesInVector = proposedNewNumValuesInVector; + } + } + + storage = static_cast(fastRealloc(storage, storageSize(newVectorLength))); + + unsigned vectorLength = m_vectorLength; + if (newNumValuesInVector == storage->m_numValuesInVector + 1) { + for (unsigned j = vectorLength; j < newVectorLength; ++j) + storage->m_vector[j] = 0; + if (i > sparseArrayCutoff) + map->remove(i); + } else { + for (unsigned j = vectorLength; j < max(vectorLength, sparseArrayCutoff); ++j) + storage->m_vector[j] = 0; + for (unsigned j = max(vectorLength, sparseArrayCutoff); j < newVectorLength; ++j) + storage->m_vector[j] = map->take(j); + } + + storage->m_vector[i] = value; + + m_vectorLength = newVectorLength; + storage->m_numValuesInVector = newNumValuesInVector; + + m_storage = storage; +} + +bool ArrayInstance::deleteProperty(ExecState* exec, const Identifier& propertyName) +{ + bool isArrayIndex; + unsigned i = propertyName.toArrayIndex(&isArrayIndex); + if (isArrayIndex) + return deleteProperty(exec, i); + + if (propertyName == exec->propertyNames().length) + return false; + + return JSObject::deleteProperty(exec, propertyName); +} + +bool ArrayInstance::deleteProperty(ExecState* exec, unsigned i) +{ + ArrayStorage* storage = m_storage; + + if (i < m_vectorLength) { + JSValue*& valueSlot = storage->m_vector[i]; + bool hadValue = valueSlot; + valueSlot = 0; + storage->m_numValuesInVector -= hadValue; + return hadValue; + } + + if (SparseArrayValueMap* map = storage->m_sparseValueMap) { + if (i >= sparseArrayCutoff) { + SparseArrayValueMap::iterator it = map->find(i); + if (it != map->end()) { + map->remove(it); + return true; + } + } + } + + if (i > maxArrayIndex) + return deleteProperty(exec, Identifier::from(i)); + + return false; +} + +void ArrayInstance::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +{ + // FIXME: Filling PropertyNameArray with an identifier for every integer + // is incredibly inefficient for large arrays. We need a different approach. + + ArrayStorage* storage = m_storage; + + unsigned usedVectorLength = min(m_length, m_vectorLength); + for (unsigned i = 0; i < usedVectorLength; ++i) { + if (storage->m_vector[i]) + propertyNames.add(Identifier::from(i)); + } + + if (SparseArrayValueMap* map = storage->m_sparseValueMap) { + SparseArrayValueMap::iterator end = map->end(); + for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) + propertyNames.add(Identifier::from(it->first)); + } + + JSObject::getPropertyNames(exec, propertyNames); +} + +void ArrayInstance::increaseVectorLength(unsigned newLength) +{ + // This function leaves the array in an internally inconsistent state, because it does not move any values from sparse value map + // to the vector. Callers have to account for that, because they can do it more efficiently. + + ArrayStorage* storage = m_storage; + + unsigned vectorLength = m_vectorLength; + ASSERT(newLength > vectorLength); + unsigned newVectorLength = increasedVectorLength(newLength); + + storage = static_cast(fastRealloc(storage, storageSize(newVectorLength))); + m_vectorLength = newVectorLength; + + for (unsigned i = vectorLength; i < newVectorLength; ++i) + storage->m_vector[i] = 0; + + m_storage = storage; +} + +void ArrayInstance::setLength(unsigned newLength) +{ + ArrayStorage* storage = m_storage; + + unsigned length = m_length; + + if (newLength < length) { + unsigned usedVectorLength = min(length, m_vectorLength); + for (unsigned i = newLength; i < usedVectorLength; ++i) { + JSValue*& valueSlot = storage->m_vector[i]; + bool hadValue = valueSlot; + valueSlot = 0; + storage->m_numValuesInVector -= hadValue; + } + + if (SparseArrayValueMap* map = storage->m_sparseValueMap) { + SparseArrayValueMap copy = *map; + SparseArrayValueMap::iterator end = copy.end(); + for (SparseArrayValueMap::iterator it = copy.begin(); it != end; ++it) { + if (it->first >= newLength) + map->remove(it->first); + } + if (map->isEmpty()) { + delete map; + storage->m_sparseValueMap = 0; + } + } + } + + m_length = newLength; +} + +void ArrayInstance::mark() +{ + JSObject::mark(); + + ArrayStorage* storage = m_storage; + + unsigned usedVectorLength = min(m_length, m_vectorLength); + for (unsigned i = 0; i < usedVectorLength; ++i) { + JSValue* value = storage->m_vector[i]; + if (value && !value->marked()) + value->mark(); + } + + if (SparseArrayValueMap* map = storage->m_sparseValueMap) { + SparseArrayValueMap::iterator end = map->end(); + for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) { + JSValue* value = it->second; + if (!value->marked()) + value->mark(); + } + } +} + +static int compareByStringPairForQSort(const void* a, const void* b) +{ + const std::pair* va = static_cast*>(a); + const std::pair* vb = static_cast*>(b); + return compare(va->second, vb->second); +} + +static ExecState* execForCompareByStringForQSort = 0; +static int compareByStringForQSort(const void* a, const void* b) +{ + ExecState* exec = execForCompareByStringForQSort; + + JSValue* va = *static_cast(a); + JSValue* vb = *static_cast(b); + ASSERT(!va->isUndefined()); + ASSERT(!vb->isUndefined()); + + return compare(va->toString(exec), vb->toString(exec)); +} + +void ArrayInstance::sort(ExecState* exec) +{ + unsigned lengthNotIncludingUndefined = compactForSorting(); + + if (lengthNotIncludingUndefined < copyingSortCutoff) { + // Converting JavaScript values to strings can be expensive, so we do it once up front and sort based on that. + // This is a considerable improvement over doing it twice per comparison, though it requires a large temporary + // buffer. For large arrays, we fall back to a qsort on the JavaScriptValues to avoid creating copies. + + Vector > values(lengthNotIncludingUndefined); + for (size_t i = 0; i < lengthNotIncludingUndefined; i++) { + JSValue* value = m_storage->m_vector[i]; + ASSERT(!value->isUndefined()); + values[i].first = value; + values[i].second = value->toString(exec); + } + + // FIXME: Since we sort by string value, a fast algorithm might be to use a radix sort. That would be O(N) rather + // than O(N log N). + +#if HAVE(MERGESORT) + mergesort(values.begin(), values.size(), sizeof(std::pair), compareByStringPairForQSort); +#else + qsort(values.begin(), values.size(), sizeof(std::pair), compareByStringPairForQSort); +#endif + for (size_t i = 0; i < lengthNotIncludingUndefined; i++) + m_storage->m_vector[i] = values[i].first; + return; + } + + ExecState* oldExec = execForCompareByStringForQSort; + execForCompareByStringForQSort = exec; + qsort(m_storage->m_vector, lengthNotIncludingUndefined, sizeof(JSValue*), compareByStringForQSort); + execForCompareByStringForQSort = oldExec; +} + +struct CompareWithCompareFunctionArguments { + CompareWithCompareFunctionArguments(ExecState *e, JSObject *cf) + : exec(e) + , compareFunction(cf) + , globalObject(e->dynamicGlobalObject()) + { + } + + ExecState *exec; + JSObject *compareFunction; + List arguments; + JSGlobalObject* globalObject; +}; + +static CompareWithCompareFunctionArguments* compareWithCompareFunctionArguments = 0; + +static int compareWithCompareFunctionForQSort(const void* a, const void* b) +{ + CompareWithCompareFunctionArguments *args = compareWithCompareFunctionArguments; + + JSValue* va = *static_cast(a); + JSValue* vb = *static_cast(b); + ASSERT(!va->isUndefined()); + ASSERT(!vb->isUndefined()); + + args->arguments.clear(); + args->arguments.append(va); + args->arguments.append(vb); + double compareResult = args->compareFunction->call + (args->exec, args->globalObject, args->arguments)->toNumber(args->exec); + return compareResult < 0 ? -1 : compareResult > 0 ? 1 : 0; +} + +void ArrayInstance::sort(ExecState* exec, JSObject* compareFunction) +{ + size_t lengthNotIncludingUndefined = compactForSorting(); + + CompareWithCompareFunctionArguments* oldArgs = compareWithCompareFunctionArguments; + CompareWithCompareFunctionArguments args(exec, compareFunction); + compareWithCompareFunctionArguments = &args; + +#if HAVE(MERGESORT) + // Because mergesort usually does fewer compares, it is faster than qsort here. + // However, because it requires extra copies of the storage buffer, don't use it for very + // large arrays. + + // FIXME: A tree sort using a perfectly balanced tree (e.g. an AVL tree) could do an even + // better job of minimizing compares. + + if (lengthNotIncludingUndefined < copyingSortCutoff) { + // During the sort, we could do a garbage collect, and it's important to still + // have references to every object in the array for ArrayInstance::mark. + // The mergesort algorithm does not guarantee this, so we sort a copy rather + // than the original. + size_t size = storageSize(m_vectorLength); + ArrayStorage* copy = static_cast(fastMalloc(size)); + memcpy(copy, m_storage, size); + mergesort(copy->m_vector, lengthNotIncludingUndefined, sizeof(JSValue*), compareWithCompareFunctionForQSort); + fastFree(m_storage); + m_storage = copy; + compareWithCompareFunctionArguments = oldArgs; + return; + } +#endif + + qsort(m_storage->m_vector, lengthNotIncludingUndefined, sizeof(JSValue*), compareWithCompareFunctionForQSort); + compareWithCompareFunctionArguments = oldArgs; +} + +unsigned ArrayInstance::compactForSorting() +{ + ArrayStorage* storage = m_storage; + + unsigned usedVectorLength = min(m_length, m_vectorLength); + + unsigned numDefined = 0; + unsigned numUndefined = 0; + + for (; numDefined < usedVectorLength; ++numDefined) { + JSValue* v = storage->m_vector[numDefined]; + if (!v || v->isUndefined()) + break; + } + for (unsigned i = numDefined; i < usedVectorLength; ++i) { + if (JSValue* v = storage->m_vector[i]) { + if (v->isUndefined()) + ++numUndefined; + else + storage->m_vector[numDefined++] = v; + } + } + + unsigned newUsedVectorLength = numDefined + numUndefined; + + if (SparseArrayValueMap* map = storage->m_sparseValueMap) { + newUsedVectorLength += map->size(); + if (newUsedVectorLength > m_vectorLength) { + increaseVectorLength(newUsedVectorLength); + storage = m_storage; + } + + SparseArrayValueMap::iterator end = map->end(); + for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) + storage->m_vector[numDefined++] = it->second; + + delete map; + storage->m_sparseValueMap = 0; + } + + for (unsigned i = numDefined; i < newUsedVectorLength; ++i) + storage->m_vector[i] = jsUndefined(); + for (unsigned i = newUsedVectorLength; i < usedVectorLength; ++i) + storage->m_vector[i] = 0; + + return numDefined; +} + +} diff --git a/kjs/array_instance.h b/kjs/array_instance.h new file mode 100644 index 0000000..913d0cd --- /dev/null +++ b/kjs/array_instance.h @@ -0,0 +1,72 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef ARRAY_INSTANCE_H +#define ARRAY_INSTANCE_H + +#include "object.h" + +namespace KJS { + + struct ArrayStorage; + + class ArrayInstance : public JSObject { + public: + ArrayInstance(JSObject* prototype, unsigned initialLength); + ArrayInstance(JSObject* prototype, const List& initialValues); + ~ArrayInstance(); + + virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); + virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); + virtual void put(ExecState*, const Identifier& propertyName, JSValue*, int attributes = None); + virtual void put(ExecState*, unsigned propertyName, JSValue*, int attributes = None); + virtual bool deleteProperty(ExecState *, const Identifier& propertyName); + virtual bool deleteProperty(ExecState *, unsigned propertyName); + virtual void getPropertyNames(ExecState*, PropertyNameArray&); + + virtual void mark(); + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + + unsigned getLength() const { return m_length; } + JSValue* getItem(unsigned) const; + + void sort(ExecState*); + void sort(ExecState*, JSObject* compareFunction); + + private: + static JSValue* lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + bool inlineGetOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); + + void setLength(unsigned); + void increaseVectorLength(unsigned newLength); + + unsigned compactForSorting(); + + unsigned m_length; + unsigned m_vectorLength; + ArrayStorage* m_storage; + }; + +} // namespace KJS + +#endif diff --git a/kjs/array_object.cpp b/kjs/array_object.cpp new file mode 100644 index 0000000..48b0855 --- /dev/null +++ b/kjs/array_object.cpp @@ -0,0 +1,760 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2003 Peter Kelly (pmk@post.com) + * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + */ + +#include "config.h" +#include "array_object.h" +#include "array_object.lut.h" + +#include "error_object.h" +#include "lookup.h" +#include "operations.h" +#include +#include +#include + +#include // for std::min + +namespace KJS { + +// ------------------------------ ArrayPrototype ---------------------------- + +const ClassInfo ArrayPrototype::info = {"Array", &ArrayInstance::info, &arrayTable}; + +/* Source for array_object.lut.h +@begin arrayTable 16 + toString arrayProtoFuncToString DontEnum|Function 0 + toLocaleString arrayProtoFuncToLocaleString DontEnum|Function 0 + concat arrayProtoFuncConcat DontEnum|Function 1 + join arrayProtoFuncJoin DontEnum|Function 1 + pop arrayProtoFuncPop DontEnum|Function 0 + push arrayProtoFuncPush DontEnum|Function 1 + reverse arrayProtoFuncReverse DontEnum|Function 0 + shift arrayProtoFuncShift DontEnum|Function 0 + slice arrayProtoFuncSlice DontEnum|Function 2 + sort arrayProtoFuncSort DontEnum|Function 1 + splice arrayProtoFuncSplice DontEnum|Function 2 + unshift arrayProtoFuncUnShift DontEnum|Function 1 + every arrayProtoFuncEvery DontEnum|Function 1 + forEach arrayProtoFuncForEach DontEnum|Function 1 + some arrayProtoFuncSome DontEnum|Function 1 + indexOf arrayProtoFuncIndexOf DontEnum|Function 1 + lastIndexOf arrayProtoFuncLastIndexOf DontEnum|Function 1 + filter arrayProtoFuncFilter DontEnum|Function 1 + map arrayProtoFuncMap DontEnum|Function 1 +@end +*/ + +// ECMA 15.4.4 +ArrayPrototype::ArrayPrototype(ExecState*, ObjectPrototype* objProto) + : ArrayInstance(objProto, 0) +{ +} + +bool ArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticFunctionSlot(exec, &arrayTable, this, propertyName, slot); +} + + +// ------------------------------ Array Functions ---------------------------- + +// Helper function +static JSValue* getProperty(ExecState* exec, JSObject* obj, unsigned index) +{ + PropertySlot slot; + if (!obj->getPropertySlot(exec, index, slot)) + return 0; + return slot.getValue(exec, obj, index); +} + +JSValue* arrayProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&ArrayInstance::info)) + return throwError(exec, TypeError); + + static HashSet visitedElems; + static const UString* empty = new UString(""); + static const UString* comma = new UString(","); + bool alreadyVisited = !visitedElems.add(thisObj).second; + if (alreadyVisited) + return jsString(*empty); + UString separator = *comma; + UString str = *empty; + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + for (unsigned k = 0; k < length; k++) { + if (k >= 1) + str += separator; + if (str.isNull()) { + JSObject* error = Error::create(exec, GeneralError, "Out of memory"); + exec->setException(error); + break; + } + + JSValue* element = thisObj->get(exec, k); + if (element->isUndefinedOrNull()) + continue; + + str += element->toString(exec); + + if (str.isNull()) { + JSObject* error = Error::create(exec, GeneralError, "Out of memory"); + exec->setException(error); + } + + if (exec->hadException()) + break; + } + visitedElems.remove(thisObj); + return jsString(str); +} + +JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&ArrayInstance::info)) + return throwError(exec, TypeError); + + static HashSet visitedElems; + static const UString* empty = new UString(""); + static const UString* comma = new UString(","); + bool alreadyVisited = !visitedElems.add(thisObj).second; + if (alreadyVisited) + return jsString(*empty); + UString separator = *comma; + UString str = *empty; + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + for (unsigned k = 0; k < length; k++) { + if (k >= 1) + str += separator; + if (str.isNull()) { + JSObject* error = Error::create(exec, GeneralError, "Out of memory"); + exec->setException(error); + break; + } + + JSValue* element = thisObj->get(exec, k); + if (element->isUndefinedOrNull()) + continue; + + JSObject* o = element->toObject(exec); + JSValue* conversionFunction = o->get(exec, exec->propertyNames().toLocaleString); + if (conversionFunction->isObject() && static_cast(conversionFunction)->implementsCall()) + str += static_cast(conversionFunction)->call(exec, o, exec->emptyList())->toString(exec); + else + str += element->toString(exec); + + if (str.isNull()) { + JSObject* error = Error::create(exec, GeneralError, "Out of memory"); + exec->setException(error); + } + + if (exec->hadException()) + break; + } + visitedElems.remove(thisObj); + return jsString(str); +} + +JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject* thisObj, const List& args) +{ + static HashSet visitedElems; + static const UString* empty = new UString(""); + static const UString* comma = new UString(","); + bool alreadyVisited = !visitedElems.add(thisObj).second; + if (alreadyVisited) + return jsString(*empty); + UString separator = *comma; + UString str = *empty; + + if (!args[0]->isUndefined()) + separator = args[0]->toString(exec); + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + for (unsigned k = 0; k < length; k++) { + if (k >= 1) + str += separator; + if (str.isNull()) { + JSObject* error = Error::create(exec, GeneralError, "Out of memory"); + exec->setException(error); + break; + } + + JSValue* element = thisObj->get(exec, k); + if (element->isUndefinedOrNull()) + continue; + + str += element->toString(exec); + + if (str.isNull()) { + JSObject* error = Error::create(exec, GeneralError, "Out of memory"); + exec->setException(error); + } + + if (exec->hadException()) + break; + } + visitedElems.remove(thisObj); + return jsString(str); +} + +JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject* thisObj, const List& args) +{ + JSObject* arr = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList())); + int n = 0; + JSValue* curArg = thisObj; + JSObject* curObj = static_cast(thisObj); + List::const_iterator it = args.begin(); + List::const_iterator end = args.end(); + while (1) { + if (curArg->isObject() && curObj->inherits(&ArrayInstance::info)) { + unsigned k = 0; + // Older versions tried to optimize out getting the length of thisObj + // by checking for n != 0, but that doesn't work if thisObj is an empty array. + unsigned length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + while (k < length) { + if (JSValue* v = getProperty(exec, curObj, k)) + arr->put(exec, n, v); + n++; + k++; + } + } else { + arr->put(exec, n, curArg); + n++; + } + if (it == end) + break; + curArg = *it; + curObj = static_cast(curArg); // may be 0 + ++it; + } + arr->put(exec, exec->propertyNames().length, jsNumber(n)); + return arr; +} + +JSValue* arrayProtoFuncPop(ExecState* exec, JSObject* thisObj, const List&) +{ + JSValue* result = 0; + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + if (length == 0) { + thisObj->put(exec, exec->propertyNames().length, jsNumber(length)); + result = jsUndefined(); + } else { + result = thisObj->get(exec, length - 1); + thisObj->deleteProperty(exec, length - 1); + thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1)); + } + return result; +} + +JSValue* arrayProtoFuncPush(ExecState* exec, JSObject* thisObj, const List& args) +{ + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + for (unsigned n = 0; n < args.size(); n++) + thisObj->put(exec, length + n, args[n]); + length += args.size(); + thisObj->put(exec, exec->propertyNames().length, jsNumber(length)); + return jsNumber(length); +} + +JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject* thisObj, const List&) +{ + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + unsigned middle = length / 2; + + for (unsigned k = 0; k < middle; k++) { + unsigned lk1 = length - k - 1; + JSValue* obj2 = getProperty(exec, thisObj, lk1); + JSValue* obj = getProperty(exec, thisObj, k); + + if (obj2) + thisObj->put(exec, k, obj2); + else + thisObj->deleteProperty(exec, k); + + if (obj) + thisObj->put(exec, lk1, obj); + else + thisObj->deleteProperty(exec, lk1); + } + return thisObj; +} + +JSValue* arrayProtoFuncShift(ExecState* exec, JSObject* thisObj, const List&) +{ + JSValue* result = 0; + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + if (length == 0) { + thisObj->put(exec, exec->propertyNames().length, jsNumber(length)); + result = jsUndefined(); + } else { + result = thisObj->get(exec, 0); + for (unsigned k = 1; k < length; k++) { + if (JSValue* obj = getProperty(exec, thisObj, k)) + thisObj->put(exec, k - 1, obj); + else + thisObj->deleteProperty(exec, k - 1); + } + thisObj->deleteProperty(exec, length - 1); + thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1)); + } + return result; +} + +JSValue* arrayProtoFuncSlice(ExecState* exec, JSObject* thisObj, const List& args) +{ + // http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10 + + // We return a new array + JSObject* resObj = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList())); + JSValue* result = resObj; + double begin = args[0]->toInteger(exec); + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + if (begin >= 0) { + if (begin > length) + begin = length; + } else { + begin += length; + if (begin < 0) + begin = 0; + } + double end; + if (args[1]->isUndefined()) + end = length; + else { + end = args[1]->toInteger(exec); + if (end < 0) { + end += length; + if (end < 0) + end = 0; + } else { + if (end > length) + end = length; + } + } + + int n = 0; + int b = static_cast(begin); + int e = static_cast(end); + for (int k = b; k < e; k++, n++) { + if (JSValue* v = getProperty(exec, thisObj, k)) + resObj->put(exec, n, v); + } + resObj->put(exec, exec->propertyNames().length, jsNumber(n)); + return result; +} + +JSValue* arrayProtoFuncSort(ExecState* exec, JSObject* thisObj, const List& args) +{ + JSObject* sortFunction = 0; + if (!args[0]->isUndefined()) { + sortFunction = args[0]->toObject(exec); + if (!sortFunction->implementsCall()) + sortFunction = 0; + } + + if (thisObj->classInfo() == &ArrayInstance::info) { + if (sortFunction) + static_cast(thisObj)->sort(exec, sortFunction); + else + static_cast(thisObj)->sort(exec); + return thisObj; + } + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + + if (!length) + return thisObj; + + // "Min" sort. Not the fastest, but definitely less code than heapsort + // or quicksort, and much less swapping than bubblesort/insertionsort. + for (unsigned i = 0; i < length - 1; ++i) { + JSValue* iObj = thisObj->get(exec, i); + unsigned themin = i; + JSValue* minObj = iObj; + for (unsigned j = i + 1; j < length; ++j) { + JSValue* jObj = thisObj->get(exec, j); + double compareResult; + if (jObj->isUndefined()) + compareResult = 1; // don't check minObj because there's no need to differentiate == (0) from > (1) + else if (minObj->isUndefined()) + compareResult = -1; + else if (sortFunction) { + List l; + l.append(jObj); + l.append(minObj); + compareResult = sortFunction->call(exec, exec->dynamicGlobalObject(), l)->toNumber(exec); + } else + compareResult = (jObj->toString(exec) < minObj->toString(exec)) ? -1 : 1; + + if (compareResult < 0) { + themin = j; + minObj = jObj; + } + } + // Swap themin and i + if (themin > i) { + thisObj->put(exec, i, minObj); + thisObj->put(exec, themin, iObj); + } + } + return thisObj; +} + +JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject* thisObj, const List& args) +{ + // 15.4.4.12 + JSObject* resObj = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList())); + JSValue* result = resObj; + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + if (!args.size()) + return jsUndefined(); + int begin = args[0]->toUInt32(exec); + if (begin < 0) + begin = std::max(begin + length, 0); + else + begin = std::min(begin, length); + + unsigned deleteCount; + if (args.size() > 1) + deleteCount = std::min(std::max(args[1]->toUInt32(exec), 0), length - begin); + else + deleteCount = length - begin; + + for (unsigned k = 0; k < deleteCount; k++) { + if (JSValue* v = getProperty(exec, thisObj, k + begin)) + resObj->put(exec, k, v); + } + resObj->put(exec, exec->propertyNames().length, jsNumber(deleteCount)); + + unsigned additionalArgs = std::max(args.size() - 2, 0); + if (additionalArgs != deleteCount) { + if (additionalArgs < deleteCount) { + for (unsigned k = begin; k < length - deleteCount; ++k) { + if (JSValue* v = getProperty(exec, thisObj, k + deleteCount)) + thisObj->put(exec, k + additionalArgs, v); + else + thisObj->deleteProperty(exec, k + additionalArgs); + } + for (unsigned k = length; k > length - deleteCount + additionalArgs; --k) + thisObj->deleteProperty(exec, k - 1); + } else { + for (unsigned k = length - deleteCount; (int)k > begin; --k) { + if (JSValue* obj = getProperty(exec, thisObj, k + deleteCount - 1)) + thisObj->put(exec, k + additionalArgs - 1, obj); + else + thisObj->deleteProperty(exec, k + additionalArgs - 1); + } + } + } + for (unsigned k = 0; k < additionalArgs; ++k) + thisObj->put(exec, k + begin, args[k + 2]); + + thisObj->put(exec, exec->propertyNames().length, jsNumber(length - deleteCount + additionalArgs)); + return result; +} + +JSValue* arrayProtoFuncUnShift(ExecState* exec, JSObject* thisObj, const List& args) +{ + // 15.4.4.13 + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + unsigned nrArgs = args.size(); + if (nrArgs) { + for (unsigned k = length; k > 0; --k) { + if (JSValue* v = getProperty(exec, thisObj, k - 1)) + thisObj->put(exec, k + nrArgs - 1, v); + else + thisObj->deleteProperty(exec, k + nrArgs - 1); + } + } + for (unsigned k = 0; k < nrArgs; ++k) + thisObj->put(exec, k, args[k]); + JSValue* result = jsNumber(length + nrArgs); + thisObj->put(exec, exec->propertyNames().length, result); + return result; +} + +JSValue* arrayProtoFuncFilter(ExecState* exec, JSObject* thisObj, const List& args) +{ + JSObject* eachFunction = args[0]->toObject(exec); + + if (!eachFunction->implementsCall()) + return throwError(exec, TypeError); + + JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); + JSObject* resultArray = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList())); + + unsigned filterIndex = 0; + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + for (unsigned k = 0; k < length && !exec->hadException(); ++k) { + PropertySlot slot; + + if (!thisObj->getPropertySlot(exec, k, slot)) + continue; + + JSValue* v = slot.getValue(exec, thisObj, k); + + List eachArguments; + + eachArguments.append(v); + eachArguments.append(jsNumber(k)); + eachArguments.append(thisObj); + + JSValue* result = eachFunction->call(exec, applyThis, eachArguments); + + if (result->toBoolean(exec)) + resultArray->put(exec, filterIndex++, v); + } + return resultArray; +} + +JSValue* arrayProtoFuncMap(ExecState* exec, JSObject* thisObj, const List& args) +{ + JSObject* eachFunction = args[0]->toObject(exec); + if (!eachFunction->implementsCall()) + return throwError(exec, TypeError); + + JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + + List mapArgs; + mapArgs.append(jsNumber(length)); + JSObject* resultArray = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, mapArgs)); + + for (unsigned k = 0; k < length && !exec->hadException(); ++k) { + PropertySlot slot; + if (!thisObj->getPropertySlot(exec, k, slot)) + continue; + + JSValue* v = slot.getValue(exec, thisObj, k); + + List eachArguments; + + eachArguments.append(v); + eachArguments.append(jsNumber(k)); + eachArguments.append(thisObj); + + JSValue* result = eachFunction->call(exec, applyThis, eachArguments); + resultArray->put(exec, k, result); + } + + return resultArray; +} + +// Documentation for these three is available at: +// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:every +// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach +// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some + +JSValue* arrayProtoFuncEvery(ExecState* exec, JSObject* thisObj, const List& args) +{ + JSObject* eachFunction = args[0]->toObject(exec); + + if (!eachFunction->implementsCall()) + return throwError(exec, TypeError); + + JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); + + JSValue* result = jsBoolean(true); + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + for (unsigned k = 0; k < length && !exec->hadException(); ++k) { + PropertySlot slot; + + if (!thisObj->getPropertySlot(exec, k, slot)) + continue; + + List eachArguments; + + eachArguments.append(slot.getValue(exec, thisObj, k)); + eachArguments.append(jsNumber(k)); + eachArguments.append(thisObj); + + bool predicateResult = eachFunction->call(exec, applyThis, eachArguments)->toBoolean(exec); + + if (!predicateResult) { + result = jsBoolean(false); + break; + } + } + + return result; +} + +JSValue* arrayProtoFuncForEach(ExecState* exec, JSObject* thisObj, const List& args) +{ + JSObject* eachFunction = args[0]->toObject(exec); + + if (!eachFunction->implementsCall()) + return throwError(exec, TypeError); + + JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + for (unsigned k = 0; k < length && !exec->hadException(); ++k) { + PropertySlot slot; + if (!thisObj->getPropertySlot(exec, k, slot)) + continue; + + List eachArguments; + eachArguments.append(slot.getValue(exec, thisObj, k)); + eachArguments.append(jsNumber(k)); + eachArguments.append(thisObj); + + eachFunction->call(exec, applyThis, eachArguments); + } + return jsUndefined(); +} + +JSValue* arrayProtoFuncSome(ExecState* exec, JSObject* thisObj, const List& args) +{ + JSObject* eachFunction = args[0]->toObject(exec); + + if (!eachFunction->implementsCall()) + return throwError(exec, TypeError); + + JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); + + JSValue* result = jsBoolean(false); + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + for (unsigned k = 0; k < length && !exec->hadException(); ++k) { + PropertySlot slot; + if (!thisObj->getPropertySlot(exec, k, slot)) + continue; + + List eachArguments; + eachArguments.append(slot.getValue(exec, thisObj, k)); + eachArguments.append(jsNumber(k)); + eachArguments.append(thisObj); + + bool predicateResult = eachFunction->call(exec, applyThis, eachArguments)->toBoolean(exec); + + if (predicateResult) { + result = jsBoolean(true); + break; + } + } + return result; +} + +JSValue* arrayProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const List& args) +{ + // JavaScript 1.5 Extension by Mozilla + // Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf + + unsigned index = 0; + double d = args[1]->toInteger(exec); + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + if (d < 0) + d += length; + if (d > 0) { + if (d > length) + index = length; + else + index = static_cast(d); + } + + JSValue* searchElement = args[0]; + for (; index < length; ++index) { + JSValue* e = getProperty(exec, thisObj, index); + if (!e) + continue; + if (strictEqual(exec, searchElement, e)) + return jsNumber(index); + } + + return jsNumber(-1); +} + +JSValue* arrayProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const List& args) +{ + // JavaScript 1.6 Extension by Mozilla + // Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf + + unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + int index = length - 1; + double d = args[1]->toIntegerPreserveNaN(exec); + + if (d < 0) { + d += length; + if (d < 0) + return jsNumber(-1); + } + if (d < length) + index = static_cast(d); + + JSValue* searchElement = args[0]; + for (; index >= 0; --index) { + JSValue* e = getProperty(exec, thisObj, index); + if (!e) + continue; + if (strictEqual(exec, searchElement, e)) + return jsNumber(index); + } + + return jsNumber(-1); +} + +// ------------------------------ ArrayObjectImp ------------------------------- + +ArrayObjectImp::ArrayObjectImp(ExecState* exec, FunctionPrototype* funcProto, ArrayPrototype* arrayProto) + : InternalFunctionImp(funcProto, arrayProto->classInfo()->className) +{ + // ECMA 15.4.3.1 Array.prototype + putDirect(exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly); + + // no. of arguments for constructor + putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); +} + +bool ArrayObjectImp::implementsConstruct() const +{ + return true; +} + +// ECMA 15.4.2 +JSObject* ArrayObjectImp::construct(ExecState* exec, const List& args) +{ + // a single numeric argument denotes the array size (!) + if (args.size() == 1 && args[0]->isNumber()) { + uint32_t n = args[0]->toUInt32(exec); + if (n != args[0]->toNumber(exec)) + return throwError(exec, RangeError, "Array size is not a small enough positive integer."); + return new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), n); + } + + // otherwise the array is constructed with the arguments in it + return new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), args); +} + +// ECMA 15.6.1 +JSValue* ArrayObjectImp::callAsFunction(ExecState* exec, JSObject*, const List& args) +{ + // equivalent to 'new Array(....)' + return construct(exec,args); +} + +} diff --git a/kjs/array_object.h b/kjs/array_object.h new file mode 100644 index 0000000..e109c47 --- /dev/null +++ b/kjs/array_object.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef ARRAY_OBJECT_H_ +#define ARRAY_OBJECT_H_ + +#include "array_instance.h" +#include "function_object.h" +#include "lookup.h" + +namespace KJS { + + class ArrayPrototype : public ArrayInstance { + public: + ArrayPrototype(ExecState*, ObjectPrototype*); + + bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + }; + + class ArrayObjectImp : public InternalFunctionImp { + public: + ArrayObjectImp(ExecState*, FunctionPrototype*, ArrayPrototype*); + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List&); + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + + }; + + JSValue* arrayProtoFuncToString(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncToLocaleString(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncConcat(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncJoin(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncPop(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncPush(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncReverse(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncShift(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncSlice(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncSort(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncSplice(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncUnShift(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncEvery(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncForEach(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncSome(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncIndexOf(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncFilter(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncMap(ExecState*, JSObject*, const List&); + JSValue* arrayProtoFuncLastIndexOf(ExecState*, JSObject*, const List&); + +} // namespace KJS + +#endif // ARRAY_OBJECT_H_ diff --git a/kjs/bool_object.cpp b/kjs/bool_object.cpp new file mode 100644 index 0000000..10bb738 --- /dev/null +++ b/kjs/bool_object.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "bool_object.h" + +#include "JSGlobalObject.h" +#include "error_object.h" +#include "operations.h" +#include + +namespace KJS { + +// ------------------------------ BooleanInstance --------------------------- + +const ClassInfo BooleanInstance::info = { "Boolean", 0, 0 }; + +BooleanInstance::BooleanInstance(JSObject* proto) + : JSWrapperObject(proto) +{ +} + +// ------------------------------ BooleanPrototype -------------------------- + +// Functions +static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, const List&); +static JSValue* booleanProtoFuncValueOf(ExecState*, JSObject*, const List&); + +// ECMA 15.6.4 + +BooleanPrototype::BooleanPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype) + : BooleanInstance(objectPrototype) +{ + setInternalValue(jsBoolean(false)); + + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum); +} + + +// ------------------------------ Functions -------------------------- + +// ECMA 15.6.4.2 + 15.6.4.3 + +JSValue* booleanProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&BooleanInstance::info)) + return throwError(exec, TypeError); + + JSValue* v = static_cast(thisObj)->internalValue(); + ASSERT(v); + + return jsString(v->toString(exec)); +} +JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&BooleanInstance::info)) + return throwError(exec, TypeError); + + JSValue* v = static_cast(thisObj)->internalValue(); + ASSERT(v); + + // TODO: optimize for bool case + return jsBoolean(v->toBoolean(exec)); +} + +// ------------------------------ BooleanObjectImp ----------------------------- + + +BooleanObjectImp::BooleanObjectImp(ExecState* exec, FunctionPrototype* functionPrototype, BooleanPrototype* booleanPrototype) + : InternalFunctionImp(functionPrototype, booleanPrototype->classInfo()->className) +{ + putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly); + + // no. of arguments for constructor + putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + + +bool BooleanObjectImp::implementsConstruct() const +{ + return true; +} + +// ECMA 15.6.2 +JSObject* BooleanObjectImp::construct(ExecState* exec, const List& args) +{ + BooleanInstance* obj(new BooleanInstance(exec->lexicalGlobalObject()->booleanPrototype())); + obj->setInternalValue(jsBoolean(args[0]->toBoolean(exec))); + return obj; +} + +// ECMA 15.6.1 +JSValue* BooleanObjectImp::callAsFunction(ExecState* exec, JSObject*, const List& args) +{ + // TODO: optimize for bool case + return jsBoolean(args[0]->toBoolean(exec)); +} + +} // namespace KJS diff --git a/kjs/bool_object.h b/kjs/bool_object.h new file mode 100644 index 0000000..c3d5a9f --- /dev/null +++ b/kjs/bool_object.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef BOOL_OBJECT_H_ +#define BOOL_OBJECT_H_ + +#include "function_object.h" +#include "JSWrapperObject.h" + +namespace KJS { + + class BooleanInstance : public JSWrapperObject { + public: + BooleanInstance(JSObject* proto); + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + }; + + /** + * @internal + * + * The initial value of Boolean.prototype (and thus all objects created + * with the Boolean constructor + */ + class BooleanPrototype : public BooleanInstance { + public: + BooleanPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*); + }; + + /** + * @internal + * + * The initial value of the the global variable's "Boolean" property + */ + class BooleanObjectImp : public InternalFunctionImp { + public: + BooleanObjectImp(ExecState*, FunctionPrototype*, BooleanPrototype*); + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List&); + + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + }; + +} // namespace KJS + +#endif // BOOL_OBJECT_H_ diff --git a/kjs/collector.cpp b/kjs/collector.cpp new file mode 100644 index 0000000..11d1625 --- /dev/null +++ b/kjs/collector.cpp @@ -0,0 +1,1078 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "collector.h" + +#include "ExecState.h" +#include "JSGlobalObject.h" +#include "internal.h" +#include "list.h" +#include "value.h" +#include "JSLockC.h" +#include +#include +#include +#include +#include +#include + +#if USE(MULTIPLE_THREADS) +#include +#endif + +#if PLATFORM(DARWIN) + +#include +#include +#include +#include +#include + +#include "CollectorHeapIntrospector.h" + +#elif PLATFORM(WIN_OS) + +#include + +#elif PLATFORM(UNIX) + +#include +#include +#include + +#if PLATFORM(SOLARIS) +#include +#endif + +#if HAVE(PTHREAD_NP_H) +#include +#else +#include +#endif + +#endif + +#define DEBUG_COLLECTOR 0 + +using std::max; + +namespace KJS { + +// tunable parameters + +const size_t SPARE_EMPTY_BLOCKS = 2; +const size_t MIN_ARRAY_SIZE = 14; +const size_t GROWTH_FACTOR = 2; +const size_t LOW_WATER_FACTOR = 4; +const size_t ALLOCATIONS_PER_COLLECTION = 4000; + +enum OperationInProgress { NoOperation, Allocation, Collection }; + +struct CollectorHeap { + CollectorBlock** blocks; + size_t numBlocks; + size_t usedBlocks; + size_t firstBlockWithPossibleSpace; + + size_t numLiveObjects; + size_t numLiveObjectsAtLastCollect; + size_t extraCost; + + OperationInProgress operationInProgress; +}; + +static CollectorHeap primaryHeap = { 0, 0, 0, 0, 0, 0, 0, NoOperation }; +static CollectorHeap numberHeap = { 0, 0, 0, 0, 0, 0, 0, NoOperation }; + +// FIXME: I don't think this needs to be a static data member of the Collector class. +// Just a private global like "heap" above would be fine. +size_t Collector::mainThreadOnlyObjectCount = 0; + +static CollectorBlock* allocateBlock() +{ +#if PLATFORM(DARWIN) + vm_address_t address = 0; + vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); +#elif PLATFORM(WIN_OS) + // windows virtual address granularity is naturally 64k + LPVOID address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); +#elif HAVE(POSIX_MEMALIGN) + void* address; + posix_memalign(&address, BLOCK_SIZE, BLOCK_SIZE); + memset(address, 0, BLOCK_SIZE); +#else + static size_t pagesize = getpagesize(); + + size_t extra = 0; + if (BLOCK_SIZE > pagesize) + extra = BLOCK_SIZE - pagesize; + + void* mmapResult = mmap(NULL, BLOCK_SIZE + extra, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); + uintptr_t address = reinterpret_cast(mmapResult); + + size_t adjust = 0; + if ((address & BLOCK_OFFSET_MASK) != 0) + adjust = BLOCK_SIZE - (address & BLOCK_OFFSET_MASK); + + if (adjust > 0) + munmap(reinterpret_cast(address), adjust); + + if (adjust < extra) + munmap(reinterpret_cast(address + adjust + BLOCK_SIZE), extra - adjust); + + address += adjust; + memset(reinterpret_cast(address), 0, BLOCK_SIZE); +#endif + + return reinterpret_cast(address); +} + +static void freeBlock(CollectorBlock* block) +{ +#if PLATFORM(DARWIN) + vm_deallocate(current_task(), reinterpret_cast(block), BLOCK_SIZE); +#elif PLATFORM(WIN_OS) + VirtualFree(block, BLOCK_SIZE, MEM_RELEASE); +#elif HAVE(POSIX_MEMALIGN) + free(block); +#else + munmap(block, BLOCK_SIZE); +#endif +} + +void Collector::recordExtraCost(size_t cost) +{ + // Our frequency of garbage collection tries to balance memory use against speed + // by collecting based on the number of newly created values. However, for values + // that hold on to a great deal of memory that's not in the form of other JS values, + // that is not good enough - in some cases a lot of those objects can pile up and + // use crazy amounts of memory without a GC happening. So we track these extra + // memory costs. Only unusually large objects are noted, and we only keep track + // of this extra cost until the next GC. In garbage collected languages, most values + // are either very short lived temporaries, or have extremely long lifetimes. So + // if a large value survives one garbage collection, there is not much point to + // collecting more frequently as long as it stays alive. + // NOTE: we target the primaryHeap unconditionally as JSNumber doesn't modify cost + + primaryHeap.extraCost += cost; +} + +template struct HeapConstants; + +template <> struct HeapConstants { + static const size_t cellSize = CELL_SIZE; + static const size_t cellsPerBlock = CELLS_PER_BLOCK; + static const size_t bitmapShift = 0; + typedef CollectorCell Cell; + typedef CollectorBlock Block; +}; + +template <> struct HeapConstants { + static const size_t cellSize = SMALL_CELL_SIZE; + static const size_t cellsPerBlock = SMALL_CELLS_PER_BLOCK; + static const size_t bitmapShift = 1; + typedef SmallCollectorCell Cell; + typedef SmallCellCollectorBlock Block; +}; + +template void* Collector::heapAllocate(size_t s) +{ + typedef typename HeapConstants::Block Block; + typedef typename HeapConstants::Cell Cell; + + CollectorHeap& heap = heapType == PrimaryHeap ? primaryHeap : numberHeap; + ASSERT(JSLock::lockCount() > 0); + ASSERT(JSLock::currentThreadIsHoldingLock()); + ASSERT(s <= HeapConstants::cellSize); + UNUSED_PARAM(s); // s is now only used for the above assert + + ASSERT(heap.operationInProgress == NoOperation); + ASSERT(heapType == PrimaryHeap || heap.extraCost == 0); + // FIXME: If another global variable access here doesn't hurt performance + // too much, we could abort() in NDEBUG builds, which could help ensure we + // don't spend any time debugging cases where we allocate inside an object's + // deallocation code. + + size_t numLiveObjects = heap.numLiveObjects; + size_t usedBlocks = heap.usedBlocks; + size_t i = heap.firstBlockWithPossibleSpace; + + // if we have a huge amount of extra cost, we'll try to collect even if we still have + // free cells left. + if (heapType == PrimaryHeap && heap.extraCost > ALLOCATIONS_PER_COLLECTION) { + size_t numLiveObjectsAtLastCollect = heap.numLiveObjectsAtLastCollect; + size_t numNewObjects = numLiveObjects - numLiveObjectsAtLastCollect; + const size_t newCost = numNewObjects + heap.extraCost; + if (newCost >= ALLOCATIONS_PER_COLLECTION && newCost >= numLiveObjectsAtLastCollect) + goto collect; + } + + ASSERT(heap.operationInProgress == NoOperation); +#ifndef NDEBUG + // FIXME: Consider doing this in NDEBUG builds too (see comment above). + heap.operationInProgress = Allocation; +#endif + +scan: + Block* targetBlock; + size_t targetBlockUsedCells; + if (i != usedBlocks) { + targetBlock = (Block*)heap.blocks[i]; + targetBlockUsedCells = targetBlock->usedCells; + ASSERT(targetBlockUsedCells <= HeapConstants::cellsPerBlock); + while (targetBlockUsedCells == HeapConstants::cellsPerBlock) { + if (++i == usedBlocks) + goto collect; + targetBlock = (Block*)heap.blocks[i]; + targetBlockUsedCells = targetBlock->usedCells; + ASSERT(targetBlockUsedCells <= HeapConstants::cellsPerBlock); + } + heap.firstBlockWithPossibleSpace = i; + } else { + +collect: + size_t numLiveObjectsAtLastCollect = heap.numLiveObjectsAtLastCollect; + size_t numNewObjects = numLiveObjects - numLiveObjectsAtLastCollect; + const size_t newCost = numNewObjects + heap.extraCost; + + if (newCost >= ALLOCATIONS_PER_COLLECTION && newCost >= numLiveObjectsAtLastCollect) { +#ifndef NDEBUG + heap.operationInProgress = NoOperation; +#endif + bool collected = collect(); +#ifndef NDEBUG + heap.operationInProgress = Allocation; +#endif + if (collected) { + numLiveObjects = heap.numLiveObjects; + usedBlocks = heap.usedBlocks; + i = heap.firstBlockWithPossibleSpace; + goto scan; + } + } + + // didn't find a block, and GC didn't reclaim anything, need to allocate a new block + size_t numBlocks = heap.numBlocks; + if (usedBlocks == numBlocks) { + numBlocks = max(MIN_ARRAY_SIZE, numBlocks * GROWTH_FACTOR); + heap.numBlocks = numBlocks; + heap.blocks = static_cast(fastRealloc(heap.blocks, numBlocks * sizeof(CollectorBlock *))); + } + + targetBlock = (Block*)allocateBlock(); + targetBlock->freeList = targetBlock->cells; + targetBlockUsedCells = 0; + heap.blocks[usedBlocks] = (CollectorBlock*)targetBlock; + heap.usedBlocks = usedBlocks + 1; + heap.firstBlockWithPossibleSpace = usedBlocks; + } + + // find a free spot in the block and detach it from the free list + Cell *newCell = targetBlock->freeList; + + // "next" field is a cell offset -- 0 means next cell, so a zeroed block is already initialized + targetBlock->freeList = (newCell + 1) + newCell->u.freeCell.next; + + targetBlock->usedCells = static_cast(targetBlockUsedCells + 1); + heap.numLiveObjects = numLiveObjects + 1; + +#ifndef NDEBUG + // FIXME: Consider doing this in NDEBUG builds too (see comment above). + heap.operationInProgress = NoOperation; +#endif + + return newCell; +} + +void* Collector::allocate(size_t s) +{ + return heapAllocate(s); +} + +void* Collector::allocateNumber(size_t s) +{ + return heapAllocate(s); +} + +static inline void* currentThreadStackBase() +{ +#if PLATFORM(DARWIN) + pthread_t thread = pthread_self(); + return pthread_get_stackaddr_np(thread); +#elif PLATFORM(WIN_OS) && PLATFORM(X86) && COMPILER(MSVC) + // offset 0x18 from the FS segment register gives a pointer to + // the thread information block for the current thread + NT_TIB* pTib; + __asm { + MOV EAX, FS:[18h] + MOV pTib, EAX + } + return (void*)pTib->StackBase; +#elif PLATFORM(WIN_OS) && PLATFORM(X86_64) && COMPILER(MSVC) + PNT_TIB64 pTib = reinterpret_cast(NtCurrentTeb()); + return (void*)pTib->StackBase; +#elif PLATFORM(WIN_OS) && PLATFORM(X86) && COMPILER(GCC) + // offset 0x18 from the FS segment register gives a pointer to + // the thread information block for the current thread + NT_TIB* pTib; + asm ( "movl %%fs:0x18, %0\n" + : "=r" (pTib) + ); + return (void*)pTib->StackBase; +#elif PLATFORM(SOLARIS) + stack_t s; + thr_stksegment(&s); + return s.ss_sp; +#elif PLATFORM(UNIX) + static void* stackBase = 0; + static size_t stackSize = 0; + static pthread_t stackThread; + pthread_t thread = pthread_self(); + if (stackBase == 0 || thread != stackThread) { + pthread_attr_t sattr; + pthread_attr_init(&sattr); +#if HAVE(PTHREAD_NP_H) + // e.g. on FreeBSD 5.4, neundorf@kde.org + pthread_attr_get_np(thread, &sattr); +#else + // FIXME: this function is non-portable; other POSIX systems may have different np alternatives + pthread_getattr_np(thread, &sattr); +#endif + int rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize); + (void)rc; // FIXME: Deal with error code somehow? Seems fatal. + ASSERT(stackBase); + pthread_attr_destroy(&sattr); + stackThread = thread; + } + return static_cast(stackBase) + stackSize; +#else +#error Need a way to get the stack base on this platform +#endif +} + +#if USE(MULTIPLE_THREADS) +static pthread_t mainThread; +#endif + +void Collector::registerAsMainThread() +{ +#if USE(MULTIPLE_THREADS) + mainThread = pthread_self(); +#endif +} + +static inline bool onMainThread() +{ +#if USE(MULTIPLE_THREADS) +#if PLATFORM(DARWIN) + pthread_t javaScriptCollectionThread = JSJavaScriptCollectionThread(); + return javaScriptCollectionThread == 0 || javaScriptCollectionThread == pthread_self(); +#else + return !!pthread_equal(pthread_self(), mainThread); +#endif +#else + return true; +#endif +} + +#if USE(MULTIPLE_THREADS) + +#if PLATFORM(DARWIN) +typedef mach_port_t PlatformThread; +#elif PLATFORM(WIN_OS) +struct PlatformThread { + PlatformThread(DWORD _id, HANDLE _handle) : id(_id), handle(_handle) {} + DWORD id; + HANDLE handle; +}; +#endif + +static inline PlatformThread getCurrentPlatformThread() +{ +#if PLATFORM(DARWIN) + return pthread_mach_thread_np(pthread_self()); +#elif PLATFORM(WIN_OS) + HANDLE threadHandle = pthread_getw32threadhandle_np(pthread_self()); + return PlatformThread(GetCurrentThreadId(), threadHandle); +#endif +} + +class Collector::Thread { +public: + Thread(pthread_t pthread, const PlatformThread& platThread, void* base) + : posixThread(pthread), platformThread(platThread), stackBase(base) {} + Thread* next; + pthread_t posixThread; + PlatformThread platformThread; + void* stackBase; +}; + +pthread_key_t registeredThreadKey; +pthread_once_t registeredThreadKeyOnce = PTHREAD_ONCE_INIT; +Collector::Thread* registeredThreads; + +static void destroyRegisteredThread(void* data) +{ + Collector::Thread* thread = (Collector::Thread*)data; + + // Can't use JSLock convenience object here because we don't want to re-register + // an exiting thread. + JSLock::lock(); + + if (registeredThreads == thread) { + registeredThreads = registeredThreads->next; + } else { + Collector::Thread *last = registeredThreads; + Collector::Thread *t; + for (t = registeredThreads->next; t != NULL; t = t->next) { + if (t == thread) { + last->next = t->next; + break; + } + last = t; + } + ASSERT(t); // If t is NULL, we never found ourselves in the list. + } + + JSLock::unlock(); + + delete thread; +} + +static void initializeRegisteredThreadKey() +{ + pthread_key_create(®isteredThreadKey, destroyRegisteredThread); +} + +void Collector::registerThread() +{ + ASSERT(JSLock::lockCount() > 0); + ASSERT(JSLock::currentThreadIsHoldingLock()); + + pthread_once(®isteredThreadKeyOnce, initializeRegisteredThreadKey); + + if (!pthread_getspecific(registeredThreadKey)) { +#if PLATFORM(DARWIN) + if (onMainThread()) + CollectorHeapIntrospector::init(&primaryHeap, &numberHeap); +#endif + + Collector::Thread *thread = new Collector::Thread(pthread_self(), getCurrentPlatformThread(), currentThreadStackBase()); + + thread->next = registeredThreads; + registeredThreads = thread; + pthread_setspecific(registeredThreadKey, thread); + } +} + +#endif + +#define IS_POINTER_ALIGNED(p) (((intptr_t)(p) & (sizeof(char *) - 1)) == 0) + +// cell size needs to be a power of two for this to be valid +#define IS_HALF_CELL_ALIGNED(p) (((intptr_t)(p) & (CELL_MASK >> 1)) == 0) + +void Collector::markStackObjectsConservatively(void *start, void *end) +{ + if (start > end) { + void* tmp = start; + start = end; + end = tmp; + } + + ASSERT(((char*)end - (char*)start) < 0x1000000); + ASSERT(IS_POINTER_ALIGNED(start)); + ASSERT(IS_POINTER_ALIGNED(end)); + + char** p = (char**)start; + char** e = (char**)end; + + size_t usedPrimaryBlocks = primaryHeap.usedBlocks; + size_t usedNumberBlocks = numberHeap.usedBlocks; + CollectorBlock **primaryBlocks = primaryHeap.blocks; + CollectorBlock **numberBlocks = numberHeap.blocks; + + const size_t lastCellOffset = sizeof(CollectorCell) * (CELLS_PER_BLOCK - 1); + + while (p != e) { + char* x = *p++; + if (IS_HALF_CELL_ALIGNED(x) && x) { + uintptr_t xAsBits = reinterpret_cast(x); + xAsBits &= CELL_ALIGN_MASK; + uintptr_t offset = xAsBits & BLOCK_OFFSET_MASK; + CollectorBlock* blockAddr = reinterpret_cast(xAsBits - offset); + // Mark the the number heap, we can mark these Cells directly to avoid the virtual call cost + for (size_t block = 0; block < usedNumberBlocks; block++) { + if ((numberBlocks[block] == blockAddr) & (offset <= lastCellOffset)) { + Collector::markCell(reinterpret_cast(xAsBits)); + goto endMarkLoop; + } + } + + // Mark the primary heap + for (size_t block = 0; block < usedPrimaryBlocks; block++) { + if ((primaryBlocks[block] == blockAddr) & (offset <= lastCellOffset)) { + if (((CollectorCell*)xAsBits)->u.freeCell.zeroIfFree != 0) { + JSCell* imp = reinterpret_cast(xAsBits); + if (!imp->marked()) + imp->mark(); + } + break; + } + } + endMarkLoop: + ; + } + } +} + +void Collector::markCurrentThreadConservatively() +{ + // setjmp forces volatile registers onto the stack + jmp_buf registers; +#if COMPILER(MSVC) +#pragma warning(push) +#pragma warning(disable: 4611) +#endif + setjmp(registers); +#if COMPILER(MSVC) +#pragma warning(pop) +#endif + + void* dummy; + void* stackPointer = &dummy; + void* stackBase = currentThreadStackBase(); + + markStackObjectsConservatively(stackPointer, stackBase); +} + +#if USE(MULTIPLE_THREADS) + +static inline void suspendThread(const PlatformThread& platformThread) +{ +#if PLATFORM(DARWIN) + thread_suspend(platformThread); +#elif PLATFORM(WIN_OS) + SuspendThread(platformThread.handle); +#else +#error Need a way to suspend threads on this platform +#endif +} + +static inline void resumeThread(const PlatformThread& platformThread) +{ +#if PLATFORM(DARWIN) + thread_resume(platformThread); +#elif PLATFORM(WIN_OS) + ResumeThread(platformThread.handle); +#else +#error Need a way to resume threads on this platform +#endif +} + +typedef unsigned long usword_t; // word size, assumed to be either 32 or 64 bit + +#if PLATFORM(DARWIN) + +#if PLATFORM(X86) +typedef i386_thread_state_t PlatformThreadRegisters; +#elif PLATFORM(X86_64) +typedef x86_thread_state64_t PlatformThreadRegisters; +#elif PLATFORM(PPC) +typedef ppc_thread_state_t PlatformThreadRegisters; +#elif PLATFORM(PPC64) +typedef ppc_thread_state64_t PlatformThreadRegisters; +#elif PLATFORM(ARM) +typedef arm_thread_state_t PlatformThreadRegisters; +#else +#error Unknown Architecture +#endif + +#elif PLATFORM(WIN_OS)&& PLATFORM(X86) +typedef CONTEXT PlatformThreadRegisters; +#else +#error Need a thread register struct for this platform +#endif + +size_t getPlatformThreadRegisters(const PlatformThread& platformThread, PlatformThreadRegisters& regs) +{ +#if PLATFORM(DARWIN) + +#if PLATFORM(X86) + unsigned user_count = sizeof(regs)/sizeof(int); + thread_state_flavor_t flavor = i386_THREAD_STATE; +#elif PLATFORM(X86_64) + unsigned user_count = x86_THREAD_STATE64_COUNT; + thread_state_flavor_t flavor = x86_THREAD_STATE64; +#elif PLATFORM(PPC) + unsigned user_count = PPC_THREAD_STATE_COUNT; + thread_state_flavor_t flavor = PPC_THREAD_STATE; +#elif PLATFORM(PPC64) + unsigned user_count = PPC_THREAD_STATE64_COUNT; + thread_state_flavor_t flavor = PPC_THREAD_STATE64; +#elif PLATFORM(ARM) + unsigned user_count = ARM_THREAD_STATE_COUNT; + thread_state_flavor_t flavor = ARM_THREAD_STATE; +#else +#error Unknown Architecture +#endif + + kern_return_t result = thread_get_state(platformThread, flavor, (thread_state_t)®s, &user_count); + if (result != KERN_SUCCESS) { + WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, + "JavaScript garbage collection failed because thread_get_state returned an error (%d). This is probably the result of running inside Rosetta, which is not supported.", result); + CRASH(); + } + return user_count * sizeof(usword_t); +// end PLATFORM(DARWIN) + +#elif PLATFORM(WIN_OS) && PLATFORM(X86) + regs.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL | CONTEXT_SEGMENTS; + GetThreadContext(platformThread.handle, ®s); + return sizeof(CONTEXT); +#else +#error Need a way to get thread registers on this platform +#endif +} + +static inline void* otherThreadStackPointer(const PlatformThreadRegisters& regs) +{ +#if PLATFORM(DARWIN) + +#if __DARWIN_UNIX03 + +#if PLATFORM(X86) + return (void*)regs.__esp; +#elif PLATFORM(X86_64) + return (void*)regs.__rsp; +#elif PLATFORM(PPC) || PLATFORM(PPC64) + return (void*)regs.__r1; +#elif PLATFORM(ARM) + return (void*)regs.__sp; +#else +#error Unknown Architecture +#endif + +#else // !__DARWIN_UNIX03 + +#if PLATFORM(X86) + return (void*)regs.esp; +#elif PLATFORM(X86_64) + return (void*)regs.rsp; +#elif (PLATFORM(PPC) || PLATFORM(PPC64)) + return (void*)regs.r1; +#else +#error Unknown Architecture +#endif + +#endif // __DARWIN_UNIX03 + +// end PLATFORM(DARWIN) +#elif PLATFORM(X86) && PLATFORM(WIN_OS) + return (void*)(uintptr_t)regs.Esp; +#else +#error Need a way to get the stack pointer for another thread on this platform +#endif +} + +void Collector::markOtherThreadConservatively(Thread* thread) +{ + suspendThread(thread->platformThread); + + PlatformThreadRegisters regs; + size_t regSize = getPlatformThreadRegisters(thread->platformThread, regs); + + // mark the thread's registers + markStackObjectsConservatively((void*)®s, (void*)((char*)®s + regSize)); + + void* stackPointer = otherThreadStackPointer(regs); + markStackObjectsConservatively(stackPointer, thread->stackBase); + + resumeThread(thread->platformThread); +} + +#endif + +void Collector::markStackObjectsConservatively() +{ + markCurrentThreadConservatively(); + +#if USE(MULTIPLE_THREADS) + for (Thread *thread = registeredThreads; thread != NULL; thread = thread->next) { + if (!pthread_equal(thread->posixThread, pthread_self())) { + markOtherThreadConservatively(thread); + } + } +#endif +} + +typedef HashCountedSet ProtectCountSet; + +static ProtectCountSet& protectedValues() +{ + static ProtectCountSet staticProtectCountSet; + return staticProtectCountSet; +} + +void Collector::protect(JSValue *k) +{ + ASSERT(k); + ASSERT(JSLock::lockCount() > 0); + ASSERT(JSLock::currentThreadIsHoldingLock()); + + if (JSImmediate::isImmediate(k)) + return; + + protectedValues().add(k->asCell()); +} + +void Collector::unprotect(JSValue *k) +{ + ASSERT(k); + ASSERT(JSLock::lockCount() > 0); + ASSERT(JSLock::currentThreadIsHoldingLock()); + + if (JSImmediate::isImmediate(k)) + return; + + protectedValues().remove(k->asCell()); +} + +void Collector::collectOnMainThreadOnly(JSValue* value) +{ + ASSERT(value); + ASSERT(JSLock::lockCount() > 0); + ASSERT(JSLock::currentThreadIsHoldingLock()); + + if (JSImmediate::isImmediate(value)) + return; + + JSCell* cell = value->asCell(); + cellBlock(cell)->collectOnMainThreadOnly.set(cellOffset(cell)); + ++mainThreadOnlyObjectCount; +} + +void Collector::markProtectedObjects() +{ + ProtectCountSet& protectedValues = KJS::protectedValues(); + ProtectCountSet::iterator end = protectedValues.end(); + for (ProtectCountSet::iterator it = protectedValues.begin(); it != end; ++it) { + JSCell *val = it->first; + if (!val->marked()) + val->mark(); + } +} + +void Collector::markMainThreadOnlyObjects() +{ +#if USE(MULTIPLE_THREADS) + ASSERT(!onMainThread()); +#endif + + // Optimization for clients that never register "main thread only" objects. + if (!mainThreadOnlyObjectCount) + return; + + // FIXME: We can optimize this marking algorithm by keeping an exact set of + // "main thread only" objects when the "main thread only" object count is + // small. We don't want to keep an exact set all the time, because WebCore + // tends to create lots of "main thread only" objects, and all that set + // thrashing can be expensive. + + size_t count = 0; + + // We don't look at the numberHeap as primitive values can never be marked as main thread only + for (size_t block = 0; block < primaryHeap.usedBlocks; block++) { + ASSERT(count < mainThreadOnlyObjectCount); + + CollectorBlock* curBlock = primaryHeap.blocks[block]; + size_t minimumCellsToProcess = curBlock->usedCells; + for (size_t i = 0; (i < minimumCellsToProcess) & (i < CELLS_PER_BLOCK); i++) { + CollectorCell* cell = curBlock->cells + i; + if (cell->u.freeCell.zeroIfFree == 0) + ++minimumCellsToProcess; + else { + if (curBlock->collectOnMainThreadOnly.get(i)) { + if (!curBlock->marked.get(i)) { + JSCell* imp = reinterpret_cast(cell); + imp->mark(); + } + if (++count == mainThreadOnlyObjectCount) + return; + } + } + } + } +} + +template size_t Collector::sweep(bool currentThreadIsMainThread) +{ + typedef typename HeapConstants::Block Block; + typedef typename HeapConstants::Cell Cell; + + UNUSED_PARAM(currentThreadIsMainThread); // currentThreadIsMainThread is only used in ASSERTs + // SWEEP: delete everything with a zero refcount (garbage) and unmark everything else + CollectorHeap& heap = heapType == Collector::PrimaryHeap ? primaryHeap : numberHeap; + + size_t emptyBlocks = 0; + size_t numLiveObjects = heap.numLiveObjects; + + for (size_t block = 0; block < heap.usedBlocks; block++) { + Block* curBlock = (Block*)heap.blocks[block]; + + size_t usedCells = curBlock->usedCells; + Cell* freeList = curBlock->freeList; + + if (usedCells == HeapConstants::cellsPerBlock) { + // special case with a block where all cells are used -- testing indicates this happens often + for (size_t i = 0; i < HeapConstants::cellsPerBlock; i++) { + if (!curBlock->marked.get(i >> HeapConstants::bitmapShift)) { + Cell* cell = curBlock->cells + i; + + if (heapType != Collector::NumberHeap) { + JSCell* imp = reinterpret_cast(cell); + // special case for allocated but uninitialized object + // (We don't need this check earlier because nothing prior this point + // assumes the object has a valid vptr.) + if (cell->u.freeCell.zeroIfFree == 0) + continue; + + ASSERT(currentThreadIsMainThread || !curBlock->collectOnMainThreadOnly.get(i)); + if (curBlock->collectOnMainThreadOnly.get(i)) { + curBlock->collectOnMainThreadOnly.clear(i); + --Collector::mainThreadOnlyObjectCount; + } + imp->~JSCell(); + } + + --usedCells; + --numLiveObjects; + + // put cell on the free list + cell->u.freeCell.zeroIfFree = 0; + cell->u.freeCell.next = freeList - (cell + 1); + freeList = cell; + } + } + } else { + size_t minimumCellsToProcess = usedCells; + for (size_t i = 0; (i < minimumCellsToProcess) & (i < HeapConstants::cellsPerBlock); i++) { + Cell *cell = curBlock->cells + i; + if (cell->u.freeCell.zeroIfFree == 0) { + ++minimumCellsToProcess; + } else { + if (!curBlock->marked.get(i >> HeapConstants::bitmapShift)) { + if (heapType != Collector::NumberHeap) { + JSCell *imp = reinterpret_cast(cell); + ASSERT(currentThreadIsMainThread || !curBlock->collectOnMainThreadOnly.get(i)); + if (curBlock->collectOnMainThreadOnly.get(i)) { + curBlock->collectOnMainThreadOnly.clear(i); + --Collector::mainThreadOnlyObjectCount; + } + imp->~JSCell(); + } + --usedCells; + --numLiveObjects; + + // put cell on the free list + cell->u.freeCell.zeroIfFree = 0; + cell->u.freeCell.next = freeList - (cell + 1); + freeList = cell; + } + } + } + } + + curBlock->usedCells = static_cast(usedCells); + curBlock->freeList = freeList; + curBlock->marked.clearAll(); + + if (usedCells == 0) { + emptyBlocks++; + if (emptyBlocks > SPARE_EMPTY_BLOCKS) { +#if !DEBUG_COLLECTOR + freeBlock((CollectorBlock*)curBlock); +#endif + // swap with the last block so we compact as we go + heap.blocks[block] = heap.blocks[heap.usedBlocks - 1]; + heap.usedBlocks--; + block--; // Don't move forward a step in this case + + if (heap.numBlocks > MIN_ARRAY_SIZE && heap.usedBlocks < heap.numBlocks / LOW_WATER_FACTOR) { + heap.numBlocks = heap.numBlocks / GROWTH_FACTOR; + heap.blocks = (CollectorBlock**)fastRealloc(heap.blocks, heap.numBlocks * sizeof(CollectorBlock *)); + } + } + } + } + + if (heap.numLiveObjects != numLiveObjects) + heap.firstBlockWithPossibleSpace = 0; + + heap.numLiveObjects = numLiveObjects; + heap.numLiveObjectsAtLastCollect = numLiveObjects; + heap.extraCost = 0; + return numLiveObjects; +} + +bool Collector::collect() +{ + ASSERT(JSLock::lockCount() > 0); + ASSERT(JSLock::currentThreadIsHoldingLock()); + + ASSERT((primaryHeap.operationInProgress == NoOperation) | (numberHeap.operationInProgress == NoOperation)); + if ((primaryHeap.operationInProgress != NoOperation) | (numberHeap.operationInProgress != NoOperation)) + abort(); + + primaryHeap.operationInProgress = Collection; + numberHeap.operationInProgress = Collection; + + bool currentThreadIsMainThread = onMainThread(); + + // MARK: first mark all referenced objects recursively starting out from the set of root objects + +#ifndef NDEBUG + // Forbid malloc during the mark phase. Marking a thread suspends it, so + // a malloc inside mark() would risk a deadlock with a thread that had been + // suspended while holding the malloc lock. + fastMallocForbid(); +#endif + + markStackObjectsConservatively(); + markProtectedObjects(); + ExecState::markActiveExecStates(); + List::markProtectedLists(); +#if USE(MULTIPLE_THREADS) + if (!currentThreadIsMainThread) + markMainThreadOnlyObjects(); +#endif + +#ifndef NDEBUG + fastMallocAllow(); +#endif + + size_t originalLiveObjects = primaryHeap.numLiveObjects + numberHeap.numLiveObjects; + size_t numLiveObjects = sweep(currentThreadIsMainThread); + numLiveObjects += sweep(currentThreadIsMainThread); + + primaryHeap.operationInProgress = NoOperation; + numberHeap.operationInProgress = NoOperation; + + return numLiveObjects < originalLiveObjects; +} + +size_t Collector::size() +{ + return primaryHeap.numLiveObjects + numberHeap.numLiveObjects; +} + +size_t Collector::globalObjectCount() +{ + size_t count = 0; + if (JSGlobalObject::head()) { + JSGlobalObject* o = JSGlobalObject::head(); + do { + ++count; + o = o->next(); + } while (o != JSGlobalObject::head()); + } + return count; +} + +size_t Collector::protectedGlobalObjectCount() +{ + size_t count = 0; + if (JSGlobalObject::head()) { + JSGlobalObject* o = JSGlobalObject::head(); + do { + if (protectedValues().contains(o)) + ++count; + o = o->next(); + } while (o != JSGlobalObject::head()); + } + return count; +} + +size_t Collector::protectedObjectCount() +{ + return protectedValues().size(); +} + +static const char *typeName(JSCell *val) +{ + const char *name = "???"; + switch (val->type()) { + case UnspecifiedType: + break; + case UndefinedType: + name = "undefined"; + break; + case NullType: + name = "null"; + break; + case BooleanType: + name = "boolean"; + break; + case StringType: + name = "string"; + break; + case NumberType: + name = "number"; + break; + case ObjectType: { + const ClassInfo *info = static_cast(val)->classInfo(); + name = info ? info->className : "Object"; + break; + } + case GetterSetterType: + name = "gettersetter"; + break; + } + return name; +} + +HashCountedSet* Collector::protectedObjectTypeCounts() +{ + HashCountedSet* counts = new HashCountedSet; + + ProtectCountSet& protectedValues = KJS::protectedValues(); + ProtectCountSet::iterator end = protectedValues.end(); + for (ProtectCountSet::iterator it = protectedValues.begin(); it != end; ++it) + counts->add(typeName(it->first)); + + return counts; +} + +bool Collector::isBusy() +{ + return (primaryHeap.operationInProgress != NoOperation) | (numberHeap.operationInProgress != NoOperation); +} + +void Collector::reportOutOfMemoryToAllExecStates() +{ + ExecStateStack::const_iterator end = ExecState::activeExecStates().end(); + for (ExecStateStack::const_iterator it = ExecState::activeExecStates().begin(); it != end; ++it) { + (*it)->setException(Error::create(*it, GeneralError, "Out of memory")); + } +} + +} // namespace KJS diff --git a/kjs/collector.h b/kjs/collector.h new file mode 100644 index 0000000..b38faaf --- /dev/null +++ b/kjs/collector.h @@ -0,0 +1,193 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef KJSCOLLECTOR_H_ +#define KJSCOLLECTOR_H_ + +#include +#include +#include + +namespace KJS { + + class JSCell; + class JSValue; + class CollectorBlock; + + class Collector { + public: + static void* allocate(size_t s); + static void* allocateNumber(size_t s); + static bool collect(); + static bool isBusy(); // true if an allocation or collection is in progress + + static const size_t minExtraCostSize = 256; + + static void reportExtraMemoryCost(size_t cost); + + static size_t size(); + + static void protect(JSValue*); + static void unprotect(JSValue*); + + static void collectOnMainThreadOnly(JSValue*); + + static size_t globalObjectCount(); + static size_t protectedObjectCount(); + static size_t protectedGlobalObjectCount(); + static HashCountedSet* protectedObjectTypeCounts(); + + class Thread; + static void registerThread(); + + static void registerAsMainThread(); + + static bool isCellMarked(const JSCell*); + static void markCell(JSCell*); + + enum HeapType { PrimaryHeap, NumberHeap }; + + private: + template static void* heapAllocate(size_t s); + template static size_t sweep(bool); + static const CollectorBlock* cellBlock(const JSCell*); + static CollectorBlock* cellBlock(JSCell*); + static size_t cellOffset(const JSCell*); + + Collector(); + + static void recordExtraCost(size_t); + static void markProtectedObjects(); + static void markMainThreadOnlyObjects(); + static void markCurrentThreadConservatively(); + static void markOtherThreadConservatively(Thread*); + static void markStackObjectsConservatively(); + static void markStackObjectsConservatively(void* start, void* end); + + static size_t mainThreadOnlyObjectCount; + static bool memoryFull; + static void reportOutOfMemoryToAllExecStates(); + }; + + // tunable parameters + template struct CellSize; + + // cell size needs to be a power of two for certain optimizations in collector.cpp + template<> struct CellSize { static const size_t m_value = 32; }; // 32-bit + template<> struct CellSize { static const size_t m_value = 64; }; // 64-bit + const size_t BLOCK_SIZE = 16 * 4096; // 64k + + // derived constants + const size_t BLOCK_OFFSET_MASK = BLOCK_SIZE - 1; + const size_t BLOCK_MASK = ~BLOCK_OFFSET_MASK; + const size_t MINIMUM_CELL_SIZE = CellSize::m_value; + const size_t CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? sizeof(double) : 0); + const size_t CELL_SIZE = CELL_ARRAY_LENGTH * sizeof(double); + const size_t SMALL_CELL_SIZE = CELL_SIZE / 2; + const size_t CELL_MASK = CELL_SIZE - 1; + const size_t CELL_ALIGN_MASK = ~CELL_MASK; + const size_t CELLS_PER_BLOCK = (BLOCK_SIZE * 8 - sizeof(uint32_t) * 8 - sizeof(void *) * 8 - 2 * (7 + 3 * 8)) / (CELL_SIZE * 8 + 2); + const size_t SMALL_CELLS_PER_BLOCK = 2 * CELLS_PER_BLOCK; + const size_t BITMAP_SIZE = (CELLS_PER_BLOCK + 7) / 8; + const size_t BITMAP_WORDS = (BITMAP_SIZE + 3) / sizeof(uint32_t); + + struct CollectorBitmap { + uint32_t bits[BITMAP_WORDS]; + bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); } + void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); } + void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); } + void clearAll() { memset(bits, 0, sizeof(bits)); } + }; + + struct CollectorCell { + union { + double memory[CELL_ARRAY_LENGTH]; + struct { + void* zeroIfFree; + ptrdiff_t next; + } freeCell; + } u; + }; + + struct SmallCollectorCell { + union { + double memory[CELL_ARRAY_LENGTH / 2]; + struct { + void* zeroIfFree; + ptrdiff_t next; + } freeCell; + } u; + }; + + class CollectorBlock { + public: + CollectorCell cells[CELLS_PER_BLOCK]; + uint32_t usedCells; + CollectorCell* freeList; + CollectorBitmap marked; + CollectorBitmap collectOnMainThreadOnly; + }; + + class SmallCellCollectorBlock { + public: + SmallCollectorCell cells[SMALL_CELLS_PER_BLOCK]; + uint32_t usedCells; + SmallCollectorCell* freeList; + CollectorBitmap marked; + CollectorBitmap collectOnMainThreadOnly; + }; + + inline const CollectorBlock* Collector::cellBlock(const JSCell* cell) + { + return reinterpret_cast(reinterpret_cast(cell) & BLOCK_MASK); + } + + inline CollectorBlock* Collector::cellBlock(JSCell* cell) + { + return const_cast(cellBlock(const_cast(cell))); + } + + inline size_t Collector::cellOffset(const JSCell* cell) + { + return (reinterpret_cast(cell) & BLOCK_OFFSET_MASK) / CELL_SIZE; + } + + inline bool Collector::isCellMarked(const JSCell* cell) + { + return cellBlock(cell)->marked.get(cellOffset(cell)); + } + + inline void Collector::markCell(JSCell* cell) + { + cellBlock(cell)->marked.set(cellOffset(cell)); + } + + inline void Collector::reportExtraMemoryCost(size_t cost) + { + if (cost > minExtraCostSize) + recordExtraCost(cost / (CELL_SIZE * 2)); + } + +} // namespace KJS + +#endif /* KJSCOLLECTOR_H_ */ diff --git a/kjs/completion.h b/kjs/completion.h new file mode 100644 index 0000000..09f3db7 --- /dev/null +++ b/kjs/completion.h @@ -0,0 +1,60 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_COMPLETION_H +#define KJS_COMPLETION_H + +namespace KJS { + + class JSValue; + + enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted }; + + /** + * Completion objects are used to convey the return status and value + * from functions. + * + * See FunctionImp::execute() + * + * @see FunctionImp + * + * @short Handle for a Completion type. + */ + class Completion { + public: + Completion(ComplType type = Normal, JSValue* value = 0) + : m_type(type), m_value(value) { } + + ComplType complType() const { return m_type; } + JSValue* value() const { return m_value; } + void setValue(JSValue* v) { m_value = v; } + bool isValueCompletion() const { return !!m_value; } + + private: + ComplType m_type; + JSValue* m_value; + }; + +} + +#endif diff --git a/kjs/config.h b/kjs/config.h new file mode 100644 index 0000000..f60561e --- /dev/null +++ b/kjs/config.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include + + +#if PLATFORM(DARWIN) + +#define HAVE_ERRNO_H 1 +#define HAVE_MMAP 1 +#define HAVE_MERGESORT 1 +#define HAVE_SBRK 1 +#define HAVE_STRINGS_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_TIMEB_H 1 + +#elif PLATFORM(WIN_OS) + +// If we don't define these, they get defined in windef.h. +// We want to use std::min and std::max +#define max max +#define min min + +#if !COMPILER(MSVC7) +// We need to define this before the first #include of stdlib.h or it won't contain rand_s. +#ifndef _CRT_RAND_S +#define _CRT_RAND_S +#endif +#endif + +#define HAVE_FLOAT_H 1 +#define HAVE_SYS_TIMEB_H 1 +#define HAVE_VIRTUALALLOC 1 + +#else + +/* FIXME: is this actually used or do other platforms generate their own config.h? */ + +#define HAVE_ERRNO_H 1 +#define HAVE_MMAP 1 +#define HAVE_SBRK 1 +#define HAVE_STRINGS_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_TIME_H 1 + +#endif + +#if PLATFORM(FREEBSD) +#define HAVE_PTHREAD_NP_H 1 +#endif + +/* FIXME: if all platforms have these, do they really need #defines? */ +#define HAVE_STDINT_H 1 +#define HAVE_STRING_H 1 + +#define WTF_CHANGES 1 + +#ifdef __cplusplus +#undef new +#undef delete +#include +#endif + +// this breaks compilation of , at least, so turn it off for now +// Also generates errors on wx on Windows, because these functions +// are used from wx headers. +#if !PLATFORM(QT) && !PLATFORM(WX) +#include +#endif diff --git a/kjs/create_hash_table b/kjs/create_hash_table new file mode 100755 index 0000000..6800722 --- /dev/null +++ b/kjs/create_hash_table @@ -0,0 +1,250 @@ +#! /usr/bin/perl -w +# +# Static Hashtable Generator +# +# (c) 2000-2002 by Harri Porten and +# David Faure +# Modified (c) 2004 by Nikolas Zimmermann +# Copyright (C) 2007 Apple Inc. All rights reserved. +# +# Part of the KJS library. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +use strict; + +my $file = $ARGV[0]; +shift; +my $includelookup = 0; + +# Use -i as second argument to make it include "lookup.h" +$includelookup = 1 if (defined($ARGV[0]) && $ARGV[0] eq "-i"); + +# Use -n as second argument to make it use the third argument as namespace parameter ie. -n KDOM +my $useNameSpace = $ARGV[1] if (defined($ARGV[0]) && $ARGV[0] eq "-n"); + +print STDERR "Creating hashtable for $file\n"; +open(IN, $file) or die "No such file $file"; + +my @keys = (); +my @values = (); +my @attrs = (); +my @params = (); +my @hashes = (); +my @table = (); +my @links = (); + +my $inside = 0; +my $name; +my $size; +my $hashSizeMask; +my $banner = 0; +sub calcTable(); +sub output(); +sub hashValue($); + +while () { + chop; + s/^\s*//g; + if (/^\#|^$/) { + # comment. do nothing + } elsif (/^\@begin/ && !$inside) { + if (/^\@begin\s*([:_\w]+)\s*\d*\s*$/) { + $inside = 1; + $name = $1; + } else { + printf STDERR "WARNING: \@begin without table name and hashsize, skipping $_\n"; + } + } elsif (/^\@end\s*$/ && $inside) { + + calcTable(); + + output(); + @keys = (); + @values = (); + @attrs = (); + @params = (); + @table = (); + @links = (); + @hashes = (); + $inside = 0; + } elsif (/^(\S+)\s*(\S+)\s*([\w\|]*)\s*(\w*)\s*$/ && $inside) { + my $key = $1; + my $val = $2; + my $att = $3; + my $param = $4; + push(@keys, $key); + push(@values, $val); + push(@hashes, hashValue($key)); + printf STDERR "WARNING: Number of arguments missing for $key/$val\n" + if ( $att =~ m/Function/ && length($param) == 0); + push(@attrs, length($att) > 0 ? $att : "0"); + push(@params, length($param) > 0 ? $param : "0"); + } elsif ($inside) { + die "invalid data {" . $_ . "}"; + } +} + +die "missing closing \@end" if ($inside); + +sub ceilingToPowerOf2 +{ + my ($size) = @_; + + my $powerOf2 = 1; + while ($size > $powerOf2) { + $powerOf2 <<= 1; + } + + return $powerOf2; +} + +sub calcTable() { + my $hashsize = ceilingToPowerOf2(2 * @keys); + $hashSizeMask = $hashsize - 1; + $size = $hashsize; + my $collisions = 0; + my $maxdepth = 0; + my $i = 0; + foreach my $key (@keys) { + my $depth = 0; + my $h = hashValue($key) % $hashsize; + while (defined($table[$h])) { + if (defined($links[$h])) { + $h = $links[$h]; + $depth++; + } else { + $collisions++; + $links[$h] = $size; + $h = $size; + $size++; + } + } + $table[$h] = $i; + $i++; + $maxdepth = $depth if ( $depth > $maxdepth); + } + + # Ensure table is big enough (in case of undef entries at the end) + if ( $#table+1 < $size ) { + $#table = $size-1; + } +} + +sub leftShift($$) { + my ($value, $distance) = @_; + return (($value << $distance) & 0xFFFFFFFF); +} + +# Paul Hsieh's SuperFastHash +# http://www.azillionmonkeys.com/qed/hash.html +# Ported from UString.. +sub hashValue($) { + my @chars = split(/ */, $_[0]); + + # This hash is designed to work on 16-bit chunks at a time. But since the normal case + # (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they + # were 16-bit chunks, which should give matching results + + my $EXP2_32 = 4294967296; + + my $hash = 0x9e3779b9; + my $l = scalar @chars; #I wish this was in Ruby --- Maks + my $rem = $l & 1; + $l = $l >> 1; + + my $s = 0; + + # Main loop + for (; $l > 0; $l--) { + $hash += ord($chars[$s]); + my $tmp = leftShift(ord($chars[$s+1]), 11) ^ $hash; + $hash = (leftShift($hash, 16)% $EXP2_32) ^ $tmp; + $s += 2; + $hash += $hash >> 11; + $hash %= $EXP2_32; + } + + # Handle end case + if ($rem !=0) { + $hash += ord($chars[$s]); + $hash ^= (leftShift($hash, 11)% $EXP2_32); + $hash += $hash >> 17; + } + + # Force "avalanching" of final 127 bits + $hash ^= leftShift($hash, 3); + $hash += ($hash >> 5); + $hash = ($hash% $EXP2_32); + $hash ^= (leftShift($hash, 2)% $EXP2_32); + $hash += ($hash >> 15); + $hash = $hash% $EXP2_32; + $hash ^= (leftShift($hash, 10)% $EXP2_32); + + # this avoids ever returning a hash code of 0, since that is used to + # signal "hash not computed yet", using a value that is likely to be + # effectively the same as 0 when the low bits are masked + $hash = 0x80000000 if ($hash == 0); + + return $hash; +} + +sub output() { + if (!$banner) { + $banner = 1; + print "/* Automatically generated from $file using $0. DO NOT EDIT ! */\n"; + } + + my $nameEntries = "${name}Entries"; + $nameEntries =~ s/:/_/g; + + print "\n#include \"lookup.h\"\n" if ($includelookup); + if ($useNameSpace) { + print "\nnamespace ${useNameSpace}\n{\n"; + print "\nusing namespace KJS;"; + } else { + print "\nnamespace KJS {\n"; + } + print "\nstatic const struct HashEntry ".$nameEntries."[] = {\n"; + my $i = 0; + + foreach my $entry (@table) { + if (defined($entry)) { + my $key = $keys[$entry]; + print " \{ \"" . $key . "\""; + print ", { (intptr_t)" . $values[$entry] . " }"; + print ", " . $attrs[$entry]; + print ", " . $params[$entry]; + print ", "; + if (defined($links[$i])) { + print "&" . $nameEntries . "[" . $links[$i] . "]" . " \}"; + } else { + print "0 \}" + } + print "/* " . $hashes[$entry] . " */ "; + } else { + print " { 0, { 0 }, 0, 0, 0 }"; + } + print "," unless ($i == $size - 1); + print "\n"; + $i++; + } + + print "};\n\n"; + print "const struct HashTable $name = "; + print "\{ 3, $size, $nameEntries, $hashSizeMask \};\n\n"; + print "} // namespace\n"; +} diff --git a/kjs/date_object.cpp b/kjs/date_object.cpp new file mode 100644 index 0000000..0c88d6c --- /dev/null +++ b/kjs/date_object.cpp @@ -0,0 +1,1542 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + */ + +#include "config.h" +#include "date_object.h" +#include "date_object.lut.h" +#include "internal.h" + +#if HAVE(ERRNO_H) +#include +#endif + +#if HAVE(SYS_PARAM_H) +#include +#endif + +#if HAVE(SYS_TIME_H) +#include +#endif + +#if HAVE(SYS_TIMEB_H) +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "error_object.h" +#include "operations.h" +#include "DateMath.h" + +#include +#include +#include +#include +#include + + #include + +using namespace WTF; + +namespace KJS { + +static double parseDate(const UString&); +static double timeClip(double); + +inline int gmtoffset(const GregorianDateTime& t) +{ + return t.utcOffset; +} + + +/** + * @internal + * + * Class to implement all methods that are properties of the + * Date object + */ +class DateObjectFuncImp : public InternalFunctionImp { +public: + DateObjectFuncImp(ExecState *, FunctionPrototype *, int i, int len, const Identifier& ); + + virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args); + + enum { Parse, UTC }; + +private: + int id; +}; + + +static CFDateFormatterStyle styleFromArgString(const UString& string, CFDateFormatterStyle defaultStyle) +{ + if (string == "short") + return kCFDateFormatterShortStyle; + if (string == "medium") + return kCFDateFormatterMediumStyle; + if (string == "long") + return kCFDateFormatterLongStyle; + if (string == "full") + return kCFDateFormatterFullStyle; + return defaultStyle; +} + +static UString formatLocaleDate(ExecState *exec, double time, bool includeDate, bool includeTime, const List &args) +{ + CFDateFormatterStyle dateStyle = (includeDate ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); + CFDateFormatterStyle timeStyle = (includeTime ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); + + bool useCustomFormat = false; + UString customFormatString; + + UString arg0String = args[0]->toString(exec); + if (arg0String == "custom" && !args[1]->isUndefined()) { + useCustomFormat = true; + customFormatString = args[1]->toString(exec); + } else if (includeDate && includeTime && !args[1]->isUndefined()) { + dateStyle = styleFromArgString(arg0String, dateStyle); + timeStyle = styleFromArgString(args[1]->toString(exec), timeStyle); + } else if (includeDate && !args[0]->isUndefined()) { + dateStyle = styleFromArgString(arg0String, dateStyle); + } else if (includeTime && !args[0]->isUndefined()) { + timeStyle = styleFromArgString(arg0String, timeStyle); + } + + CFLocaleRef locale = CFLocaleCopyCurrent(); + CFDateFormatterRef formatter = CFDateFormatterCreate(0, locale, dateStyle, timeStyle); + CFRelease(locale); + + if (useCustomFormat) { + CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, (UniChar *)customFormatString.data(), customFormatString.size()); + CFDateFormatterSetFormat(formatter, customFormatCFString); + CFRelease(customFormatCFString); + } + + CFStringRef string = CFDateFormatterCreateStringWithAbsoluteTime(0, formatter, time - kCFAbsoluteTimeIntervalSince1970); + + CFRelease(formatter); + + // We truncate the string returned from CFDateFormatter if it's absurdly long (> 200 characters). + // That's not great error handling, but it just won't happen so it doesn't matter. + UChar buffer[200]; + const size_t bufferLength = sizeof(buffer) / sizeof(buffer[0]); + size_t length = CFStringGetLength(string); + ASSERT(length <= bufferLength); + if (length > bufferLength) + length = bufferLength; + CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast(buffer)); + + CFRelease(string); + + return UString(buffer, length); +} + + +static UString formatDate(const GregorianDateTime &t) +{ + char buffer[100]; + snprintf(buffer, sizeof(buffer), "%s %s %02d %04d", + weekdayName[(t.weekDay + 6) % 7], + monthName[t.month], t.monthDay, t.year + 1900); + return buffer; +} + +static UString formatDateUTCVariant(const GregorianDateTime &t) +{ + char buffer[100]; + snprintf(buffer, sizeof(buffer), "%s, %02d %s %04d", + weekdayName[(t.weekDay + 6) % 7], + t.monthDay, monthName[t.month], t.year + 1900); + return buffer; +} + +static UString formatTime(const GregorianDateTime &t, bool utc) +{ + char buffer[100]; + if (utc) { + snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT", t.hour, t.minute, t.second); + } else { + int offset = abs(gmtoffset(t)); + char tzname[70]; + struct tm gtm = t; + strftime(tzname, sizeof(tzname), "%Z", >m); + + if (tzname[0]) { + snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%c%02d%02d (%s)", + t.hour, t.minute, t.second, + gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, tzname); + } else { + snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%c%02d%02d", + t.hour, t.minute, t.second, + gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60); + } + } + return UString(buffer); +} + +// Converts a list of arguments sent to a Date member function into milliseconds, updating +// ms (representing milliseconds) and t (representing the rest of the date structure) appropriately. +// +// Format of member function: f([hour,] [min,] [sec,] [ms]) +static void fillStructuresUsingTimeArgs(ExecState* exec, const List& args, int maxArgs, double* ms, GregorianDateTime* t) +{ + double milliseconds = 0; + int idx = 0; + int numArgs = args.size(); + + // JS allows extra trailing arguments -- ignore them + if (numArgs > maxArgs) + numArgs = maxArgs; + + // hours + if (maxArgs >= 4 && idx < numArgs) { + t->hour = 0; + milliseconds += args[idx++]->toInt32(exec) * msPerHour; + } + + // minutes + if (maxArgs >= 3 && idx < numArgs) { + t->minute = 0; + milliseconds += args[idx++]->toInt32(exec) * msPerMinute; + } + + // seconds + if (maxArgs >= 2 && idx < numArgs) { + t->second = 0; + milliseconds += args[idx++]->toInt32(exec) * msPerSecond; + } + + // milliseconds + if (idx < numArgs) + milliseconds += args[idx]->toNumber(exec); + else + milliseconds += *ms; + + *ms = milliseconds; +} + +// Converts a list of arguments sent to a Date member function into years, months, and milliseconds, updating +// ms (representing milliseconds) and t (representing the rest of the date structure) appropriately. +// +// Format of member function: f([years,] [months,] [days]) +static void fillStructuresUsingDateArgs(ExecState *exec, const List &args, int maxArgs, double *ms, GregorianDateTime *t) +{ + int idx = 0; + int numArgs = args.size(); + + // JS allows extra trailing arguments -- ignore them + if (numArgs > maxArgs) + numArgs = maxArgs; + + // years + if (maxArgs >= 3 && idx < numArgs) + t->year = args[idx++]->toInt32(exec) - 1900; + + // months + if (maxArgs >= 2 && idx < numArgs) + t->month = args[idx++]->toInt32(exec); + + // days + if (idx < numArgs) { + t->monthDay = 0; + *ms += args[idx]->toInt32(exec) * msPerDay; + } +} + +// ------------------------------ DateInstance ------------------------------ + +const ClassInfo DateInstance::info = {"Date", 0, 0}; + +DateInstance::DateInstance(JSObject *proto) + : JSWrapperObject(proto) +{ +} + +bool DateInstance::getTime(GregorianDateTime &t, int &offset) const +{ + double milli = internalValue()->getNumber(); + if (isnan(milli)) + return false; + + msToGregorianDateTime(milli, false, t); + offset = gmtoffset(t); + return true; +} + +bool DateInstance::getUTCTime(GregorianDateTime &t) const +{ + double milli = internalValue()->getNumber(); + if (isnan(milli)) + return false; + + msToGregorianDateTime(milli, true, t); + return true; +} + +bool DateInstance::getTime(double &milli, int &offset) const +{ + milli = internalValue()->getNumber(); + if (isnan(milli)) + return false; + + GregorianDateTime t; + msToGregorianDateTime(milli, false, t); + offset = gmtoffset(t); + return true; +} + +bool DateInstance::getUTCTime(double &milli) const +{ + milli = internalValue()->getNumber(); + if (isnan(milli)) + return false; + + return true; +} + +static inline bool isTime_tSigned() +{ + time_t minusOne = (time_t)(-1); + return minusOne < 0; +} + +// ------------------------------ DatePrototype ----------------------------- + +const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, &dateTable}; + +/* Source for date_object.lut.h + FIXMEL We could use templates to simplify the UTC variants. +@begin dateTable 61 + toString dateProtoFuncToString DontEnum|Function 0 + toUTCString dateProtoFuncToUTCString DontEnum|Function 0 + toDateString dateProtoFuncToDateString DontEnum|Function 0 + toTimeString dateProtoFuncToTimeString DontEnum|Function 0 + toLocaleString dateProtoFuncToLocaleString DontEnum|Function 0 + toLocaleDateString dateProtoFuncToLocaleDateString DontEnum|Function 0 + toLocaleTimeString dateProtoFuncToLocaleTimeString DontEnum|Function 0 + valueOf dateProtoFuncValueOf DontEnum|Function 0 + getTime dateProtoFuncGetTime DontEnum|Function 0 + getFullYear dateProtoFuncGetFullYear DontEnum|Function 0 + getUTCFullYear dateProtoFuncGetUTCFullYear DontEnum|Function 0 + toGMTString dateProtoFuncToGMTString DontEnum|Function 0 + getMonth dateProtoFuncGetMonth DontEnum|Function 0 + getUTCMonth dateProtoFuncGetUTCMonth DontEnum|Function 0 + getDate dateProtoFuncGetDate DontEnum|Function 0 + getUTCDate dateProtoFuncGetUTCDate DontEnum|Function 0 + getDay dateProtoFuncGetDay DontEnum|Function 0 + getUTCDay dateProtoFuncGetUTCDay DontEnum|Function 0 + getHours dateProtoFuncGetHours DontEnum|Function 0 + getUTCHours dateProtoFuncGetUTCHours DontEnum|Function 0 + getMinutes dateProtoFuncGetMinutes DontEnum|Function 0 + getUTCMinutes dateProtoFuncGetUTCMinutes DontEnum|Function 0 + getSeconds dateProtoFuncGetSeconds DontEnum|Function 0 + getUTCSeconds dateProtoFuncGetUTCSeconds DontEnum|Function 0 + getMilliseconds dateProtoFuncGetMilliSeconds DontEnum|Function 0 + getUTCMilliseconds dateProtoFuncGetUTCMilliseconds DontEnum|Function 0 + getTimezoneOffset dateProtoFuncGetTimezoneOffset DontEnum|Function 0 + setTime dateProtoFuncSetTime DontEnum|Function 1 + setMilliseconds dateProtoFuncSetMilliSeconds DontEnum|Function 1 + setUTCMilliseconds dateProtoFuncSetUTCMilliseconds DontEnum|Function 1 + setSeconds dateProtoFuncSetSeconds DontEnum|Function 2 + setUTCSeconds dateProtoFuncSetUTCSeconds DontEnum|Function 2 + setMinutes dateProtoFuncSetMinutes DontEnum|Function 3 + setUTCMinutes dateProtoFuncSetUTCMinutes DontEnum|Function 3 + setHours dateProtoFuncSetHours DontEnum|Function 4 + setUTCHours dateProtoFuncSetUTCHours DontEnum|Function 4 + setDate dateProtoFuncSetDate DontEnum|Function 1 + setUTCDate dateProtoFuncSetUTCDate DontEnum|Function 1 + setMonth dateProtoFuncSetMonth DontEnum|Function 2 + setUTCMonth dateProtoFuncSetUTCMonth DontEnum|Function 2 + setFullYear dateProtoFuncSetFullYear DontEnum|Function 3 + setUTCFullYear dateProtoFuncSetUTCFullYear DontEnum|Function 3 + setYear dateProtoFuncSetYear DontEnum|Function 1 + getYear dateProtoFuncGetYear DontEnum|Function 0 +@end +*/ +// ECMA 15.9.4 + +DatePrototype::DatePrototype(ExecState *, ObjectPrototype *objectProto) + : DateInstance(objectProto) +{ + setInternalValue(jsNaN()); + // The constructor will be added later, after DateObjectImp has been built. +} + +bool DatePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticFunctionSlot(exec, &dateTable, this, propertyName, slot); +} + +// ------------------------------ DateObjectImp -------------------------------- + +// TODO: MakeTime (15.9.11.1) etc. ? + +DateObjectImp::DateObjectImp(ExecState* exec, FunctionPrototype* funcProto, DatePrototype* dateProto) + : InternalFunctionImp(funcProto, dateProto->classInfo()->className) +{ + static const Identifier* parsePropertyName = new Identifier("parse"); + static const Identifier* UTCPropertyName = new Identifier("UTC"); + + putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly); + putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, *parsePropertyName), DontEnum); + putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, *UTCPropertyName), DontEnum); + putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum); +} + +bool DateObjectImp::implementsConstruct() const +{ + return true; +} + +// ECMA 15.9.3 +JSObject *DateObjectImp::construct(ExecState *exec, const List &args) +{ + int numArgs = args.size(); + + double value; + + if (numArgs == 0) { // new Date() ECMA 15.9.3.3 + value = getCurrentUTCTime(); + } else if (numArgs == 1) { + if (args[0]->isObject(&DateInstance::info)) + value = static_cast(args[0])->internalValue()->toNumber(exec); + else { + JSValue* primitive = args[0]->toPrimitive(exec); + if (primitive->isString()) + value = parseDate(primitive->getString()); + else + value = primitive->toNumber(exec); + } + } else { + if (isnan(args[0]->toNumber(exec)) + || isnan(args[1]->toNumber(exec)) + || (numArgs >= 3 && isnan(args[2]->toNumber(exec))) + || (numArgs >= 4 && isnan(args[3]->toNumber(exec))) + || (numArgs >= 5 && isnan(args[4]->toNumber(exec))) + || (numArgs >= 6 && isnan(args[5]->toNumber(exec))) + || (numArgs >= 7 && isnan(args[6]->toNumber(exec)))) { + value = NaN; + } else { + GregorianDateTime t; + int year = args[0]->toInt32(exec); + t.year = (year >= 0 && year <= 99) ? year : year - 1900; + t.month = args[1]->toInt32(exec); + t.monthDay = (numArgs >= 3) ? args[2]->toInt32(exec) : 1; + t.hour = args[3]->toInt32(exec); + t.minute = args[4]->toInt32(exec); + t.second = args[5]->toInt32(exec); + t.isDST = -1; + double ms = (numArgs >= 7) ? args[6]->toNumber(exec) : 0; + value = gregorianDateTimeToMS(t, ms, false); + } + } + + DateInstance *ret = new DateInstance(exec->lexicalGlobalObject()->datePrototype()); + ret->setInternalValue(jsNumber(timeClip(value))); + return ret; +} + +// ECMA 15.9.2 +JSValue *DateObjectImp::callAsFunction(ExecState * /*exec*/, JSObject * /*thisObj*/, const List &/*args*/) +{ + time_t t = time(0); + GregorianDateTime ts(*localtime(&t)); + return jsString(formatDate(ts) + " " + formatTime(ts, false)); +} + +// ------------------------------ DateObjectFuncImp ---------------------------- + +DateObjectFuncImp::DateObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name) + : InternalFunctionImp(funcProto, name), id(i) +{ + putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum); +} + +// ECMA 15.9.4.2 - 3 +JSValue *DateObjectFuncImp::callAsFunction(ExecState* exec, JSObject*, const List& args) +{ + if (id == Parse) { + return jsNumber(parseDate(args[0]->toString(exec))); + } + else { // UTC + int n = args.size(); + if (isnan(args[0]->toNumber(exec)) + || isnan(args[1]->toNumber(exec)) + || (n >= 3 && isnan(args[2]->toNumber(exec))) + || (n >= 4 && isnan(args[3]->toNumber(exec))) + || (n >= 5 && isnan(args[4]->toNumber(exec))) + || (n >= 6 && isnan(args[5]->toNumber(exec))) + || (n >= 7 && isnan(args[6]->toNumber(exec)))) { + return jsNaN(); + } + + GregorianDateTime t; + memset(&t, 0, sizeof(t)); + int year = args[0]->toInt32(exec); + t.year = (year >= 0 && year <= 99) ? year : year - 1900; + t.month = args[1]->toInt32(exec); + t.monthDay = (n >= 3) ? args[2]->toInt32(exec) : 1; + t.hour = args[3]->toInt32(exec); + t.minute = args[4]->toInt32(exec); + t.second = args[5]->toInt32(exec); + double ms = (n >= 7) ? args[6]->toNumber(exec) : 0; + return jsNumber(gregorianDateTimeToMS(t, ms, true)); + } +} + +// ----------------------------------------------------------------------------- + +// Code originally from krfcdate.cpp, but we don't want to use kdecore, and we want double range. + +static inline double ymdhmsToSeconds(long year, int mon, int day, int hour, int minute, int second) +{ + double days = (day - 32075) + + floor(1461 * (year + 4800.0 + (mon - 14) / 12) / 4) + + 367 * (mon - 2 - (mon - 14) / 12 * 12) / 12 + - floor(3 * ((year + 4900.0 + (mon - 14) / 12) / 100) / 4) + - 2440588; + return ((days * hoursPerDay + hour) * minutesPerHour + minute) * secondsPerMinute + second; +} + +// We follow the recommendation of RFC 2822 to consider all +// obsolete time zones not listed here equivalent to "-0000". +static const struct KnownZone { +#if !PLATFORM(WIN_OS) + const +#endif + char tzName[4]; + int tzOffset; +} known_zones[] = { + { "UT", 0 }, + { "GMT", 0 }, + { "EST", -300 }, + { "EDT", -240 }, + { "CST", -360 }, + { "CDT", -300 }, + { "MST", -420 }, + { "MDT", -360 }, + { "PST", -480 }, + { "PDT", -420 } +}; + +inline static void skipSpacesAndComments(const char*& s) +{ + int nesting = 0; + char ch; + while ((ch = *s)) { + if (!isASCIISpace(ch)) { + if (ch == '(') + nesting++; + else if (ch == ')' && nesting > 0) + nesting--; + else if (nesting == 0) + break; + } + s++; + } +} + +// returns 0-11 (Jan-Dec); -1 on failure +static int findMonth(const char* monthStr) +{ + ASSERT(monthStr); + char needle[4]; + for (int i = 0; i < 3; ++i) { + if (!*monthStr) + return -1; + needle[i] = static_cast(toASCIILower(*monthStr++)); + } + needle[3] = '\0'; + const char *haystack = "janfebmaraprmayjunjulaugsepoctnovdec"; + const char *str = strstr(haystack, needle); + if (str) { + int position = static_cast(str - haystack); + if (position % 3 == 0) + return position / 3; + } + return -1; +} + +static double parseDate(const UString &date) +{ + // This parses a date in the form: + // Tuesday, 09-Nov-99 23:12:40 GMT + // or + // Sat, 01-Jan-2000 08:00:00 GMT + // or + // Sat, 01 Jan 2000 08:00:00 GMT + // or + // 01 Jan 99 22:00 +0100 (exceptions in rfc822/rfc2822) + // ### non RFC formats, added for Javascript: + // [Wednesday] January 09 1999 23:12:40 GMT + // [Wednesday] January 09 23:12:40 GMT 1999 + // + // We ignore the weekday. + + CString dateCString = date.UTF8String(); + const char *dateString = dateCString.c_str(); + + // Skip leading space + skipSpacesAndComments(dateString); + + long month = -1; + const char *wordStart = dateString; + // Check contents of first words if not number + while (*dateString && !isASCIIDigit(*dateString)) { + if (isASCIISpace(*dateString) || *dateString == '(') { + if (dateString - wordStart >= 3) + month = findMonth(wordStart); + skipSpacesAndComments(dateString); + wordStart = dateString; + } else + dateString++; + } + + // Missing delimiter between month and day (like "January29")? + if (month == -1 && wordStart != dateString) + month = findMonth(wordStart); + + skipSpacesAndComments(dateString); + + if (!*dateString) + return NaN; + + // ' 09-Nov-99 23:12:40 GMT' + char *newPosStr; + errno = 0; + long day = strtol(dateString, &newPosStr, 10); + if (errno) + return NaN; + dateString = newPosStr; + + if (!*dateString) + return NaN; + + if (day < 0) + return NaN; + + long year = 0; + if (day > 31) { + // ### where is the boundary and what happens below? + if (*dateString != '/') + return NaN; + // looks like a YYYY/MM/DD date + if (!*++dateString) + return NaN; + year = day; + month = strtol(dateString, &newPosStr, 10) - 1; + if (errno) + return NaN; + dateString = newPosStr; + if (*dateString++ != '/' || !*dateString) + return NaN; + day = strtol(dateString, &newPosStr, 10); + if (errno) + return NaN; + dateString = newPosStr; + } else if (*dateString == '/' && month == -1) { + dateString++; + // This looks like a MM/DD/YYYY date, not an RFC date. + month = day - 1; // 0-based + day = strtol(dateString, &newPosStr, 10); + if (errno) + return NaN; + if (day < 1 || day > 31) + return NaN; + dateString = newPosStr; + if (*dateString == '/') + dateString++; + if (!*dateString) + return NaN; + } else { + if (*dateString == '-') + dateString++; + + skipSpacesAndComments(dateString); + + if (*dateString == ',') + dateString++; + + if (month == -1) { // not found yet + month = findMonth(dateString); + if (month == -1) + return NaN; + + while (*dateString && *dateString != '-' && *dateString != ',' && !isASCIISpace(*dateString)) + dateString++; + + if (!*dateString) + return NaN; + + // '-99 23:12:40 GMT' + if (*dateString != '-' && *dateString != '/' && *dateString != ',' && !isASCIISpace(*dateString)) + return NaN; + dateString++; + } + } + + if (month < 0 || month > 11) + return NaN; + + // '99 23:12:40 GMT' + if (year <= 0 && *dateString) { + year = strtol(dateString, &newPosStr, 10); + if (errno) + return NaN; + } + + // Don't fail if the time is missing. + long hour = 0; + long minute = 0; + long second = 0; + if (!*newPosStr) + dateString = newPosStr; + else { + // ' 23:12:40 GMT' + if (!(isASCIISpace(*newPosStr) || *newPosStr == ',')) { + if (*newPosStr != ':') + return NaN; + // There was no year; the number was the hour. + year = -1; + } else { + // in the normal case (we parsed the year), advance to the next number + dateString = ++newPosStr; + skipSpacesAndComments(dateString); + } + + hour = strtol(dateString, &newPosStr, 10); + // Do not check for errno here since we want to continue + // even if errno was set becasue we are still looking + // for the timezone! + + // Read a number? If not, this might be a timezone name. + if (newPosStr != dateString) { + dateString = newPosStr; + + if (hour < 0 || hour > 23) + return NaN; + + if (!*dateString) + return NaN; + + // ':12:40 GMT' + if (*dateString++ != ':') + return NaN; + + minute = strtol(dateString, &newPosStr, 10); + if (errno) + return NaN; + dateString = newPosStr; + + if (minute < 0 || minute > 59) + return NaN; + + // ':40 GMT' + if (*dateString && *dateString != ':' && !isASCIISpace(*dateString)) + return NaN; + + // seconds are optional in rfc822 + rfc2822 + if (*dateString ==':') { + dateString++; + + second = strtol(dateString, &newPosStr, 10); + if (errno) + return NaN; + dateString = newPosStr; + + if (second < 0 || second > 59) + return NaN; + } + + skipSpacesAndComments(dateString); + + if (strncasecmp(dateString, "AM", 2) == 0) { + if (hour > 12) + return NaN; + if (hour == 12) + hour = 0; + dateString += 2; + skipSpacesAndComments(dateString); + } else if (strncasecmp(dateString, "PM", 2) == 0) { + if (hour > 12) + return NaN; + if (hour != 12) + hour += 12; + dateString += 2; + skipSpacesAndComments(dateString); + } + } + } + + bool haveTZ = false; + int offset = 0; + + // Don't fail if the time zone is missing. + // Some websites omit the time zone (4275206). + if (*dateString) { + if (strncasecmp(dateString, "GMT", 3) == 0 || strncasecmp(dateString, "UTC", 3) == 0) { + dateString += 3; + haveTZ = true; + } + + if (*dateString == '+' || *dateString == '-') { + long o = strtol(dateString, &newPosStr, 10); + if (errno) + return NaN; + dateString = newPosStr; + + if (o < -9959 || o > 9959) + return NaN; + + int sgn = (o < 0) ? -1 : 1; + o = abs(o); + if (*dateString != ':') { + offset = ((o / 100) * 60 + (o % 100)) * sgn; + } else { // GMT+05:00 + long o2 = strtol(dateString, &newPosStr, 10); + if (errno) + return NaN; + dateString = newPosStr; + offset = (o * 60 + o2) * sgn; + } + haveTZ = true; + } else { + for (int i = 0; i < int(sizeof(known_zones) / sizeof(KnownZone)); i++) { + if (0 == strncasecmp(dateString, known_zones[i].tzName, strlen(known_zones[i].tzName))) { + offset = known_zones[i].tzOffset; + dateString += strlen(known_zones[i].tzName); + haveTZ = true; + break; + } + } + } + } + + skipSpacesAndComments(dateString); + + if (*dateString && year == -1) { + year = strtol(dateString, &newPosStr, 10); + if (errno) + return NaN; + dateString = newPosStr; + } + + skipSpacesAndComments(dateString); + + // Trailing garbage + if (*dateString) + return NaN; + + // Y2K: Handle 2 digit years. + if (year >= 0 && year < 100) { + if (year < 50) + year += 2000; + else + year += 1900; + } + + // fall back to local timezone + if (!haveTZ) { + GregorianDateTime t; + memset(&t, 0, sizeof(tm)); + t.monthDay = day; + t.month = month; + t.year = year - 1900; + t.isDST = -1; + t.second = second; + t.minute = minute; + t.hour = hour; + + // Use our gregorianDateTimeToMS() rather than mktime() as the latter can't handle the full year range. + return gregorianDateTimeToMS(t, 0, false); + } + + return (ymdhmsToSeconds(year, month + 1, day, hour, minute, second) - (offset * 60.0)) * msPerSecond; +} + +double timeClip(double t) +{ + if (!isfinite(t)) + return NaN; + if (fabs(t) > 8.64E15) + return NaN; + return trunc(t); +} + +// Functions + +JSValue* dateProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsString("Invalid Date"); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsString(formatDate(t) + " " + formatTime(t, utc)); +} + +JSValue* dateProtoFuncToUTCString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = true; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsString("Invalid Date"); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsString(formatDateUTCVariant(t) + " " + formatTime(t, utc)); +} + +JSValue* dateProtoFuncToDateString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsString("Invalid Date"); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsString(formatDate(t)); +} + +JSValue* dateProtoFuncToTimeString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsString("Invalid Date"); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsString(formatTime(t, utc)); +} + +JSValue* dateProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsString("Invalid Date"); + + double secs = floor(milli / msPerSecond); + return jsString(formatLocaleDate(exec, secs, true, true, args)); +} + +JSValue* dateProtoFuncToLocaleDateString(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsString("Invalid Date"); + + double secs = floor(milli / msPerSecond); + return jsString(formatLocaleDate(exec, secs, true, false, args)); +} + +JSValue* dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsString("Invalid Date"); + + double secs = floor(milli / msPerSecond); + return jsString(formatLocaleDate(exec, secs, false, true, args)); +} + +JSValue* dateProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + return jsNumber(milli); +} + +JSValue* dateProtoFuncGetTime(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + return jsNumber(milli); +} + +JSValue* dateProtoFuncGetFullYear(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(1900 + t.year); +} + +JSValue* dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = true; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(1900 + t.year); +} + +JSValue* dateProtoFuncToGMTString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = true; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsString("Invalid Date"); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsString(formatDateUTCVariant(t) + " " + formatTime(t, utc)); +} + +JSValue* dateProtoFuncGetMonth(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.month); +} + +JSValue* dateProtoFuncGetUTCMonth(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = true; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.month); +} + +JSValue* dateProtoFuncGetDate(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.monthDay); +} + +JSValue* dateProtoFuncGetUTCDate(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = true; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.monthDay); +} + +JSValue* dateProtoFuncGetDay(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.weekDay); +} + +JSValue* dateProtoFuncGetUTCDay(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = true; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.weekDay); +} + +JSValue* dateProtoFuncGetHours(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.hour); +} + +JSValue* dateProtoFuncGetUTCHours(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = true; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.hour); +} + +JSValue* dateProtoFuncGetMinutes(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.minute); +} + +JSValue* dateProtoFuncGetUTCMinutes(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = true; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.minute); +} + +JSValue* dateProtoFuncGetSeconds(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.second); +} + +JSValue* dateProtoFuncGetUTCSeconds(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = true; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(t.second); +} + +JSValue* dateProtoFuncGetMilliSeconds(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + double secs = floor(milli / msPerSecond); + double ms = milli - secs * msPerSecond; + return jsNumber(ms); +} + +JSValue* dateProtoFuncGetUTCMilliseconds(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + double secs = floor(milli / msPerSecond); + double ms = milli - secs * msPerSecond; + return jsNumber(ms); +} + +JSValue* dateProtoFuncGetTimezoneOffset(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + return jsNumber(-gmtoffset(t) / minutesPerHour); +} + +JSValue* dateProtoFuncSetTime(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + + double milli = timeClip(args[0]->toNumber(exec)); + JSValue* result = jsNumber(milli); + thisDateObj->setInternalValue(result); + return result; +} + +static JSValue* setNewValueFromTimeArgs(ExecState* exec, JSObject* thisObj, const List& args, int numArgsToUse, bool inputIsUTC) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + double secs = floor(milli / msPerSecond); + double ms = milli - secs * msPerSecond; + + GregorianDateTime t; + msToGregorianDateTime(milli, inputIsUTC, t); + + fillStructuresUsingTimeArgs(exec, args, numArgsToUse, &ms, &t); + + JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, inputIsUTC)); + thisDateObj->setInternalValue(result); + return result; +} + +static JSValue* setNewValueFromDateArgs(ExecState* exec, JSObject* thisObj, const List& args, int numArgsToUse, bool inputIsUTC) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + double secs = floor(milli / msPerSecond); + double ms = milli - secs * msPerSecond; + + GregorianDateTime t; + msToGregorianDateTime(milli, inputIsUTC, t); + + fillStructuresUsingDateArgs(exec, args, numArgsToUse, &ms, &t); + + JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, inputIsUTC)); + thisDateObj->setInternalValue(result); + return result; +} + +JSValue* dateProtoFuncSetMilliSeconds(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = false; + return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC); +} + +JSValue* dateProtoFuncSetUTCMilliseconds(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = true; + return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC); +} + +JSValue* dateProtoFuncSetSeconds(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = false; + return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC); +} + +JSValue* dateProtoFuncSetUTCSeconds(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = true; + return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC); +} + +JSValue* dateProtoFuncSetMinutes(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = false; + return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC); +} + +JSValue* dateProtoFuncSetUTCMinutes(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = true; + return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC); +} + +JSValue* dateProtoFuncSetHours(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = false; + return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC); +} + +JSValue* dateProtoFuncSetUTCHours(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = true; + return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC); +} + +JSValue* dateProtoFuncSetDate(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = false; + return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC); +} + +JSValue* dateProtoFuncSetUTCDate(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = true; + return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC); +} + +JSValue* dateProtoFuncSetMonth(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = false; + return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC); +} + +JSValue* dateProtoFuncSetUTCMonth(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = true; + return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC); +} + +JSValue* dateProtoFuncSetFullYear(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = false; + return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC); +} + +JSValue* dateProtoFuncSetUTCFullYear(ExecState* exec, JSObject* thisObj, const List& args) +{ + const bool inputIsUTC = true; + return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC); +} + +JSValue* dateProtoFuncSetYear(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + double secs = floor(milli / msPerSecond); + double ms = milli - secs * msPerSecond; + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + + t.year = (args[0]->toInt32(exec) > 99 || args[0]->toInt32(exec) < 0) ? args[0]->toInt32(exec) - 1900 : args[0]->toInt32(exec); + + JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc)); + thisDateObj->setInternalValue(result); + return result; +} + +JSValue* dateProtoFuncGetYear(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&DateInstance::info)) + return throwError(exec, TypeError); + + const bool utc = false; + + DateInstance* thisDateObj = static_cast(thisObj); + JSValue* v = thisDateObj->internalValue(); + double milli = v->toNumber(exec); + if (isnan(milli)) + return jsNaN(); + + GregorianDateTime t; + msToGregorianDateTime(milli, utc, t); + + // IE returns the full year even in getYear. + if (exec->dynamicGlobalObject()->compatMode() == IECompat) + return jsNumber(1900 + t.year); + return jsNumber(t.year); +} + +} // namespace KJS diff --git a/kjs/date_object.h b/kjs/date_object.h new file mode 100644 index 0000000..c545980 --- /dev/null +++ b/kjs/date_object.h @@ -0,0 +1,135 @@ +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef DATE_OBJECT_H +#define DATE_OBJECT_H + +#include "function.h" +#include "JSWrapperObject.h" +#include "lookup.h" + +namespace KJS { + + struct GregorianDateTime; + + class FunctionPrototype; + class ObjectPrototype; + + class DateInstance : public JSWrapperObject { + public: + DateInstance(JSObject *proto); + + bool getTime(GregorianDateTime&, int& offset) const; + bool getUTCTime(GregorianDateTime&) const; + bool getTime(double& milli, int& offset) const; + bool getUTCTime(double& milli) const; + + virtual const ClassInfo *classInfo() const { return &info; } + static const ClassInfo info; + }; + + /** + * @internal + * + * The initial value of Date.prototype (and thus all objects created + * with the Date constructor + */ + class DatePrototype : public DateInstance { + public: + DatePrototype(ExecState *, ObjectPrototype *); + virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&); + virtual const ClassInfo *classInfo() const { return &info; } + static const ClassInfo info; + }; + + /** + * @internal + * + * Functions to implement all methods that are properties of the + * Date.prototype object + */ + + // Non-normative properties (Appendix B) + // GetYear, SetYear, ToGMTString + + JSValue* dateProtoFuncToString(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncToUTCString(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncToDateString(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncToTimeString(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncToLocaleString(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncToLocaleDateString(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncValueOf(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetTime(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncToGMTString(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetMonth(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetUTCMonth(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetUTCDate(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetUTCDay(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetHours(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetUTCHours(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetMinutes(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetSeconds(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetTime(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetSeconds(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetMinutes(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetHours(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetUTCHours(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetDate(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetUTCDate(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetMonth(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetUTCMonth(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetFullYear(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncSetYear(ExecState*, JSObject*, const List&); + JSValue* dateProtoFuncGetYear(ExecState*, JSObject*, const List&); + + /** + * @internal + * + * The initial value of the the global variable's "Date" property + */ + class DateObjectImp : public InternalFunctionImp { + public: + DateObjectImp(ExecState *, FunctionPrototype *, DatePrototype *); + + virtual bool implementsConstruct() const; + virtual JSObject *construct(ExecState *, const List &args); + virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args); + + JSObject *construct(const List &); + }; + +} // namespace + +#endif diff --git a/kjs/debugger.cpp b/kjs/debugger.cpp new file mode 100644 index 0000000..af9c5fa --- /dev/null +++ b/kjs/debugger.cpp @@ -0,0 +1,134 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "debugger.h" + +#include "JSGlobalObject.h" +#include "internal.h" +#include "ustring.h" + +using namespace KJS; + +// ------------------------------ Debugger ------------------------------------- + +namespace KJS { + struct AttachedGlobalObject + { + public: + AttachedGlobalObject(JSGlobalObject* o, AttachedGlobalObject* ai) : globalObj(o), next(ai) { ++Debugger::debuggersPresent; } + ~AttachedGlobalObject() { --Debugger::debuggersPresent; } + JSGlobalObject* globalObj; + AttachedGlobalObject* next; + }; + +} + +int Debugger::debuggersPresent = 0; + +Debugger::Debugger() +{ + rep = new DebuggerImp(); +} + +Debugger::~Debugger() +{ + detach(0); + delete rep; +} + +void Debugger::attach(JSGlobalObject* globalObject) +{ + Debugger* other = globalObject->debugger(); + if (other == this) + return; + if (other) + other->detach(globalObject); + globalObject->setDebugger(this); + rep->globalObjects = new AttachedGlobalObject(globalObject, rep->globalObjects); +} + +void Debugger::detach(JSGlobalObject* globalObj) +{ + // iterate the addresses where AttachedGlobalObject pointers are stored + // so we can unlink items from the list + AttachedGlobalObject **p = &rep->globalObjects; + AttachedGlobalObject *q; + while ((q = *p)) { + if (!globalObj || q->globalObj == globalObj) { + *p = q->next; + q->globalObj->setDebugger(0); + delete q; + } else + p = &q->next; + } + + if (globalObj) + latestExceptions.remove(globalObj); + else + latestExceptions.clear(); +} + +bool Debugger::hasHandledException(ExecState *exec, JSValue *exception) +{ + if (latestExceptions.get(exec->dynamicGlobalObject()).get() == exception) + return true; + + latestExceptions.set(exec->dynamicGlobalObject(), exception); + return false; +} + +bool Debugger::sourceParsed(ExecState*, int /*sourceId*/, const UString &/*sourceURL*/, + const UString &/*source*/, int /*startingLineNumber*/, int /*errorLine*/, const UString & /*errorMsg*/) +{ + return true; +} + +bool Debugger::sourceUnused(ExecState*, int /*sourceId*/) +{ + return true; +} + +bool Debugger::exception(ExecState*, int /*sourceId*/, int /*lineno*/, + JSValue* /*exception */) +{ + return true; +} + +bool Debugger::atStatement(ExecState*, int /*sourceId*/, int /*firstLine*/, + int /*lastLine*/) +{ + return true; +} + +bool Debugger::callEvent(ExecState*, int /*sourceId*/, int /*lineno*/, + JSObject* /*function*/, const List &/*args*/) +{ + return true; +} + +bool Debugger::returnEvent(ExecState*, int /*sourceId*/, int /*lineno*/, + JSObject* /*function*/) +{ + return true; +} + diff --git a/kjs/debugger.h b/kjs/debugger.h new file mode 100644 index 0000000..2d5cb6f --- /dev/null +++ b/kjs/debugger.h @@ -0,0 +1,225 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _KJSDEBUGGER_H_ +#define _KJSDEBUGGER_H_ + +#include +#include "protect.h" + +namespace KJS { + + class DebuggerImp; + class ExecState; + class JSGlobalObject; + class JSObject; + class JSValue; + class UString; + class List; + + /** + * @internal + * + * Provides an interface which receives notification about various + * script-execution related events such as statement execution and function + * calls. + * + * WARNING: This interface is still a work in progress and is not yet + * offically publicly available. It is likely to change in binary incompatible + * (and possibly source incompatible) ways in future versions. It is + * anticipated that at some stage the interface will be frozen and made + * available for general use. + */ + class Debugger { + public: + + /** + * Creates a new debugger + */ + Debugger(); + + /** + * Destroys the debugger. If the debugger is attached to any global objects, + * it is automatically detached. + */ + virtual ~Debugger(); + + DebuggerImp *imp() const { return rep; } + + /** + * Attaches the debugger to specified global object. This will cause this + * object to receive notification of events during execution. + * + * If the global object is deleted, it will detach the debugger. + * + * Note: only one debugger can be attached to a global object at a time. + * Attaching another debugger to the same global object will cause the + * original debugger to be detached. + * + * @param The global object to attach to. + * + * @see detach() + */ + void attach(JSGlobalObject*); + + /** + * Detach the debugger from a global object. + * + * @param The global object to detach from. If 0, the debugger will be + * detached from all global objects to which it is attached. + * + * @see attach() + */ + void detach(JSGlobalObject*); + + /** + * Called to notify the debugger that some javascript source code has + * been parsed. For calls to Interpreter::evaluate(), this will be called + * with the supplied source code before any other code is parsed. + * Other situations in which this may be called include creation of a + * function using the Function() constructor, or the eval() function. + * + * The default implementation does nothing. Override this method if + * you want to process this event. + * + * @param exec The current execution state + * @param sourceId The ID of the source code (corresponds to the + * sourceId supplied in other functions such as atStatement() + * @param sourceURL Where the source code that was parsed came from + * @param source The source code that was parsed + * @param startingLineNumber The line number at which parsing started + * @param errorLine The line number at which parsing encountered an + * error, or -1 if the source code was valid and parsed successfully + * @param errorMsg The error description, or null if the source code + was valid and parsed successfully + * @return true if execution should be continue, false if it should + * be aborted + */ + virtual bool sourceParsed(ExecState *exec, int sourceId, const UString &sourceURL, + const UString &source, int startingLineNumber, int errorLine, const UString &errorMsg); + + /** + * Called when all functions/programs associated with a particular + * sourceId have been deleted. After this function has been called for + * a particular sourceId, that sourceId will not be used again. + * + * The default implementation does nothing. Override this method if + * you want to process this event. + * + * @param exec The current execution state + * @param sourceId The ID of the source code (corresponds to the + * sourceId supplied in other functions such as atLine() + * @return true if execution should be continue, false if it should + * be aborted + */ + virtual bool sourceUnused(ExecState *exec, int sourceId); + + /** + * Called when an exception is thrown during script execution. + * + * The default implementation does nothing. Override this method if + * you want to process this event. + * + * @param exec The current execution state + * @param sourceId The ID of the source code being executed + * @param lineno The line at which the error occurred + * @param exceptionObj The exception object + * @return true if execution should be continue, false if it should + * be aborted + */ + virtual bool exception(ExecState *exec, int sourceId, int lineno, + JSValue *exception); + + bool hasHandledException(ExecState *, JSValue *); + + /** + * Called when a line of the script is reached (before it is executed) + * + * The default implementation does nothing. Override this method if + * you want to process this event. + * + * @param exec The current execution state + * @param sourceId The ID of the source code being executed + * @param firstLine The starting line of the statement that is about to be + * executed + * @param lastLine The ending line of the statement that is about to be + * executed (usually the same as firstLine) + * @return true if execution should be continue, false if it should + * be aborted + */ + virtual bool atStatement(ExecState *exec, int sourceId, int firstLine, + int lastLine); + /** + * Called on each function call. Use together with @ref #returnEvent + * if you want to keep track of the call stack. + * + * Note: This only gets called for functions that are declared in ECMAScript + * source code or passed to eval(), not for internal KJS or + * application-supplied functions. + * + * The default implementation does nothing. Override this method if + * you want to process this event. + * + * @param exec The current execution state + * @param sourceId The ID of the source code being executed + * @param lineno The line that is about to be executed + * @param function The function being called + * @param args The arguments that were passed to the function + * line is being executed + * @return true if execution should be continue, false if it should + * be aborted + */ + virtual bool callEvent(ExecState *exec, int sourceId, int lineno, + JSObject *function, const List &args); + + /** + * Called on each function exit. The function being returned from is that + * which was supplied in the last callEvent(). + * + * Note: This only gets called for functions that are declared in ECMAScript + * source code or passed to eval(), not for internal KJS or + * application-supplied functions. + * + * The default implementation does nothing. Override this method if + * you want to process this event. + * + * @param exec The current execution state + * @param sourceId The ID of the source code being executed + * @param lineno The line that is about to be executed + * @param function The function being called + * @return true if execution should be continue, false if it should + * be aborted + */ + virtual bool returnEvent(ExecState *exec, int sourceId, int lineno, + JSObject *function); + + private: + DebuggerImp *rep; + HashMap > latestExceptions; + + public: + static int debuggersPresent; + }; + +} + +#endif diff --git a/kjs/dtoa.cpp b/kjs/dtoa.cpp new file mode 100644 index 0000000..a8e3a68 --- /dev/null +++ b/kjs/dtoa.cpp @@ -0,0 +1,3300 @@ +/**************************************************************** + * + * The author of this software is David M. Gay. + * + * Copyright (c) 1991, 2000, 2001 by Lucent Technologies. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose without fee is hereby granted, provided that this entire notice + * is included in all copies of any software which is or includes a copy + * or modification of this software and in all copies of the supporting + * documentation for such software. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + * + ***************************************************************/ + +/* Please send bug reports to + David M. Gay + Bell Laboratories, Room 2C-463 + 600 Mountain Avenue + Murray Hill, NJ 07974-0636 + U.S.A. + dmg@bell-labs.com + */ + +/* On a machine with IEEE extended-precision registers, it is + * necessary to specify double-precision (53-bit) rounding precision + * before invoking strtod or dtoa. If the machine uses (the equivalent + * of) Intel 80x87 arithmetic, the call + * _control87(PC_53, MCW_PC); + * does this with many compilers. Whether this or another call is + * appropriate depends on the compiler; for this to work, it may be + * necessary to #include "float.h" or another system-dependent header + * file. + */ + +/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. + * + * This strtod returns a nearest machine number to the input decimal + * string (or sets errno to ERANGE). With IEEE arithmetic, ties are + * broken by the IEEE round-even rule. Otherwise ties are broken by + * biased rounding (add half and chop). + * + * Inspired loosely by William D. Clinger's paper "How to Read Floating + * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * + * 1. We only require IEEE, IBM, or VAX double-precision + * arithmetic (not IEEE double-extended). + * 2. We get by with floating-point arithmetic in a case that + * Clinger missed -- when we're computing d * 10^n + * for a small integer d and the integer n is not too + * much larger than 22 (the maximum integer k for which + * we can represent 10^k exactly), we may be able to + * compute (d*10^k) * 10^(e-k) with just one roundoff. + * 3. Rather than a bit-at-a-time adjustment of the binary + * result in the hard case, we use floating-point + * arithmetic to determine the adjustment to within + * one bit; only in really hard cases do we need to + * compute a second residual. + * 4. Because of 3., we don't need a large table of powers of 10 + * for ten-to-e (just some small tables, e.g. of 10^k + * for 0 <= k <= 22). + */ + +/* + * #define IEEE_8087 for IEEE-arithmetic machines where the least + * significant byte has the lowest address. + * #define IEEE_MC68k for IEEE-arithmetic machines where the most + * significant byte has the lowest address. + * #define Long int on machines with 32-bit ints and 64-bit longs. + * #define IBM for IBM mainframe-style floating-point arithmetic. + * #define VAX for VAX-style floating-point arithmetic (D_floating). + * #define No_leftright to omit left-right logic in fast floating-point + * computation of dtoa. + * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 + * and strtod and dtoa should round accordingly. + * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 + * and Honor_FLT_ROUNDS is not #defined. + * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines + * that use extended-precision instructions to compute rounded + * products and quotients) with IBM. + * #define ROUND_BIASED for IEEE-format with biased rounding. + * #define Inaccurate_Divide for IEEE-format with correctly rounded + * products but inaccurate quotients, e.g., for Intel i860. + * #define NO_LONG_LONG on machines that do not have a "long long" + * integer type (of >= 64 bits). On such machines, you can + * #define Just_16 to store 16 bits per 32-bit Long when doing + * high-precision integer arithmetic. Whether this speeds things + * up or slows things down depends on the machine and the number + * being converted. If long long is available and the name is + * something other than "long long", #define Llong to be the name, + * and if "unsigned Llong" does not work as an unsigned version of + * Llong, #define #ULLong to be the corresponding unsigned type. + * #define KR_headers for old-style C function headers. + * #define Bad_float_h if your system lacks a float.h or if it does not + * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, + * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. + * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) + * if memory is available and otherwise does something you deem + * appropriate. If MALLOC is undefined, malloc will be invoked + * directly -- and assumed always to succeed. + * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making + * memory allocations from a private pool of memory when possible. + * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes, + * unless #defined to be a different length. This default length + * suffices to get rid of MALLOC calls except for unusual cases, + * such as decimal-to-binary conversion of a very long string of + * digits. The longest string dtoa can return is about 751 bytes + * long. For conversions by strtod of strings of 800 digits and + * all dtoa conversions in single-threaded executions with 8-byte + * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte + * pointers, PRIVATE_MEM >= 7112 appears adequate. + * #define INFNAN_CHECK on IEEE systems to cause strtod to check for + * Infinity and NaN (case insensitively). On some systems (e.g., + * some HP systems), it may be necessary to #define NAN_WORD0 + * appropriately -- to the most significant word of a quiet NaN. + * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.) + * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined, + * strtod also accepts (case insensitively) strings of the form + * NaN(x), where x is a string of hexadecimal digits and spaces; + * if there is only one string of hexadecimal digits, it is taken + * for the 52 fraction bits of the resulting NaN; if there are two + * or more strings of hex digits, the first is for the high 20 bits, + * the second and subsequent for the low 32 bits, with intervening + * white space ignored; but if this results in none of the 52 + * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0 + * and NAN_WORD1 are used instead. + * #define MULTIPLE_THREADS if the system offers preemptively scheduled + * multiple threads. In this case, you must provide (or suitably + * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed + * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed + * in pow5mult, ensures lazy evaluation of only one copy of high + * powers of 5; omitting this lock would introduce a small + * probability of wasting memory, but would otherwise be harmless.) + * You must also invoke freedtoa(s) to free the value s returned by + * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. + * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that + * avoids underflows on inputs whose result does not underflow. + * If you #define NO_IEEE_Scale on a machine that uses IEEE-format + * floating-point numbers and flushes underflows to zero rather + * than implementing gradual underflow, then you must also #define + * Sudden_Underflow. + * #define YES_ALIAS to permit aliasing certain double values with + * arrays of ULongs. This leads to slightly better code with + * some compilers and was always used prior to 19990916, but it + * is not strictly legal and can cause trouble with aggressively + * optimizing compilers (e.g., gcc 2.95.1 under -O2). + * #define SET_INEXACT if IEEE arithmetic is being used and extra + * computation should be done to set the inexact flag when the + * result is inexact and avoid setting inexact when the result + * is exact. In this case, dtoa.c must be compiled in + * an environment, perhaps provided by #include "dtoa.c" in a + * suitable wrapper, that defines two functions, + * int get_inexact(void); + * void clear_inexact(void); + * such that get_inexact() returns a nonzero value if the + * inexact bit is already set, and clear_inexact() sets the + * inexact bit to 0. When SET_INEXACT is #defined, strtod + * also does extra computations to set the underflow and overflow + * flags when appropriate (i.e., when the result is tiny and + * inexact or when it is a numeric value rounded to +-infinity). + * #define NO_ERRNO if strtod should not assign errno = ERANGE when + * the result overflows to +-Infinity or underflows to 0. + */ + +#include "config.h" +#include "dtoa.h" + +#if COMPILER(MSVC) +#pragma warning(disable: 4244) +#pragma warning(disable: 4245) +#pragma warning(disable: 4554) +#endif + +#if PLATFORM(BIG_ENDIAN) +#define IEEE_MC68k +#else +#define IEEE_8087 +#endif +#define INFNAN_CHECK + + + +#ifndef Long +#define Long int +#endif +#ifndef ULong +typedef unsigned Long ULong; +#endif + +#ifdef DEBUG +#include +#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} +#endif + +#include +#include + +#ifdef MALLOC +#ifdef KR_headers +extern char *MALLOC(); +#else +extern void *MALLOC(size_t); +#endif +#else +#define MALLOC malloc +#endif + +#ifndef Omit_Private_Memory +#ifndef PRIVATE_MEM +#define PRIVATE_MEM 2304 +#endif +#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) +static double private_mem[PRIVATE_mem], *pmem_next = private_mem; +#endif + +#undef IEEE_Arith +#undef Avoid_Underflow +#ifdef IEEE_MC68k +#define IEEE_Arith +#endif +#ifdef IEEE_8087 +#define IEEE_Arith +#endif + +#include + +#ifdef Bad_float_h + +#ifdef IEEE_Arith +#define DBL_DIG 15 +#define DBL_MAX_10_EXP 308 +#define DBL_MAX_EXP 1024 +#define FLT_RADIX 2 +#endif /*IEEE_Arith*/ + +#ifdef IBM +#define DBL_DIG 16 +#define DBL_MAX_10_EXP 75 +#define DBL_MAX_EXP 63 +#define FLT_RADIX 16 +#define DBL_MAX 7.2370055773322621e+75 +#endif + +#ifdef VAX +#define DBL_DIG 16 +#define DBL_MAX_10_EXP 38 +#define DBL_MAX_EXP 127 +#define FLT_RADIX 2 +#define DBL_MAX 1.7014118346046923e+38 +#endif + +#ifndef LONG_MAX +#define LONG_MAX 2147483647 +#endif + +#else /* ifndef Bad_float_h */ +#include +#endif /* Bad_float_h */ + +#ifndef __MATH_H__ +#include +#endif + +#define strtod kjs_strtod +#define dtoa kjs_dtoa +#define freedtoa kjs_freedtoa + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CONST_ +#ifdef KR_headers +#define CONST_ /* blank */ +#else +#define CONST_ const +#endif +#endif + +#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 +Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. +#endif + +typedef union { double d; ULong L[2]; } U; + +#ifdef YES_ALIAS +#define dval(x) x +#ifdef IEEE_8087 +#define word0(x) ((ULong *)&x)[1] +#define word1(x) ((ULong *)&x)[0] +#else +#define word0(x) ((ULong *)&x)[0] +#define word1(x) ((ULong *)&x)[1] +#endif +#else +#ifdef IEEE_8087 +#define word0(x) ((U*)&x)->L[1] +#define word1(x) ((U*)&x)->L[0] +#else +#define word0(x) ((U*)&x)->L[0] +#define word1(x) ((U*)&x)->L[1] +#endif +#define dval(x) ((U*)&x)->d +#endif + +/* The following definition of Storeinc is appropriate for MIPS processors. + * An alternative that might be better on some machines is + * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) + */ +#if defined(IEEE_8087) + defined(VAX) +#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ +((unsigned short *)a)[0] = (unsigned short)c, a++) +#else +#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ +((unsigned short *)a)[1] = (unsigned short)c, a++) +#endif + +/* #define P DBL_MANT_DIG */ +/* Ten_pmax = floor(P*log(2)/log(5)) */ +/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ +/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ +/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ + +#ifdef IEEE_Arith +#define Exp_shift 20 +#define Exp_shift1 20 +#define Exp_msk1 0x100000 +#define Exp_msk11 0x100000 +#define Exp_mask 0x7ff00000 +#define P 53 +#define Bias 1023 +#define Emin (-1022) +#define Exp_1 0x3ff00000 +#define Exp_11 0x3ff00000 +#define Ebits 11 +#define Frac_mask 0xfffff +#define Frac_mask1 0xfffff +#define Ten_pmax 22 +#define Bletch 0x10 +#define Bndry_mask 0xfffff +#define Bndry_mask1 0xfffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 1 +#define Tiny0 0 +#define Tiny1 1 +#define Quick_max 14 +#define Int_max 14 +#ifndef NO_IEEE_Scale +#define Avoid_Underflow +#ifdef Flush_Denorm /* debugging option */ +#undef Sudden_Underflow +#endif +#endif + +#ifndef Flt_Rounds +#ifdef FLT_ROUNDS +#define Flt_Rounds FLT_ROUNDS +#else +#define Flt_Rounds 1 +#endif +#endif /*Flt_Rounds*/ + +#ifdef Honor_FLT_ROUNDS +#define Rounding rounding +#undef Check_FLT_ROUNDS +#define Check_FLT_ROUNDS +#else +#define Rounding Flt_Rounds +#endif + +#else /* ifndef IEEE_Arith */ +#undef Check_FLT_ROUNDS +#undef Honor_FLT_ROUNDS +#undef SET_INEXACT +#undef Sudden_Underflow +#define Sudden_Underflow +#ifdef IBM +#undef Flt_Rounds +#define Flt_Rounds 0 +#define Exp_shift 24 +#define Exp_shift1 24 +#define Exp_msk1 0x1000000 +#define Exp_msk11 0x1000000 +#define Exp_mask 0x7f000000 +#define P 14 +#define Bias 65 +#define Exp_1 0x41000000 +#define Exp_11 0x41000000 +#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ +#define Frac_mask 0xffffff +#define Frac_mask1 0xffffff +#define Bletch 4 +#define Ten_pmax 22 +#define Bndry_mask 0xefffff +#define Bndry_mask1 0xffffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 4 +#define Tiny0 0x100000 +#define Tiny1 0 +#define Quick_max 14 +#define Int_max 15 +#else /* VAX */ +#undef Flt_Rounds +#define Flt_Rounds 1 +#define Exp_shift 23 +#define Exp_shift1 7 +#define Exp_msk1 0x80 +#define Exp_msk11 0x800000 +#define Exp_mask 0x7f80 +#define P 56 +#define Bias 129 +#define Exp_1 0x40800000 +#define Exp_11 0x4080 +#define Ebits 8 +#define Frac_mask 0x7fffff +#define Frac_mask1 0xffff007f +#define Ten_pmax 24 +#define Bletch 2 +#define Bndry_mask 0xffff007f +#define Bndry_mask1 0xffff007f +#define LSB 0x10000 +#define Sign_bit 0x8000 +#define Log2P 1 +#define Tiny0 0x80 +#define Tiny1 0 +#define Quick_max 15 +#define Int_max 15 +#endif /* IBM, VAX */ +#endif /* IEEE_Arith */ + +#ifndef IEEE_Arith +#define ROUND_BIASED +#endif + +#ifdef RND_PRODQUOT +#define rounded_product(a,b) a = rnd_prod(a, b) +#define rounded_quotient(a,b) a = rnd_quot(a, b) +#ifdef KR_headers +extern double rnd_prod(), rnd_quot(); +#else +extern double rnd_prod(double, double), rnd_quot(double, double); +#endif +#else +#define rounded_product(a,b) a *= b +#define rounded_quotient(a,b) a /= b +#endif + +#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) +#define Big1 0xffffffff + +#ifndef Pack_32 +#define Pack_32 +#endif + +#ifdef KR_headers +#define FFFFFFFF ((((unsigned long)0xffff)<<16)|(unsigned long)0xffff) +#else +#define FFFFFFFF 0xffffffffUL +#endif + +#ifdef NO_LONG_LONG +#undef ULLong +#ifdef Just_16 +#undef Pack_32 +/* When Pack_32 is not defined, we store 16 bits per 32-bit Long. + * This makes some inner loops simpler and sometimes saves work + * during multiplications, but it often seems to make things slightly + * slower. Hence the default is now to store 32 bits per Long. + */ +#endif +#else /* long long available */ +#ifndef Llong +#define Llong long long +#endif +#ifndef ULLong +#define ULLong unsigned Llong +#endif +#endif /* NO_LONG_LONG */ + +#ifndef MULTIPLE_THREADS +#define ACQUIRE_DTOA_LOCK(n) /*nothing*/ +#define FREE_DTOA_LOCK(n) /*nothing*/ +#endif + +#define Kmax 15 + + struct +Bigint { + struct Bigint *next; + int k, maxwds, sign, wds; + ULong x[1]; + }; + + typedef struct Bigint Bigint; + + static Bigint *freelist[Kmax+1]; + + static Bigint * +Balloc +#ifdef KR_headers + (k) int k; +#else + (int k) +#endif +{ + int x; + Bigint *rv; +#ifndef Omit_Private_Memory + unsigned int len; +#endif + + ACQUIRE_DTOA_LOCK(0); + if ((rv = freelist[k])) { + freelist[k] = rv->next; + } + else { + x = 1 << k; +#ifdef Omit_Private_Memory + rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); +#else + len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) + /sizeof(double); + if (pmem_next - private_mem + len <= (unsigned)PRIVATE_mem) { + rv = (Bigint*)pmem_next; + pmem_next += len; + } + else + rv = (Bigint*)MALLOC(len*sizeof(double)); +#endif + rv->k = k; + rv->maxwds = x; + } + FREE_DTOA_LOCK(0); + rv->sign = rv->wds = 0; + return rv; + } + + static void +Bfree +#ifdef KR_headers + (v) Bigint *v; +#else + (Bigint *v) +#endif +{ + if (v) { + ACQUIRE_DTOA_LOCK(0); + v->next = freelist[v->k]; + freelist[v->k] = v; + FREE_DTOA_LOCK(0); + } + } + +#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \ +y->wds*sizeof(Long) + 2*sizeof(int)) + + static Bigint * +multadd +#ifdef KR_headers + (b, m, a) Bigint *b; int m, a; +#else + (Bigint *b, int m, int a) /* multiply by m and add a */ +#endif +{ + int i, wds; +#ifdef ULLong + ULong *x; + ULLong carry, y; +#else + ULong carry, *x, y; +#ifdef Pack_32 + ULong xi, z; +#endif +#endif + Bigint *b1; + + wds = b->wds; + x = b->x; + i = 0; + carry = a; + do { +#ifdef ULLong + y = *x * (ULLong)m + carry; + carry = y >> 32; + *x++ = (ULong)y & FFFFFFFF; +#else +#ifdef Pack_32 + xi = *x; + y = (xi & 0xffff) * m + carry; + z = (xi >> 16) * m + (y >> 16); + carry = z >> 16; + *x++ = (z << 16) + (y & 0xffff); +#else + y = *x * m + carry; + carry = y >> 16; + *x++ = y & 0xffff; +#endif +#endif + } + while(++i < wds); + if (carry) { + if (wds >= b->maxwds) { + b1 = Balloc(b->k+1); + Bcopy(b1, b); + Bfree(b); + b = b1; + } + b->x[wds++] = (ULong)carry; + b->wds = wds; + } + return b; + } + + static Bigint * +s2b +#ifdef KR_headers + (s, nd0, nd, y9) CONST_ char *s; int nd0, nd; ULong y9; +#else + (CONST_ char *s, int nd0, int nd, ULong y9) +#endif +{ + Bigint *b; + int i, k; + Long x, y; + + x = (nd + 8) / 9; + for(k = 0, y = 1; x > y; y <<= 1, k++) ; +#ifdef Pack_32 + b = Balloc(k); + b->x[0] = y9; + b->wds = 1; +#else + b = Balloc(k+1); + b->x[0] = y9 & 0xffff; + b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; +#endif + + i = 9; + if (9 < nd0) { + s += 9; + do b = multadd(b, 10, *s++ - '0'); + while(++i < nd0); + s++; + } + else + s += 10; + for(; i < nd; i++) + b = multadd(b, 10, *s++ - '0'); + return b; + } + + static int +hi0bits +#ifdef KR_headers + (x) register ULong x; +#else + (register ULong x) +#endif +{ + register int k = 0; + + if (!(x & 0xffff0000)) { + k = 16; + x <<= 16; + } + if (!(x & 0xff000000)) { + k += 8; + x <<= 8; + } + if (!(x & 0xf0000000)) { + k += 4; + x <<= 4; + } + if (!(x & 0xc0000000)) { + k += 2; + x <<= 2; + } + if (!(x & 0x80000000)) { + k++; + if (!(x & 0x40000000)) + return 32; + } + return k; + } + + static int +lo0bits +#ifdef KR_headers + (y) ULong *y; +#else + (ULong *y) +#endif +{ + register int k; + register ULong x = *y; + + if (x & 7) { + if (x & 1) + return 0; + if (x & 2) { + *y = x >> 1; + return 1; + } + *y = x >> 2; + return 2; + } + k = 0; + if (!(x & 0xffff)) { + k = 16; + x >>= 16; + } + if (!(x & 0xff)) { + k += 8; + x >>= 8; + } + if (!(x & 0xf)) { + k += 4; + x >>= 4; + } + if (!(x & 0x3)) { + k += 2; + x >>= 2; + } + if (!(x & 1)) { + k++; + x >>= 1; + if (!x & 1) + return 32; + } + *y = x; + return k; + } + + static Bigint * +i2b +#ifdef KR_headers + (i) int i; +#else + (int i) +#endif +{ + Bigint *b; + + b = Balloc(1); + b->x[0] = i; + b->wds = 1; + return b; + } + + static Bigint * +mult +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + Bigint *c; + int k, wa, wb, wc; + ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; + ULong y; +#ifdef ULLong + ULLong carry, z; +#else + ULong carry, z; +#ifdef Pack_32 + ULong z2; +#endif +#endif + + if (a->wds < b->wds) { + c = a; + a = b; + b = c; + } + k = a->k; + wa = a->wds; + wb = b->wds; + wc = wa + wb; + if (wc > a->maxwds) + k++; + c = Balloc(k); + for(x = c->x, xa = x + wc; x < xa; x++) + *x = 0; + xa = a->x; + xae = xa + wa; + xb = b->x; + xbe = xb + wb; + xc0 = c->x; +#ifdef ULLong + for(; xb < xbe; xc0++) { + if ((y = *xb++)) { + x = xa; + xc = xc0; + carry = 0; + do { + z = *x++ * (ULLong)y + *xc + carry; + carry = z >> 32; + *xc++ = (ULong)z & FFFFFFFF; + } + while(x < xae); + *xc = (ULong)carry; + } + } +#else +#ifdef Pack_32 + for(; xb < xbe; xb++, xc0++) { + if (y = *xb & 0xffff) { + x = xa; + xc = xc0; + carry = 0; + do { + z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; + carry = z >> 16; + z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; + carry = z2 >> 16; + Storeinc(xc, z2, z); + } + while(x < xae); + *xc = carry; + } + if (y = *xb >> 16) { + x = xa; + xc = xc0; + carry = 0; + z2 = *xc; + do { + z = (*x & 0xffff) * y + (*xc >> 16) + carry; + carry = z >> 16; + Storeinc(xc, z, z2); + z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; + carry = z2 >> 16; + } + while(x < xae); + *xc = z2; + } + } +#else + for(; xb < xbe; xc0++) { + if (y = *xb++) { + x = xa; + xc = xc0; + carry = 0; + do { + z = *x++ * y + *xc + carry; + carry = z >> 16; + *xc++ = z & 0xffff; + } + while(x < xae); + *xc = carry; + } + } +#endif +#endif + for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; + c->wds = wc; + return c; + } + + static Bigint *p5s; + + static Bigint * +pow5mult +#ifdef KR_headers + (b, k) Bigint *b; int k; +#else + (Bigint *b, int k) +#endif +{ + Bigint *b1, *p5, *p51; + int i; + static int p05[3] = { 5, 25, 125 }; + + if ((i = k & 3)) + b = multadd(b, p05[i-1], 0); + + if (!(k >>= 2)) + return b; + if (!(p5 = p5s)) { + /* first time */ +#ifdef MULTIPLE_THREADS + ACQUIRE_DTOA_LOCK(1); + if (!(p5 = p5s)) { + p5 = p5s = i2b(625); + p5->next = 0; + } + FREE_DTOA_LOCK(1); +#else + p5 = p5s = i2b(625); + p5->next = 0; +#endif + } + for(;;) { + if (k & 1) { + b1 = mult(b, p5); + Bfree(b); + b = b1; + } + if (!(k >>= 1)) + break; + if (!(p51 = p5->next)) { +#ifdef MULTIPLE_THREADS + ACQUIRE_DTOA_LOCK(1); + if (!(p51 = p5->next)) { + p51 = p5->next = mult(p5,p5); + p51->next = 0; + } + FREE_DTOA_LOCK(1); +#else + p51 = p5->next = mult(p5,p5); + p51->next = 0; +#endif + } + p5 = p51; + } + return b; + } + + static Bigint * +lshift +#ifdef KR_headers + (b, k) Bigint *b; int k; +#else + (Bigint *b, int k) +#endif +{ + int i, k1, n, n1; + Bigint *b1; + ULong *x, *x1, *xe, z; + +#ifdef Pack_32 + n = k >> 5; +#else + n = k >> 4; +#endif + k1 = b->k; + n1 = n + b->wds + 1; + for(i = b->maxwds; n1 > i; i <<= 1) + k1++; + b1 = Balloc(k1); + x1 = b1->x; + for(i = 0; i < n; i++) + *x1++ = 0; + x = b->x; + xe = x + b->wds; +#ifdef Pack_32 + if (k &= 0x1f) { + k1 = 32 - k; + z = 0; + do { + *x1++ = *x << k | z; + z = *x++ >> k1; + } + while(x < xe); + if ((*x1 = z)) + ++n1; + } +#else + if (k &= 0xf) { + k1 = 16 - k; + z = 0; + do { + *x1++ = *x << k & 0xffff | z; + z = *x++ >> k1; + } + while(x < xe); + if (*x1 = z) + ++n1; + } +#endif + else do + *x1++ = *x++; + while(x < xe); + b1->wds = n1 - 1; + Bfree(b); + return b1; + } + + static int +cmp +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + ULong *xa, *xa0, *xb, *xb0; + int i, j; + + i = a->wds; + j = b->wds; +#ifdef DEBUG + if (i > 1 && !a->x[i-1]) + Bug("cmp called with a->x[a->wds-1] == 0"); + if (j > 1 && !b->x[j-1]) + Bug("cmp called with b->x[b->wds-1] == 0"); +#endif + if (i -= j) + return i; + xa0 = a->x; + xa = xa0 + j; + xb0 = b->x; + xb = xb0 + j; + for(;;) { + if (*--xa != *--xb) + return *xa < *xb ? -1 : 1; + if (xa <= xa0) + break; + } + return 0; + } + + static Bigint * +diff +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + Bigint *c; + int i, wa, wb; + ULong *xa, *xae, *xb, *xbe, *xc; +#ifdef ULLong + ULLong borrow, y; +#else + ULong borrow, y; +#ifdef Pack_32 + ULong z; +#endif +#endif + + i = cmp(a,b); + if (!i) { + c = Balloc(0); + c->wds = 1; + c->x[0] = 0; + return c; + } + if (i < 0) { + c = a; + a = b; + b = c; + i = 1; + } + else + i = 0; + c = Balloc(a->k); + c->sign = i; + wa = a->wds; + xa = a->x; + xae = xa + wa; + wb = b->wds; + xb = b->x; + xbe = xb + wb; + xc = c->x; + borrow = 0; +#ifdef ULLong + do { + y = (ULLong)*xa++ - *xb++ - borrow; + borrow = y >> 32 & (ULong)1; + *xc++ = (ULong)y & FFFFFFFF; + } + while(xb < xbe); + while(xa < xae) { + y = *xa++ - borrow; + borrow = y >> 32 & (ULong)1; + *xc++ = (ULong)y & FFFFFFFF; + } +#else +#ifdef Pack_32 + do { + y = (*xa & 0xffff) - (*xb & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*xa++ >> 16) - (*xb++ >> 16) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } + while(xb < xbe); + while(xa < xae) { + y = (*xa & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*xa++ >> 16) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(xc, z, y); + } +#else + do { + y = *xa++ - *xb++ - borrow; + borrow = (y & 0x10000) >> 16; + *xc++ = y & 0xffff; + } + while(xb < xbe); + while(xa < xae) { + y = *xa++ - borrow; + borrow = (y & 0x10000) >> 16; + *xc++ = y & 0xffff; + } +#endif +#endif + while(!*--xc) + wa--; + c->wds = wa; + return c; + } + + static double +ulp +#ifdef KR_headers + (x) double x; +#else + (double x) +#endif +{ + register Long L; + double a; + + L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; +#ifndef Avoid_Underflow +#ifndef Sudden_Underflow + if (L > 0) { +#endif +#endif +#ifdef IBM + L |= Exp_msk1 >> 4; +#endif + word0(a) = L; + word1(a) = 0; +#ifndef Avoid_Underflow +#ifndef Sudden_Underflow + } + else { + L = -L >> Exp_shift; + if (L < Exp_shift) { + word0(a) = 0x80000 >> L; + word1(a) = 0; + } + else { + word0(a) = 0; + L -= Exp_shift; + word1(a) = L >= 31 ? 1 : 1 << 31 - L; + } + } +#endif +#endif + return dval(a); + } + + static double +b2d +#ifdef KR_headers + (a, e) Bigint *a; int *e; +#else + (Bigint *a, int *e) +#endif +{ + ULong *xa, *xa0, w, y, z; + int k; + double d; +#ifdef VAX + ULong d0, d1; +#else +#define d0 word0(d) +#define d1 word1(d) +#endif + + xa0 = a->x; + xa = xa0 + a->wds; + y = *--xa; +#ifdef DEBUG + if (!y) Bug("zero y in b2d"); +#endif + k = hi0bits(y); + *e = 32 - k; +#ifdef Pack_32 + if (k < Ebits) { + d0 = Exp_1 | y >> Ebits - k; + w = xa > xa0 ? *--xa : 0; + d1 = y << (32-Ebits) + k | w >> Ebits - k; + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + if (k -= Ebits) { + d0 = Exp_1 | y << k | z >> 32 - k; + y = xa > xa0 ? *--xa : 0; + d1 = z << k | y >> 32 - k; + } + else { + d0 = Exp_1 | y; + d1 = z; + } +#else + if (k < Ebits + 16) { + z = xa > xa0 ? *--xa : 0; + d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k; + w = xa > xa0 ? *--xa : 0; + y = xa > xa0 ? *--xa : 0; + d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + w = xa > xa0 ? *--xa : 0; + k -= Ebits + 16; + d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k; + y = xa > xa0 ? *--xa : 0; + d1 = w << k + 16 | y << k; +#endif + ret_d: +#ifdef VAX + word0(d) = d0 >> 16 | d0 << 16; + word1(d) = d1 >> 16 | d1 << 16; +#else +#undef d0 +#undef d1 +#endif + return dval(d); + } + + static Bigint * +d2b +#ifdef KR_headers + (d, e, bits) double d; int *e, *bits; +#else + (double d, int *e, int *bits) +#endif +{ + Bigint *b; + int de, k; + ULong *x, y, z; +#ifndef Sudden_Underflow + int i; +#endif +#ifdef VAX + ULong d0, d1; + d0 = word0(d) >> 16 | word0(d) << 16; + d1 = word1(d) >> 16 | word1(d) << 16; +#else +#define d0 word0(d) +#define d1 word1(d) +#endif + +#ifdef Pack_32 + b = Balloc(1); +#else + b = Balloc(2); +#endif + x = b->x; + + z = d0 & Frac_mask; + d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ +#ifdef Sudden_Underflow + de = (int)(d0 >> Exp_shift); +#ifndef IBM + z |= Exp_msk11; +#endif +#else + if ((de = (int)(d0 >> Exp_shift))) + z |= Exp_msk1; +#endif +#ifdef Pack_32 + if ((y = d1)) { + if ((k = lo0bits(&y))) { + x[0] = y | z << 32 - k; + z >>= k; + } + else + x[0] = y; +#ifndef Sudden_Underflow + i = +#endif + b->wds = (x[1] = z) ? 2 : 1; + } + else { +#ifdef DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + x[0] = z; +#ifndef Sudden_Underflow + i = +#endif + b->wds = 1; + k += 32; + } +#else + if (y = d1) { + if (k = lo0bits(&y)) + if (k >= 16) { + x[0] = y | z << 32 - k & 0xffff; + x[1] = z >> k - 16 & 0xffff; + x[2] = z >> k; + i = 2; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16 | z << 16 - k & 0xffff; + x[2] = z >> k & 0xffff; + x[3] = z >> k+16; + i = 3; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16; + x[2] = z & 0xffff; + x[3] = z >> 16; + i = 3; + } + } + else { +#ifdef DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + if (k >= 16) { + x[0] = z; + i = 0; + } + else { + x[0] = z & 0xffff; + x[1] = z >> 16; + i = 1; + } + k += 32; + } + while(!x[i]) + --i; + b->wds = i + 1; +#endif +#ifndef Sudden_Underflow + if (de) { +#endif +#ifdef IBM + *e = (de - Bias - (P-1) << 2) + k; + *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask); +#else + *e = de - Bias - (P-1) + k; + *bits = P - k; +#endif +#ifndef Sudden_Underflow + } + else { + *e = de - Bias - (P-1) + 1 + k; +#ifdef Pack_32 + *bits = 32*i - hi0bits(x[i-1]); +#else + *bits = (i+2)*16 - hi0bits(x[i]); +#endif + } +#endif + return b; + } +#undef d0 +#undef d1 + + static double +ratio +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + double da, db; + int k, ka, kb; + + dval(da) = b2d(a, &ka); + dval(db) = b2d(b, &kb); +#ifdef Pack_32 + k = ka - kb + 32*(a->wds - b->wds); +#else + k = ka - kb + 16*(a->wds - b->wds); +#endif +#ifdef IBM + if (k > 0) { + word0(da) += (k >> 2)*Exp_msk1; + if (k &= 3) + dval(da) *= 1 << k; + } + else { + k = -k; + word0(db) += (k >> 2)*Exp_msk1; + if (k &= 3) + dval(db) *= 1 << k; + } +#else + if (k > 0) + word0(da) += k*Exp_msk1; + else { + k = -k; + word0(db) += k*Exp_msk1; + } +#endif + return dval(da) / dval(db); + } + + static CONST_ double +tens[] = { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22 +#ifdef VAX + , 1e23, 1e24 +#endif + }; + + static CONST_ double +#ifdef IEEE_Arith +bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; +static CONST_ double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, +#ifdef Avoid_Underflow + 9007199254740992.*9007199254740992.e-256 + /* = 2^106 * 1e-53 */ +#else + 1e-256 +#endif + }; +/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */ +/* flag unnecessarily. It leads to a song and dance at the end of strtod. */ +#define Scale_Bit 0x10 +#define n_bigtens 5 +#else +#ifdef IBM +bigtens[] = { 1e16, 1e32, 1e64 }; +static CONST_ double tinytens[] = { 1e-16, 1e-32, 1e-64 }; +#define n_bigtens 3 +#else +bigtens[] = { 1e16, 1e32 }; +static CONST_ double tinytens[] = { 1e-16, 1e-32 }; +#define n_bigtens 2 +#endif +#endif + +#ifndef IEEE_Arith +#undef INFNAN_CHECK +#endif + +#ifdef INFNAN_CHECK + +#ifndef NAN_WORD0 +#define NAN_WORD0 0x7ff80000 +#endif + +#ifndef NAN_WORD1 +#define NAN_WORD1 0 +#endif + + static int +match +#ifdef KR_headers + (sp, t) char **sp, *t; +#else + (CONST_ char **sp, CONST_ char *t) +#endif +{ + int c, d; + CONST_ char *s = *sp; + + while((d = *t++)) { + if ((c = *++s) >= 'A' && c <= 'Z') + c += 'a' - 'A'; + if (c != d) + return 0; + } + *sp = s + 1; + return 1; + } + +#ifndef No_Hex_NaN + static void +hexnan +#ifdef KR_headers + (rvp, sp) double *rvp; CONST_ char **sp; +#else + (double *rvp, CONST_ char **sp) +#endif +{ + ULong c, x[2]; + CONST_ char *s; + int havedig, udx0, xshift; + + x[0] = x[1] = 0; + havedig = xshift = 0; + udx0 = 1; + s = *sp; + while((c = *(CONST_ unsigned char*)++s)) { + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'a' && c <= 'f') + c += 10 - 'a'; + else if (c >= 'A' && c <= 'F') + c += 10 - 'A'; + else if (c <= ' ') { + if (udx0 && havedig) { + udx0 = 0; + xshift = 1; + } + continue; + } + else if (/*(*/ c == ')' && havedig) { + *sp = s + 1; + break; + } + else + return; /* invalid form: don't change *sp */ + havedig = 1; + if (xshift) { + xshift = 0; + x[0] = x[1]; + x[1] = 0; + } + if (udx0) + x[0] = (x[0] << 4) | (x[1] >> 28); + x[1] = (x[1] << 4) | c; + } + if ((x[0] &= 0xfffff) || x[1]) { + word0(*rvp) = Exp_mask | x[0]; + word1(*rvp) = x[1]; + } + } +#endif /*No_Hex_NaN*/ +#endif /* INFNAN_CHECK */ + + double +strtod +#ifdef KR_headers + (s00, se) CONST_ char *s00; char **se; +#else + (CONST_ char *s00, char **se) +#endif +{ +#ifdef Avoid_Underflow + int scale; +#endif + int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, + e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; + CONST_ char *s, *s0, *s1; + double aadj, aadj1, adj, rv, rv0; + Long L; + ULong y, z; + Bigint *bb = NULL, *bb1 = NULL, *bd = NULL, *bd0 = NULL, *bs = NULL, *delta = NULL; +#ifdef SET_INEXACT + int inexact, oldinexact; +#endif +#ifdef Honor_FLT_ROUNDS + int rounding; +#endif + + sign = nz0 = nz = 0; + dval(rv) = 0.; + for(s = s00;;s++) switch(*s) { + case '-': + sign = 1; + /* no break */ + case '+': + if (*++s) + goto break2; + /* no break */ + case 0: + goto ret0; + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case ' ': + continue; + default: + goto break2; + } + break2: + if (*s == '0') { + nz0 = 1; + while(*++s == '0') ; + if (!*s) + goto ret; + } + s0 = s; + y = z = 0; + for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) + if (nd < 9) + y = 10*y + c - '0'; + else if (nd < 16) + z = 10*z + c - '0'; + nd0 = nd; + if (c == '.') { + c = *++s; + if (!nd) { + for(; c == '0'; c = *++s) + nz++; + if (c > '0' && c <= '9') { + s0 = s; + nf += nz; + nz = 0; + goto have_dig; + } + goto dig_done; + } + for(; c >= '0' && c <= '9'; c = *++s) { + have_dig: + nz++; + if (c -= '0') { + nf += nz; + for(i = 1; i < nz; i++) + if (nd++ < 9) + y *= 10; + else if (nd <= DBL_DIG + 1) + z *= 10; + if (nd++ < 9) + y = 10*y + c; + else if (nd <= DBL_DIG + 1) + z = 10*z + c; + nz = 0; + } + } + } + dig_done: + e = 0; + if (c == 'e' || c == 'E') { + if (!nd && !nz && !nz0) { + goto ret0; + } + s00 = s; + esign = 0; + switch(c = *++s) { + case '-': + esign = 1; + case '+': + c = *++s; + } + if (c >= '0' && c <= '9') { + while(c == '0') + c = *++s; + if (c > '0' && c <= '9') { + L = c - '0'; + s1 = s; + while((c = *++s) >= '0' && c <= '9') + L = 10*L + c - '0'; + if (s - s1 > 8 || L > 19999) + /* Avoid confusion from exponents + * so large that e might overflow. + */ + e = 19999; /* safe for 16 bit ints */ + else + e = (int)L; + if (esign) + e = -e; + } + else + e = 0; + } + else + s = s00; + } + if (!nd) { + if (!nz && !nz0) { +#ifdef INFNAN_CHECK + /* Check for Nan and Infinity */ + switch(c) { + case 'i': + case 'I': + if (match(&s,"nf")) { + --s; + if (!match(&s,"inity")) + ++s; + word0(rv) = 0x7ff00000; + word1(rv) = 0; + goto ret; + } + break; + case 'n': + case 'N': + if (match(&s, "an")) { + word0(rv) = NAN_WORD0; + word1(rv) = NAN_WORD1; +#ifndef No_Hex_NaN + if (*s == '(') /*)*/ + hexnan(&rv, &s); +#endif + goto ret; + } + } +#endif /* INFNAN_CHECK */ + ret0: + s = s00; + sign = 0; + } + goto ret; + } + e1 = e -= nf; + + /* Now we have nd0 digits, starting at s0, followed by a + * decimal point, followed by nd-nd0 digits. The number we're + * after is the integer represented by those digits times + * 10**e */ + + if (!nd0) + nd0 = nd; + k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; + dval(rv) = y; + if (k > 9) { +#ifdef SET_INEXACT + if (k > DBL_DIG) + oldinexact = get_inexact(); +#endif + dval(rv) = tens[k - 9] * dval(rv) + z; + } + bd0 = 0; + if (nd <= DBL_DIG +#ifndef RND_PRODQUOT +#ifndef Honor_FLT_ROUNDS + && Flt_Rounds == 1 +#endif +#endif + ) { + if (!e) + goto ret; + if (e > 0) { + if (e <= Ten_pmax) { +#ifdef VAX + goto vax_ovfl_check; +#else +#ifdef Honor_FLT_ROUNDS + /* round correctly FLT_ROUNDS = 2 or 3 */ + if (sign) { + rv = -rv; + sign = 0; + } +#endif + /* rv = */ rounded_product(dval(rv), tens[e]); + goto ret; +#endif + } + i = DBL_DIG - nd; + if (e <= Ten_pmax + i) { + /* A fancier test would sometimes let us do + * this for larger i values. + */ +#ifdef Honor_FLT_ROUNDS + /* round correctly FLT_ROUNDS = 2 or 3 */ + if (sign) { + rv = -rv; + sign = 0; + } +#endif + e -= i; + dval(rv) *= tens[i]; +#ifdef VAX + /* VAX exponent range is so narrow we must + * worry about overflow here... + */ + vax_ovfl_check: + word0(rv) -= P*Exp_msk1; + /* rv = */ rounded_product(dval(rv), tens[e]); + if ((word0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) + goto ovfl; + word0(rv) += P*Exp_msk1; +#else + /* rv = */ rounded_product(dval(rv), tens[e]); +#endif + goto ret; + } + } +#ifndef Inaccurate_Divide + else if (e >= -Ten_pmax) { +#ifdef Honor_FLT_ROUNDS + /* round correctly FLT_ROUNDS = 2 or 3 */ + if (sign) { + rv = -rv; + sign = 0; + } +#endif + /* rv = */ rounded_quotient(dval(rv), tens[-e]); + goto ret; + } +#endif + } + e1 += nd - k; + +#ifdef IEEE_Arith +#ifdef SET_INEXACT + inexact = 1; + if (k <= DBL_DIG) + oldinexact = get_inexact(); +#endif +#ifdef Avoid_Underflow + scale = 0; +#endif +#ifdef Honor_FLT_ROUNDS + if ((rounding = Flt_Rounds) >= 2) { + if (sign) + rounding = rounding == 2 ? 0 : 2; + else + if (rounding != 2) + rounding = 0; + } +#endif +#endif /*IEEE_Arith*/ + + /* Get starting approximation = rv * 10**e1 */ + + if (e1 > 0) { + if ((i = e1 & 15)) + dval(rv) *= tens[i]; + if (e1 &= ~15) { + if (e1 > DBL_MAX_10_EXP) { + ovfl: +#ifndef NO_ERRNO + errno = ERANGE; +#endif + /* Can't trust HUGE_VAL */ +#ifdef IEEE_Arith +#ifdef Honor_FLT_ROUNDS + switch(rounding) { + case 0: /* toward 0 */ + case 3: /* toward -infinity */ + word0(rv) = Big0; + word1(rv) = Big1; + break; + default: + word0(rv) = Exp_mask; + word1(rv) = 0; + } +#else /*Honor_FLT_ROUNDS*/ + word0(rv) = Exp_mask; + word1(rv) = 0; +#endif /*Honor_FLT_ROUNDS*/ +#ifdef SET_INEXACT + /* set overflow bit */ + dval(rv0) = 1e300; + dval(rv0) *= dval(rv0); +#endif +#else /*IEEE_Arith*/ + word0(rv) = Big0; + word1(rv) = Big1; +#endif /*IEEE_Arith*/ + if (bd0) + goto retfree; + goto ret; + } + e1 >>= 4; + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + dval(rv) *= bigtens[j]; + /* The last multiplication could overflow. */ + word0(rv) -= P*Exp_msk1; + dval(rv) *= bigtens[j]; + if ((z = word0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-P)) + goto ovfl; + if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { + /* set to largest number */ + /* (Can't trust DBL_MAX) */ + word0(rv) = Big0; + word1(rv) = Big1; + } + else + word0(rv) += P*Exp_msk1; + } + } + else if (e1 < 0) { + e1 = -e1; + if ((i = e1 & 15)) + dval(rv) /= tens[i]; + if (e1 >>= 4) { + if (e1 >= 1 << n_bigtens) + goto undfl; +#ifdef Avoid_Underflow + if (e1 & Scale_Bit) + scale = 2*P; + for(j = 0; e1 > 0; j++, e1 >>= 1) + if (e1 & 1) + dval(rv) *= tinytens[j]; + if (scale && (j = 2*P + 1 - ((word0(rv) & Exp_mask) + >> Exp_shift)) > 0) { + /* scaled rv is denormal; zap j low bits */ + if (j >= 32) { + word1(rv) = 0; + if (j >= 53) + word0(rv) = (P+2)*Exp_msk1; + else + word0(rv) &= 0xffffffff << j-32; + } + else + word1(rv) &= 0xffffffff << j; + } +#else + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + dval(rv) *= tinytens[j]; + /* The last multiplication could underflow. */ + dval(rv0) = dval(rv); + dval(rv) *= tinytens[j]; + if (!dval(rv)) { + dval(rv) = 2.*dval(rv0); + dval(rv) *= tinytens[j]; +#endif + if (!dval(rv)) { + undfl: + dval(rv) = 0.; +#ifndef NO_ERRNO + errno = ERANGE; +#endif + if (bd0) + goto retfree; + goto ret; + } +#ifndef Avoid_Underflow + word0(rv) = Tiny0; + word1(rv) = Tiny1; + /* The refinement below will clean + * this approximation up. + */ + } +#endif + } + } + + /* Now the hard part -- adjusting rv to the correct value.*/ + + /* Put digits into bd: true value = bd * 10^e */ + + bd0 = s2b(s0, nd0, nd, y); + + for(;;) { + bd = Balloc(bd0->k); + Bcopy(bd, bd0); + bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */ + bs = i2b(1); + + if (e >= 0) { + bb2 = bb5 = 0; + bd2 = bd5 = e; + } + else { + bb2 = bb5 = -e; + bd2 = bd5 = 0; + } + if (bbe >= 0) + bb2 += bbe; + else + bd2 -= bbe; + bs2 = bb2; +#ifdef Honor_FLT_ROUNDS + if (rounding != 1) + bs2++; +#endif +#ifdef Avoid_Underflow + j = bbe - scale; + i = j + bbbits - 1; /* logb(rv) */ + if (i < Emin) /* denormal */ + j += P - Emin; + else + j = P + 1 - bbbits; +#else /*Avoid_Underflow*/ +#ifdef Sudden_Underflow +#ifdef IBM + j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); +#else + j = P + 1 - bbbits; +#endif +#else /*Sudden_Underflow*/ + j = bbe; + i = j + bbbits - 1; /* logb(rv) */ + if (i < Emin) /* denormal */ + j += P - Emin; + else + j = P + 1 - bbbits; +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + bb2 += j; + bd2 += j; +#ifdef Avoid_Underflow + bd2 += scale; +#endif + i = bb2 < bd2 ? bb2 : bd2; + if (i > bs2) + i = bs2; + if (i > 0) { + bb2 -= i; + bd2 -= i; + bs2 -= i; + } + if (bb5 > 0) { + bs = pow5mult(bs, bb5); + bb1 = mult(bs, bb); + Bfree(bb); + bb = bb1; + } + if (bb2 > 0) + bb = lshift(bb, bb2); + if (bd5 > 0) + bd = pow5mult(bd, bd5); + if (bd2 > 0) + bd = lshift(bd, bd2); + if (bs2 > 0) + bs = lshift(bs, bs2); + delta = diff(bb, bd); + dsign = delta->sign; + delta->sign = 0; + i = cmp(delta, bs); +#ifdef Honor_FLT_ROUNDS + if (rounding != 1) { + if (i < 0) { + /* Error is less than an ulp */ + if (!delta->x[0] && delta->wds <= 1) { + /* exact */ +#ifdef SET_INEXACT + inexact = 0; +#endif + break; + } + if (rounding) { + if (dsign) { + adj = 1.; + goto apply_adj; + } + } + else if (!dsign) { + adj = -1.; + if (!word1(rv) + && !(word0(rv) & Frac_mask)) { + y = word0(rv) & Exp_mask; +#ifdef Avoid_Underflow + if (!scale || y > 2*P*Exp_msk1) +#else + if (y) +#endif + { + delta = lshift(delta,Log2P); + if (cmp(delta, bs) <= 0) + adj = -0.5; + } + } + apply_adj: +#ifdef Avoid_Underflow + if (scale && (y = word0(rv) & Exp_mask) + <= 2*P*Exp_msk1) + word0(adj) += (2*P+1)*Exp_msk1 - y; +#else +#ifdef Sudden_Underflow + if ((word0(rv) & Exp_mask) <= + P*Exp_msk1) { + word0(rv) += P*Exp_msk1; + dval(rv) += adj*ulp(dval(rv)); + word0(rv) -= P*Exp_msk1; + } + else +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + dval(rv) += adj*ulp(dval(rv)); + } + break; + } + adj = ratio(delta, bs); + if (adj < 1.) + adj = 1.; + if (adj <= 0x7ffffffe) { + /* adj = rounding ? ceil(adj) : floor(adj); */ + y = adj; + if (y != adj) { + if (!((rounding>>1) ^ dsign)) + y++; + adj = y; + } + } +#ifdef Avoid_Underflow + if (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1) + word0(adj) += (2*P+1)*Exp_msk1 - y; +#else +#ifdef Sudden_Underflow + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { + word0(rv) += P*Exp_msk1; + adj *= ulp(dval(rv)); + if (dsign) + dval(rv) += adj; + else + dval(rv) -= adj; + word0(rv) -= P*Exp_msk1; + goto cont; + } +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + adj *= ulp(dval(rv)); + if (dsign) + dval(rv) += adj; + else + dval(rv) -= adj; + goto cont; + } +#endif /*Honor_FLT_ROUNDS*/ + + if (i < 0) { + /* Error is less than half an ulp -- check for + * special case of mantissa a power of two. + */ + if (dsign || word1(rv) || word0(rv) & Bndry_mask +#ifdef IEEE_Arith +#ifdef Avoid_Underflow + || (word0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1 +#else + || (word0(rv) & Exp_mask) <= Exp_msk1 +#endif +#endif + ) { +#ifdef SET_INEXACT + if (!delta->x[0] && delta->wds <= 1) + inexact = 0; +#endif + break; + } + if (!delta->x[0] && delta->wds <= 1) { + /* exact result */ +#ifdef SET_INEXACT + inexact = 0; +#endif + break; + } + delta = lshift(delta,Log2P); + if (cmp(delta, bs) > 0) + goto drop_down; + break; + } + if (i == 0) { + /* exactly half-way between */ + if (dsign) { + if ((word0(rv) & Bndry_mask1) == Bndry_mask1 + && word1(rv) == ( +#ifdef Avoid_Underflow + (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1) + ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) : +#endif + 0xffffffff)) { + /*boundary case -- increment exponent*/ + word0(rv) = (word0(rv) & Exp_mask) + + Exp_msk1 +#ifdef IBM + | Exp_msk1 >> 4 +#endif + ; + word1(rv) = 0; +#ifdef Avoid_Underflow + dsign = 0; +#endif + break; + } + } + else if (!(word0(rv) & Bndry_mask) && !word1(rv)) { + drop_down: + /* boundary case -- decrement exponent */ +#ifdef Sudden_Underflow /*{{*/ + L = word0(rv) & Exp_mask; +#ifdef IBM + if (L < Exp_msk1) +#else +#ifdef Avoid_Underflow + if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1)) +#else + if (L <= Exp_msk1) +#endif /*Avoid_Underflow*/ +#endif /*IBM*/ + goto undfl; + L -= Exp_msk1; +#else /*Sudden_Underflow}{*/ +#ifdef Avoid_Underflow + if (scale) { + L = word0(rv) & Exp_mask; + if (L <= (2*P+1)*Exp_msk1) { + if (L > (P+2)*Exp_msk1) + /* round even ==> */ + /* accept rv */ + break; + /* rv = smallest denormal */ + goto undfl; + } + } +#endif /*Avoid_Underflow*/ + L = (word0(rv) & Exp_mask) - Exp_msk1; +#endif /*Sudden_Underflow}}*/ + word0(rv) = L | Bndry_mask1; + word1(rv) = 0xffffffff; +#ifdef IBM + goto cont; +#else + break; +#endif + } +#ifndef ROUND_BIASED + if (!(word1(rv) & LSB)) + break; +#endif + if (dsign) + dval(rv) += ulp(dval(rv)); +#ifndef ROUND_BIASED + else { + dval(rv) -= ulp(dval(rv)); +#ifndef Sudden_Underflow + if (!dval(rv)) + goto undfl; +#endif + } +#ifdef Avoid_Underflow + dsign = 1 - dsign; +#endif +#endif + break; + } + if ((aadj = ratio(delta, bs)) <= 2.) { + if (dsign) + aadj = aadj1 = 1.; + else if (word1(rv) || word0(rv) & Bndry_mask) { +#ifndef Sudden_Underflow + if (word1(rv) == Tiny1 && !word0(rv)) + goto undfl; +#endif + aadj = 1.; + aadj1 = -1.; + } + else { + /* special case -- power of FLT_RADIX to be */ + /* rounded down... */ + + if (aadj < 2./FLT_RADIX) + aadj = 1./FLT_RADIX; + else + aadj *= 0.5; + aadj1 = -aadj; + } + } + else { + aadj *= 0.5; + aadj1 = dsign ? aadj : -aadj; +#ifdef Check_FLT_ROUNDS + switch(Rounding) { + case 2: /* towards +infinity */ + aadj1 -= 0.5; + break; + case 0: /* towards 0 */ + case 3: /* towards -infinity */ + aadj1 += 0.5; + } +#else + if (Flt_Rounds == 0) + aadj1 += 0.5; +#endif /*Check_FLT_ROUNDS*/ + } + y = word0(rv) & Exp_mask; + + /* Check for overflow */ + + if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { + dval(rv0) = dval(rv); + word0(rv) -= P*Exp_msk1; + adj = aadj1 * ulp(dval(rv)); + dval(rv) += adj; + if ((word0(rv) & Exp_mask) >= + Exp_msk1*(DBL_MAX_EXP+Bias-P)) { + if (word0(rv0) == Big0 && word1(rv0) == Big1) + goto ovfl; + word0(rv) = Big0; + word1(rv) = Big1; + goto cont; + } + else + word0(rv) += P*Exp_msk1; + } + else { +#ifdef Avoid_Underflow + if (scale && y <= 2*P*Exp_msk1) { + if (aadj <= 0x7fffffff) { + if ((z = (ULong)aadj) <= 0) + z = 1; + aadj = z; + aadj1 = dsign ? aadj : -aadj; + } + word0(aadj1) += (2*P+1)*Exp_msk1 - y; + } + adj = aadj1 * ulp(dval(rv)); + dval(rv) += adj; +#else +#ifdef Sudden_Underflow + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { + dval(rv0) = dval(rv); + word0(rv) += P*Exp_msk1; + adj = aadj1 * ulp(dval(rv)); + dval(rv) += adj; +#ifdef IBM + if ((word0(rv) & Exp_mask) < P*Exp_msk1) +#else + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) +#endif + { + if (word0(rv0) == Tiny0 + && word1(rv0) == Tiny1) + goto undfl; + word0(rv) = Tiny0; + word1(rv) = Tiny1; + goto cont; + } + else + word0(rv) -= P*Exp_msk1; + } + else { + adj = aadj1 * ulp(dval(rv)); + dval(rv) += adj; + } +#else /*Sudden_Underflow*/ + /* Compute adj so that the IEEE rounding rules will + * correctly round rv + adj in some half-way cases. + * If rv * ulp(rv) is denormalized (i.e., + * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid + * trouble from bits lost to denormalization; + * example: 1.2e-307 . + */ + if (y <= (P-1)*Exp_msk1 && aadj > 1.) { + aadj1 = (double)(int)(aadj + 0.5); + if (!dsign) + aadj1 = -aadj1; + } + adj = aadj1 * ulp(dval(rv)); + dval(rv) += adj; +#endif /*Sudden_Underflow*/ +#endif /*Avoid_Underflow*/ + } + z = word0(rv) & Exp_mask; +#ifndef SET_INEXACT +#ifdef Avoid_Underflow + if (!scale) +#endif + if (y == z) { + /* Can we stop now? */ + L = (Long)aadj; + aadj -= L; + /* The tolerances below are conservative. */ + if (dsign || word1(rv) || word0(rv) & Bndry_mask) { + if (aadj < .4999999 || aadj > .5000001) + break; + } + else if (aadj < .4999999/FLT_RADIX) + break; + } +#endif + cont: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(delta); + } +#ifdef SET_INEXACT + if (inexact) { + if (!oldinexact) { + word0(rv0) = Exp_1 + (70 << Exp_shift); + word1(rv0) = 0; + dval(rv0) += 1.; + } + } + else if (!oldinexact) + clear_inexact(); +#endif +#ifdef Avoid_Underflow + if (scale) { + word0(rv0) = Exp_1 - 2*P*Exp_msk1; + word1(rv0) = 0; + dval(rv) *= dval(rv0); +#ifndef NO_ERRNO + /* try to avoid the bug of testing an 8087 register value */ + if (word0(rv) == 0 && word1(rv) == 0) + errno = ERANGE; +#endif + } +#endif /* Avoid_Underflow */ +#ifdef SET_INEXACT + if (inexact && !(word0(rv) & Exp_mask)) { + /* set underflow bit */ + dval(rv0) = 1e-300; + dval(rv0) *= dval(rv0); + } +#endif + retfree: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(bd0); + Bfree(delta); + ret: + if (se) + *se = (char *)s; + return sign ? -dval(rv) : dval(rv); + } + + static int +quorem +#ifdef KR_headers + (b, S) Bigint *b, *S; +#else + (Bigint *b, Bigint *S) +#endif +{ + int n; + ULong *bx, *bxe, q, *sx, *sxe; +#ifdef ULLong + ULLong borrow, carry, y, ys; +#else + ULong borrow, carry, y, ys; +#ifdef Pack_32 + ULong si, z, zs; +#endif +#endif + + n = S->wds; +#ifdef DEBUG + /*debug*/ if (b->wds > n) + /*debug*/ Bug("oversize b in quorem"); +#endif + if (b->wds < n) + return 0; + sx = S->x; + sxe = sx + --n; + bx = b->x; + bxe = bx + n; + q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ +#ifdef DEBUG + /*debug*/ if (q > 9) + /*debug*/ Bug("oversized quotient in quorem"); +#endif + if (q) { + borrow = 0; + carry = 0; + do { +#ifdef ULLong + ys = *sx++ * (ULLong)q + carry; + carry = ys >> 32; + y = *bx - (ys & FFFFFFFF) - borrow; + borrow = y >> 32 & (ULong)1; + *bx++ = (ULong)y & FFFFFFFF; +#else +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) * q + carry; + zs = (si >> 16) * q + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*bx >> 16) - (zs & 0xffff) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(bx, z, y); +#else + ys = *sx++ * q + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + *bx++ = y & 0xffff; +#endif +#endif + } + while(sx <= sxe); + if (!*bxe) { + bx = b->x; + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + if (cmp(b, S) >= 0) { + q++; + borrow = 0; + carry = 0; + bx = b->x; + sx = S->x; + do { +#ifdef ULLong + ys = *sx++ + carry; + carry = ys >> 32; + y = *bx - (ys & FFFFFFFF) - borrow; + borrow = y >> 32 & (ULong)1; + *bx++ = (ULong)y & FFFFFFFF; +#else +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) + carry; + zs = (si >> 16) + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + z = (*bx >> 16) - (zs & 0xffff) - borrow; + borrow = (z & 0x10000) >> 16; + Storeinc(bx, z, y); +#else + ys = *sx++ + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) - borrow; + borrow = (y & 0x10000) >> 16; + *bx++ = y & 0xffff; +#endif +#endif + } + while(sx <= sxe); + bx = b->x; + bxe = bx + n; + if (!*bxe) { + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + return q; + } + +#ifndef MULTIPLE_THREADS + static char *dtoa_result; +#endif + + static char * +#ifdef KR_headers +rv_alloc(i) int i; +#else +rv_alloc(int i) +#endif +{ + int j, k, *r; + + j = sizeof(ULong); + for(k = 0; + sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= (unsigned)i; + j <<= 1) + k++; + r = (int*)Balloc(k); + *r = k; + return +#ifndef MULTIPLE_THREADS + dtoa_result = +#endif + (char *)(r+1); + } + + static char * +#ifdef KR_headers +nrv_alloc(s, rve, n) char *s, **rve; int n; +#else +nrv_alloc(CONST_ char *s, char **rve, int n) +#endif +{ + char *rv, *t; + + t = rv = rv_alloc(n); + while((*t = *s++)) t++; + if (rve) + *rve = t; + return rv; + } + +/* freedtoa(s) must be used to free values s returned by dtoa + * when MULTIPLE_THREADS is #defined. It should be used in all cases, + * but for consistency with earlier versions of dtoa, it is optional + * when MULTIPLE_THREADS is not defined. + */ + + void +#ifdef KR_headers +freedtoa(s) char *s; +#else +freedtoa(char *s) +#endif +{ + Bigint *b = (Bigint *)((int *)s - 1); + b->maxwds = 1 << (b->k = *(int*)b); + Bfree(b); +#ifndef MULTIPLE_THREADS + if (s == dtoa_result) + dtoa_result = 0; +#endif + } + +/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. + * + * Inspired by "How to Print Floating-Point Numbers Accurately" by + * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * 1. Rather than iterating, we use a simple numeric overestimate + * to determine k = floor(log10(d)). We scale relevant + * quantities using O(log2(k)) rather than O(k) multiplications. + * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't + * try to generate digits strictly left to right. Instead, we + * compute with fewer bits and propagate the carry if necessary + * when rounding the final digit up. This is often faster. + * 3. Under the assumption that input will be rounded nearest, + * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. + * That is, we allow equality in stopping tests when the + * round-nearest rule will give the same floating-point value + * as would satisfaction of the stopping test with strict + * inequality. + * 4. We remove common factors of powers of 2 from relevant + * quantities. + * 5. When converting floating-point integers less than 1e16, + * we use floating-point arithmetic rather than resorting + * to multiple-precision integers. + * 6. When asked to produce fewer than 15 digits, we first try + * to get by with floating-point arithmetic; we resort to + * multiple-precision integer arithmetic only if we cannot + * guarantee that the floating-point calculation has given + * the correctly rounded result. For k requested digits and + * "uniformly" distributed input, the probability is + * something like 10^(k-15) that we must resort to the Long + * calculation. + */ + + char * +dtoa +#ifdef KR_headers + (d, mode, ndigits, decpt, sign, rve) + double d; int mode, ndigits, *decpt, *sign; char **rve; +#else + (double d, int mode, int ndigits, int *decpt, int *sign, char **rve) +#endif +{ + /* Arguments ndigits, decpt, sign are similar to those + of ecvt and fcvt; trailing zeros are suppressed from + the returned string. If not null, *rve is set to point + to the end of the return value. If d is +-Infinity or NaN, + then *decpt is set to 9999. + + mode: + 0 ==> shortest string that yields d when read in + and rounded to nearest. + 1 ==> like 0, but with Steele & White stopping rule; + e.g. with IEEE P754 arithmetic , mode 0 gives + 1e23 whereas mode 1 gives 9.999999999999999e22. + 2 ==> max(1,ndigits) significant digits. This gives a + return value similar to that of ecvt, except + that trailing zeros are suppressed. + 3 ==> through ndigits past the decimal point. This + gives a return value similar to that from fcvt, + except that trailing zeros are suppressed, and + ndigits can be negative. + 4,5 ==> similar to 2 and 3, respectively, but (in + round-nearest mode) with the tests of mode 0 to + possibly return a shorter string that rounds to d. + With IEEE arithmetic and compilation with + -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same + as modes 2 and 3 when FLT_ROUNDS != 1. + 6-9 ==> Debugging modes similar to mode - 4: don't try + fast floating-point estimate (if applicable). + + Values of mode other than 0-9 are treated as mode 0. + + Sufficient space is allocated to the return value + to hold the suppressed trailing zeros. + */ + + int bbits, b2, b5, be, dig, i, ieps, ilim = 0, ilim0, ilim1 = 0, + j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, + spec_case, try_quick; + Long L; +#ifndef Sudden_Underflow + int denorm; + ULong x; +#endif + Bigint *b, *b1, *delta, *mlo = NULL, *mhi, *S; + double d2, ds, eps; + char *s, *s0; +#ifdef Honor_FLT_ROUNDS + int rounding; +#endif +#ifdef SET_INEXACT + int inexact, oldinexact; +#endif + +#ifndef MULTIPLE_THREADS + if (dtoa_result) { + freedtoa(dtoa_result); + dtoa_result = 0; + } +#endif + + if (word0(d) & Sign_bit) { + /* set sign for everything, including 0's and NaNs */ + *sign = 1; + word0(d) &= ~Sign_bit; /* clear sign bit */ + } + else + *sign = 0; + +#if defined(IEEE_Arith) + defined(VAX) +#ifdef IEEE_Arith + if ((word0(d) & Exp_mask) == Exp_mask) +#else + if (word0(d) == 0x8000) +#endif + { + /* Infinity or NaN */ + *decpt = 9999; +#ifdef IEEE_Arith + if (!word1(d) && !(word0(d) & 0xfffff)) + return nrv_alloc("Infinity", rve, 8); +#endif + return nrv_alloc("NaN", rve, 3); + } +#endif +#ifdef IBM + dval(d) += 0; /* normalize */ +#endif + if (!dval(d)) { + *decpt = 1; + return nrv_alloc("0", rve, 1); + } + +#ifdef SET_INEXACT + try_quick = oldinexact = get_inexact(); + inexact = 1; +#endif +#ifdef Honor_FLT_ROUNDS + if ((rounding = Flt_Rounds) >= 2) { + if (*sign) + rounding = rounding == 2 ? 0 : 2; + else + if (rounding != 2) + rounding = 0; + } +#endif + + b = d2b(dval(d), &be, &bbits); +#ifdef Sudden_Underflow + i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); +#else + if ((i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)))) { +#endif + dval(d2) = dval(d); + word0(d2) &= Frac_mask1; + word0(d2) |= Exp_11; +#ifdef IBM + if (j = 11 - hi0bits(word0(d2) & Frac_mask)) + dval(d2) /= 1 << j; +#endif + + /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 + * log10(x) = log(x) / log(10) + * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) + * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) + * + * This suggests computing an approximation k to log10(d) by + * + * k = (i - Bias)*0.301029995663981 + * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); + * + * We want k to be too large rather than too small. + * The error in the first-order Taylor series approximation + * is in our favor, so we just round up the constant enough + * to compensate for any error in the multiplication of + * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, + * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, + * adding 1e-13 to the constant term more than suffices. + * Hence we adjust the constant term to 0.1760912590558. + * (We could get a more accurate k by invoking log10, + * but this is probably not worthwhile.) + */ + + i -= Bias; +#ifdef IBM + i <<= 2; + i += j; +#endif +#ifndef Sudden_Underflow + denorm = 0; + } + else { + /* d is denormalized */ + + i = bbits + be + (Bias + (P-1) - 1); + x = i > 32 ? word0(d) << 64 - i | word1(d) >> i - 32 + : word1(d) << 32 - i; + dval(d2) = x; + word0(d2) -= 31*Exp_msk1; /* adjust exponent */ + i -= (Bias + (P-1) - 1) + 1; + denorm = 1; + } +#endif + ds = (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; + k = (int)ds; + if (ds < 0. && ds != k) + k--; /* want k = floor(ds) */ + k_check = 1; + if (k >= 0 && k <= Ten_pmax) { + if (dval(d) < tens[k]) + k--; + k_check = 0; + } + j = bbits - i - 1; + if (j >= 0) { + b2 = 0; + s2 = j; + } + else { + b2 = -j; + s2 = 0; + } + if (k >= 0) { + b5 = 0; + s5 = k; + s2 += k; + } + else { + b2 -= k; + b5 = -k; + s5 = 0; + } + if (mode < 0 || mode > 9) + mode = 0; + +#ifndef SET_INEXACT +#ifdef Check_FLT_ROUNDS + try_quick = Rounding == 1; +#else + try_quick = 1; +#endif +#endif /*SET_INEXACT*/ + + if (mode > 5) { + mode -= 4; + try_quick = 0; + } + leftright = 1; + switch(mode) { + case 0: + case 1: + ilim = ilim1 = -1; + i = 18; + ndigits = 0; + break; + case 2: + leftright = 0; + /* no break */ + case 4: + if (ndigits <= 0) + ndigits = 1; + ilim = ilim1 = i = ndigits; + break; + case 3: + leftright = 0; + /* no break */ + case 5: + i = ndigits + k + 1; + ilim = i; + ilim1 = i - 1; + if (i <= 0) + i = 1; + } + s = s0 = rv_alloc(i); + +#ifdef Honor_FLT_ROUNDS + if (mode > 1 && rounding != 1) + leftright = 0; +#endif + + if (ilim >= 0 && ilim <= Quick_max && try_quick) { + + /* Try to get by with floating-point arithmetic. */ + + i = 0; + dval(d2) = dval(d); + k0 = k; + ilim0 = ilim; + ieps = 2; /* conservative */ + if (k > 0) { + ds = tens[k&0xf]; + j = k >> 4; + if (j & Bletch) { + /* prevent overflows */ + j &= Bletch - 1; + dval(d) /= bigtens[n_bigtens-1]; + ieps++; + } + for(; j; j >>= 1, i++) + if (j & 1) { + ieps++; + ds *= bigtens[i]; + } + dval(d) /= ds; + } + else if ((j1 = -k)) { + dval(d) *= tens[j1 & 0xf]; + for(j = j1 >> 4; j; j >>= 1, i++) + if (j & 1) { + ieps++; + dval(d) *= bigtens[i]; + } + } + if (k_check && dval(d) < 1. && ilim > 0) { + if (ilim1 <= 0) + goto fast_failed; + ilim = ilim1; + k--; + dval(d) *= 10.; + ieps++; + } + dval(eps) = ieps*dval(d) + 7.; + word0(eps) -= (P-1)*Exp_msk1; + if (ilim == 0) { + S = mhi = 0; + dval(d) -= 5.; + if (dval(d) > dval(eps)) + goto one_digit; + if (dval(d) < -dval(eps)) + goto no_digits; + goto fast_failed; + } +#ifndef No_leftright + if (leftright) { + /* Use Steele & White method of only + * generating digits needed. + */ + dval(eps) = 0.5/tens[ilim-1] - dval(eps); + for(i = 0;;) { + L = (long int)dval(d); + dval(d) -= L; + *s++ = '0' + (int)L; + if (dval(d) < dval(eps)) + goto ret1; + if (1. - dval(d) < dval(eps)) + goto bump_up; + if (++i >= ilim) + break; + dval(eps) *= 10.; + dval(d) *= 10.; + } + } + else { +#endif + /* Generate ilim digits, then fix them up. */ + dval(eps) *= tens[ilim-1]; + for(i = 1;; i++, dval(d) *= 10.) { + L = (Long)(dval(d)); + if (!(dval(d) -= L)) + ilim = i; + *s++ = '0' + (int)L; + if (i == ilim) { + if (dval(d) > 0.5 + dval(eps)) + goto bump_up; + else if (dval(d) < 0.5 - dval(eps)) { + while (*--s == '0') { } + s++; + goto ret1; + } + break; + } + } +#ifndef No_leftright + } +#endif + fast_failed: + s = s0; + dval(d) = dval(d2); + k = k0; + ilim = ilim0; + } + + /* Do we have a "small" integer? */ + + if (be >= 0 && k <= Int_max) { + /* Yes. */ + ds = tens[k]; + if (ndigits < 0 && ilim <= 0) { + S = mhi = 0; + if (ilim < 0 || dval(d) <= 5*ds) + goto no_digits; + goto one_digit; + } + for(i = 1;; i++, dval(d) *= 10.) { + L = (Long)(dval(d) / ds); + dval(d) -= L*ds; +#ifdef Check_FLT_ROUNDS + /* If FLT_ROUNDS == 2, L will usually be high by 1 */ + if (dval(d) < 0) { + L--; + dval(d) += ds; + } +#endif + *s++ = '0' + (int)L; + if (!dval(d)) { +#ifdef SET_INEXACT + inexact = 0; +#endif + break; + } + if (i == ilim) { +#ifdef Honor_FLT_ROUNDS + if (mode > 1) + switch(rounding) { + case 0: goto ret1; + case 2: goto bump_up; + } +#endif + dval(d) += dval(d); + if (dval(d) > ds || dval(d) == ds && L & 1) { + bump_up: + while(*--s == '9') + if (s == s0) { + k++; + *s = '0'; + break; + } + ++*s++; + } + break; + } + } + goto ret1; + } + + m2 = b2; + m5 = b5; + mhi = mlo = 0; + if (leftright) { + i = +#ifndef Sudden_Underflow + denorm ? be + (Bias + (P-1) - 1 + 1) : +#endif +#ifdef IBM + 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); +#else + 1 + P - bbits; +#endif + b2 += i; + s2 += i; + mhi = i2b(1); + } + if (m2 > 0 && s2 > 0) { + i = m2 < s2 ? m2 : s2; + b2 -= i; + m2 -= i; + s2 -= i; + } + if (b5 > 0) { + if (leftright) { + if (m5 > 0) { + mhi = pow5mult(mhi, m5); + b1 = mult(mhi, b); + Bfree(b); + b = b1; + } + if ((j = b5 - m5)) + b = pow5mult(b, j); + } + else + b = pow5mult(b, b5); + } + S = i2b(1); + if (s5 > 0) + S = pow5mult(S, s5); + + /* Check for special case that d is a normalized power of 2. */ + + spec_case = 0; + if ((mode < 2 || leftright) +#ifdef Honor_FLT_ROUNDS + && rounding == 1 +#endif + ) { + if (!word1(d) && !(word0(d) & Bndry_mask) +#ifndef Sudden_Underflow + && word0(d) & (Exp_mask & ~Exp_msk1) +#endif + ) { + /* The special case */ + b2 += Log2P; + s2 += Log2P; + spec_case = 1; + } + } + + /* Arrange for convenient computation of quotients: + * shift left if necessary so divisor has 4 leading 0 bits. + * + * Perhaps we should just compute leading 28 bits of S once + * and for all and pass them and a shift to quorem, so it + * can do shifts and ors to compute the numerator for q. + */ +#ifdef Pack_32 + if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f)) + i = 32 - i; +#else + if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) + i = 16 - i; +#endif + if (i > 4) { + i -= 4; + b2 += i; + m2 += i; + s2 += i; + } + else if (i < 4) { + i += 28; + b2 += i; + m2 += i; + s2 += i; + } + if (b2 > 0) + b = lshift(b, b2); + if (s2 > 0) + S = lshift(S, s2); + if (k_check) { + if (cmp(b,S) < 0) { + k--; + b = multadd(b, 10, 0); /* we botched the k estimate */ + if (leftright) + mhi = multadd(mhi, 10, 0); + ilim = ilim1; + } + } + if (ilim <= 0 && (mode == 3 || mode == 5)) { + if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { + /* no digits, fcvt style */ + no_digits: + k = -1 - ndigits; + goto ret; + } + one_digit: + *s++ = '1'; + k++; + goto ret; + } + if (leftright) { + if (m2 > 0) + mhi = lshift(mhi, m2); + + /* Compute mlo -- check for special case + * that d is a normalized power of 2. + */ + + mlo = mhi; + if (spec_case) { + mhi = Balloc(mhi->k); + Bcopy(mhi, mlo); + mhi = lshift(mhi, Log2P); + } + + for(i = 1;;i++) { + dig = quorem(b,S) + '0'; + /* Do we yet have the shortest decimal string + * that will round to d? + */ + j = cmp(b, mlo); + delta = diff(S, mhi); + j1 = delta->sign ? 1 : cmp(b, delta); + Bfree(delta); +#ifndef ROUND_BIASED + if (j1 == 0 && mode != 1 && !(word1(d) & 1) +#ifdef Honor_FLT_ROUNDS + && rounding >= 1 +#endif + ) { + if (dig == '9') + goto round_9_up; + if (j > 0) + dig++; +#ifdef SET_INEXACT + else if (!b->x[0] && b->wds <= 1) + inexact = 0; +#endif + *s++ = dig; + goto ret; + } +#endif + if (j < 0 || j == 0 && mode != 1 +#ifndef ROUND_BIASED + && !(word1(d) & 1) +#endif + ) { + if (!b->x[0] && b->wds <= 1) { +#ifdef SET_INEXACT + inexact = 0; +#endif + goto accept_dig; + } +#ifdef Honor_FLT_ROUNDS + if (mode > 1) + switch(rounding) { + case 0: goto accept_dig; + case 2: goto keep_dig; + } +#endif /*Honor_FLT_ROUNDS*/ + if (j1 > 0) { + b = lshift(b, 1); + j1 = cmp(b, S); + if ((j1 > 0 || j1 == 0 && dig & 1) + && dig++ == '9') + goto round_9_up; + } + accept_dig: + *s++ = dig; + goto ret; + } + if (j1 > 0) { +#ifdef Honor_FLT_ROUNDS + if (!rounding) + goto accept_dig; +#endif + if (dig == '9') { /* possible if i == 1 */ + round_9_up: + *s++ = '9'; + goto roundoff; + } + *s++ = dig + 1; + goto ret; + } +#ifdef Honor_FLT_ROUNDS + keep_dig: +#endif + *s++ = dig; + if (i == ilim) + break; + b = multadd(b, 10, 0); + if (mlo == mhi) + mlo = mhi = multadd(mhi, 10, 0); + else { + mlo = multadd(mlo, 10, 0); + mhi = multadd(mhi, 10, 0); + } + } + } + else + for(i = 1;; i++) { + *s++ = dig = quorem(b,S) + '0'; + if (!b->x[0] && b->wds <= 1) { +#ifdef SET_INEXACT + inexact = 0; +#endif + goto ret; + } + if (i >= ilim) + break; + b = multadd(b, 10, 0); + } + + /* Round off last digit */ + +#ifdef Honor_FLT_ROUNDS + switch(rounding) { + case 0: goto trimzeros; + case 2: goto roundoff; + } +#endif + b = lshift(b, 1); + j = cmp(b, S); + if (j > 0 || j == 0 && dig & 1) { + roundoff: + while(*--s == '9') + if (s == s0) { + k++; + *s++ = '1'; + goto ret; + } + ++*s++; + } + else { +#ifdef Honor_FLT_ROUNDS +trimzeros: +#endif + while (*--s == '0') { } + s++; + } + ret: + Bfree(S); + if (mhi) { + if (mlo && mlo != mhi) + Bfree(mlo); + Bfree(mhi); + } + ret1: +#ifdef SET_INEXACT + if (inexact) { + if (!oldinexact) { + word0(d) = Exp_1 + (70 << Exp_shift); + word1(d) = 0; + dval(d) += 1.; + } + } + else if (!oldinexact) + clear_inexact(); +#endif + Bfree(b); + *s = 0; + *decpt = k + 1; + if (rve) + *rve = s; + return s0; + } +#ifdef __cplusplus +} +#endif diff --git a/kjs/dtoa.h b/kjs/dtoa.h new file mode 100644 index 0000000..79ff828 --- /dev/null +++ b/kjs/dtoa.h @@ -0,0 +1,31 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2003 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef _KJS_DTOA_H_ +#define _KJS_DTOA_H_ + +extern "C" double kjs_strtod(const char *s00, char **se); +extern "C" char *kjs_dtoa(double d, int mode, int ndigits, + int *decpt, int *sign, char **rve); +extern "C" void kjs_freedtoa(char *s); + +#endif /* _KJS_DTOA_H */ diff --git a/kjs/error_object.cpp b/kjs/error_object.cpp new file mode 100644 index 0000000..75ef0ba --- /dev/null +++ b/kjs/error_object.cpp @@ -0,0 +1,153 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "error_object.h" + +#include "JSGlobalObject.h" +#include "object.h" +#include "operations.h" +#include "types.h" +#include "value.h" + +namespace KJS { + +// ------------------------------ ErrorInstance ---------------------------- + +const ClassInfo ErrorInstance::info = { "Error", 0, 0 }; + +ErrorInstance::ErrorInstance(JSObject* prototype) + : JSObject(prototype) +{ +} + +// ------------------------------ ErrorPrototype ---------------------------- + +// ECMA 15.9.4 +ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype) + : ErrorInstance(objectPrototype) +{ + // The constructor will be added later in ErrorObjectImp's constructor + + putDirect(exec->propertyNames().name, jsString("Error"), DontEnum); + putDirect(exec->propertyNames().message, jsString("Unknown error"), DontEnum); + + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum); +} + +JSValue* errorProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) +{ + UString s = "Error"; + + JSValue* v = thisObj->get(exec, exec->propertyNames().name); + if (!v->isUndefined()) + s = v->toString(exec); + + v = thisObj->get(exec, exec->propertyNames().message); + if (!v->isUndefined()) + // Mozilla compatible format + s += ": " + v->toString(exec); + + return jsString(s); +} + +// ------------------------------ ErrorObjectImp ------------------------------- + +ErrorObjectImp::ErrorObjectImp(ExecState* exec, FunctionPrototype* funcProto, ErrorPrototype* errorProto) + : InternalFunctionImp(funcProto, errorProto->classInfo()->className) +{ + // ECMA 15.11.3.1 Error.prototype + putDirect(exec->propertyNames().prototype, errorProto, DontEnum|DontDelete|ReadOnly); + putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); +} + +bool ErrorObjectImp::implementsConstruct() const +{ + return true; +} + +// ECMA 15.9.3 +JSObject* ErrorObjectImp::construct(ExecState* exec, const List& args) +{ + JSObject* proto = static_cast(exec->lexicalGlobalObject()->errorPrototype()); + JSObject* imp = new ErrorInstance(proto); + JSObject* obj(imp); + + if (!args[0]->isUndefined()) + imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec))); + + return obj; +} + +// ECMA 15.9.2 +JSValue* ErrorObjectImp::callAsFunction(ExecState* exec, JSObject* /*thisObj*/, const List& args) +{ + // "Error()" gives the sames result as "new Error()" + return construct(exec, args); +} + +// ------------------------------ NativeErrorPrototype ---------------------- + +NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorProto, const UString& name, const UString& message) + : JSObject(errorProto) +{ + putDirect(exec->propertyNames().name, jsString(name), 0); + putDirect(exec->propertyNames().message, jsString(message), 0); +} + +// ------------------------------ NativeErrorImp ------------------------------- + +const ClassInfo NativeErrorImp::info = { "Function", &InternalFunctionImp::info, 0 }; + +NativeErrorImp::NativeErrorImp(ExecState* exec, FunctionPrototype* funcProto, NativeErrorPrototype* prot) + : InternalFunctionImp(funcProto, Identifier(prot->getDirect(exec->propertyNames().name)->getString())) + , proto(prot) +{ + putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5 + putDirect(exec->propertyNames().prototype, proto, DontDelete|ReadOnly|DontEnum); +} + +bool NativeErrorImp::implementsConstruct() const +{ + return true; +} + +JSObject* NativeErrorImp::construct(ExecState* exec, const List& args) +{ + JSObject* imp = new ErrorInstance(proto); + JSObject* obj(imp); + if (!args[0]->isUndefined()) + imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec))); + return obj; +} + +JSValue* NativeErrorImp::callAsFunction(ExecState* exec, JSObject*, const List& args) +{ + return construct(exec, args); +} + +void NativeErrorImp::mark() +{ + JSObject::mark(); + if (proto && !proto->marked()) + proto->mark(); +} + +} // namespace KJS diff --git a/kjs/error_object.h b/kjs/error_object.h new file mode 100644 index 0000000..9734085 --- /dev/null +++ b/kjs/error_object.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef ERROR_OBJECT_H_ +#define ERROR_OBJECT_H_ + +#include "function_object.h" + +namespace KJS { + + class ErrorInstance : public JSObject { + public: + ErrorInstance(JSObject* prototype); + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + }; + + class ErrorPrototype : public ErrorInstance { + public: + ErrorPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*); + }; + + JSValue* errorProtoFuncToString(ExecState*, JSObject*, const List&); + + class ErrorObjectImp : public InternalFunctionImp { + public: + ErrorObjectImp(ExecState*, FunctionPrototype*, ErrorPrototype*); + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List&); + + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + }; + + class NativeErrorPrototype : public JSObject { + public: + NativeErrorPrototype(ExecState*, ErrorPrototype*, const UString& name, const UString& message); + }; + + class NativeErrorImp : public InternalFunctionImp { + public: + NativeErrorImp(ExecState*, FunctionPrototype*, NativeErrorPrototype*); + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List&); + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + + virtual void mark(); + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + + private: + JSObject* proto; + }; + +} // namespace KJS + +#endif // ERROR_OBJECT_H_ diff --git a/kjs/function.cpp b/kjs/function.cpp new file mode 100644 index 0000000..9f1b62c --- /dev/null +++ b/kjs/function.cpp @@ -0,0 +1,881 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2002 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) + * Copyright (C) 2007 Maks Orlovich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "function.h" + +#include "Activation.h" +#include "ExecState.h" +#include "JSGlobalObject.h" +#include "Parser.h" +#include "PropertyNameArray.h" +#include "debugger.h" +#include "dtoa.h" +#include "function_object.h" +#include "internal.h" +#include "lexer.h" +#include "nodes.h" +#include "operations.h" +#include "scope_chain_mark.h" +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace WTF; +using namespace Unicode; + +namespace KJS { + +// ----------------------------- FunctionImp ---------------------------------- + +const ClassInfo FunctionImp::info = { "Function", &InternalFunctionImp::info, 0 }; + +FunctionImp::FunctionImp(ExecState* exec, const Identifier& name, FunctionBodyNode* b, const ScopeChain& sc) + : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name) + , body(b) + , _scope(sc) +{ +} + +void FunctionImp::mark() +{ + InternalFunctionImp::mark(); + _scope.mark(); +} + +JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) +{ + FunctionExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), exec, this, args); + JSValue* result = body->execute(&newExec); + if (newExec.completionType() == Throw) { + exec->setException(result); + return result; + } + if (newExec.completionType() == ReturnValue) + return result; + return jsUndefined(); +} + +JSValue* FunctionImp::argumentsGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) +{ + FunctionImp* thisObj = static_cast(slot.slotBase()); + + for (ExecState* e = exec; e; e = e->callingExecState()) + if (e->function() == thisObj) { + e->dynamicGlobalObject()->tearOffActivation(e, e != exec); + return e->activationObject()->get(exec, propertyName); + } + + return jsNull(); +} + +JSValue* FunctionImp::callerGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot) +{ + FunctionImp* thisObj = static_cast(slot.slotBase()); + ExecState* e = exec; + while (e) { + if (e->function() == thisObj) + break; + e = e->callingExecState(); + } + + if (!e) + return jsNull(); + + ExecState* callingExecState = e->callingExecState(); + if (!callingExecState) + return jsNull(); + + FunctionImp* callingFunction = callingExecState->function(); + if (!callingFunction) + return jsNull(); + + return callingFunction; +} + +JSValue* FunctionImp::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) +{ + FunctionImp* thisObj = static_cast(slot.slotBase()); + return jsNumber(thisObj->body->parameters().size()); +} + +bool FunctionImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + // Find the arguments from the closest context. + if (propertyName == exec->propertyNames().arguments) { + slot.setCustom(this, argumentsGetter); + return true; + } + + // Compute length of parameters. + if (propertyName == exec->propertyNames().length) { + slot.setCustom(this, lengthGetter); + return true; + } + + if (propertyName == exec->propertyNames().caller) { + slot.setCustom(this, callerGetter); + return true; + } + + return InternalFunctionImp::getOwnPropertySlot(exec, propertyName, slot); +} + +void FunctionImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) +{ + if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length) + return; + InternalFunctionImp::put(exec, propertyName, value, attr); +} + +bool FunctionImp::deleteProperty(ExecState* exec, const Identifier& propertyName) +{ + if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length) + return false; + return InternalFunctionImp::deleteProperty(exec, propertyName); +} + +/* Returns the parameter name corresponding to the given index. eg: + * function f1(x, y, z): getParameterName(0) --> x + * + * If a name appears more than once, only the last index at which + * it appears associates with it. eg: + * function f2(x, x): getParameterName(0) --> null + */ +Identifier FunctionImp::getParameterName(int index) +{ + Vector& parameters = body->parameters(); + + if (static_cast(index) >= body->parameters().size()) + return CommonIdentifiers::shared()->nullIdentifier; + + Identifier name = parameters[index]; + + // Are there any subsequent parameters with the same name? + size_t size = parameters.size(); + for (size_t i = index + 1; i < size; ++i) + if (parameters[i] == name) + return CommonIdentifiers::shared()->nullIdentifier; + + return name; +} + +// ECMA 13.2.2 [[Construct]] +JSObject* FunctionImp::construct(ExecState* exec, const List& args) +{ + JSObject* proto; + JSValue* p = get(exec, exec->propertyNames().prototype); + if (p->isObject()) + proto = static_cast(p); + else + proto = exec->lexicalGlobalObject()->objectPrototype(); + + JSObject* obj(new JSObject(proto)); + + JSValue* res = call(exec,obj,args); + + if (res->isObject()) + return static_cast(res); + else + return obj; +} + +// ------------------------------ IndexToNameMap --------------------------------- + +// We map indexes in the arguments array to their corresponding argument names. +// Example: function f(x, y, z): arguments[0] = x, so we map 0 to Identifier("x"). + +// Once we have an argument name, we can get and set the argument's value in the +// activation object. + +// We use Identifier::null to indicate that a given argument's value +// isn't stored in the activation object. + +IndexToNameMap::IndexToNameMap(FunctionImp* func, const List& args) +{ + _map = new Identifier[args.size()]; + this->size = args.size(); + + unsigned i = 0; + List::const_iterator end = args.end(); + for (List::const_iterator it = args.begin(); it != end; ++i, ++it) + _map[i] = func->getParameterName(i); // null if there is no corresponding parameter +} + +IndexToNameMap::~IndexToNameMap() +{ + delete [] _map; +} + +bool IndexToNameMap::isMapped(const Identifier& index) const +{ + bool indexIsNumber; + unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber); + + if (!indexIsNumber) + return false; + + if (indexAsNumber >= size) + return false; + + if (_map[indexAsNumber].isNull()) + return false; + + return true; +} + +void IndexToNameMap::unMap(const Identifier& index) +{ + bool indexIsNumber; + unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber); + + ASSERT(indexIsNumber && indexAsNumber < size); + + _map[indexAsNumber] = CommonIdentifiers::shared()->nullIdentifier; +} + +Identifier& IndexToNameMap::operator[](const Identifier& index) +{ + bool indexIsNumber; + unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber); + + ASSERT(indexIsNumber && indexAsNumber < size); + + return _map[indexAsNumber]; +} + +// ------------------------------ Arguments --------------------------------- + +const ClassInfo Arguments::info = { "Arguments", 0, 0 }; + +// ECMA 10.1.8 +Arguments::Arguments(ExecState* exec, FunctionImp* func, const List& args, ActivationImp* act) + : JSObject(exec->lexicalGlobalObject()->objectPrototype()) + , _activationObject(act) + , indexToNameMap(func, args) +{ + putDirect(exec->propertyNames().callee, func, DontEnum); + putDirect(exec->propertyNames().length, args.size(), DontEnum); + + int i = 0; + List::const_iterator end = args.end(); + for (List::const_iterator it = args.begin(); it != end; ++it, ++i) { + Identifier name = Identifier::from(i); + if (!indexToNameMap.isMapped(name)) + putDirect(name, *it, DontEnum); + } +} + +void Arguments::mark() +{ + JSObject::mark(); + if (_activationObject && !_activationObject->marked()) + _activationObject->mark(); +} + +JSValue* Arguments::mappedIndexGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) +{ + Arguments* thisObj = static_cast(slot.slotBase()); + return thisObj->_activationObject->get(exec, thisObj->indexToNameMap[propertyName]); +} + +bool Arguments::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + if (indexToNameMap.isMapped(propertyName)) { + slot.setCustom(this, mappedIndexGetter); + return true; + } + + return JSObject::getOwnPropertySlot(exec, propertyName, slot); +} + +void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) +{ + if (indexToNameMap.isMapped(propertyName)) { + _activationObject->put(exec, indexToNameMap[propertyName], value, attr); + } else { + JSObject::put(exec, propertyName, value, attr); + } +} + +bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName) +{ + if (indexToNameMap.isMapped(propertyName)) { + indexToNameMap.unMap(propertyName); + return true; + } else { + return JSObject::deleteProperty(exec, propertyName); + } +} + +// ------------------------------ ActivationImp -------------------------------- + +const ClassInfo ActivationImp::info = { "Activation", 0, 0 }; + +ActivationImp::ActivationImp(const ActivationData& oldData, bool leaveRelic) +{ + JSVariableObject::d = new ActivationData(oldData); + d()->leftRelic = leaveRelic; +} + +ActivationImp::~ActivationImp() +{ + if (!d()->isOnStack) + delete d(); +} + +void ActivationImp::init(ExecState* exec) +{ + d()->symbolTable = &exec->function()->body->symbolTable(); + d()->exec = exec; + d()->function = exec->function(); + d()->argumentsObject = 0; +} + +JSValue* ActivationImp::argumentsGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot) +{ + ActivationImp* thisObj = static_cast(slot.slotBase()); + + if (!thisObj->d()->argumentsObject) + thisObj->createArgumentsObject(exec); + + return thisObj->d()->argumentsObject; +} + +PropertySlot::GetValueFunc ActivationImp::getArgumentsGetter() +{ + return ActivationImp::argumentsGetter; +} + +bool ActivationImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + if (symbolTableGet(propertyName, slot)) + return true; + + if (JSValue** location = getDirectLocation(propertyName)) { + slot.setValueSlot(this, location); + return true; + } + + // Only return the built-in arguments object if it wasn't overridden above. + if (propertyName == exec->propertyNames().arguments) { + for (ExecState* e = exec; e; e = e->callingExecState()) + if (e->function() == d()->function) { + e->dynamicGlobalObject()->tearOffActivation(e, e != exec); + ActivationImp* newActivation = e->activationObject(); + slot.setCustom(newActivation, newActivation->getArgumentsGetter()); + return true; + } + + slot.setCustom(this, getArgumentsGetter()); + return true; + } + + // We don't call through to JSObject because there's no way to give an + // activation object getter properties or a prototype. + ASSERT(!_prop.hasGetterSetterProperties()); + ASSERT(prototype() == jsNull()); + return false; +} + +bool ActivationImp::deleteProperty(ExecState* exec, const Identifier& propertyName) +{ + if (propertyName == exec->propertyNames().arguments) + return false; + + return JSVariableObject::deleteProperty(exec, propertyName); +} + +void ActivationImp::put(ExecState*, const Identifier& propertyName, JSValue* value, int attr) +{ + // If any bits other than DontDelete are set, then we bypass the read-only check. + bool checkReadOnly = !(attr & ~DontDelete); + if (symbolTablePut(propertyName, value, checkReadOnly)) + return; + + // We don't call through to JSObject because __proto__ and getter/setter + // properties are non-standard extensions that other implementations do not + // expose in the activation object. + ASSERT(!_prop.hasGetterSetterProperties()); + _prop.put(propertyName, value, attr, checkReadOnly); +} + +void ActivationImp::markChildren() +{ + LocalStorage& localStorage = d()->localStorage; + size_t size = localStorage.size(); + + for (size_t i = 0; i < size; ++i) { + JSValue* value = localStorage[i].value; + + if (!value->marked()) + value->mark(); + } + + if (!d()->function->marked()) + d()->function->mark(); + + if (d()->argumentsObject && !d()->argumentsObject->marked()) + d()->argumentsObject->mark(); +} + +void ActivationImp::mark() +{ + JSObject::mark(); + markChildren(); +} + +void ActivationImp::createArgumentsObject(ExecState* exec) +{ + // Since "arguments" is only accessible while a function is being called, + // we can retrieve our argument list from the ExecState for our function + // call instead of storing the list ourselves. + d()->argumentsObject = new Arguments(exec, d()->exec->function(), *d()->exec->arguments(), this); +} + +ActivationImp::ActivationData::ActivationData(const ActivationData& old) + : JSVariableObjectData(old) + , exec(old.exec) + , function(old.function) + , argumentsObject(old.argumentsObject) + , isOnStack(false) +{ +} + +// ------------------------------ Global Functions ----------------------------------- + +static JSValue* encode(ExecState* exec, const List& args, const char* do_not_escape) +{ + UString r = "", s, str = args[0]->toString(exec); + CString cstr = str.UTF8String(true); + if (!cstr.c_str()) + return throwError(exec, URIError, "String contained an illegal UTF-16 sequence."); + const char* p = cstr.c_str(); + for (size_t k = 0; k < cstr.size(); k++, p++) { + char c = *p; + if (c && strchr(do_not_escape, c)) { + r.append(c); + } else { + char tmp[4]; + snprintf(tmp, sizeof(tmp), "%%%02X", (unsigned char)c); + r += tmp; + } + } + return jsString(r); +} + +static JSValue* decode(ExecState* exec, const List& args, const char* do_not_unescape, bool strict) +{ + UString s = "", str = args[0]->toString(exec); + int k = 0, len = str.size(); + const UChar* d = str.data(); + UChar u; + while (k < len) { + const UChar* p = d + k; + UChar c = *p; + if (c == '%') { + int charLen = 0; + if (k <= len - 3 && isASCIIHexDigit(p[1].uc) && isASCIIHexDigit(p[2].uc)) { + const char b0 = Lexer::convertHex(p[1].uc, p[2].uc); + const int sequenceLen = UTF8SequenceLength(b0); + if (sequenceLen != 0 && k <= len - sequenceLen * 3) { + charLen = sequenceLen * 3; + char sequence[5]; + sequence[0] = b0; + for (int i = 1; i < sequenceLen; ++i) { + const UChar* q = p + i * 3; + if (q[0] == '%' && isASCIIHexDigit(q[1].uc) && isASCIIHexDigit(q[2].uc)) + sequence[i] = Lexer::convertHex(q[1].uc, q[2].uc); + else { + charLen = 0; + break; + } + } + if (charLen != 0) { + sequence[sequenceLen] = 0; + const int character = decodeUTF8Sequence(sequence); + if (character < 0 || character >= 0x110000) { + charLen = 0; + } else if (character >= 0x10000) { + // Convert to surrogate pair. + s.append(static_cast(0xD800 | ((character - 0x10000) >> 10))); + u = static_cast(0xDC00 | ((character - 0x10000) & 0x3FF)); + } else { + u = static_cast(character); + } + } + } + } + if (charLen == 0) { + if (strict) + return throwError(exec, URIError); + // The only case where we don't use "strict" mode is the "unescape" function. + // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE. + if (k <= len - 6 && p[1] == 'u' + && isASCIIHexDigit(p[2].uc) && isASCIIHexDigit(p[3].uc) + && isASCIIHexDigit(p[4].uc) && isASCIIHexDigit(p[5].uc)) { + charLen = 6; + u = Lexer::convertUnicode(p[2].uc, p[3].uc, p[4].uc, p[5].uc); + } + } + if (charLen && (u.uc == 0 || u.uc >= 128 || !strchr(do_not_unescape, u.low()))) { + c = u; + k += charLen - 1; + } + } + k++; + s.append(c); + } + return jsString(s); +} + +static bool isStrWhiteSpace(unsigned short c) +{ + switch (c) { + case 0x0009: + case 0x000A: + case 0x000B: + case 0x000C: + case 0x000D: + case 0x0020: + case 0x00A0: + case 0x2028: + case 0x2029: + return true; + default: + return isSeparatorSpace(c); + } +} + +static int parseDigit(unsigned short c, int radix) +{ + int digit = -1; + + if (c >= '0' && c <= '9') { + digit = c - '0'; + } else if (c >= 'A' && c <= 'Z') { + digit = c - 'A' + 10; + } else if (c >= 'a' && c <= 'z') { + digit = c - 'a' + 10; + } + + if (digit >= radix) + return -1; + return digit; +} + +double parseIntOverflow(const char* s, int length, int radix) +{ + double number = 0.0; + double radixMultiplier = 1.0; + + for (const char* p = s + length - 1; p >= s; p--) { + if (radixMultiplier == Inf) { + if (*p != '0') { + number = Inf; + break; + } + } else { + int digit = parseDigit(*p, radix); + number += digit * radixMultiplier; + } + + radixMultiplier *= radix; + } + + return number; +} + +static double parseInt(const UString& s, int radix) +{ + int length = s.size(); + int p = 0; + + while (p < length && isStrWhiteSpace(s[p].uc)) { + ++p; + } + + double sign = 1; + if (p < length) { + if (s[p] == '+') { + ++p; + } else if (s[p] == '-') { + sign = -1; + ++p; + } + } + + if ((radix == 0 || radix == 16) && length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X')) { + radix = 16; + p += 2; + } else if (radix == 0) { + if (p < length && s[p] == '0') + radix = 8; + else + radix = 10; + } + + if (radix < 2 || radix > 36) + return NaN; + + int firstDigitPosition = p; + bool sawDigit = false; + double number = 0; + while (p < length) { + int digit = parseDigit(s[p].uc, radix); + if (digit == -1) + break; + sawDigit = true; + number *= radix; + number += digit; + ++p; + } + + if (number >= mantissaOverflowLowerBound) { + if (radix == 10) + number = kjs_strtod(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), 0); + else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32) + number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), p - firstDigitPosition, radix); + } + + if (!sawDigit) + return NaN; + + return sign * number; +} + +static double parseFloat(const UString& s) +{ + // Check for 0x prefix here, because toDouble allows it, but we must treat it as 0. + // Need to skip any whitespace and then one + or - sign. + int length = s.size(); + int p = 0; + while (p < length && isStrWhiteSpace(s[p].uc)) { + ++p; + } + if (p < length && (s[p] == '+' || s[p] == '-')) { + ++p; + } + if (length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X')) { + return 0; + } + + return s.toDouble( true /*tolerant*/, false /* NaN for empty string */ ); +} + +JSValue* globalFuncEval(ExecState* exec, JSObject* thisObj, const List& args) +{ + JSValue* x = args[0]; + if (!x->isString()) + return x; + + UString s = x->toString(exec); + + int sourceId; + int errLine; + UString errMsg; + RefPtr evalNode = parser().parse(UString(), 0, s.data(), s.size(), &sourceId, &errLine, &errMsg); + + Debugger* dbg = exec->dynamicGlobalObject()->debugger(); + if (dbg) { + bool cont = dbg->sourceParsed(exec, sourceId, UString(), s, 0, errLine, errMsg); + if (!cont) + return jsUndefined(); + } + + // No program node means a syntax occurred + if (!evalNode) + return throwError(exec, SyntaxError, errMsg, errLine, sourceId, NULL); + + bool switchGlobal = thisObj && thisObj != exec->dynamicGlobalObject() && thisObj->isGlobalObject(); + + // enter a new execution context + exec->dynamicGlobalObject()->tearOffActivation(exec); + JSGlobalObject* globalObject = switchGlobal ? static_cast(thisObj) : exec->dynamicGlobalObject(); + EvalExecState newExec(globalObject, evalNode.get(), exec); + + if (switchGlobal) { + newExec.pushScope(thisObj); + newExec.setVariableObject(static_cast(thisObj)); + } + JSValue* value = evalNode->execute(&newExec); + if (switchGlobal) + newExec.popScope(); + + if (newExec.completionType() == Throw) { + exec->setException(value); + return value; + } + + return value ? value : jsUndefined(); +} + +JSValue* globalFuncParseInt(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(parseInt(args[0]->toString(exec), args[1]->toInt32(exec))); +} + +JSValue* globalFuncParseFloat(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(parseFloat(args[0]->toString(exec))); +} + +JSValue* globalFuncIsNaN(ExecState* exec, JSObject*, const List& args) +{ + return jsBoolean(isnan(args[0]->toNumber(exec))); +} + +JSValue* globalFuncIsFinite(ExecState* exec, JSObject*, const List& args) +{ + double n = args[0]->toNumber(exec); + return jsBoolean(!isnan(n) && !isinf(n)); +} + +JSValue* globalFuncDecodeURI(ExecState* exec, JSObject*, const List& args) +{ + static const char do_not_unescape_when_decoding_URI[] = + "#$&+,/:;=?@"; + + return decode(exec, args, do_not_unescape_when_decoding_URI, true); +} + +JSValue* globalFuncDecodeURIComponent(ExecState* exec, JSObject*, const List& args) +{ + return decode(exec, args, "", true); +} + +JSValue* globalFuncEncodeURI(ExecState* exec, JSObject*, const List& args) +{ + static const char do_not_escape_when_encoding_URI[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "!#$&'()*+,-./:;=?@_~"; + + return encode(exec, args, do_not_escape_when_encoding_URI); +} + +JSValue* globalFuncEncodeURIComponent(ExecState* exec, JSObject*, const List& args) +{ + static const char do_not_escape_when_encoding_URI_component[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "!'()*-._~"; + + return encode(exec, args, do_not_escape_when_encoding_URI_component); +} + +JSValue* globalFuncEscape(ExecState* exec, JSObject*, const List& args) +{ + static const char do_not_escape[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "*+-./@_"; + + UString r = "", s, str = args[0]->toString(exec); + const UChar* c = str.data(); + for (int k = 0; k < str.size(); k++, c++) { + int u = c->uc; + if (u > 255) { + char tmp[7]; + snprintf(tmp, sizeof(tmp), "%%u%04X", u); + s = UString(tmp); + } else if (u != 0 && strchr(do_not_escape, (char)u)) + s = UString(c, 1); + else { + char tmp[4]; + snprintf(tmp, sizeof(tmp), "%%%02X", u); + s = UString(tmp); + } + r += s; + } + + return jsString(r); +} + +JSValue* globalFuncUnescape(ExecState* exec, JSObject*, const List& args) +{ + UString s = "", str = args[0]->toString(exec); + int k = 0, len = str.size(); + while (k < len) { + const UChar* c = str.data() + k; + UChar u; + if (*c == UChar('%') && k <= len - 6 && *(c + 1) == UChar('u')) { + if (Lexer::isHexDigit((c + 2)->uc) && Lexer::isHexDigit((c + 3)->uc) && Lexer::isHexDigit((c + 4)->uc) && Lexer::isHexDigit((c + 5)->uc)) { + u = Lexer::convertUnicode((c + 2)->uc, (c + 3)->uc, (c + 4)->uc, (c + 5)->uc); + c = &u; + k += 5; + } + } else if (*c == UChar('%') && k <= len - 3 && Lexer::isHexDigit((c + 1)->uc) && Lexer::isHexDigit((c + 2)->uc)) { + u = UChar(Lexer::convertHex((c+1)->uc, (c+2)->uc)); + c = &u; + k += 2; + } + k++; + s += UString(c, 1); + } + + return jsString(s); +} + +#ifndef NDEBUG +JSValue* globalFuncKJSPrint(ExecState* exec, JSObject*, const List& args) +{ + puts(args[0]->toString(exec).ascii()); + return jsUndefined(); +} +#endif + +// ------------------------------ PrototypeFunction ------------------------------- + +PrototypeFunction::PrototypeFunction(ExecState* exec, int len, const Identifier& name, JSMemberFunction function) + : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name) + , m_function(function) +{ + ASSERT_ARG(function, function); + putDirect(exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum); +} + +PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function) + : InternalFunctionImp(functionPrototype, name) + , m_function(function) +{ + ASSERT_ARG(function, function); + putDirect(exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum); +} + +JSValue* PrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) +{ + return m_function(exec, thisObj, args); +} + +} // namespace KJS diff --git a/kjs/function.h b/kjs/function.h new file mode 100644 index 0000000..49cf61b --- /dev/null +++ b/kjs/function.h @@ -0,0 +1,159 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) + * Copyright (C) 2007 Maks Orlovich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_FUNCTION_H +#define KJS_FUNCTION_H + +#include "JSVariableObject.h" +#include "LocalStorage.h" +#include "SymbolTable.h" +#include "nodes.h" +#include "object.h" + +namespace KJS { + + class ActivationImp; + class FunctionBodyNode; + class FunctionPrototype; + class JSGlobalObject; + + class InternalFunctionImp : public JSObject { + public: + InternalFunctionImp(); + InternalFunctionImp(FunctionPrototype*, const Identifier&); + + virtual bool implementsCall() const; + virtual JSValue* callAsFunction(ExecState*, JSObject* thisObjec, const List& args) = 0; + virtual bool implementsHasInstance() const; + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + const Identifier& functionName() const { return m_name; } + + private: + Identifier m_name; + }; + + class FunctionImp : public InternalFunctionImp { + friend class ActivationImp; + public: + FunctionImp(ExecState*, const Identifier& name, FunctionBodyNode*, const ScopeChain&); + + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None); + virtual bool deleteProperty(ExecState*, const Identifier& propertyName); + + virtual bool implementsConstruct() const { return true; } + virtual JSObject* construct(ExecState*, const List& args); + + virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List& args); + + // Note: unlike body->paramName, this returns Identifier::null for parameters + // that will never get set, due to later param having the same name + Identifier getParameterName(int index); + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + + RefPtr body; + + void setScope(const ScopeChain& s) { _scope = s; } + const ScopeChain& scope() const { return _scope; } + + virtual void mark(); + + private: + ScopeChain _scope; + + static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + static JSValue* callerGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + static JSValue* lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + }; + + class IndexToNameMap { + public: + IndexToNameMap(FunctionImp*, const List& args); + ~IndexToNameMap(); + + Identifier& operator[](const Identifier& index); + bool isMapped(const Identifier& index) const; + void unMap(const Identifier& index); + + private: + unsigned size; + Identifier* _map; + }; + + class Arguments : public JSObject { + public: + Arguments(ExecState*, FunctionImp* func, const List& args, ActivationImp* act); + virtual void mark(); + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None); + virtual bool deleteProperty(ExecState*, const Identifier& propertyName); + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + private: + static JSValue* mappedIndexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot); + + ActivationImp* _activationObject; + mutable IndexToNameMap indexToNameMap; + }; + + class PrototypeFunction : public InternalFunctionImp { + public: + typedef KJS::JSValue* (*JSMemberFunction)(ExecState*, JSObject*, const List&); + + PrototypeFunction(ExecState*, int len, const Identifier&, JSMemberFunction); + PrototypeFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction); + + virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List&); + + private: + const JSMemberFunction m_function; + }; + + + // Global Functions + JSValue* globalFuncEval(ExecState*, JSObject*, const List&); + JSValue* globalFuncParseInt(ExecState*, JSObject*, const List&); + JSValue* globalFuncParseFloat(ExecState*, JSObject*, const List&); + JSValue* globalFuncIsNaN(ExecState*, JSObject*, const List&); + JSValue* globalFuncIsFinite(ExecState*, JSObject*, const List&); + JSValue* globalFuncDecodeURI(ExecState*, JSObject*, const List&); + JSValue* globalFuncDecodeURIComponent(ExecState*, JSObject*, const List&); + JSValue* globalFuncEncodeURI(ExecState*, JSObject*, const List&); + JSValue* globalFuncEncodeURIComponent(ExecState*, JSObject*, const List&); + JSValue* globalFuncEscape(ExecState*, JSObject*, const List&); + JSValue* globalFuncUnescape(ExecState*, JSObject*, const List&); +#ifndef NDEBUG + JSValue* globalFuncKJSPrint(ExecState*, JSObject*, const List&); +#endif + + static const double mantissaOverflowLowerBound = 9007199254740992.0; + double parseIntOverflow(const char*, int length, int radix); + +} // namespace + +#endif diff --git a/kjs/function_object.cpp b/kjs/function_object.cpp new file mode 100644 index 0000000..5af2970 --- /dev/null +++ b/kjs/function_object.cpp @@ -0,0 +1,244 @@ +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "function_object.h" + +#include "JSGlobalObject.h" +#include "Parser.h" +#include "array_object.h" +#include "debugger.h" +#include "function.h" +#include "internal.h" +#include "lexer.h" +#include "nodes.h" +#include "object.h" +#include +#include +#include + +namespace KJS { + +// ------------------------------ FunctionPrototype ------------------------- + +static JSValue* functionProtoFuncToString(ExecState*, JSObject*, const List&); +static JSValue* functionProtoFuncApply(ExecState*, JSObject*, const List&); +static JSValue* functionProtoFuncCall(ExecState*, JSObject*, const List&); + +FunctionPrototype::FunctionPrototype(ExecState* exec) +{ + static const Identifier* applyPropertyName = new Identifier("apply"); + static const Identifier* callPropertyName = new Identifier("call"); + + putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum); + + putDirectFunction(new PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum); + putDirectFunction(new PrototypeFunction(exec, this, 2, *applyPropertyName, functionProtoFuncApply), DontEnum); + putDirectFunction(new PrototypeFunction(exec, this, 1, *callPropertyName, functionProtoFuncCall), DontEnum); +} + +// ECMA 15.3.4 +JSValue* FunctionPrototype::callAsFunction(ExecState*, JSObject*, const List&) +{ + return jsUndefined(); +} + +// Functions + +JSValue* functionProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj || !thisObj->inherits(&InternalFunctionImp::info)) { +#ifndef NDEBUG + fprintf(stderr,"attempted toString() call on null or non-function object\n"); +#endif + return throwError(exec, TypeError); + } + + if (thisObj->inherits(&FunctionImp::info)) { + FunctionImp* fi = static_cast(thisObj); + return jsString("function " + fi->functionName().ustring() + "(" + fi->body->paramString() + ") " + fi->body->toString()); + } + + return jsString("function " + static_cast(thisObj)->functionName().ustring() + "() {\n [native code]\n}"); +} + +JSValue* functionProtoFuncApply(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->implementsCall()) + return throwError(exec, TypeError); + + JSValue* thisArg = args[0]; + JSValue* argArray = args[1]; + + JSObject* applyThis; + if (thisArg->isUndefinedOrNull()) + applyThis = exec->dynamicGlobalObject(); + else + applyThis = thisArg->toObject(exec); + + List applyArgs; + if (!argArray->isUndefinedOrNull()) { + if (argArray->isObject() && + (static_cast(argArray)->inherits(&ArrayInstance::info) || + static_cast(argArray)->inherits(&Arguments::info))) { + + JSObject* argArrayObj = static_cast(argArray); + unsigned int length = argArrayObj->get(exec, exec->propertyNames().length)->toUInt32(exec); + for (unsigned int i = 0; i < length; i++) + applyArgs.append(argArrayObj->get(exec, i)); + } else + return throwError(exec, TypeError); + } + + return thisObj->call(exec, applyThis, applyArgs); +} + +JSValue* functionProtoFuncCall(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->implementsCall()) + return throwError(exec, TypeError); + + JSValue* thisArg = args[0]; + + JSObject* callThis; + if (thisArg->isUndefinedOrNull()) + callThis = exec->dynamicGlobalObject(); + else + callThis = thisArg->toObject(exec); + + List argsTail; + args.getSlice(1, argsTail); + return thisObj->call(exec, callThis, argsTail); +} + +// ------------------------------ FunctionObjectImp ---------------------------- + +FunctionObjectImp::FunctionObjectImp(ExecState* exec, FunctionPrototype* functionPrototype) + : InternalFunctionImp(functionPrototype, functionPrototype->classInfo()->className) +{ + putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly); + + // Number of arguments for constructor + putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); +} + +bool FunctionObjectImp::implementsConstruct() const +{ + return true; +} + +// ECMA 15.3.2 The Function Constructor +JSObject* FunctionObjectImp::construct(ExecState* exec, const List& args, const Identifier& functionName, const UString& sourceURL, int lineNumber) +{ + UString p(""); + UString body; + int argsSize = args.size(); + if (argsSize == 0) + body = ""; + else if (argsSize == 1) + body = args[0]->toString(exec); + else { + p = args[0]->toString(exec); + for (int k = 1; k < argsSize - 1; k++) + p += "," + args[k]->toString(exec); + body = args[argsSize - 1]->toString(exec); + } + + // parse the source code + int sourceId; + int errLine; + UString errMsg; + RefPtr functionBody = parser().parse(sourceURL, lineNumber, body.data(), body.size(), &sourceId, &errLine, &errMsg); + + // notify debugger that source has been parsed + Debugger* dbg = exec->dynamicGlobalObject()->debugger(); + if (dbg) { + // send empty sourceURL to indicate constructed code + bool cont = dbg->sourceParsed(exec, sourceId, UString(), body, lineNumber, errLine, errMsg); + if (!cont) { + dbg->imp()->abort(); + return new JSObject(); + } + } + + // No program node == syntax error - throw a syntax error + if (!functionBody) + // We can't return a Completion(Throw) here, so just set the exception + // and return it + return throwError(exec, SyntaxError, errMsg, errLine, sourceId, sourceURL); + + ScopeChain scopeChain; + scopeChain.push(exec->lexicalGlobalObject()); + + FunctionImp* fimp = new FunctionImp(exec, functionName, functionBody.get(), scopeChain); + + // parse parameter list. throw syntax error on illegal identifiers + int len = p.size(); + const UChar* c = p.data(); + int i = 0, params = 0; + UString param; + while (i < len) { + while (*c == ' ' && i < len) + c++, i++; + if (Lexer::isIdentStart(c->uc)) { // else error + param = UString(c, 1); + c++, i++; + while (i < len && (Lexer::isIdentPart(c->uc))) { + param += UString(c, 1); + c++, i++; + } + while (i < len && *c == ' ') + c++, i++; + if (i == len) { + functionBody->parameters().append(Identifier(param)); + params++; + break; + } else if (*c == ',') { + functionBody->parameters().append(Identifier(param)); + params++; + c++, i++; + continue; + } // else error + } + return throwError(exec, SyntaxError, "Syntax error in parameter list"); + } + + List consArgs; + + JSObject* objCons = exec->lexicalGlobalObject()->objectConstructor(); + JSObject* prototype = objCons->construct(exec, exec->emptyList()); + prototype->putDirect(exec->propertyNames().constructor, fimp, DontEnum | DontDelete | ReadOnly); + fimp->putDirect(exec->propertyNames().prototype, prototype, Internal | DontDelete); + return fimp; +} + +// ECMA 15.3.2 The Function Constructor +JSObject* FunctionObjectImp::construct(ExecState* exec, const List& args) +{ + return construct(exec, args, "anonymous", UString(), 0); +} + +// ECMA 15.3.1 The Function Constructor Called as a Function +JSValue* FunctionObjectImp::callAsFunction(ExecState* exec, JSObject*, const List& args) +{ + return construct(exec, args); +} + +} // namespace KJS diff --git a/kjs/function_object.h b/kjs/function_object.h new file mode 100644 index 0000000..cd0fe3e --- /dev/null +++ b/kjs/function_object.h @@ -0,0 +1,61 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef FUNCTION_OBJECT_H_ +#define FUNCTION_OBJECT_H_ + +#include "object_object.h" +#include "function.h" + +namespace KJS { + + /** + * @internal + * + * The initial value of Function.prototype (and thus all objects created + * with the Function constructor) + */ + class FunctionPrototype : public InternalFunctionImp { + public: + FunctionPrototype(ExecState*); + + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + }; + + /** + * @internal + * + * The initial value of the the global variable's "Function" property + */ + class FunctionObjectImp : public InternalFunctionImp { + public: + FunctionObjectImp(ExecState*, FunctionPrototype*); + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List&); + virtual JSObject* construct(ExecState*, const List&, const Identifier& functionName, const UString& sourceURL, int lineNumber); + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + }; + +} // namespace KJS + +#endif // _FUNCTION_OBJECT_H_ diff --git a/kjs/grammar.y b/kjs/grammar.y new file mode 100644 index 0000000..658ae89 --- /dev/null +++ b/kjs/grammar.y @@ -0,0 +1,1261 @@ +%{ + +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" + +#include +#include +#include "value.h" +#include "object.h" +#include "types.h" +#include "nodes.h" +#include "lexer.h" +#include "internal.h" +#include "CommonIdentifiers.h" +#include "NodeInfo.h" +#include "Parser.h" +#include + +// Not sure why, but yacc doesn't add this define along with the others. +#define yylloc kjsyylloc + +#define YYMAXDEPTH 10000 +#define YYENABLE_NLS 0 + +/* default values for bison */ +#define YYDEBUG 0 // Set to 1 to debug a parse error. +#define kjsyydebug 0 // Set to 1 to debug a parse error. +#if !PLATFORM(DARWIN) + // avoid triggering warnings in older bison +#define YYERROR_VERBOSE +#endif + +extern int kjsyylex(); +int kjsyyerror(const char *); +static bool allowAutomaticSemicolon(); + +#define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon()) YYABORT; } while (0) +#define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line) + +using namespace KJS; +using namespace std; + +static AddNode* makeAddNode(ExpressionNode*, ExpressionNode*); +static LessNode* makeLessNode(ExpressionNode*, ExpressionNode*); +static ExpressionNode* makeAssignNode(ExpressionNode* loc, Operator, ExpressionNode* expr); +static ExpressionNode* makePrefixNode(ExpressionNode* expr, Operator); +static ExpressionNode* makePostfixNode(ExpressionNode* expr, Operator); +static PropertyNode* makeGetterOrSetterPropertyNode(const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*); +static ExpressionNode* makeFunctionCallNode(ExpressionNode* func, ArgumentsNode*); +static ExpressionNode* makeTypeOfNode(ExpressionNode*); +static ExpressionNode* makeDeleteNode(ExpressionNode*); +static ExpressionNode* makeNegateNode(ExpressionNode*); +static NumberNode* makeNumberNode(double); +static StatementNode* makeVarStatementNode(ExpressionNode*); +static ExpressionNode* combineVarInitializers(ExpressionNode* list, AssignResolveNode* init); + + +#if COMPILER(MSVC) + +#pragma warning(disable: 4065) +#pragma warning(disable: 4244) +#pragma warning(disable: 4702) + +// At least some of the time, the declarations of malloc and free that bison +// generates are causing warnings. A way to avoid this is to explicitly define +// the macros so that bison doesn't try to declare malloc and free. +#define YYMALLOC malloc +#define YYFREE free + +#endif + +template NodeInfo createNodeInfo(T node, ParserRefCountedData* varDecls, + ParserRefCountedData* funcDecls) +{ + NodeInfo result = {node, varDecls, funcDecls}; + return result; +} + +template T mergeDeclarationLists(T decls1, T decls2) +{ + // decls1 or both are null + if (!decls1) + return decls2; + // only decls1 is non-null + if (!decls2) + return decls1; + + // Both are non-null + decls1->data.append(decls2->data); + + // We manually release the declaration lists to avoid accumulating many many + // unused heap allocated vectors + decls2->ref(); + decls2->deref(); + return decls1; +} + +static void appendToVarDeclarationList(ParserRefCountedData*& varDecls, const Identifier& ident, unsigned attrs) +{ + if (!varDecls) + varDecls = new ParserRefCountedData; + + varDecls->data.append(make_pair(ident, attrs)); + +} + +static inline void appendToVarDeclarationList(ParserRefCountedData*& varDecls, ConstDeclNode* decl) +{ + unsigned attrs = DeclarationStacks::IsConstant; + if (decl->m_init) + attrs |= DeclarationStacks::HasInitializer; + appendToVarDeclarationList(varDecls, decl->m_ident, attrs); +} + +%} + +%union { + int intValue; + double doubleValue; + UString* string; + Identifier* ident; + + // expression subtrees + ExpressionNode* expressionNode; + FuncDeclNode* funcDeclNode; + PropertyNode* propertyNode; + ArgumentsNode* argumentsNode; + ConstDeclNode* constDeclNode; + CaseBlockNodeInfo caseBlockNode; + CaseClauseNodeInfo caseClauseNode; + FuncExprNode* funcExprNode; + + // statement nodes + StatementNodeInfo statementNode; + FunctionBodyNode* functionBodyNode; + ProgramNode* programNode; + + SourceElementsInfo sourceElements; + PropertyList propertyList; + ArgumentList argumentList; + VarDeclListInfo varDeclList; + ConstDeclListInfo constDeclList; + ClauseListInfo clauseList; + ElementList elementList; + ParameterList parameterList; + + Operator op; +} + +%start Program + +/* literals */ +%token NULLTOKEN TRUETOKEN FALSETOKEN + +/* keywords */ +%token BREAK CASE DEFAULT FOR NEW VAR CONSTTOKEN CONTINUE +%token FUNCTION RETURN VOIDTOKEN DELETETOKEN +%token IF THISTOKEN DO WHILE INTOKEN INSTANCEOF TYPEOF +%token SWITCH WITH RESERVED +%token THROW TRY CATCH FINALLY +%token DEBUGGER + +/* give an if without an else higher precedence than an else to resolve the ambiguity */ +%nonassoc IF_WITHOUT_ELSE +%nonassoc ELSE + +/* punctuators */ +%token EQEQ NE /* == and != */ +%token STREQ STRNEQ /* === and !== */ +%token LE GE /* < and > */ +%token OR AND /* || and && */ +%token PLUSPLUS MINUSMINUS /* ++ and -- */ +%token LSHIFT /* << */ +%token RSHIFT URSHIFT /* >> and >>> */ +%token PLUSEQUAL MINUSEQUAL /* += and -= */ +%token MULTEQUAL DIVEQUAL /* *= and /= */ +%token LSHIFTEQUAL /* <<= */ +%token RSHIFTEQUAL URSHIFTEQUAL /* >>= and >>>= */ +%token ANDEQUAL MODEQUAL /* &= and %= */ +%token XOREQUAL OREQUAL /* ^= and |= */ + +/* terminal types */ +%token NUMBER +%token STRING +%token IDENT + +/* automatically inserted semicolon */ +%token AUTOPLUSPLUS AUTOMINUSMINUS + +/* non-terminal types */ +%type Literal ArrayLiteral + +%type PrimaryExpr PrimaryExprNoBrace +%type MemberExpr MemberExprNoBF /* BF => brace or function */ +%type NewExpr NewExprNoBF +%type CallExpr CallExprNoBF +%type LeftHandSideExpr LeftHandSideExprNoBF +%type PostfixExpr PostfixExprNoBF +%type UnaryExpr UnaryExprNoBF UnaryExprCommon +%type MultiplicativeExpr MultiplicativeExprNoBF +%type AdditiveExpr AdditiveExprNoBF +%type ShiftExpr ShiftExprNoBF +%type RelationalExpr RelationalExprNoIn RelationalExprNoBF +%type EqualityExpr EqualityExprNoIn EqualityExprNoBF +%type BitwiseANDExpr BitwiseANDExprNoIn BitwiseANDExprNoBF +%type BitwiseXORExpr BitwiseXORExprNoIn BitwiseXORExprNoBF +%type BitwiseORExpr BitwiseORExprNoIn BitwiseORExprNoBF +%type LogicalANDExpr LogicalANDExprNoIn LogicalANDExprNoBF +%type LogicalORExpr LogicalORExprNoIn LogicalORExprNoBF +%type ConditionalExpr ConditionalExprNoIn ConditionalExprNoBF +%type AssignmentExpr AssignmentExprNoIn AssignmentExprNoBF +%type Expr ExprNoIn ExprNoBF + +%type ExprOpt ExprNoInOpt + +%type Statement Block +%type VariableStatement ConstStatement EmptyStatement ExprStatement +%type IfStatement IterationStatement ContinueStatement +%type BreakStatement ReturnStatement WithStatement +%type SwitchStatement LabelledStatement +%type ThrowStatement TryStatement +%type DebuggerStatement +%type SourceElement + +%type Initializer InitializerNoIn +%type FunctionDeclaration +%type FunctionExpr +%type FunctionBody +%type SourceElements +%type FormalParameterList +%type AssignmentOperator +%type Arguments +%type ArgumentList +%type VariableDeclarationList VariableDeclarationListNoIn +%type ConstDeclarationList +%type ConstDeclaration +%type CaseBlock +%type CaseClause DefaultClause +%type CaseClauses CaseClausesOpt +%type Elision ElisionOpt +%type ElementList +%type Property +%type PropertyList +%% + +Literal: + NULLTOKEN { $$ = new NullNode; } + | TRUETOKEN { $$ = new TrueNode; } + | FALSETOKEN { $$ = new FalseNode; } + | NUMBER { $$ = makeNumberNode($1); } + | STRING { $$ = new StringNode($1); } + | '/' /* regexp */ { + Lexer& l = lexer(); + if (!l.scanRegExp()) + YYABORT; + $$ = new RegExpNode(l.pattern(), l.flags()); + } + | DIVEQUAL /* regexp with /= */ { + Lexer& l = lexer(); + if (!l.scanRegExp()) + YYABORT; + $$ = new RegExpNode("=" + l.pattern(), l.flags()); + } +; + +Property: + IDENT ':' AssignmentExpr { $$ = new PropertyNode(*$1, $3, PropertyNode::Constant); } + | STRING ':' AssignmentExpr { $$ = new PropertyNode(Identifier(*$1), $3, PropertyNode::Constant); } + | NUMBER ':' AssignmentExpr { $$ = new PropertyNode(Identifier(UString::from($1)), $3, PropertyNode::Constant); } + | IDENT IDENT '(' ')' '{' FunctionBody '}' { $$ = makeGetterOrSetterPropertyNode(*$1, *$2, 0, $6); DBG($6, @5, @7); if (!$$) YYABORT; } + | IDENT IDENT '(' FormalParameterList ')' '{' FunctionBody '}' + { $$ = makeGetterOrSetterPropertyNode(*$1, *$2, $4.head, $7); DBG($7, @6, @8); if (!$$) YYABORT; } +; + +PropertyList: + Property { $$.head = new PropertyListNode($1); + $$.tail = $$.head; } + | PropertyList ',' Property { $$.head = $1.head; + $$.tail = new PropertyListNode($3, $1.tail); } +; + +PrimaryExpr: + PrimaryExprNoBrace + | '{' '}' { $$ = new ObjectLiteralNode(); } + | '{' PropertyList '}' { $$ = new ObjectLiteralNode($2.head); } + /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */ + | '{' PropertyList ',' '}' { $$ = new ObjectLiteralNode($2.head); } +; + +PrimaryExprNoBrace: + THISTOKEN { $$ = new ThisNode(); } + | Literal + | ArrayLiteral + | IDENT { $$ = new ResolveNode(*$1); } + | '(' Expr ')' { $$ = $2; } +; + +ArrayLiteral: + '[' ElisionOpt ']' { $$ = new ArrayNode($2); } + | '[' ElementList ']' { $$ = new ArrayNode($2.head); } + | '[' ElementList ',' ElisionOpt ']' { $$ = new ArrayNode($4, $2.head); } +; + +ElementList: + ElisionOpt AssignmentExpr { $$.head = new ElementNode($1, $2); + $$.tail = $$.head; } + | ElementList ',' ElisionOpt AssignmentExpr + { $$.head = $1.head; + $$.tail = new ElementNode($1.tail, $3, $4); } +; + +ElisionOpt: + /* nothing */ { $$ = 0; } + | Elision +; + +Elision: + ',' { $$ = 1; } + | Elision ',' { $$ = $1 + 1; } +; + +MemberExpr: + PrimaryExpr + | FunctionExpr { $$ = $1; } + | MemberExpr '[' Expr ']' { $$ = new BracketAccessorNode($1, $3); } + | MemberExpr '.' IDENT { $$ = new DotAccessorNode($1, *$3); } + | NEW MemberExpr Arguments { $$ = new NewExprNode($2, $3); } +; + +MemberExprNoBF: + PrimaryExprNoBrace + | MemberExprNoBF '[' Expr ']' { $$ = new BracketAccessorNode($1, $3); } + | MemberExprNoBF '.' IDENT { $$ = new DotAccessorNode($1, *$3); } + | NEW MemberExpr Arguments { $$ = new NewExprNode($2, $3); } +; + +NewExpr: + MemberExpr + | NEW NewExpr { $$ = new NewExprNode($2); } +; + +NewExprNoBF: + MemberExprNoBF + | NEW NewExpr { $$ = new NewExprNode($2); } +; + +CallExpr: + MemberExpr Arguments { $$ = makeFunctionCallNode($1, $2); } + | CallExpr Arguments { $$ = makeFunctionCallNode($1, $2); } + | CallExpr '[' Expr ']' { $$ = new BracketAccessorNode($1, $3); } + | CallExpr '.' IDENT { $$ = new DotAccessorNode($1, *$3); } +; + +CallExprNoBF: + MemberExprNoBF Arguments { $$ = makeFunctionCallNode($1, $2); } + | CallExprNoBF Arguments { $$ = makeFunctionCallNode($1, $2); } + | CallExprNoBF '[' Expr ']' { $$ = new BracketAccessorNode($1, $3); } + | CallExprNoBF '.' IDENT { $$ = new DotAccessorNode($1, *$3); } +; + +Arguments: + '(' ')' { $$ = new ArgumentsNode(); } + | '(' ArgumentList ')' { $$ = new ArgumentsNode($2.head); } +; + +ArgumentList: + AssignmentExpr { $$.head = new ArgumentListNode($1); + $$.tail = $$.head; } + | ArgumentList ',' AssignmentExpr { $$.head = $1.head; + $$.tail = new ArgumentListNode($1.tail, $3); } +; + +LeftHandSideExpr: + NewExpr + | CallExpr +; + +LeftHandSideExprNoBF: + NewExprNoBF + | CallExprNoBF +; + +PostfixExpr: + LeftHandSideExpr + | LeftHandSideExpr PLUSPLUS { $$ = makePostfixNode($1, OpPlusPlus); } + | LeftHandSideExpr MINUSMINUS { $$ = makePostfixNode($1, OpMinusMinus); } +; + +PostfixExprNoBF: + LeftHandSideExprNoBF + | LeftHandSideExprNoBF PLUSPLUS { $$ = makePostfixNode($1, OpPlusPlus); } + | LeftHandSideExprNoBF MINUSMINUS { $$ = makePostfixNode($1, OpMinusMinus); } +; + +UnaryExprCommon: + DELETETOKEN UnaryExpr { $$ = makeDeleteNode($2); } + | VOIDTOKEN UnaryExpr { $$ = new VoidNode($2); } + | TYPEOF UnaryExpr { $$ = makeTypeOfNode($2); } + | PLUSPLUS UnaryExpr { $$ = makePrefixNode($2, OpPlusPlus); } + | AUTOPLUSPLUS UnaryExpr { $$ = makePrefixNode($2, OpPlusPlus); } + | MINUSMINUS UnaryExpr { $$ = makePrefixNode($2, OpMinusMinus); } + | AUTOMINUSMINUS UnaryExpr { $$ = makePrefixNode($2, OpMinusMinus); } + | '+' UnaryExpr { $$ = new UnaryPlusNode($2); } + | '-' UnaryExpr { $$ = makeNegateNode($2); } + | '~' UnaryExpr { $$ = new BitwiseNotNode($2); } + | '!' UnaryExpr { $$ = new LogicalNotNode($2); } + +UnaryExpr: + PostfixExpr + | UnaryExprCommon +; + +UnaryExprNoBF: + PostfixExprNoBF + | UnaryExprCommon +; + +MultiplicativeExpr: + UnaryExpr + | MultiplicativeExpr '*' UnaryExpr { $$ = new MultNode($1, $3); } + | MultiplicativeExpr '/' UnaryExpr { $$ = new DivNode($1, $3); } + | MultiplicativeExpr '%' UnaryExpr { $$ = new ModNode($1, $3); } +; + +MultiplicativeExprNoBF: + UnaryExprNoBF + | MultiplicativeExprNoBF '*' UnaryExpr + { $$ = new MultNode($1, $3); } + | MultiplicativeExprNoBF '/' UnaryExpr + { $$ = new DivNode($1, $3); } + | MultiplicativeExprNoBF '%' UnaryExpr + { $$ = new ModNode($1, $3); } +; + +AdditiveExpr: + MultiplicativeExpr + | AdditiveExpr '+' MultiplicativeExpr { $$ = makeAddNode($1, $3); } + | AdditiveExpr '-' MultiplicativeExpr { $$ = new SubNode($1, $3); } +; + +AdditiveExprNoBF: + MultiplicativeExprNoBF + | AdditiveExprNoBF '+' MultiplicativeExpr + { $$ = makeAddNode($1, $3); } + | AdditiveExprNoBF '-' MultiplicativeExpr + { $$ = new SubNode($1, $3); } +; + +ShiftExpr: + AdditiveExpr + | ShiftExpr LSHIFT AdditiveExpr { $$ = new LeftShiftNode($1, $3); } + | ShiftExpr RSHIFT AdditiveExpr { $$ = new RightShiftNode($1, $3); } + | ShiftExpr URSHIFT AdditiveExpr { $$ = new UnsignedRightShiftNode($1, $3); } +; + +ShiftExprNoBF: + AdditiveExprNoBF + | ShiftExprNoBF LSHIFT AdditiveExpr { $$ = new LeftShiftNode($1, $3); } + | ShiftExprNoBF RSHIFT AdditiveExpr { $$ = new RightShiftNode($1, $3); } + | ShiftExprNoBF URSHIFT AdditiveExpr { $$ = new UnsignedRightShiftNode($1, $3); } +; + +RelationalExpr: + ShiftExpr + | RelationalExpr '<' ShiftExpr { $$ = makeLessNode($1, $3); } + | RelationalExpr '>' ShiftExpr { $$ = new GreaterNode($1, $3); } + | RelationalExpr LE ShiftExpr { $$ = new LessEqNode($1, $3); } + | RelationalExpr GE ShiftExpr { $$ = new GreaterEqNode($1, $3); } + | RelationalExpr INSTANCEOF ShiftExpr { $$ = new InstanceOfNode($1, $3); } + | RelationalExpr INTOKEN ShiftExpr { $$ = new InNode($1, $3); } +; + +RelationalExprNoIn: + ShiftExpr + | RelationalExprNoIn '<' ShiftExpr { $$ = makeLessNode($1, $3); } + | RelationalExprNoIn '>' ShiftExpr { $$ = new GreaterNode($1, $3); } + | RelationalExprNoIn LE ShiftExpr { $$ = new LessEqNode($1, $3); } + | RelationalExprNoIn GE ShiftExpr { $$ = new GreaterEqNode($1, $3); } + | RelationalExprNoIn INSTANCEOF ShiftExpr + { $$ = new InstanceOfNode($1, $3); } +; + +RelationalExprNoBF: + ShiftExprNoBF + | RelationalExprNoBF '<' ShiftExpr { $$ = makeLessNode($1, $3); } + | RelationalExprNoBF '>' ShiftExpr { $$ = new GreaterNode($1, $3); } + | RelationalExprNoBF LE ShiftExpr { $$ = new LessEqNode($1, $3); } + | RelationalExprNoBF GE ShiftExpr { $$ = new GreaterEqNode($1, $3); } + | RelationalExprNoBF INSTANCEOF ShiftExpr + { $$ = new InstanceOfNode($1, $3); } + | RelationalExprNoBF INTOKEN ShiftExpr { $$ = new InNode($1, $3); } +; + +EqualityExpr: + RelationalExpr + | EqualityExpr EQEQ RelationalExpr { $$ = new EqualNode($1, $3); } + | EqualityExpr NE RelationalExpr { $$ = new NotEqualNode($1, $3); } + | EqualityExpr STREQ RelationalExpr { $$ = new StrictEqualNode($1, $3); } + | EqualityExpr STRNEQ RelationalExpr { $$ = new NotStrictEqualNode($1, $3); } +; + +EqualityExprNoIn: + RelationalExprNoIn + | EqualityExprNoIn EQEQ RelationalExprNoIn + { $$ = new EqualNode($1, $3); } + | EqualityExprNoIn NE RelationalExprNoIn + { $$ = new NotEqualNode($1, $3); } + | EqualityExprNoIn STREQ RelationalExprNoIn + { $$ = new StrictEqualNode($1, $3); } + | EqualityExprNoIn STRNEQ RelationalExprNoIn + { $$ = new NotStrictEqualNode($1, $3); } +; + +EqualityExprNoBF: + RelationalExprNoBF + | EqualityExprNoBF EQEQ RelationalExpr + { $$ = new EqualNode($1, $3); } + | EqualityExprNoBF NE RelationalExpr { $$ = new NotEqualNode($1, $3); } + | EqualityExprNoBF STREQ RelationalExpr + { $$ = new StrictEqualNode($1, $3); } + | EqualityExprNoBF STRNEQ RelationalExpr + { $$ = new NotStrictEqualNode($1, $3); } +; + +BitwiseANDExpr: + EqualityExpr + | BitwiseANDExpr '&' EqualityExpr { $$ = new BitAndNode($1, $3); } +; + +BitwiseANDExprNoIn: + EqualityExprNoIn + | BitwiseANDExprNoIn '&' EqualityExprNoIn + { $$ = new BitAndNode($1, $3); } +; + +BitwiseANDExprNoBF: + EqualityExprNoBF + | BitwiseANDExprNoBF '&' EqualityExpr { $$ = new BitAndNode($1, $3); } +; + +BitwiseXORExpr: + BitwiseANDExpr + | BitwiseXORExpr '^' BitwiseANDExpr { $$ = new BitXOrNode($1, $3); } +; + +BitwiseXORExprNoIn: + BitwiseANDExprNoIn + | BitwiseXORExprNoIn '^' BitwiseANDExprNoIn + { $$ = new BitXOrNode($1, $3); } +; + +BitwiseXORExprNoBF: + BitwiseANDExprNoBF + | BitwiseXORExprNoBF '^' BitwiseANDExpr + { $$ = new BitXOrNode($1, $3); } +; + +BitwiseORExpr: + BitwiseXORExpr + | BitwiseORExpr '|' BitwiseXORExpr { $$ = new BitOrNode($1, $3); } +; + +BitwiseORExprNoIn: + BitwiseXORExprNoIn + | BitwiseORExprNoIn '|' BitwiseXORExprNoIn + { $$ = new BitOrNode($1, $3); } +; + +BitwiseORExprNoBF: + BitwiseXORExprNoBF + | BitwiseORExprNoBF '|' BitwiseXORExpr + { $$ = new BitOrNode($1, $3); } +; + +LogicalANDExpr: + BitwiseORExpr + | LogicalANDExpr AND BitwiseORExpr { $$ = new LogicalAndNode($1, $3); } +; + +LogicalANDExprNoIn: + BitwiseORExprNoIn + | LogicalANDExprNoIn AND BitwiseORExprNoIn + { $$ = new LogicalAndNode($1, $3); } +; + +LogicalANDExprNoBF: + BitwiseORExprNoBF + | LogicalANDExprNoBF AND BitwiseORExpr + { $$ = new LogicalAndNode($1, $3); } +; + +LogicalORExpr: + LogicalANDExpr + | LogicalORExpr OR LogicalANDExpr { $$ = new LogicalOrNode($1, $3); } +; + +LogicalORExprNoIn: + LogicalANDExprNoIn + | LogicalORExprNoIn OR LogicalANDExprNoIn + { $$ = new LogicalOrNode($1, $3); } +; + +LogicalORExprNoBF: + LogicalANDExprNoBF + | LogicalORExprNoBF OR LogicalANDExpr { $$ = new LogicalOrNode($1, $3); } +; + +ConditionalExpr: + LogicalORExpr + | LogicalORExpr '?' AssignmentExpr ':' AssignmentExpr + { $$ = new ConditionalNode($1, $3, $5); } +; + +ConditionalExprNoIn: + LogicalORExprNoIn + | LogicalORExprNoIn '?' AssignmentExprNoIn ':' AssignmentExprNoIn + { $$ = new ConditionalNode($1, $3, $5); } +; + +ConditionalExprNoBF: + LogicalORExprNoBF + | LogicalORExprNoBF '?' AssignmentExpr ':' AssignmentExpr + { $$ = new ConditionalNode($1, $3, $5); } +; + +AssignmentExpr: + ConditionalExpr + | LeftHandSideExpr AssignmentOperator AssignmentExpr + { $$ = makeAssignNode($1, $2, $3); } +; + +AssignmentExprNoIn: + ConditionalExprNoIn + | LeftHandSideExpr AssignmentOperator AssignmentExprNoIn + { $$ = makeAssignNode($1, $2, $3); } +; + +AssignmentExprNoBF: + ConditionalExprNoBF + | LeftHandSideExprNoBF AssignmentOperator AssignmentExpr + { $$ = makeAssignNode($1, $2, $3); } +; + +AssignmentOperator: + '=' { $$ = OpEqual; } + | PLUSEQUAL { $$ = OpPlusEq; } + | MINUSEQUAL { $$ = OpMinusEq; } + | MULTEQUAL { $$ = OpMultEq; } + | DIVEQUAL { $$ = OpDivEq; } + | LSHIFTEQUAL { $$ = OpLShift; } + | RSHIFTEQUAL { $$ = OpRShift; } + | URSHIFTEQUAL { $$ = OpURShift; } + | ANDEQUAL { $$ = OpAndEq; } + | XOREQUAL { $$ = OpXOrEq; } + | OREQUAL { $$ = OpOrEq; } + | MODEQUAL { $$ = OpModEq; } +; + +Expr: + AssignmentExpr + | Expr ',' AssignmentExpr { $$ = new CommaNode($1, $3); } +; + +ExprNoIn: + AssignmentExprNoIn + | ExprNoIn ',' AssignmentExprNoIn { $$ = new CommaNode($1, $3); } +; + +ExprNoBF: + AssignmentExprNoBF + | ExprNoBF ',' AssignmentExpr { $$ = new CommaNode($1, $3); } +; + +Statement: + Block + | VariableStatement + | ConstStatement + | EmptyStatement + | ExprStatement + | IfStatement + | IterationStatement + | ContinueStatement + | BreakStatement + | ReturnStatement + | WithStatement + | SwitchStatement + | LabelledStatement + | ThrowStatement + | TryStatement + | DebuggerStatement +; + +Block: + '{' '}' { $$ = createNodeInfo(new BlockNode(0), 0, 0); + DBG($$.m_node, @1, @2); } + | '{' SourceElements '}' { $$ = createNodeInfo(new BlockNode($2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations); + DBG($$.m_node, @1, @3); } +; + +VariableStatement: + VAR VariableDeclarationList ';' { $$ = createNodeInfo(makeVarStatementNode($2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations); + DBG($$.m_node, @1, @3); } + | VAR VariableDeclarationList error { $$ = createNodeInfo(makeVarStatementNode($2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations); + DBG($$.m_node, @1, @2); + AUTO_SEMICOLON; } +; + +VariableDeclarationList: + IDENT { $$.m_node = 0; + $$.m_varDeclarations = new ParserRefCountedData; + appendToVarDeclarationList($$.m_varDeclarations, *$1, 0); + $$.m_funcDeclarations = 0; + } + | IDENT Initializer { $$.m_node = new AssignResolveNode(*$1, $2); + $$.m_varDeclarations = new ParserRefCountedData; + appendToVarDeclarationList($$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer); + $$.m_funcDeclarations = 0; + } + | VariableDeclarationList ',' IDENT + { $$.m_node = $1.m_node; + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList($$.m_varDeclarations, *$3, 0); + $$.m_funcDeclarations = 0; + } + | VariableDeclarationList ',' IDENT Initializer + { $$.m_node = combineVarInitializers($1.m_node, new AssignResolveNode(*$3, $4)); + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList($$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer); + $$.m_funcDeclarations = 0; + } +; + +VariableDeclarationListNoIn: + IDENT { $$.m_node = 0; + $$.m_varDeclarations = new ParserRefCountedData; + appendToVarDeclarationList($$.m_varDeclarations, *$1, 0); + $$.m_funcDeclarations = 0; + } + | IDENT InitializerNoIn { $$.m_node = new AssignResolveNode(*$1, $2); + $$.m_varDeclarations = new ParserRefCountedData; + appendToVarDeclarationList($$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer); + $$.m_funcDeclarations = 0; + } + | VariableDeclarationListNoIn ',' IDENT + { $$.m_node = $1.m_node; + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList($$.m_varDeclarations, *$3, 0); + $$.m_funcDeclarations = 0; + } + | VariableDeclarationListNoIn ',' IDENT InitializerNoIn + { $$.m_node = combineVarInitializers($1.m_node, new AssignResolveNode(*$3, $4)); + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList($$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer); + $$.m_funcDeclarations = 0; + } +; + +ConstStatement: + CONSTTOKEN ConstDeclarationList ';' { $$ = createNodeInfo(new ConstStatementNode($2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations); + DBG($$.m_node, @1, @3); } + | CONSTTOKEN ConstDeclarationList error + { $$ = createNodeInfo(new ConstStatementNode($2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations); + DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } +; + +ConstDeclarationList: + ConstDeclaration { $$.m_node.head = $1; + $$.m_node.tail = $$.m_node.head; + $$.m_varDeclarations = new ParserRefCountedData; + appendToVarDeclarationList($$.m_varDeclarations, $1); + $$.m_funcDeclarations = 0; } + | ConstDeclarationList ',' ConstDeclaration + { $$.m_node.head = $1.m_node.head; + $1.m_node.tail->m_next = $3; + $$.m_node.tail = $3; + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList($$.m_varDeclarations, $3); + $$.m_funcDeclarations = 0; } +; + +ConstDeclaration: + IDENT { $$ = new ConstDeclNode(*$1, 0); } + | IDENT Initializer { $$ = new ConstDeclNode(*$1, $2); } +; + +Initializer: + '=' AssignmentExpr { $$ = $2; } +; + +InitializerNoIn: + '=' AssignmentExprNoIn { $$ = $2; } +; + +EmptyStatement: + ';' { $$ = createNodeInfo(new EmptyStatementNode(), 0, 0); } +; + +ExprStatement: + ExprNoBF ';' { $$ = createNodeInfo(new ExprStatementNode($1), 0, 0); + DBG($$.m_node, @1, @2); } + | ExprNoBF error { $$ = createNodeInfo(new ExprStatementNode($1), 0, 0); + DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } +; + +IfStatement: + IF '(' Expr ')' Statement %prec IF_WITHOUT_ELSE + { $$ = createNodeInfo(new IfNode($3, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations); + DBG($$.m_node, @1, @4); } + | IF '(' Expr ')' Statement ELSE Statement + { $$ = createNodeInfo(new IfElseNode($3, $5.m_node, $7.m_node), mergeDeclarationLists($5.m_varDeclarations, $7.m_varDeclarations), mergeDeclarationLists($5.m_funcDeclarations, $7.m_funcDeclarations)); + DBG($$.m_node, @1, @4); } +; + +IterationStatement: + DO Statement WHILE '(' Expr ')' ';' { $$ = createNodeInfo(new DoWhileNode($2.m_node, $5), $2.m_varDeclarations, $2.m_funcDeclarations); + DBG($$.m_node, @1, @3); } + | DO Statement WHILE '(' Expr ')' error { $$ = createNodeInfo(new DoWhileNode($2.m_node, $5), $2.m_varDeclarations, $2.m_funcDeclarations); + DBG($$.m_node, @1, @3); } // Always performs automatic semicolon insertion. + | WHILE '(' Expr ')' Statement { $$ = createNodeInfo(new WhileNode($3, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations); + DBG($$.m_node, @1, @4); } + | FOR '(' ExprNoInOpt ';' ExprOpt ';' ExprOpt ')' Statement + { $$ = createNodeInfo(new ForNode($3, $5, $7, $9.m_node, false), $9.m_varDeclarations, $9.m_funcDeclarations); + DBG($$.m_node, @1, @8); + } + | FOR '(' VAR VariableDeclarationListNoIn ';' ExprOpt ';' ExprOpt ')' Statement + { $$ = createNodeInfo(new ForNode($4.m_node, $6, $8, $10.m_node, true), + mergeDeclarationLists($4.m_varDeclarations, $10.m_varDeclarations), + mergeDeclarationLists($4.m_funcDeclarations, $10.m_funcDeclarations)); + DBG($$.m_node, @1, @9); } + | FOR '(' LeftHandSideExpr INTOKEN Expr ')' Statement + { + ExpressionNode* n = $3; + if (!n->isLocation()) + YYABORT; + $$ = createNodeInfo(new ForInNode(n, $5, $7.m_node), $7.m_varDeclarations, $7.m_funcDeclarations); + DBG($$.m_node, @1, @6); + } + | FOR '(' VAR IDENT INTOKEN Expr ')' Statement + { ForInNode *forIn = new ForInNode(*$4, 0, $6, $8.m_node); + appendToVarDeclarationList($8.m_varDeclarations, *$4, DeclarationStacks::HasInitializer); + $$ = createNodeInfo(forIn, $8.m_varDeclarations, $8.m_funcDeclarations); + DBG($$.m_node, @1, @7); } + | FOR '(' VAR IDENT InitializerNoIn INTOKEN Expr ')' Statement + { ForInNode *forIn = new ForInNode(*$4, $5, $7, $9.m_node); + appendToVarDeclarationList($9.m_varDeclarations, *$4, DeclarationStacks::HasInitializer); + $$ = createNodeInfo(forIn, $9.m_varDeclarations, $9.m_funcDeclarations); + DBG($$.m_node, @1, @8); } +; + +ExprOpt: + /* nothing */ { $$ = 0; } + | Expr +; + +ExprNoInOpt: + /* nothing */ { $$ = 0; } + | ExprNoIn +; + +ContinueStatement: + CONTINUE ';' { $$ = createNodeInfo(new ContinueNode(), 0, 0); + DBG($$.m_node, @1, @2); } + | CONTINUE error { $$ = createNodeInfo(new ContinueNode(), 0, 0); + DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } + | CONTINUE IDENT ';' { $$ = createNodeInfo(new ContinueNode(*$2), 0, 0); + DBG($$.m_node, @1, @3); } + | CONTINUE IDENT error { $$ = createNodeInfo(new ContinueNode(*$2), 0, 0); + DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } +; + +BreakStatement: + BREAK ';' { $$ = createNodeInfo(new BreakNode(), 0, 0); DBG($$.m_node, @1, @2); } + | BREAK error { $$ = createNodeInfo(new BreakNode(), 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } + | BREAK IDENT ';' { $$ = createNodeInfo(new BreakNode(*$2), 0, 0); DBG($$.m_node, @1, @3); } + | BREAK IDENT error { $$ = createNodeInfo(new BreakNode(*$2), 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } +; + +ReturnStatement: + RETURN ';' { $$ = createNodeInfo(new ReturnNode(0), 0, 0); DBG($$.m_node, @1, @2); } + | RETURN error { $$ = createNodeInfo(new ReturnNode(0), 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } + | RETURN Expr ';' { $$ = createNodeInfo(new ReturnNode($2), 0, 0); DBG($$.m_node, @1, @3); } + | RETURN Expr error { $$ = createNodeInfo(new ReturnNode($2), 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } +; + +WithStatement: + WITH '(' Expr ')' Statement { $$ = createNodeInfo(new WithNode($3, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations); + DBG($$.m_node, @1, @4); } +; + +SwitchStatement: + SWITCH '(' Expr ')' CaseBlock { $$ = createNodeInfo(new SwitchNode($3, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations); + DBG($$.m_node, @1, @4); } +; + +CaseBlock: + '{' CaseClausesOpt '}' { $$ = createNodeInfo(new CaseBlockNode($2.m_node.head, 0, 0), $2.m_varDeclarations, $2.m_funcDeclarations); } + | '{' CaseClausesOpt DefaultClause CaseClausesOpt '}' + { $$ = createNodeInfo(new CaseBlockNode($2.m_node.head, $3.m_node, $4.m_node.head), + mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $3.m_varDeclarations), $4.m_varDeclarations), + mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $3.m_funcDeclarations), $4.m_funcDeclarations)); } +; + +CaseClausesOpt: + /* nothing */ { $$.m_node.head = 0; $$.m_node.tail = 0; $$.m_varDeclarations = 0; $$.m_funcDeclarations = 0; } + | CaseClauses +; + +CaseClauses: + CaseClause { $$.m_node.head = new ClauseListNode($1.m_node); + $$.m_node.tail = $$.m_node.head; + $$.m_varDeclarations = $1.m_varDeclarations; + $$.m_funcDeclarations = $1.m_funcDeclarations; } + | CaseClauses CaseClause { $$.m_node.head = $1.m_node.head; + $$.m_node.tail = new ClauseListNode($1.m_node.tail, $2.m_node); + $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations); + $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations); + } +; + +CaseClause: + CASE Expr ':' { $$ = createNodeInfo(new CaseClauseNode($2), 0, 0); } + | CASE Expr ':' SourceElements { $$ = createNodeInfo(new CaseClauseNode($2, $4.m_node), $4.m_varDeclarations, $4.m_funcDeclarations); } +; + +DefaultClause: + DEFAULT ':' { $$ = createNodeInfo(new CaseClauseNode(0), 0, 0); } + | DEFAULT ':' SourceElements { $$ = createNodeInfo(new CaseClauseNode(0, $3.m_node), $3.m_varDeclarations, $3.m_funcDeclarations); } +; + +LabelledStatement: + IDENT ':' Statement { $3.m_node->pushLabel(*$1); + $$ = createNodeInfo(new LabelNode(*$1, $3.m_node), $3.m_varDeclarations, $3.m_funcDeclarations); } +; + +ThrowStatement: + THROW Expr ';' { $$ = createNodeInfo(new ThrowNode($2), 0, 0); DBG($$.m_node, @1, @3); } + | THROW Expr error { $$ = createNodeInfo(new ThrowNode($2), 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } +; + +TryStatement: + TRY Block FINALLY Block { $$ = createNodeInfo(new TryNode($2.m_node, CommonIdentifiers::shared()->nullIdentifier, 0, $4.m_node), + mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations), + mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations)); + DBG($$.m_node, @1, @2); } + | TRY Block CATCH '(' IDENT ')' Block { $$ = createNodeInfo(new TryNode($2.m_node, *$5, $7.m_node, 0), + mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), + mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations)); + DBG($$.m_node, @1, @2); } + | TRY Block CATCH '(' IDENT ')' Block FINALLY Block + { $$ = createNodeInfo(new TryNode($2.m_node, *$5, $7.m_node, $9.m_node), + mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), $9.m_varDeclarations), + mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations), $9.m_funcDeclarations)); + DBG($$.m_node, @1, @2); } +; + +DebuggerStatement: + DEBUGGER ';' { $$ = createNodeInfo(new EmptyStatementNode(), 0, 0); + DBG($$.m_node, @1, @2); } + | DEBUGGER error { $$ = createNodeInfo(new EmptyStatementNode(), 0, 0); + DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } +; + +FunctionDeclaration: + FUNCTION IDENT '(' ')' '{' FunctionBody '}' { $$ = new FuncDeclNode(*$2, $6); DBG($6, @5, @7); } + | FUNCTION IDENT '(' FormalParameterList ')' '{' FunctionBody '}' + { $$ = new FuncDeclNode(*$2, $4.head, $7); DBG($7, @6, @8); } +; + +FunctionExpr: + FUNCTION '(' ')' '{' FunctionBody '}' { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $5); DBG($5, @4, @6); } + | FUNCTION '(' FormalParameterList ')' '{' FunctionBody '}' { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $6, $3.head); DBG($6, @5, @7); } + | FUNCTION IDENT '(' ')' '{' FunctionBody '}' { $$ = new FuncExprNode(*$2, $6); DBG($6, @5, @7); } + | FUNCTION IDENT '(' FormalParameterList ')' '{' FunctionBody '}' { $$ = new FuncExprNode(*$2, $7, $4.head); DBG($7, @6, @8); } +; + +FormalParameterList: + IDENT { $$.head = new ParameterNode(*$1); + $$.tail = $$.head; } + | FormalParameterList ',' IDENT { $$.head = $1.head; + $$.tail = new ParameterNode($1.tail, *$3); } +; + +FunctionBody: + /* not in spec */ { $$ = FunctionBodyNode::create(0, 0, 0); } + | SourceElements { $$ = FunctionBodyNode::create($1.m_node, $1.m_varDeclarations ? &$1.m_varDeclarations->data : 0, + $1.m_funcDeclarations ? &$1.m_funcDeclarations->data : 0); + // As in mergeDeclarationLists() we have to ref/deref to safely get rid of + // the declaration lists. + if ($1.m_varDeclarations) { + $1.m_varDeclarations->ref(); + $1.m_varDeclarations->deref(); + } + if ($1.m_funcDeclarations) { + $1.m_funcDeclarations->ref(); + $1.m_funcDeclarations->deref(); + } + } +; + +Program: + /* not in spec */ { parser().didFinishParsing(0, 0, 0, @0.last_line); } + | SourceElements { parser().didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, @1.last_line); } +; + +SourceElements: + SourceElement { $$.m_node = new SourceElements; + $$.m_node->append($1.m_node); + $$.m_varDeclarations = $1.m_varDeclarations; + $$.m_funcDeclarations = $1.m_funcDeclarations; + } + | SourceElements SourceElement { $$.m_node->append($2.m_node); + $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations); + $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations); + } +; + +SourceElement: + FunctionDeclaration { $$ = createNodeInfo($1, 0, new ParserRefCountedData); $$.m_funcDeclarations->data.append($1); } + | Statement { $$ = $1; } +; + +%% + +static AddNode* makeAddNode(ExpressionNode* left, ExpressionNode* right) +{ + JSType t1 = left->expectedReturnType(); + JSType t2 = right->expectedReturnType(); + + if (t1 == NumberType && t2 == NumberType) + return new AddNumbersNode(left, right); + if (t1 == StringType && t2 == StringType) + return new AddStringsNode(left, right); + if (t1 == StringType) + return new AddStringLeftNode(left, right); + if (t2 == StringType) + return new AddStringRightNode(left, right); + return new AddNode(left, right); +} + +static LessNode* makeLessNode(ExpressionNode* left, ExpressionNode* right) +{ + JSType t1 = left->expectedReturnType(); + JSType t2 = right->expectedReturnType(); + + if (t1 == StringType && t2 == StringType) + return new LessStringsNode(left, right); + + // There are certainly more efficient ways to do this type check if necessary + if (t1 == NumberType || t1 == BooleanType || t1 == UndefinedType || t1 == NullType || + t2 == NumberType || t2 == BooleanType || t2 == UndefinedType || t2 == NullType) + return new LessNumbersNode(left, right); + + // Neither is certain to be a number, nor were both certain to be strings, so we use the default (slow) implementation. + return new LessNode(left, right); +} + +static ExpressionNode* makeAssignNode(ExpressionNode* loc, Operator op, ExpressionNode* expr) +{ + if (!loc->isLocation()) + return new AssignErrorNode(loc, op, expr); + + if (loc->isResolveNode()) { + ResolveNode* resolve = static_cast(loc); + if (op == OpEqual) + return new AssignResolveNode(resolve->identifier(), expr); + else + return new ReadModifyResolveNode(resolve->identifier(), op, expr); + } + if (loc->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(loc); + if (op == OpEqual) + return new AssignBracketNode(bracket->base(), bracket->subscript(), expr); + else + return new ReadModifyBracketNode(bracket->base(), bracket->subscript(), op, expr); + } + ASSERT(loc->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(loc); + if (op == OpEqual) + return new AssignDotNode(dot->base(), dot->identifier(), expr); + return new ReadModifyDotNode(dot->base(), dot->identifier(), op, expr); +} + +static ExpressionNode* makePrefixNode(ExpressionNode* expr, Operator op) +{ + if (!expr->isLocation()) + return new PrefixErrorNode(expr, op); + + if (expr->isResolveNode()) { + ResolveNode* resolve = static_cast(expr); + if (op == OpPlusPlus) + return new PreIncResolveNode(resolve->identifier()); + else + return new PreDecResolveNode(resolve->identifier()); + } + if (expr->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(expr); + if (op == OpPlusPlus) + return new PreIncBracketNode(bracket->base(), bracket->subscript()); + else + return new PreDecBracketNode(bracket->base(), bracket->subscript()); + } + ASSERT(expr->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(expr); + if (op == OpPlusPlus) + return new PreIncDotNode(dot->base(), dot->identifier()); + return new PreDecDotNode(dot->base(), dot->identifier()); +} + +static ExpressionNode* makePostfixNode(ExpressionNode* expr, Operator op) +{ + if (!expr->isLocation()) + return new PostfixErrorNode(expr, op); + + if (expr->isResolveNode()) { + ResolveNode* resolve = static_cast(expr); + if (op == OpPlusPlus) + return new PostIncResolveNode(resolve->identifier()); + else + return new PostDecResolveNode(resolve->identifier()); + } + if (expr->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(expr); + if (op == OpPlusPlus) + return new PostIncBracketNode(bracket->base(), bracket->subscript()); + else + return new PostDecBracketNode(bracket->base(), bracket->subscript()); + } + ASSERT(expr->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(expr); + + if (op == OpPlusPlus) + return new PostIncDotNode(dot->base(), dot->identifier()); + return new PostDecDotNode(dot->base(), dot->identifier()); +} + +static ExpressionNode* makeFunctionCallNode(ExpressionNode* func, ArgumentsNode* args) +{ + if (!func->isLocation()) + return new FunctionCallValueNode(func, args); + if (func->isResolveNode()) { + ResolveNode* resolve = static_cast(func); + return new FunctionCallResolveNode(resolve->identifier(), args); + } + if (func->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(func); + return new FunctionCallBracketNode(bracket->base(), bracket->subscript(), args); + } + ASSERT(func->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(func); + return new FunctionCallDotNode(dot->base(), dot->identifier(), args); +} + +static ExpressionNode* makeTypeOfNode(ExpressionNode* expr) +{ + if (expr->isResolveNode()) { + ResolveNode* resolve = static_cast(expr); + return new TypeOfResolveNode(resolve->identifier()); + } + return new TypeOfValueNode(expr); +} + +static ExpressionNode* makeDeleteNode(ExpressionNode* expr) +{ + if (!expr->isLocation()) + return new DeleteValueNode(expr); + if (expr->isResolveNode()) { + ResolveNode* resolve = static_cast(expr); + return new DeleteResolveNode(resolve->identifier()); + } + if (expr->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(expr); + return new DeleteBracketNode(bracket->base(), bracket->subscript()); + } + ASSERT(expr->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(expr); + return new DeleteDotNode(dot->base(), dot->identifier()); +} + +static PropertyNode* makeGetterOrSetterPropertyNode(const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body) +{ + PropertyNode::Type type; + if (getOrSet == "get") + type = PropertyNode::Getter; + else if (getOrSet == "set") + type = PropertyNode::Setter; + else + return 0; + return new PropertyNode(name, new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, body, params), type); +} + +static ExpressionNode* makeNegateNode(ExpressionNode* n) +{ + if (n->isNumber()) { + NumberNode* number = static_cast(n); + + if (number->value() > 0.0) { + number->setValue(-number->value()); + return number; + } + } + + return new NegateNode(n); +} + +static NumberNode* makeNumberNode(double d) +{ + JSValue* value = JSImmediate::from(d); + if (value) + return new ImmediateNumberNode(value, d); + return new NumberNode(d); +} + +/* called by yyparse on error */ +int yyerror(const char *) +{ + return 1; +} + +/* may we automatically insert a semicolon ? */ +static bool allowAutomaticSemicolon() +{ + return yychar == '}' || yychar == 0 || lexer().prevTerminator(); +} + +static ExpressionNode* combineVarInitializers(ExpressionNode* list, AssignResolveNode* init) +{ + if (!list) + return init; + return new VarDeclCommaNode(list, init); +} + +// We turn variable declarations into either assignments or empty +// statements (which later get stripped out), because the actual +// declaration work is hoisted up to the start of the function body +static StatementNode* makeVarStatementNode(ExpressionNode* expr) +{ + if (!expr) + return new EmptyStatementNode(); + return new VarStatementNode(expr); +} + diff --git a/kjs/identifier.cpp b/kjs/identifier.cpp new file mode 100644 index 0000000..3fa01ad --- /dev/null +++ b/kjs/identifier.cpp @@ -0,0 +1,205 @@ +/* + * This file is part of the KDE libraries + * Copyright (C) 2003 Apple Computer, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" + +#include "identifier.h" + +#include "JSLock.h" +#include // for placement new +#include // for strlen +#include +#include +#include + +namespace WTF { + + template struct DefaultHash; + template struct StrHash; + + template<> struct StrHash { + static unsigned hash(const KJS::UString::Rep *key) { return key->hash(); } + static bool equal(const KJS::UString::Rep *a, const KJS::UString::Rep *b) { return KJS::Identifier::equal(a, b); } + static const bool safeToCompareToEmptyOrDeleted = false; + }; + + template<> struct DefaultHash { + typedef StrHash Hash; + }; + +} + +namespace KJS { + +typedef HashSet IdentifierTable; +static IdentifierTable *table; + +static inline IdentifierTable& identifierTable() +{ + ASSERT(JSLock::lockCount() > 0); + + if (!table) + table = new IdentifierTable; + return *table; +} + + +bool Identifier::equal(const UString::Rep *r, const char *s) +{ + int length = r->len; + const UChar *d = r->data(); + for (int i = 0; i != length; ++i) + if (d[i].uc != (unsigned char)s[i]) + return false; + return s[length] == 0; +} + +bool Identifier::equal(const UString::Rep *r, const UChar *s, int length) +{ + if (r->len != length) + return false; + const UChar *d = r->data(); + for (int i = 0; i != length; ++i) + if (d[i].uc != s[i].uc) + return false; + return true; +} + +bool Identifier::equal(const UString::Rep *r, const UString::Rep *b) +{ + int length = r->len; + if (length != b->len) + return false; + const UChar *d = r->data(); + const UChar *s = b->data(); + for (int i = 0; i != length; ++i) + if (d[i].uc != s[i].uc) + return false; + return true; +} + +struct CStringTranslator +{ + static unsigned hash(const char *c) + { + return UString::Rep::computeHash(c); + } + + static bool equal(UString::Rep *r, const char *s) + { + return Identifier::equal(r, s); + } + + static void translate(UString::Rep*& location, const char *c, unsigned hash) + { + size_t length = strlen(c); + UChar *d = static_cast(fastMalloc(sizeof(UChar) * length)); + for (size_t i = 0; i != length; i++) + d[i] = c[i]; + + UString::Rep *r = UString::Rep::create(d, static_cast(length)).releaseRef(); + r->isIdentifier = 1; + r->rc = 0; + r->_hash = hash; + + location = r; + } +}; + +PassRefPtr Identifier::add(const char *c) +{ + if (!c) { + UString::Rep::null.hash(); + return &UString::Rep::null; + } + + if (!c[0]) { + UString::Rep::empty.hash(); + return &UString::Rep::empty; + } + + return *identifierTable().add(c).first; +} + +struct UCharBuffer { + const UChar *s; + unsigned int length; +}; + +struct UCharBufferTranslator +{ + static unsigned hash(const UCharBuffer& buf) + { + return UString::Rep::computeHash(buf.s, buf.length); + } + + static bool equal(UString::Rep *str, const UCharBuffer& buf) + { + return Identifier::equal(str, buf.s, buf.length); + } + + static void translate(UString::Rep *& location, const UCharBuffer& buf, unsigned hash) + { + UChar *d = static_cast(fastMalloc(sizeof(UChar) * buf.length)); + for (unsigned i = 0; i != buf.length; i++) + d[i] = buf.s[i]; + + UString::Rep *r = UString::Rep::create(d, buf.length).releaseRef(); + r->isIdentifier = 1; + r->rc = 0; + r->_hash = hash; + + location = r; + } +}; + +PassRefPtr Identifier::add(const UChar *s, int length) +{ + if (!length) { + UString::Rep::empty.hash(); + return &UString::Rep::empty; + } + + UCharBuffer buf = {s, length}; + return *identifierTable().add(buf).first; +} + +PassRefPtr Identifier::addSlowCase(UString::Rep *r) +{ + ASSERT(!r->isIdentifier); + + if (r->len == 0) { + UString::Rep::empty.hash(); + return &UString::Rep::empty; + } + + UString::Rep *result = *identifierTable().add(r).first; + if (result == r) + r->isIdentifier = true; + return result; +} + +void Identifier::remove(UString::Rep *r) +{ + identifierTable().remove(r); +} + +} // namespace KJS diff --git a/kjs/identifier.h b/kjs/identifier.h new file mode 100644 index 0000000..fc43344 --- /dev/null +++ b/kjs/identifier.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_IDENTIFIER_H +#define KJS_IDENTIFIER_H + +#include "ustring.h" + +namespace KJS { + + class Identifier { + friend class PropertyMap; + public: + Identifier() { } + Identifier(const char* s) : _ustring(add(s)) { } + Identifier(const UChar* s, int length) : _ustring(add(s, length)) { } + explicit Identifier(UString::Rep* rep) : _ustring(add(rep)) { } + explicit Identifier(const UString& s) : _ustring(add(s.rep())) { } + + // Special constructor for cases where we overwrite an object in place. + Identifier(PlacementNewAdoptType) : _ustring(PlacementNewAdopt) { } + + const UString& ustring() const { return _ustring; } + DOM::DOMString domString() const; + + const UChar* data() const { return _ustring.data(); } + int size() const { return _ustring.size(); } + + const char* ascii() const { return _ustring.ascii(); } + + static Identifier from(unsigned y) { return Identifier(UString::from(y)); } + + bool isNull() const { return _ustring.isNull(); } + bool isEmpty() const { return _ustring.isEmpty(); } + + uint32_t toUInt32(bool* ok) const { return _ustring.toUInt32(ok); } + uint32_t toUInt32(bool* ok, bool tolerateEmptyString) const { return _ustring.toUInt32(ok, tolerateEmptyString); }; + uint32_t toStrictUInt32(bool* ok) const { return _ustring.toStrictUInt32(ok); } + unsigned toArrayIndex(bool* ok) const { return _ustring.toArrayIndex(ok); } + double toDouble() const { return _ustring.toDouble(); } + + friend bool operator==(const Identifier&, const Identifier&); + friend bool operator!=(const Identifier&, const Identifier&); + + friend bool operator==(const Identifier&, const char*); + + static void remove(UString::Rep* ); + + static bool equal(const UString::Rep*, const char*); + static bool equal(const UString::Rep*, const UChar*, int length); + static bool equal(const UString::Rep*, const UString::Rep*); + + private: + UString _ustring; + + static bool equal(const Identifier& a, const Identifier& b) + { return a._ustring.rep() == b._ustring.rep(); } + static bool equal(const Identifier& a, const char* b) + { return equal(a._ustring.rep(), b); } + + static PassRefPtr add(const char*); + static PassRefPtr add(const UChar*, int length); + static PassRefPtr add(UString::Rep* r) + { + if (r->isIdentifier) + return r; + return addSlowCase(r); + } + static PassRefPtr addSlowCase(UString::Rep *r); + }; + + inline bool operator==(const Identifier& a, const Identifier& b) + { return Identifier::equal(a, b); } + + inline bool operator!=(const Identifier& a, const Identifier& b) + { return !Identifier::equal(a, b); } + + inline bool operator==(const Identifier& a, const char* b) + { return Identifier::equal(a, b); } + +} // namespace KJS + +#endif // KJS_IDENTIFIER_H diff --git a/kjs/internal.cpp b/kjs/internal.cpp new file mode 100644 index 0000000..5482b48 --- /dev/null +++ b/kjs/internal.cpp @@ -0,0 +1,302 @@ +/* + * Copyright (C) 1999-2002 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "internal.h" + +#include "ExecState.h" +#include "array_object.h" +#include "bool_object.h" +#include "collector.h" +#include "date_object.h" +#include "debugger.h" +#include "error_object.h" +#include "function_object.h" +#include "lexer.h" +#include "math_object.h" +#include "nodes.h" +#include "number_object.h" +#include "object.h" +#include "object_object.h" +#include "operations.h" +#include "regexp_object.h" +#include "string_object.h" +#include +#include +#include +#include +#include +#include + +namespace KJS { + +// ------------------------------ StringImp ------------------------------------ + +JSValue* StringImp::toPrimitive(ExecState*, JSType) const +{ + return const_cast(this); +} + +bool StringImp::getPrimitiveNumber(ExecState*, double& number, JSValue*& value) +{ + value = this; + number = val.toDouble(); + return false; +} + +bool StringImp::toBoolean(ExecState *) const +{ + return (val.size() > 0); +} + +double StringImp::toNumber(ExecState *) const +{ + return val.toDouble(); +} + +UString StringImp::toString(ExecState *) const +{ + return val; +} + +JSObject* StringImp::toObject(ExecState *exec) const +{ + return new StringInstance(exec->lexicalGlobalObject()->stringPrototype(), const_cast(this)); +} + +// ------------------------------ NumberImp ------------------------------------ + +JSValue* NumberImp::toPrimitive(ExecState*, JSType) const +{ + return const_cast(this); +} + +bool NumberImp::getPrimitiveNumber(ExecState*, double& number, JSValue*& value) +{ + number = val; + value = this; + return true; +} + +bool NumberImp::toBoolean(ExecState *) const +{ + return val < 0.0 || val > 0.0; // false for NaN +} + +double NumberImp::toNumber(ExecState *) const +{ + return val; +} + +UString NumberImp::toString(ExecState *) const +{ + if (val == 0.0) // +0.0 or -0.0 + return "0"; + return UString::from(val); +} + +JSObject *NumberImp::toObject(ExecState *exec) const +{ + List args; + args.append(const_cast(this)); + return static_cast(exec->lexicalGlobalObject()->numberConstructor()->construct(exec,args)); +} + +bool NumberImp::getUInt32(uint32_t& uint32) const +{ + uint32 = static_cast(val); + return uint32 == val; +} + +bool NumberImp::getTruncatedInt32(int32_t& int32) const +{ + if (!(val >= -2147483648.0 && val < 2147483648.0)) + return false; + int32 = static_cast(val); + return true; +} + +bool NumberImp::getTruncatedUInt32(uint32_t& uint32) const +{ + if (!(val >= 0.0 && val < 4294967296.0)) + return false; + uint32 = static_cast(val); + return true; +} + +// --------------------------- GetterSetterImp --------------------------------- +void GetterSetterImp::mark() +{ + JSCell::mark(); + + if (getter && !getter->marked()) + getter->mark(); + if (setter && !setter->marked()) + setter->mark(); +} + +JSValue* GetterSetterImp::toPrimitive(ExecState*, JSType) const +{ + ASSERT(false); + return jsNull(); +} + +bool GetterSetterImp::getPrimitiveNumber(ExecState*, double& number, JSValue*& value) +{ + ASSERT_NOT_REACHED(); + number = 0; + value = 0; + return true; +} + +bool GetterSetterImp::toBoolean(ExecState*) const +{ + ASSERT(false); + return false; +} + +double GetterSetterImp::toNumber(ExecState *) const +{ + ASSERT(false); + return 0.0; +} + +UString GetterSetterImp::toString(ExecState *) const +{ + ASSERT(false); + return UString::null(); +} + +JSObject *GetterSetterImp::toObject(ExecState *exec) const +{ + ASSERT(false); + return jsNull()->toObject(exec); +} + +// ------------------------------ LabelStack ----------------------------------- + +bool LabelStack::push(const Identifier &id) +{ + if (contains(id)) + return false; + + StackElem *newtos = new StackElem; + newtos->id = id; + newtos->prev = tos; + tos = newtos; + return true; +} + +bool LabelStack::contains(const Identifier &id) const +{ + if (id.isEmpty()) + return true; + + for (StackElem *curr = tos; curr; curr = curr->prev) + if (curr->id == id) + return true; + + return false; +} + +// ------------------------------ InternalFunctionImp -------------------------- + +const ClassInfo InternalFunctionImp::info = { "Function", 0, 0 }; + +InternalFunctionImp::InternalFunctionImp() +{ +} + +InternalFunctionImp::InternalFunctionImp(FunctionPrototype* funcProto, const Identifier& name) + : JSObject(funcProto) + , m_name(name) +{ +} + +bool InternalFunctionImp::implementsCall() const +{ + return true; +} + +bool InternalFunctionImp::implementsHasInstance() const +{ + return true; +} + +// ------------------------------ global functions ----------------------------- + +#ifndef NDEBUG +#include +void printInfo(ExecState *exec, const char *s, JSValue *o, int lineno) +{ + if (!o) + fprintf(stderr, "KJS: %s: (null)", s); + else { + JSValue *v = o; + + UString name; + switch (v->type()) { + case UnspecifiedType: + name = "Unspecified"; + break; + case UndefinedType: + name = "Undefined"; + break; + case NullType: + name = "Null"; + break; + case BooleanType: + name = "Boolean"; + break; + case StringType: + name = "String"; + break; + case NumberType: + name = "Number"; + break; + case ObjectType: + name = static_cast(v)->className(); + if (name.isNull()) + name = "(unknown class)"; + break; + case GetterSetterType: + name = "GetterSetter"; + break; + } + UString vString = v->toString(exec); + if ( vString.size() > 50 ) + vString = vString.substr( 0, 50 ) + "..."; + // Can't use two UString::ascii() in the same fprintf call + CString tempString( vString.cstring() ); + + fprintf(stderr, "KJS: %s: %s : %s (%p)", + s, tempString.c_str(), name.ascii(), (void*)v); + + if (lineno >= 0) + fprintf(stderr, ", line %d\n",lineno); + else + fprintf(stderr, "\n"); + } +} +#endif + +} diff --git a/kjs/internal.h b/kjs/internal.h new file mode 100644 index 0000000..51438b3 --- /dev/null +++ b/kjs/internal.h @@ -0,0 +1,122 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef INTERNAL_H +#define INTERNAL_H + +#include "JSType.h" +#include "object.h" +#include "protect.h" +#include "scope_chain.h" +#include "types.h" +#include "ustring.h" + +#include + +#define I18N_NOOP(s) s + +namespace KJS { + + class FunctionPrototype; + + // --------------------------------------------------------------------------- + // Primitive impls + // --------------------------------------------------------------------------- + + class StringImp : public JSCell { + public: + StringImp(const UString& v) : val(v) { Collector::reportExtraMemoryCost(v.cost()); } + enum HasOtherOwnerType { HasOtherOwner }; + StringImp(const UString& value, HasOtherOwnerType) : val(value) { } + const UString& value() const { return val; } + + private: + virtual JSType type() const { return StringType; } + + virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const; + virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); + virtual bool toBoolean(ExecState *exec) const; + virtual double toNumber(ExecState *exec) const; + virtual JSObject *toObject(ExecState *exec) const; + virtual UString toString(ExecState*) const; + + UString val; + }; + + class NumberImp : public JSCell { + friend class ConstantValues; + friend JSValue *jsNumberCell(double); + public: + double value() const { return val; } + + virtual JSType type() const { return NumberType; } + + virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const; + virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); + virtual bool toBoolean(ExecState *exec) const; + virtual double toNumber(ExecState *exec) const; + virtual UString toString(ExecState *exec) const; + virtual JSObject *toObject(ExecState *exec) const; + + void* operator new(size_t size) + { + return Collector::allocateNumber(size); + } + private: + NumberImp(double v) : val(v) { } + + virtual bool getUInt32(uint32_t&) const; + virtual bool getTruncatedInt32(int32_t&) const; + virtual bool getTruncatedUInt32(uint32_t&) const; + + double val; + }; + + + // --------------------------------------------------------------------------- + // Evaluation + // --------------------------------------------------------------------------- + + struct AttachedGlobalObject; + class DebuggerImp { + public: + + DebuggerImp() { + globalObjects = 0; + isAborted = false; + } + + void abort() { isAborted = true; } + bool aborted() const { return isAborted; } + + AttachedGlobalObject* globalObjects; + bool isAborted; + }; + +#ifndef NDEBUG + void printInfo(ExecState *exec, const char *s, JSValue *, int lineno = -1); +#endif + +} // namespace + +#endif // INTERNAL_H diff --git a/kjs/interpreter.cpp b/kjs/interpreter.cpp new file mode 100644 index 0000000..f7ea2c5 --- /dev/null +++ b/kjs/interpreter.cpp @@ -0,0 +1,156 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2007 Apple Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "interpreter.h" + +#include "ExecState.h" +#include "JSGlobalObject.h" +#include "Parser.h" +#include "SavedBuiltins.h" +#include "array_object.h" +#include "bool_object.h" +#include "collector.h" +#include "date_object.h" +#include "debugger.h" +#include "error_object.h" +#include "function_object.h" +#include "internal.h" +#include "math_object.h" +#include "nodes.h" +#include "number_object.h" +#include "object.h" +#include "object_object.h" +#include "operations.h" +#include "regexp_object.h" +#include "runtime.h" +#include "string_object.h" +#include "types.h" +#include "value.h" +#include +#include +#include + +namespace KJS { + +Completion Interpreter::checkSyntax(ExecState* exec, const UString& sourceURL, int startingLineNumber, const UString& code) +{ + return checkSyntax(exec, sourceURL, startingLineNumber, code.data(), code.size()); +} + +Completion Interpreter::checkSyntax(ExecState* exec, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength) +{ + JSLock lock; + + int errLine; + UString errMsg; + RefPtr progNode = parser().parse(sourceURL, startingLineNumber, code, codeLength, 0, &errLine, &errMsg); + if (!progNode) + return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, 0, sourceURL)); + return Completion(Normal); +} + +Completion Interpreter::evaluate(ExecState* exec, const UString& sourceURL, int startingLineNumber, const UString& code, JSValue* thisV) +{ + return evaluate(exec, sourceURL, startingLineNumber, code.data(), code.size(), thisV); +} + +Completion Interpreter::evaluate(ExecState* exec, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength, JSValue* thisV) +{ + JSLock lock; + + JSGlobalObject* globalObject = exec->dynamicGlobalObject(); + + if (globalObject->recursion() >= 20) + return Completion(Throw, Error::create(exec, GeneralError, "Recursion too deep")); + + // parse the source code + int sourceId; + int errLine; + UString errMsg; + RefPtr progNode = parser().parse(sourceURL, startingLineNumber, code, codeLength, &sourceId, &errLine, &errMsg); + + // notify debugger that source has been parsed + if (globalObject->debugger()) { + bool cont = globalObject->debugger()->sourceParsed(exec, sourceId, sourceURL, UString(code, codeLength), startingLineNumber, errLine, errMsg); + if (!cont) + return Completion(Break); + } + + // no program node means a syntax error occurred + if (!progNode) + return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, sourceId, sourceURL)); + + exec->clearException(); + + globalObject->incRecursion(); + + JSObject* thisObj = globalObject; + + // "this" must be an object... use same rules as Function.prototype.apply() + if (thisV && !thisV->isUndefinedOrNull()) + thisObj = thisV->toObject(exec); + + Completion res; + if (exec->hadException()) + // the thisV->toObject() conversion above might have thrown an exception - if so, propagate it + res = Completion(Throw, exec->exception()); + else { + // execute the code + InterpreterExecState newExec(globalObject, thisObj, progNode.get()); + JSValue* value = progNode->execute(&newExec); + res = Completion(newExec.completionType(), value); + } + + globalObject->decRecursion(); + + if (shouldPrintExceptions() && res.complType() == Throw) { + JSLock lock; + ExecState* exec = globalObject->globalExec(); + CString f = sourceURL.UTF8String(); + CString message = res.value()->toObject(exec)->toString(exec).UTF8String(); + int line = res.value()->toObject(exec)->get(exec, "line")->toUInt32(exec); +#if PLATFORM(WIN_OS) + printf("%s line %d: %s\n", f.c_str(), line, message.c_str()); +#else + printf("[%d] %s line %d: %s\n", getpid(), f.c_str(), line, message.c_str()); +#endif + } + + return res; +} + +static bool printExceptions = false; + +bool Interpreter::shouldPrintExceptions() +{ + return printExceptions; +} + +void Interpreter::setShouldPrintExceptions(bool print) +{ + printExceptions = print; +} + +} // namespace KJS diff --git a/kjs/interpreter.h b/kjs/interpreter.h new file mode 100644 index 0000000..79b9398 --- /dev/null +++ b/kjs/interpreter.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_Interpreter_h +#define KJS_Interpreter_h + +namespace KJS { + + class Completion; + class ExecState; + class JSValue; + class UString; + + struct UChar; + + class Interpreter { + public: + /** + * Parses the supplied ECMAScript code and checks for syntax errors. + * + * @param code The code to check + * @return A normal completion if there were no syntax errors in the code, + * otherwise a throw completion with the syntax error as its value. + */ + static Completion checkSyntax(ExecState*, const UString& sourceURL, int startingLineNumber, const UString& code); + static Completion checkSyntax(ExecState*, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength); + + /** + * Evaluates the supplied ECMAScript code. + * + * Since this method returns a Completion, you should check the type of + * completion to detect an error or before attempting to access the returned + * value. For example, if an error occurs during script execution and is not + * caught by the script, the completion type will be Throw. + * + * If the supplied code is invalid, a SyntaxError will be thrown. + * + * @param code The code to evaluate + * @param thisV The value to pass in as the "this" value for the script + * execution. This should either be jsNull() or an Object. + * @return A completion object representing the result of the execution. + */ + static Completion evaluate(ExecState*, const UString& sourceURL, int startingLineNumber, const UString& code, JSValue* thisV = 0); + static Completion evaluate(ExecState*, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength, JSValue* thisV = 0); + + static bool shouldPrintExceptions(); + static void setShouldPrintExceptions(bool); + }; + +} // namespace KJS + +#endif // KJS_Interpreter_h diff --git a/kjs/keywords.table b/kjs/keywords.table new file mode 100644 index 0000000..490c1cc --- /dev/null +++ b/kjs/keywords.table @@ -0,0 +1,72 @@ +# main keywords +@begin mainTable 41 + +# types +null NULLTOKEN +true TRUETOKEN +false FALSETOKEN + +# keywords +break BREAK +case CASE +catch CATCH +const CONSTTOKEN +default DEFAULT +finally FINALLY +for FOR +instanceof INSTANCEOF +new NEW +var VAR +continue CONTINUE +function FUNCTION +return RETURN +void VOIDTOKEN +delete DELETETOKEN +if IF +this THISTOKEN +do DO +while WHILE +else ELSE +in INTOKEN +switch SWITCH +throw THROW +try TRY +typeof TYPEOF +with WITH +debugger DEBUGGER + +# reserved for future use +class RESERVED +enum RESERVED +export RESERVED +extends RESERVED +import RESERVED +super RESERVED + +# these words are reserved for future use in the ECMA spec, but not in WinIE +# (see http://bugs.webkit.org/show_bug.cgi?id=6179) +# abstract RESERVED +# boolean RESERVED +# byte RESERVED +# char RESERVED +# double RESERVED +# final RESERVED +# float RESERVED +# goto RESERVED +# implements RESERVED +# int RESERVED +# interface RESERVED +# long RESERVED +# native RESERVED +# package RESERVED +# private RESERVED +# protected RESERVED +# public RESERVED +# short RESERVED +# static RESERVED +# synchronized RESERVED +# throws RESERVED +# transient RESERVED +# volatile RESERVED +@end + diff --git a/kjs/lexer.cpp b/kjs/lexer.cpp new file mode 100644 index 0000000..c4d327f --- /dev/null +++ b/kjs/lexer.cpp @@ -0,0 +1,897 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2006, 2007 Apple Inc. All Rights Reserved. + * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "lexer.h" + +#include "dtoa.h" +#include "function.h" +#include "nodes.h" +#include "NodeInfo.h" +#include +#include +#include +#include +#include + +using namespace WTF; +using namespace Unicode; + +// we can't specify the namespace in yacc's C output, so do it here +using namespace KJS; + +#ifndef KDE_USE_FINAL +#include "grammar.h" +#endif + +#include "lookup.h" +#include "lexer.lut.h" + +extern YYLTYPE kjsyylloc; // global bison variable holding token info + +// a bridge for yacc from the C world to C++ +int kjsyylex() +{ + return lexer().lex(); +} + +namespace KJS { + +static bool isDecimalDigit(int); + +static const size_t initialReadBufferCapacity = 32; +static const size_t initialStringTableCapacity = 64; + +Lexer& lexer() +{ + ASSERT(JSLock::currentThreadIsHoldingLock()); + + // FIXME: We'd like to avoid calling new here, but we don't currently + // support tearing down the Lexer at app quit time, since that would involve + // tearing down its UString data members without holding the JSLock. + static Lexer* staticLexer = new Lexer; + return *staticLexer; +} + +Lexer::Lexer() + : yylineno(1) + , restrKeyword(false) + , eatNextIdentifier(false) + , stackToken(-1) + , lastToken(-1) + , pos(0) + , code(0) + , length(0) + , atLineStart(true) + , current(0) + , next1(0) + , next2(0) + , next3(0) +{ + m_buffer8.reserveCapacity(initialReadBufferCapacity); + m_buffer16.reserveCapacity(initialReadBufferCapacity); + m_strings.reserveCapacity(initialStringTableCapacity); + m_identifiers.reserveCapacity(initialStringTableCapacity); +} + +void Lexer::setCode(int startingLineNumber, const KJS::UChar *c, unsigned int len) +{ + yylineno = 1 + startingLineNumber; + restrKeyword = false; + delimited = false; + eatNextIdentifier = false; + stackToken = -1; + lastToken = -1; + pos = 0; + code = c; + length = len; + skipLF = false; + skipCR = false; + error = false; + atLineStart = true; + + // read first characters + current = (length > 0) ? code[0].uc : -1; + next1 = (length > 1) ? code[1].uc : -1; + next2 = (length > 2) ? code[2].uc : -1; + next3 = (length > 3) ? code[3].uc : -1; +} + +void Lexer::shift(unsigned int p) +{ + // Here would be a good place to strip Cf characters, but that has caused compatibility problems: + // . + while (p--) { + pos++; + current = next1; + next1 = next2; + next2 = next3; + next3 = (pos + 3 < length) ? code[pos + 3].uc : -1; + } +} + +// called on each new line +void Lexer::nextLine() +{ + yylineno++; + atLineStart = true; +} + +void Lexer::setDone(State s) +{ + state = s; + done = true; +} + +int Lexer::lex() +{ + int token = 0; + state = Start; + unsigned short stringType = 0; // either single or double quotes + m_buffer8.clear(); + m_buffer16.clear(); + done = false; + terminator = false; + skipLF = false; + skipCR = false; + + // did we push a token on the stack previously ? + // (after an automatic semicolon insertion) + if (stackToken >= 0) { + setDone(Other); + token = stackToken; + stackToken = 0; + } + + while (!done) { + if (skipLF && current != '\n') // found \r but not \n afterwards + skipLF = false; + if (skipCR && current != '\r') // found \n but not \r afterwards + skipCR = false; + if (skipLF || skipCR) // found \r\n or \n\r -> eat the second one + { + skipLF = false; + skipCR = false; + shift(1); + } + switch (state) { + case Start: + if (isWhiteSpace()) { + // do nothing + } else if (current == '/' && next1 == '/') { + shift(1); + state = InSingleLineComment; + } else if (current == '/' && next1 == '*') { + shift(1); + state = InMultiLineComment; + } else if (current == -1) { + if (!terminator && !delimited) { + // automatic semicolon insertion if program incomplete + token = ';'; + stackToken = 0; + setDone(Other); + } else + setDone(Eof); + } else if (isLineTerminator()) { + nextLine(); + terminator = true; + if (restrKeyword) { + token = ';'; + setDone(Other); + } + } else if (current == '"' || current == '\'') { + state = InString; + stringType = static_cast(current); + } else if (isIdentStart(current)) { + record16(current); + state = InIdentifierOrKeyword; + } else if (current == '\\') { + state = InIdentifierStartUnicodeEscapeStart; + } else if (current == '0') { + record8(current); + state = InNum0; + } else if (isDecimalDigit(current)) { + record8(current); + state = InNum; + } else if (current == '.' && isDecimalDigit(next1)) { + record8(current); + state = InDecimal; + // + } else if (atLineStart && current == '-' && next1 == '-' && next2 == '>') { + shift(2); + state = InSingleLineComment; + } else { + token = matchPunctuator(current, next1, next2, next3); + if (token != -1) { + setDone(Other); + } else { + // cerr << "encountered unknown character" << endl; + setDone(Bad); + } + } + break; + case InString: + if (current == stringType) { + shift(1); + setDone(String); + } else if (isLineTerminator() || current == -1) { + setDone(Bad); + } else if (current == '\\') { + state = InEscapeSequence; + } else { + record16(current); + } + break; + // Escape Sequences inside of strings + case InEscapeSequence: + if (isOctalDigit(current)) { + if (current >= '0' && current <= '3' && + isOctalDigit(next1) && isOctalDigit(next2)) { + record16(convertOctal(current, next1, next2)); + shift(2); + state = InString; + } else if (isOctalDigit(current) && isOctalDigit(next1)) { + record16(convertOctal('0', current, next1)); + shift(1); + state = InString; + } else if (isOctalDigit(current)) { + record16(convertOctal('0', '0', current)); + state = InString; + } else { + setDone(Bad); + } + } else if (current == 'x') + state = InHexEscape; + else if (current == 'u') + state = InUnicodeEscape; + else if (isLineTerminator()) { + nextLine(); + state = InString; + } else { + record16(singleEscape(static_cast(current))); + state = InString; + } + break; + case InHexEscape: + if (isHexDigit(current) && isHexDigit(next1)) { + state = InString; + record16(convertHex(current, next1)); + shift(1); + } else if (current == stringType) { + record16('x'); + shift(1); + setDone(String); + } else { + record16('x'); + record16(current); + state = InString; + } + break; + case InUnicodeEscape: + if (isHexDigit(current) && isHexDigit(next1) && isHexDigit(next2) && isHexDigit(next3)) { + record16(convertUnicode(current, next1, next2, next3)); + shift(3); + state = InString; + } else if (current == stringType) { + record16('u'); + shift(1); + setDone(String); + } else { + setDone(Bad); + } + break; + case InSingleLineComment: + if (isLineTerminator()) { + nextLine(); + terminator = true; + if (restrKeyword) { + token = ';'; + setDone(Other); + } else + state = Start; + } else if (current == -1) { + setDone(Eof); + } + break; + case InMultiLineComment: + if (current == -1) { + setDone(Bad); + } else if (isLineTerminator()) { + nextLine(); + } else if (current == '*' && next1 == '/') { + state = Start; + shift(1); + } + break; + case InIdentifierOrKeyword: + case InIdentifier: + if (isIdentPart(current)) + record16(current); + else if (current == '\\') + state = InIdentifierPartUnicodeEscapeStart; + else + setDone(state == InIdentifierOrKeyword ? IdentifierOrKeyword : Identifier); + break; + case InNum0: + if (current == 'x' || current == 'X') { + record8(current); + state = InHex; + } else if (current == '.') { + record8(current); + state = InDecimal; + } else if (current == 'e' || current == 'E') { + record8(current); + state = InExponentIndicator; + } else if (isOctalDigit(current)) { + record8(current); + state = InOctal; + } else if (isDecimalDigit(current)) { + record8(current); + state = InDecimal; + } else { + setDone(Number); + } + break; + case InHex: + if (isHexDigit(current)) { + record8(current); + } else { + setDone(Hex); + } + break; + case InOctal: + if (isOctalDigit(current)) { + record8(current); + } + else if (isDecimalDigit(current)) { + record8(current); + state = InDecimal; + } else + setDone(Octal); + break; + case InNum: + if (isDecimalDigit(current)) { + record8(current); + } else if (current == '.') { + record8(current); + state = InDecimal; + } else if (current == 'e' || current == 'E') { + record8(current); + state = InExponentIndicator; + } else + setDone(Number); + break; + case InDecimal: + if (isDecimalDigit(current)) { + record8(current); + } else if (current == 'e' || current == 'E') { + record8(current); + state = InExponentIndicator; + } else + setDone(Number); + break; + case InExponentIndicator: + if (current == '+' || current == '-') { + record8(current); + } else if (isDecimalDigit(current)) { + record8(current); + state = InExponent; + } else + setDone(Bad); + break; + case InExponent: + if (isDecimalDigit(current)) { + record8(current); + } else + setDone(Number); + break; + case InIdentifierStartUnicodeEscapeStart: + if (current == 'u') + state = InIdentifierStartUnicodeEscape; + else + setDone(Bad); + break; + case InIdentifierPartUnicodeEscapeStart: + if (current == 'u') + state = InIdentifierPartUnicodeEscape; + else + setDone(Bad); + break; + case InIdentifierStartUnicodeEscape: + if (!isHexDigit(current) || !isHexDigit(next1) || !isHexDigit(next2) || !isHexDigit(next3)) { + setDone(Bad); + break; + } + token = convertUnicode(current, next1, next2, next3).uc; + shift(3); + if (!isIdentStart(token)) { + setDone(Bad); + break; + } + record16(token); + state = InIdentifier; + break; + case InIdentifierPartUnicodeEscape: + if (!isHexDigit(current) || !isHexDigit(next1) || !isHexDigit(next2) || !isHexDigit(next3)) { + setDone(Bad); + break; + } + token = convertUnicode(current, next1, next2, next3).uc; + shift(3); + if (!isIdentPart(token)) { + setDone(Bad); + break; + } + record16(token); + state = InIdentifier; + break; + default: + ASSERT(!"Unhandled state in switch statement"); + } + + // move on to the next character + if (!done) + shift(1); + if (state != Start && state != InSingleLineComment) + atLineStart = false; + } + + // no identifiers allowed directly after numeric literal, e.g. "3in" is bad + if ((state == Number || state == Octal || state == Hex) && isIdentStart(current)) + state = Bad; + + // terminate string + m_buffer8.append('\0'); + +#ifdef KJS_DEBUG_LEX + fprintf(stderr, "line: %d ", lineNo()); + fprintf(stderr, "yytext (%x): ", m_buffer8[0]); + fprintf(stderr, "%s ", buffer8.data()); +#endif + + double dval = 0; + if (state == Number) { + dval = kjs_strtod(m_buffer8.data(), 0L); + } else if (state == Hex) { // scan hex numbers + const char* p = m_buffer8.data() + 2; + while (char c = *p++) { + dval *= 16; + dval += convertHex(c); + } + + if (dval >= mantissaOverflowLowerBound) + dval = parseIntOverflow(m_buffer8.data() + 2, p - (m_buffer8.data() + 3), 16); + + state = Number; + } else if (state == Octal) { // scan octal number + const char* p = m_buffer8.data() + 1; + while (char c = *p++) { + dval *= 8; + dval += c - '0'; + } + + if (dval >= mantissaOverflowLowerBound) + dval = parseIntOverflow(m_buffer8.data() + 1, p - (m_buffer8.data() + 2), 8); + + state = Number; + } + +#ifdef KJS_DEBUG_LEX + switch (state) { + case Eof: + printf("(EOF)\n"); + break; + case Other: + printf("(Other)\n"); + break; + case Identifier: + printf("(Identifier)/(Keyword)\n"); + break; + case String: + printf("(String)\n"); + break; + case Number: + printf("(Number)\n"); + break; + default: + printf("(unknown)"); + } +#endif + + if (state != Identifier && eatNextIdentifier) + eatNextIdentifier = false; + + restrKeyword = false; + delimited = false; + kjsyylloc.first_line = yylineno; // ??? + kjsyylloc.last_line = yylineno; + + switch (state) { + case Eof: + token = 0; + break; + case Other: + if(token == '}' || token == ';') { + delimited = true; + } + break; + case IdentifierOrKeyword: + if ((token = Lookup::find(&mainTable, m_buffer16.data(), m_buffer16.size())) < 0) { + case Identifier: + // Lookup for keyword failed, means this is an identifier + // Apply anonymous-function hack below (eat the identifier) + if (eatNextIdentifier) { + eatNextIdentifier = false; + token = lex(); + break; + } + kjsyylval.ident = makeIdentifier(m_buffer16); + token = IDENT; + break; + } + + eatNextIdentifier = false; + // Hack for "f = function somename() { ... }", too hard to get into the grammar + if (token == FUNCTION && lastToken == '=' ) + eatNextIdentifier = true; + + if (token == CONTINUE || token == BREAK || + token == RETURN || token == THROW) + restrKeyword = true; + break; + case String: + kjsyylval.string = makeUString(m_buffer16); + token = STRING; + break; + case Number: + kjsyylval.doubleValue = dval; + token = NUMBER; + break; + case Bad: +#ifdef KJS_DEBUG_LEX + fprintf(stderr, "yylex: ERROR.\n"); +#endif + error = true; + return -1; + default: + ASSERT(!"unhandled numeration value in switch"); + error = true; + return -1; + } + lastToken = token; + return token; +} + +bool Lexer::isWhiteSpace() const +{ + return current == '\t' || current == 0x0b || current == 0x0c || isSeparatorSpace(current); +} + +bool Lexer::isLineTerminator() +{ + bool cr = (current == '\r'); + bool lf = (current == '\n'); + if (cr) + skipLF = true; + else if (lf) + skipCR = true; + return cr || lf || current == 0x2028 || current == 0x2029; +} + +bool Lexer::isIdentStart(int c) +{ + return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other)) + || c == '$' || c == '_'; +} + +bool Lexer::isIdentPart(int c) +{ + return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other + | Mark_NonSpacing | Mark_SpacingCombining | Number_DecimalDigit | Punctuation_Connector)) + || c == '$' || c == '_'; +} + +static bool isDecimalDigit(int c) +{ + return (c >= '0' && c <= '9'); +} + +bool Lexer::isHexDigit(int c) +{ + return (c >= '0' && c <= '9' || + c >= 'a' && c <= 'f' || + c >= 'A' && c <= 'F'); +} + +bool Lexer::isOctalDigit(int c) +{ + return (c >= '0' && c <= '7'); +} + +int Lexer::matchPunctuator(int c1, int c2, int c3, int c4) +{ + if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') { + shift(4); + return URSHIFTEQUAL; + } else if (c1 == '=' && c2 == '=' && c3 == '=') { + shift(3); + return STREQ; + } else if (c1 == '!' && c2 == '=' && c3 == '=') { + shift(3); + return STRNEQ; + } else if (c1 == '>' && c2 == '>' && c3 == '>') { + shift(3); + return URSHIFT; + } else if (c1 == '<' && c2 == '<' && c3 == '=') { + shift(3); + return LSHIFTEQUAL; + } else if (c1 == '>' && c2 == '>' && c3 == '=') { + shift(3); + return RSHIFTEQUAL; + } else if (c1 == '<' && c2 == '=') { + shift(2); + return LE; + } else if (c1 == '>' && c2 == '=') { + shift(2); + return GE; + } else if (c1 == '!' && c2 == '=') { + shift(2); + return NE; + } else if (c1 == '+' && c2 == '+') { + shift(2); + if (terminator) + return AUTOPLUSPLUS; + else + return PLUSPLUS; + } else if (c1 == '-' && c2 == '-') { + shift(2); + if (terminator) + return AUTOMINUSMINUS; + else + return MINUSMINUS; + } else if (c1 == '=' && c2 == '=') { + shift(2); + return EQEQ; + } else if (c1 == '+' && c2 == '=') { + shift(2); + return PLUSEQUAL; + } else if (c1 == '-' && c2 == '=') { + shift(2); + return MINUSEQUAL; + } else if (c1 == '*' && c2 == '=') { + shift(2); + return MULTEQUAL; + } else if (c1 == '/' && c2 == '=') { + shift(2); + return DIVEQUAL; + } else if (c1 == '&' && c2 == '=') { + shift(2); + return ANDEQUAL; + } else if (c1 == '^' && c2 == '=') { + shift(2); + return XOREQUAL; + } else if (c1 == '%' && c2 == '=') { + shift(2); + return MODEQUAL; + } else if (c1 == '|' && c2 == '=') { + shift(2); + return OREQUAL; + } else if (c1 == '<' && c2 == '<') { + shift(2); + return LSHIFT; + } else if (c1 == '>' && c2 == '>') { + shift(2); + return RSHIFT; + } else if (c1 == '&' && c2 == '&') { + shift(2); + return AND; + } else if (c1 == '|' && c2 == '|') { + shift(2); + return OR; + } + + switch(c1) { + case '=': + case '>': + case '<': + case ',': + case '!': + case '~': + case '?': + case ':': + case '.': + case '+': + case '-': + case '*': + case '/': + case '&': + case '|': + case '^': + case '%': + case '(': + case ')': + case '{': + case '}': + case '[': + case ']': + case ';': + shift(1); + return static_cast(c1); + default: + return -1; + } +} + +unsigned short Lexer::singleEscape(unsigned short c) +{ + switch(c) { + case 'b': + return 0x08; + case 't': + return 0x09; + case 'n': + return 0x0A; + case 'v': + return 0x0B; + case 'f': + return 0x0C; + case 'r': + return 0x0D; + case '"': + return 0x22; + case '\'': + return 0x27; + case '\\': + return 0x5C; + default: + return c; + } +} + +unsigned short Lexer::convertOctal(int c1, int c2, int c3) +{ + return static_cast((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0'); +} + +unsigned char Lexer::convertHex(int c) +{ + if (c >= '0' && c <= '9') + return static_cast(c - '0'); + if (c >= 'a' && c <= 'f') + return static_cast(c - 'a' + 10); + return static_cast(c - 'A' + 10); +} + +unsigned char Lexer::convertHex(int c1, int c2) +{ + return ((convertHex(c1) << 4) + convertHex(c2)); +} + +KJS::UChar Lexer::convertUnicode(int c1, int c2, int c3, int c4) +{ + return KJS::UChar((convertHex(c1) << 4) + convertHex(c2), + (convertHex(c3) << 4) + convertHex(c4)); +} + +void Lexer::record8(int c) +{ + ASSERT(c >= 0); + ASSERT(c <= 0xff); + m_buffer8.append(static_cast(c)); +} + +void Lexer::record16(int c) +{ + ASSERT(c >= 0); + ASSERT(c <= USHRT_MAX); + record16(UChar(static_cast(c))); +} + +void Lexer::record16(KJS::UChar c) +{ + m_buffer16.append(c); +} + +bool Lexer::scanRegExp() +{ + m_buffer16.clear(); + bool lastWasEscape = false; + bool inBrackets = false; + + while (1) { + if (isLineTerminator() || current == -1) + return false; + else if (current != '/' || lastWasEscape == true || inBrackets == true) + { + // keep track of '[' and ']' + if (!lastWasEscape) { + if ( current == '[' && !inBrackets ) + inBrackets = true; + if ( current == ']' && inBrackets ) + inBrackets = false; + } + record16(current); + lastWasEscape = + !lastWasEscape && (current == '\\'); + } else { // end of regexp + m_pattern = UString(m_buffer16); + m_buffer16.clear(); + shift(1); + break; + } + shift(1); + } + + while (isIdentPart(current)) { + record16(current); + shift(1); + } + m_flags = UString(m_buffer16); + + return true; +} + +void Lexer::clear() +{ + deleteAllValues(m_strings); + Vector newStrings; + newStrings.reserveCapacity(initialStringTableCapacity); + m_strings.swap(newStrings); + + deleteAllValues(m_identifiers); + Vector newIdentifiers; + newIdentifiers.reserveCapacity(initialStringTableCapacity); + m_identifiers.swap(newIdentifiers); + + Vector newBuffer8; + newBuffer8.reserveCapacity(initialReadBufferCapacity); + m_buffer8.swap(newBuffer8); + + Vector newBuffer16; + newBuffer16.reserveCapacity(initialReadBufferCapacity); + m_buffer16.swap(newBuffer16); + + m_pattern = 0; + m_flags = 0; +} + +Identifier* Lexer::makeIdentifier(const Vector& buffer) +{ + KJS::Identifier* identifier = new KJS::Identifier(buffer.data(), buffer.size()); + m_identifiers.append(identifier); + return identifier; +} + +UString* Lexer::makeUString(const Vector& buffer) +{ + UString* string = new UString(buffer); + m_strings.append(string); + return string; +} + +} // namespace KJS diff --git a/kjs/lexer.h b/kjs/lexer.h new file mode 100644 index 0000000..1ce27af --- /dev/null +++ b/kjs/lexer.h @@ -0,0 +1,149 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2007 Apple Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef Lexer_h +#define Lexer_h + +#include "ustring.h" +#include + +namespace KJS { + + class Identifier; + class RegExp; + + class Lexer : Noncopyable { + public: + void setCode(int startingLineNumber, const UChar *c, unsigned int len); + int lex(); + + int lineNo() const { return yylineno; } + + bool prevTerminator() const { return terminator; } + + enum State { Start, + IdentifierOrKeyword, + Identifier, + InIdentifierOrKeyword, + InIdentifier, + InIdentifierStartUnicodeEscapeStart, + InIdentifierStartUnicodeEscape, + InIdentifierPartUnicodeEscapeStart, + InIdentifierPartUnicodeEscape, + InSingleLineComment, + InMultiLineComment, + InNum, + InNum0, + InHex, + InOctal, + InDecimal, + InExponentIndicator, + InExponent, + Hex, + Octal, + Number, + String, + Eof, + InString, + InEscapeSequence, + InHexEscape, + InUnicodeEscape, + Other, + Bad }; + + bool scanRegExp(); + const UString& pattern() const { return m_pattern; } + const UString& flags() const { return m_flags; } + + static unsigned char convertHex(int); + static unsigned char convertHex(int c1, int c2); + static UChar convertUnicode(int c1, int c2, int c3, int c4); + static bool isIdentStart(int); + static bool isIdentPart(int); + static bool isHexDigit(int); + + bool sawError() const { return error; } + + void clear(); + + private: + friend Lexer& lexer(); + Lexer(); + + int yylineno; + bool done; + Vector m_buffer8; + Vector m_buffer16; + bool terminator; + bool restrKeyword; + // encountered delimiter like "'" and "}" on last run + bool delimited; + bool skipLF; + bool skipCR; + bool eatNextIdentifier; + int stackToken; + int lastToken; + + State state; + void setDone(State); + unsigned int pos; + void shift(unsigned int p); + void nextLine(); + int lookupKeyword(const char *); + + bool isWhiteSpace() const; + bool isLineTerminator(); + static bool isOctalDigit(int); + + int matchPunctuator(int c1, int c2, int c3, int c4); + static unsigned short singleEscape(unsigned short); + static unsigned short convertOctal(int c1, int c2, int c3); + + void record8(int); + void record16(int); + void record16(UChar); + + KJS::Identifier* makeIdentifier(const Vector& buffer); + UString* makeUString(const Vector& buffer); + + const UChar* code; + unsigned int length; + int yycolumn; + int atLineStart; + bool error; + + // current and following unicode characters (int to allow for -1 for end-of-file marker) + int current, next1, next2, next3; + + Vector m_strings; + Vector m_identifiers; + + UString m_pattern; + UString m_flags; + }; + + Lexer& lexer(); // Returns the singletone JavaScript lexer. + +} // namespace KJS + +#endif // Lexer_h diff --git a/kjs/list.cpp b/kjs/list.cpp new file mode 100644 index 0000000..5cc7cc2 --- /dev/null +++ b/kjs/list.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "list.h" + +using std::min; + +namespace KJS { + +void List::getSlice(int startIndex, List& result) const +{ + const_iterator start = min(begin() + startIndex, end()); + result.m_vector.appendRange(start, end()); +} + +List::ListSet& List::markSet() +{ + static ListSet staticMarkSet; + return staticMarkSet; +} + +void List::markProtectedListsSlowCase() +{ + ListSet::iterator end = markSet().end(); + for (ListSet::iterator it = markSet().begin(); it != end; ++it) { + List* list = *it; + + iterator end2 = list->end(); + for (iterator it2 = list->begin(); it2 != end2; ++it2) { + JSValue* v = *it2; + if (!v->marked()) + v->mark(); + } + } +} + +void List::expandAndAppend(JSValue* v) +{ + ASSERT(m_vector.size() == m_vector.capacity()); + + // 4x growth would be excessive for a normal vector, but it's OK for Lists + // because they're short-lived. + m_vector.reserveCapacity(m_vector.capacity() * 4); + + // As long as our size stays within our Vector's inline + // capacity, all our values are allocated on the stack, and + // therefore don't need explicit marking. Once our size exceeds + // our Vector's inline capacity, though, our values move to the + // heap, where they do need explicit marking. + if (!m_isInMarkSet) { + markSet().add(this); + m_isInMarkSet = true; + } + + m_vector.uncheckedAppend(v); +} + +} // namespace KJS diff --git a/kjs/list.h b/kjs/list.h new file mode 100644 index 0000000..6a43e08 --- /dev/null +++ b/kjs/list.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2007 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_LIST_H +#define KJS_LIST_H + +#include +#include +#include +#include + +namespace KJS { + + class JSValue; + class List; + + class List : Noncopyable { + private: + typedef Vector VectorType; + typedef HashSet ListSet; + + public: + typedef VectorType::iterator iterator; + typedef VectorType::const_iterator const_iterator; + + List() + : m_isInMarkSet(false) + { + } + + ~List() + { + if (m_isInMarkSet) + markSet().remove(this); + } + + size_t size() const { return m_vector.size(); } + bool isEmpty() const { return m_vector.isEmpty(); } + + JSValue* at(size_t i) const + { + if (i < m_vector.size()) + return m_vector.at(i); + return jsUndefined(); + } + + JSValue* operator[](int i) const { return at(i); } + + void clear() { m_vector.clear(); } + + void append(JSValue* v) + { + if (m_vector.size() < m_vector.capacity()) + m_vector.uncheckedAppend(v); + else + // Putting the slow "expand and append" case all in one + // function measurably improves the performance of the fast + // "just append" case. + expandAndAppend(v); + } + + void getSlice(int startIndex, List& result) const; + + iterator begin() { return m_vector.begin(); } + iterator end() { return m_vector.end(); } + + const_iterator begin() const { return m_vector.begin(); } + const_iterator end() const { return m_vector.end(); } + + static void markProtectedLists() + { + if (!markSet().size()) + return; + markProtectedListsSlowCase(); + } + + private: + static ListSet& markSet(); + static void markProtectedListsSlowCase(); + + void expandAndAppend(JSValue*); + + VectorType m_vector; + bool m_isInMarkSet; + + private: + // Prohibits new / delete, which would break GC. + void* operator new(size_t); + void operator delete(void*); + + void* operator new[](size_t); + void operator delete[](void*); + + void* operator new(size_t, void*); + void operator delete(void*, size_t); + }; + +} // namespace KJS + +#endif // KJS_LIST_H diff --git a/kjs/lookup.cpp b/kjs/lookup.cpp new file mode 100644 index 0000000..95dc5cb --- /dev/null +++ b/kjs/lookup.cpp @@ -0,0 +1,81 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "lookup.h" + +#include + +namespace KJS { + +static inline bool keysMatch(const UChar* c, unsigned len, const char* s) +{ + // FIXME: This can run off the end of |s| if |c| has a U+0000 character in it. + const char* end = s + len; + for (; s != end; c++, s++) + if (c->uc != *s) + return false; + return *s == 0; +} + +static inline const HashEntry* findEntry(const struct HashTable* table, unsigned int hash, + const UChar* c, unsigned int len) +{ + ASSERT(table->type == 3); + + const HashEntry* e = &table->entries[hash & table->hashSizeMask]; + + if (!e->s) + return 0; + + do { + // compare strings + if (keysMatch(c, len, e->s)) + return e; + + // try next bucket + e = e->next; + } while (e); + return 0; +} + +const HashEntry* Lookup::findEntry(const struct HashTable* table, const Identifier& s) +{ + return KJS::findEntry(table, s.ustring().rep()->computedHash(), s.data(), s.size()); +} + +int Lookup::find(const struct HashTable *table, const UChar *c, unsigned int len) +{ + const HashEntry *entry = KJS::findEntry(table, UString::Rep::computeHash(c, len), c, len); + if (entry) + return entry->value.intValue; + return -1; +} + +int Lookup::find(const struct HashTable* table, const Identifier& s) +{ + const HashEntry* entry = KJS::findEntry(table, s.ustring().rep()->computedHash(), s.data(), s.size()); + if (entry) + return entry->value.intValue; + return -1; +} + +} diff --git a/kjs/lookup.h b/kjs/lookup.h new file mode 100644 index 0000000..199c9d9 --- /dev/null +++ b/kjs/lookup.h @@ -0,0 +1,342 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef KJS_lookup_h +#define KJS_lookup_h + +#include "ExecState.h" +#include "function.h" +#include "identifier.h" +#include "JSGlobalObject.h" +#include "object.h" +#include +#include + +namespace KJS { + + /** + * An entry in a hash table. + */ + struct HashEntry { + /** + * s is the key (e.g. a property name) + */ + const char* s; + + /** + * value is the result value (enum value for properties and a function pointer to a constructor factory for functions) + */ + union { + intptr_t intValue; + PrototypeFunction::JSMemberFunction functionValue; + } value; + + /** + * attr is a set for flags (e.g. the property flags, see object.h) + */ + unsigned char attr; + /** + * params is another number. For property hashtables, it is used to + * denote the number of argument of the function + */ + short int params; + /** + * next is the pointer to the next entry for the same hash value + */ + const HashEntry* next; + }; + + /** + * A hash table + * Usually the hashtable is generated by the create_hash_table script, from a .table file. + * + * The implementation uses an array of entries, "size" is the total size of that array. + * The entries between 0 and hashSize-1 are the entry points + * for each hash value, and the entries between hashSize and size-1 + * are the overflow entries for the hash values that need one. + * The "next" pointer of the entry links entry points to overflow entries, + * and links overflow entries between them. + */ + struct HashTable { + /** + * type is a version number. Currently always 2 + */ + int type; + /** + * size is the total number of entries in the hashtable, including the null entries, + * i.e. the size of the "entries" array. + * Used to iterate over all entries in the table + */ + int size; + /** + * pointer to the array of entries + * Mind that some entries in the array are null (0,0,0,0). + */ + const HashEntry* entries; + /** + * the maximum value for the hash minus 1. Always smaller than size. + */ + int hashSizeMask; + }; + + /** + * @short Fast keyword lookup. + */ + class Lookup { + public: + /** + * Find an entry in the table, and return its value (i.e. the value field of HashEntry) + */ + static int find(const struct HashTable*, const Identifier&); + static int find(const struct HashTable*, const UChar*, unsigned int len); + + /** + * Find an entry in the table, and return the entry + * This variant gives access to the other attributes of the entry, + * especially the attr field. + */ + static const HashEntry* findEntry(const struct HashTable*, const Identifier&); + + }; + + class ExecState; + class UString; + /** + * @internal + * Helper for getStaticFunctionSlot and getStaticPropertySlot + */ + inline JSValue* staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) + { + // Look for cached value in dynamic map of properties (in JSObject) + JSObject* thisObj = slot.slotBase(); + JSValue* cachedVal = thisObj->getDirect(propertyName); + if (cachedVal) + return cachedVal; + + const HashEntry* entry = slot.staticEntry(); + JSValue* val = new PrototypeFunction(exec, entry->params, propertyName, entry->value.functionValue); + thisObj->putDirect(propertyName, val, entry->attr); + return val; + } + + /** + * @internal + * Helper for getStaticValueSlot and getStaticPropertySlot + */ + template + inline JSValue* staticValueGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot) + { + ThisImp* thisObj = static_cast(slot.slotBase()); + const HashEntry* entry = slot.staticEntry(); + return thisObj->getValueProperty(exec, entry->value.intValue); + } + + /** + * Helper method for property lookups + * + * This method does it all (looking in the hashtable, checking for function + * overrides, creating the function or retrieving from cache, calling + * getValueProperty in case of a non-function property, forwarding to parent if + * unknown property). + * + * Template arguments: + * @param FuncImp the class which implements this object's functions + * @param ThisImp the class of "this". It must implement the getValueProperty(exec,token) method, + * for non-function properties. + * @param ParentImp the class of the parent, to propagate the lookup. + * + * Method arguments: + * @param exec execution state, as usual + * @param propertyName the property we're looking for + * @param table the static hashtable for this class + * @param thisObj "this" + */ + template + inline bool getStaticPropertySlot(ExecState* exec, const HashTable* table, + ThisImp* thisObj, const Identifier& propertyName, PropertySlot& slot) + { + const HashEntry* entry = Lookup::findEntry(table, propertyName); + + if (!entry) // not found, forward to parent + return thisObj->ParentImp::getOwnPropertySlot(exec, propertyName, slot); + + if (entry->attr & Function) + slot.setStaticEntry(thisObj, entry, staticFunctionGetter); + else + slot.setStaticEntry(thisObj, entry, staticValueGetter); + + return true; + } + + /** + * Simplified version of getStaticPropertySlot in case there are only functions. + * Using this instead of getStaticPropertySlot allows 'this' to avoid implementing + * a dummy getValueProperty. + */ + template + inline bool getStaticFunctionSlot(ExecState* exec, const HashTable* table, + JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot) + { + const HashEntry* entry = Lookup::findEntry(table, propertyName); + + if (!entry) // not found, forward to parent + return static_cast(thisObj)->ParentImp::getOwnPropertySlot(exec, propertyName, slot); + + ASSERT(entry->attr & Function); + + slot.setStaticEntry(thisObj, entry, staticFunctionGetter); + return true; + } + + /** + * Simplified version of getStaticPropertySlot in case there are no functions, only "values". + * Using this instead of getStaticPropertySlot removes the need for a FuncImp class. + */ + template + inline bool getStaticValueSlot(ExecState* exec, const HashTable* table, + ThisImp* thisObj, const Identifier& propertyName, PropertySlot& slot) + { + const HashEntry* entry = Lookup::findEntry(table, propertyName); + + if (!entry) // not found, forward to parent + return thisObj->ParentImp::getOwnPropertySlot(exec, propertyName, slot); + + ASSERT(!(entry->attr & Function)); + + slot.setStaticEntry(thisObj, entry, staticValueGetter); + return true; + } + + /** + * This one is for "put". + * It looks up a hash entry for the property to be set. If an entry + * is found it sets the value and returns true, else it returns false. + */ + template + inline bool lookupPut(ExecState* exec, const Identifier& propertyName, + JSValue* value, int attr, + const HashTable* table, ThisImp* thisObj) + { + const HashEntry* entry = Lookup::findEntry(table, propertyName); + + if (!entry) + return false; + + if (entry->attr & Function) // function: put as override property + thisObj->JSObject::put(exec, propertyName, value, attr); + else if (!(entry->attr & ReadOnly)) + thisObj->putValueProperty(exec, entry->value.intValue, value, attr); + + return true; + } + + /** + * This one is for "put". + * It calls lookupPut() to set the value. If that call + * returns false (meaning no entry in the hash table was found), + * then it calls put() on the ParentImp class. + */ + template + inline void lookupPut(ExecState* exec, const Identifier& propertyName, + JSValue* value, int attr, + const HashTable* table, ThisImp* thisObj) + { + if (!lookupPut(exec, propertyName, value, attr, table, thisObj)) + thisObj->ParentImp::put(exec, propertyName, value, attr); // not found: forward to parent + } + + /** + * This template method retrieves or create an object that is unique + * (for a given global object) The first time this is called (for a given + * property name), the Object will be constructed, and set as a property + * of the global object. Later calls will simply retrieve that cached object. + * Note that the object constructor must take 1 argument, exec. + */ + template + inline JSObject* cacheGlobalObject(ExecState* exec, const Identifier& propertyName) + { + JSGlobalObject* globalObject = exec->lexicalGlobalObject(); + JSValue* obj = globalObject->getDirect(propertyName); + if (obj) { + ASSERT(obj->isObject()); + return static_cast(obj); + } + JSObject* newObject = new ClassCtor(exec); + globalObject->putDirect(propertyName, newObject, Internal | DontEnum); + return newObject; + } + +} // namespace + +/** + * Helpers to define prototype objects (each of which simply implements + * the functions for a type of objects). + * Sorry for this not being very readable, but it actually saves much copy-n-paste. + * ParentPrototype is not our base class, it's the object we use as fallback. + * The reason for this is that there should only be ONE DOMNode.hasAttributes (e.g.), + * not one in each derived class. So we link the (unique) prototypes between them. + * + * Using those macros is very simple: define the hashtable (e.g. "DOMNodePrototypeTable"), then + * KJS_DEFINE_PROTOTYPE(DOMNodePrototype) + * KJS_IMPLEMENT_PROTOTYPE("DOMNode", DOMNodePrototype, DOMNodePrototypeFunction) + * and use DOMNodePrototype::self(exec) as prototype in the DOMNode constructor. + * If the prototype has a "parent prototype", e.g. DOMElementPrototype falls back on DOMNodePrototype, + * then the first line will use KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE, with DOMNodePrototype as the second argument. + */ + +// These macros assume that a prototype's only properties are functions +#define KJS_DEFINE_PROTOTYPE(ClassPrototype) \ + class ClassPrototype : public KJS::JSObject { \ + public: \ + static KJS::JSObject* self(KJS::ExecState* exec); \ + virtual const KJS::ClassInfo* classInfo() const { return &info; } \ + static const KJS::ClassInfo info; \ + bool getOwnPropertySlot(KJS::ExecState* , const KJS::Identifier&, KJS::PropertySlot&); \ + ClassPrototype(KJS::ExecState* exec) \ + : KJS::JSObject(exec->lexicalGlobalObject()->objectPrototype()) { } \ + \ + }; + +#define KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(ClassPrototype, ClassPrototypePrototype) \ + class ClassPrototype : public KJS::JSObject { \ + public: \ + static KJS::JSObject* self(KJS::ExecState* exec); \ + virtual const KJS::ClassInfo* classInfo() const { return &info; } \ + static const KJS::ClassInfo info; \ + bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&); \ + ClassPrototype(KJS::ExecState* exec) \ + : KJS::JSObject(ClassPrototypePrototype::self(exec)) { } \ + \ + }; + +#define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassPrototype) \ + const ClassInfo ClassPrototype::info = { ClassName"Prototype", 0, &ClassPrototype##Table }; \ + JSObject* ClassPrototype::self(ExecState* exec) \ + { \ + static Identifier* prototypeIdentifier = new Identifier("[[" ClassName ".prototype]]"); \ + return KJS::cacheGlobalObject(exec, *prototypeIdentifier); \ + } \ + bool ClassPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \ + { \ + return getStaticFunctionSlot(exec, &ClassPrototype##Table, this, propertyName, slot); \ + } + +#endif // KJS_lookup_h diff --git a/kjs/math_object.cpp b/kjs/math_object.cpp new file mode 100644 index 0000000..805efda --- /dev/null +++ b/kjs/math_object.cpp @@ -0,0 +1,243 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "math_object.h" +#include "math_object.lut.h" + +#include "operations.h" +#include +#include +#include + +namespace KJS { + +// ------------------------------ MathObjectImp -------------------------------- + +const ClassInfo MathObjectImp::info = { "Math", 0, &mathTable }; + +/* Source for math_object.lut.h +@begin mathTable 21 + E MathObjectImp::Euler DontEnum|DontDelete|ReadOnly + LN2 MathObjectImp::Ln2 DontEnum|DontDelete|ReadOnly + LN10 MathObjectImp::Ln10 DontEnum|DontDelete|ReadOnly + LOG2E MathObjectImp::Log2E DontEnum|DontDelete|ReadOnly + LOG10E MathObjectImp::Log10E DontEnum|DontDelete|ReadOnly + PI MathObjectImp::Pi DontEnum|DontDelete|ReadOnly + SQRT1_2 MathObjectImp::Sqrt1_2 DontEnum|DontDelete|ReadOnly + SQRT2 MathObjectImp::Sqrt2 DontEnum|DontDelete|ReadOnly + abs mathProtoFuncAbs DontEnum|Function 1 + acos mathProtoFuncACos DontEnum|Function 1 + asin mathProtoFuncASin DontEnum|Function 1 + atan mathProtoFuncATan DontEnum|Function 1 + atan2 mathProtoFuncATan2 DontEnum|Function 2 + ceil mathProtoFuncCeil DontEnum|Function 1 + cos mathProtoFuncCos DontEnum|Function 1 + exp mathProtoFuncExp DontEnum|Function 1 + floor mathProtoFuncFloor DontEnum|Function 1 + log mathProtoFuncLog DontEnum|Function 1 + max mathProtoFuncMax DontEnum|Function 2 + min mathProtoFuncMin DontEnum|Function 2 + pow mathProtoFuncPow DontEnum|Function 2 + random mathProtoFuncRandom DontEnum|Function 0 + round mathProtoFuncRound DontEnum|Function 1 + sin mathProtoFuncSin DontEnum|Function 1 + sqrt mathProtoFuncSqrt DontEnum|Function 1 + tan mathProtoFuncTan DontEnum|Function 1 +@end +*/ + +MathObjectImp::MathObjectImp(ExecState*, ObjectPrototype* objectPrototype) + : JSObject(objectPrototype) +{ +} + +// ECMA 15.8 + +bool MathObjectImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot &slot) +{ + return getStaticPropertySlot(exec, &mathTable, this, propertyName, slot); +} + +JSValue* MathObjectImp::getValueProperty(ExecState*, int token) const +{ + switch (token) { + case Euler: + return jsNumber(exp(1.0)); + case Ln2: + return jsNumber(log(2.0)); + case Ln10: + return jsNumber(log(10.0)); + case Log2E: + return jsNumber(1.0 / log(2.0)); + case Log10E: + return jsNumber(1.0 / log(10.0)); + case Pi: + return jsNumber(piDouble); + case Sqrt1_2: + return jsNumber(sqrt(0.5)); + case Sqrt2: + return jsNumber(sqrt(2.0)); + } + + ASSERT_NOT_REACHED(); + return 0; +} + +// ------------------------------ Functions -------------------------------- + +JSValue* mathProtoFuncAbs(ExecState* exec, JSObject*, const List& args) +{ + double arg = args[0]->toNumber(exec); + return signbit(arg) ? jsNumber(-arg) : jsNumber(arg); +} + +JSValue* mathProtoFuncACos(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(acos(args[0]->toNumber(exec))); +} + +JSValue* mathProtoFuncASin(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(asin(args[0]->toNumber(exec))); +} + +JSValue* mathProtoFuncATan(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(atan(args[0]->toNumber(exec))); +} + +JSValue* mathProtoFuncATan2(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(atan2(args[0]->toNumber(exec), args[1]->toNumber(exec))); +} + +JSValue* mathProtoFuncCeil(ExecState* exec, JSObject*, const List& args) +{ + double arg = args[0]->toNumber(exec); + if (signbit(arg) && arg > -1.0) + return jsNumber(-0.0); + return jsNumber(ceil(arg)); +} + +JSValue* mathProtoFuncCos(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(cos(args[0]->toNumber(exec))); +} + +JSValue* mathProtoFuncExp(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(exp(args[0]->toNumber(exec))); +} + +JSValue* mathProtoFuncFloor(ExecState* exec, JSObject*, const List& args) +{ + double arg = args[0]->toNumber(exec); + if (signbit(arg) && arg == 0.0) + return jsNumber(-0.0); + return jsNumber(floor(arg)); +} + +JSValue* mathProtoFuncLog(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(log(args[0]->toNumber(exec))); +} + +JSValue* mathProtoFuncMax(ExecState* exec, JSObject*, const List& args) +{ + unsigned argsCount = args.size(); + double result = -Inf; + for (unsigned k = 0; k < argsCount; ++k) { + double val = args[k]->toNumber(exec); + if (isnan(val)) { + result = NaN; + break; + } + if (val > result || (val == 0 && result == 0 && !signbit(val))) + result = val; + } + return jsNumber(result); +} + +JSValue* mathProtoFuncMin(ExecState* exec, JSObject*, const List& args) +{ + unsigned argsCount = args.size(); + double result = +Inf; + for (unsigned k = 0; k < argsCount; ++k) { + double val = args[k]->toNumber(exec); + if (isnan(val)) { + result = NaN; + break; + } + if (val < result || (val == 0 && result == 0 && signbit(val))) + result = val; + } + return jsNumber(result); +} + +JSValue* mathProtoFuncPow(ExecState* exec, JSObject*, const List& args) +{ + // ECMA 15.8.2.1.13 + + double arg = args[0]->toNumber(exec); + double arg2 = args[1]->toNumber(exec); + + if (isnan(arg2)) + return jsNumber(NaN); + if (isinf(arg2) && fabs(arg) == 1) + return jsNumber(NaN); + return jsNumber(pow(arg, arg2)); +} + +static bool didInitRandom; + +JSValue* mathProtoFuncRandom(ExecState*, JSObject*, const List&) +{ + if (!didInitRandom) { + wtf_random_init(); + didInitRandom = true; + } + return jsNumber(wtf_random()); +} + +JSValue* mathProtoFuncRound(ExecState* exec, JSObject*, const List& args) +{ + double arg = args[0]->toNumber(exec); + if (signbit(arg) && arg >= -0.5) + return jsNumber(-0.0); + return jsNumber(floor(arg + 0.5)); +} + +JSValue* mathProtoFuncSin(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(sin(args[0]->toNumber(exec))); +} + +JSValue* mathProtoFuncSqrt(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(sqrt(args[0]->toNumber(exec))); +} + +JSValue* mathProtoFuncTan(ExecState* exec, JSObject*, const List& args) +{ + return jsNumber(tan(args[0]->toNumber(exec))); +} + +} // namespace KJS diff --git a/kjs/math_object.h b/kjs/math_object.h new file mode 100644 index 0000000..72e442f --- /dev/null +++ b/kjs/math_object.h @@ -0,0 +1,65 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef MATH_OBJECT_H_ +#define MATH_OBJECT_H_ + +#include "function_object.h" +#include "lookup.h" + +namespace KJS { + + class MathObjectImp : public JSObject { + public: + MathObjectImp(ExecState*, ObjectPrototype*); + + bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + JSValue* getValueProperty(ExecState*, int token) const; + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + + enum { Euler, Ln2, Ln10, Log2E, Log10E, Pi, Sqrt1_2, Sqrt2 }; + }; + + // Functions + JSValue* mathProtoFuncAbs(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncACos(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncASin(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncATan(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncATan2(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncCeil(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncCos(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncExp(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncFloor(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncLog(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncMax(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncMin(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncPow(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncRandom(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncRound(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncSin(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncSqrt(ExecState*, JSObject*, const List&); + JSValue* mathProtoFuncTan(ExecState*, JSObject*, const List&); + +} // namespace KJS + +#endif // MATH_OBJECT_H_ diff --git a/kjs/nodes.cpp b/kjs/nodes.cpp new file mode 100644 index 0000000..16e6b1e --- /dev/null +++ b/kjs/nodes.cpp @@ -0,0 +1,4725 @@ +/* +* Copyright (C) 1999-2002 Harri Porten (porten@kde.org) +* Copyright (C) 2001 Peter Kelly (pmk@post.com) +* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. +* Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) +* Copyright (C) 2007 Maks Orlovich +* Copyright (C) 2007 Eric Seidel +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public License +* along with this library; see the file COPYING.LIB. If not, write to +* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301, USA. +* +*/ + +#include "config.h" +#include "nodes.h" + +#include "ExecState.h" +#include "JSGlobalObject.h" +#include "Parser.h" +#include "PropertyNameArray.h" +#include "array_object.h" +#include "debugger.h" +#include "function_object.h" +#include "lexer.h" +#include "operations.h" +#include "regexp_object.h" +#include +#include +#include +#include +#include + +namespace KJS { + +class FunctionBodyNodeWithDebuggerHooks : public FunctionBodyNode { +public: + FunctionBodyNodeWithDebuggerHooks(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; +}; + +#define KJS_CHECKEXCEPTION \ +if (exec->hadException()) \ + return rethrowException(exec); + +#define KJS_CHECKEXCEPTIONVALUE \ +if (exec->hadException()) { \ + handleException(exec); \ + return jsUndefined(); \ +} + +#define KJS_CHECKEXCEPTIONNUMBER \ +if (exec->hadException()) { \ + handleException(exec); \ + return 0; \ +} + +#define KJS_CHECKEXCEPTIONBOOLEAN \ +if (exec->hadException()) { \ + handleException(exec); \ + return false; \ +} + +#define KJS_CHECKEXCEPTIONVOID \ +if (exec->hadException()) { \ + handleException(exec); \ + return; \ +} + +#if !ASSERT_DISABLED +static inline bool canSkipLookup(ExecState* exec, const Identifier& ident) +{ + // Static lookup in EvalCode is impossible because variables aren't DontDelete. + // Static lookup in GlobalCode may be possible, but we haven't implemented support for it yet. + if (exec->codeType() != FunctionCode) + return false; + + // Static lookup is impossible when something dynamic has been added to the front of the scope chain. + if (exec->variableObject() != exec->scopeChain().top()) + return false; + + // Static lookup is impossible if the symbol isn't statically declared. + if (!exec->variableObject()->symbolTable().contains(ident.ustring().rep())) + return false; + + return true; +} +#endif + +static inline bool isConstant(const LocalStorage& localStorage, size_t index) +{ + ASSERT(index < localStorage.size()); + return localStorage[index].attributes & ReadOnly; +} + +// ------------------------------ Node ----------------------------------------- + +#ifndef NDEBUG +#ifndef LOG_CHANNEL_PREFIX +#define LOG_CHANNEL_PREFIX Log +#endif +static WTFLogChannel LogKJSNodeLeaks = { 0x00000000, "", WTFLogChannelOn }; + +struct ParserRefCountedCounter { + static unsigned count; + ParserRefCountedCounter() + { + if (count) + LOG(KJSNodeLeaks, "LEAK: %u KJS::Node\n", count); + } +}; +unsigned ParserRefCountedCounter::count = 0; +static ParserRefCountedCounter parserRefCountedCounter; +#endif + +static HashSet* newTrackedObjects; +static HashCountedSet* trackedObjectExtraRefCounts; + +ParserRefCounted::ParserRefCounted() +{ +#ifndef NDEBUG + ++ParserRefCountedCounter::count; +#endif + if (!newTrackedObjects) + newTrackedObjects = new HashSet; + newTrackedObjects->add(this); + ASSERT(newTrackedObjects->contains(this)); +} + +ParserRefCounted::~ParserRefCounted() +{ +#ifndef NDEBUG + --ParserRefCountedCounter::count; +#endif +} + +void ParserRefCounted::ref() +{ + // bumping from 0 to 1 is just removing from the new nodes set + if (newTrackedObjects) { + HashSet::iterator it = newTrackedObjects->find(this); + if (it != newTrackedObjects->end()) { + newTrackedObjects->remove(it); + ASSERT(!trackedObjectExtraRefCounts || !trackedObjectExtraRefCounts->contains(this)); + return; + } + } + + ASSERT(!newTrackedObjects || !newTrackedObjects->contains(this)); + + if (!trackedObjectExtraRefCounts) + trackedObjectExtraRefCounts = new HashCountedSet; + trackedObjectExtraRefCounts->add(this); +} + +void ParserRefCounted::deref() +{ + ASSERT(!newTrackedObjects || !newTrackedObjects->contains(this)); + + if (!trackedObjectExtraRefCounts) { + delete this; + return; + } + + HashCountedSet::iterator it = trackedObjectExtraRefCounts->find(this); + if (it == trackedObjectExtraRefCounts->end()) + delete this; + else + trackedObjectExtraRefCounts->remove(it); +} + +unsigned ParserRefCounted::refcount() +{ + if (newTrackedObjects && newTrackedObjects->contains(this)) { + ASSERT(!trackedObjectExtraRefCounts || !trackedObjectExtraRefCounts->contains(this)); + return 0; + } + + ASSERT(!newTrackedObjects || !newTrackedObjects->contains(this)); + + if (!trackedObjectExtraRefCounts) + return 1; + + return 1 + trackedObjectExtraRefCounts->count(this); +} + +void ParserRefCounted::deleteNewObjects() +{ + if (!newTrackedObjects) + return; + +#ifndef NDEBUG + HashSet::iterator end = newTrackedObjects->end(); + for (HashSet::iterator it = newTrackedObjects->begin(); it != end; ++it) + ASSERT(!trackedObjectExtraRefCounts || !trackedObjectExtraRefCounts->contains(*it)); +#endif + deleteAllValues(*newTrackedObjects); + delete newTrackedObjects; + newTrackedObjects = 0; +} + +Node::Node() + : m_expectedReturnType(ObjectType) +{ + m_line = lexer().lineNo(); +} + +Node::Node(JSType expectedReturn) + : m_expectedReturnType(expectedReturn) +{ + m_line = lexer().lineNo(); +} + +double ExpressionNode::evaluateToNumber(ExecState* exec) +{ + JSValue* value = evaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return value->toNumber(exec); +} + +bool ExpressionNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* value = evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return value->toBoolean(exec); +} + +int32_t ExpressionNode::evaluateToInt32(ExecState* exec) +{ + JSValue* value = evaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return value->toInt32(exec); +} + +uint32_t ExpressionNode::evaluateToUInt32(ExecState* exec) +{ + JSValue* value = evaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return value->toUInt32(exec); +} + +static void substitute(UString& string, const UString& substring) KJS_FAST_CALL; +static void substitute(UString& string, const UString& substring) +{ + int position = string.find("%s"); + ASSERT(position != -1); + UString newString = string.substr(0, position); + newString.append(substring); + newString.append(string.substr(position + 2)); + string = newString; +} + +static inline int currentSourceId(ExecState* exec) KJS_FAST_CALL; +static inline int currentSourceId(ExecState* exec) +{ + return exec->scopeNode()->sourceId(); +} + +static inline const UString& currentSourceURL(ExecState* exec) KJS_FAST_CALL; +static inline const UString& currentSourceURL(ExecState* exec) +{ + return exec->scopeNode()->sourceURL(); +} + +JSValue* Node::setInterruptedCompletion(ExecState* exec) +{ + return exec->setInterruptedCompletion(Error::create(exec, TimeoutError, "JavaScript execution exceeded timeout.", lineNo(), currentSourceId(exec), currentSourceURL(exec))); +} + +JSValue* Node::setErrorCompletion(ExecState* exec, ErrorType e, const char* msg) +{ + return exec->setThrowCompletion(Error::create(exec, e, msg, lineNo(), currentSourceId(exec), currentSourceURL(exec))); +} + +JSValue* Node::setErrorCompletion(ExecState* exec, ErrorType e, const char* msg, const Identifier& ident) +{ + UString message = msg; + substitute(message, ident.ustring()); + return exec->setThrowCompletion(Error::create(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec))); +} + +JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg) +{ + return KJS::throwError(exec, e, msg, lineNo(), currentSourceId(exec), currentSourceURL(exec)); +} + +JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, const char* string) +{ + UString message = msg; + substitute(message, string); + return KJS::throwError(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec)); +} + +JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, JSValue* v, Node* expr) +{ + UString message = msg; + substitute(message, v->toString(exec)); + substitute(message, expr->toString()); + return KJS::throwError(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec)); +} + +JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, const Identifier& label) +{ + UString message = msg; + substitute(message, label.ustring()); + return KJS::throwError(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec)); +} + +JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, JSValue* v, Node* e1, Node* e2) +{ + UString message = msg; + substitute(message, v->toString(exec)); + substitute(message, e1->toString()); + substitute(message, e2->toString()); + return KJS::throwError(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec)); +} + +JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, JSValue* v, Node* expr, const Identifier& label) +{ + UString message = msg; + substitute(message, v->toString(exec)); + substitute(message, expr->toString()); + substitute(message, label.ustring()); + return KJS::throwError(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec)); +} + +JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, JSValue* v, const Identifier& label) +{ + UString message = msg; + substitute(message, v->toString(exec)); + substitute(message, label.ustring()); + return KJS::throwError(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec)); +} + +JSValue* Node::throwUndefinedVariableError(ExecState* exec, const Identifier& ident) +{ + return throwError(exec, ReferenceError, "Can't find variable: %s", ident); +} + +void Node::handleException(ExecState* exec) +{ + handleException(exec, exec->exception()); +} + +void Node::handleException(ExecState* exec, JSValue* exceptionValue) +{ + if (exceptionValue->isObject()) { + JSObject* exception = static_cast(exceptionValue); + if (!exception->hasProperty(exec, "line") && !exception->hasProperty(exec, "sourceURL")) { + exception->put(exec, "line", jsNumber(m_line)); + exception->put(exec, "sourceURL", jsString(currentSourceURL(exec))); + } + } + Debugger* dbg = exec->dynamicGlobalObject()->debugger(); + if (dbg && !dbg->hasHandledException(exec, exceptionValue)) { + bool cont = dbg->exception(exec, currentSourceId(exec), m_line, exceptionValue); + if (!cont) + dbg->imp()->abort(); + } +} + +NEVER_INLINE JSValue* Node::rethrowException(ExecState* exec) +{ + JSValue* exception = exec->exception(); + exec->clearException(); + handleException(exec, exception); + return exec->setThrowCompletion(exception); +} + +// ------------------------------ StatementNode -------------------------------- + +StatementNode::StatementNode() + : m_lastLine(-1) +{ + m_line = -1; +} + +void StatementNode::setLoc(int firstLine, int lastLine) +{ + m_line = firstLine; + m_lastLine = lastLine; +} + +// ------------------------------ SourceElements -------------------------------- + +void SourceElements::append(PassRefPtr statement) +{ + if (statement->isEmptyStatement()) + return; + + if (Debugger::debuggersPresent) + m_statements.append(new BreakpointCheckStatement(statement)); + else + m_statements.append(statement); +} + +// ------------------------------ BreakpointCheckStatement -------------------------------- + +BreakpointCheckStatement::BreakpointCheckStatement(PassRefPtr statement) + : m_statement(statement) +{ + ASSERT(m_statement); +} + +JSValue* BreakpointCheckStatement::execute(ExecState* exec) +{ + if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) + if (!debugger->atStatement(exec, currentSourceId(exec), m_statement->firstLine(), m_statement->lastLine())) + return exec->setNormalCompletion(); + return m_statement->execute(exec); +} + +void BreakpointCheckStatement::streamTo(SourceStream& stream) const +{ + m_statement->streamTo(stream); +} + +void BreakpointCheckStatement::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_statement.get()); +} + +// ------------------------------ NullNode ------------------------------------- + +JSValue* NullNode::evaluate(ExecState* ) +{ + return jsNull(); +} + +// ------------------------------ FalseNode ---------------------------------- + +JSValue* FalseNode::evaluate(ExecState*) +{ + return jsBoolean(false); +} + +// ------------------------------ TrueNode ---------------------------------- + +JSValue* TrueNode::evaluate(ExecState*) +{ + return jsBoolean(true); +} + +// ------------------------------ NumberNode ----------------------------------- + +JSValue* NumberNode::evaluate(ExecState*) +{ + // Number nodes are only created when the number can't fit in a JSImmediate, so no need to check again. + return jsNumberCell(m_double); +} + +double NumberNode::evaluateToNumber(ExecState*) +{ + return m_double; +} + +bool NumberNode::evaluateToBoolean(ExecState*) +{ + return m_double < 0.0 || m_double > 0.0; // false for NaN as well as 0 +} + +int32_t NumberNode::evaluateToInt32(ExecState*) +{ + return JSValue::toInt32(m_double); +} + +uint32_t NumberNode::evaluateToUInt32(ExecState*) +{ + return JSValue::toUInt32(m_double); +} + +// ------------------------------ ImmediateNumberNode ----------------------------------- + +JSValue* ImmediateNumberNode::evaluate(ExecState*) +{ + return m_value; +} + +int32_t ImmediateNumberNode::evaluateToInt32(ExecState*) +{ + return JSImmediate::getTruncatedInt32(m_value); +} + +uint32_t ImmediateNumberNode::evaluateToUInt32(ExecState*) +{ + uint32_t i; + if (JSImmediate::getTruncatedUInt32(m_value, i)) + return i; + bool ok; + return JSValue::toUInt32SlowCase(m_double, ok); +} + +// ------------------------------ StringNode ----------------------------------- + +JSValue* StringNode::evaluate(ExecState*) +{ + return jsOwnedString(m_value); +} + +double StringNode::evaluateToNumber(ExecState*) +{ + return m_value.toDouble(); +} + +bool StringNode::evaluateToBoolean(ExecState*) +{ + return !m_value.isEmpty(); +} + +// ------------------------------ RegExpNode ----------------------------------- + +JSValue* RegExpNode::evaluate(ExecState* exec) +{ + return exec->lexicalGlobalObject()->regExpConstructor()->createRegExpImp(exec, m_regExp); +} + +// ------------------------------ ThisNode ------------------------------------- + +// ECMA 11.1.1 +JSValue* ThisNode::evaluate(ExecState* exec) +{ + return exec->thisValue(); +} + +// ------------------------------ ResolveNode ---------------------------------- + +// ECMA 11.1.2 & 10.1.4 +JSValue* ResolveNode::inlineEvaluate(ExecState* exec) +{ + // Check for missed optimization opportunity. + ASSERT(!canSkipLookup(exec, m_ident)); + + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // we must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + do { + JSObject* o = *iter; + + if (o->getPropertySlot(exec, m_ident, slot)) + return slot.getValue(exec, o, m_ident); + + ++iter; + } while (iter != end); + + return throwUndefinedVariableError(exec, m_ident); +} + +JSValue* ResolveNode::evaluate(ExecState* exec) +{ + return inlineEvaluate(exec); +} + +double ResolveNode::evaluateToNumber(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toNumber(exec); +} + +bool ResolveNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return v->toBoolean(exec); +} + +int32_t ResolveNode::evaluateToInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toInt32(exec); +} + +uint32_t ResolveNode::evaluateToUInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toUInt32(exec); +} + +void ResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage&, NodeStack&) +{ + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) + new (this) LocalVarAccessNode(index); +} + +JSValue* LocalVarAccessNode::inlineEvaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + return exec->localStorage()[m_index].value; +} + +JSValue* LocalVarAccessNode::evaluate(ExecState* exec) +{ + return inlineEvaluate(exec); +} + +double LocalVarAccessNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluate(exec)->toNumber(exec); +} + +bool LocalVarAccessNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluate(exec)->toBoolean(exec); +} + +int32_t LocalVarAccessNode::evaluateToInt32(ExecState* exec) +{ + return inlineEvaluate(exec)->toInt32(exec); +} + +uint32_t LocalVarAccessNode::evaluateToUInt32(ExecState* exec) +{ + return inlineEvaluate(exec)->toUInt32(exec); +} + +// ------------------------------ ElementNode ---------------------------------- + +void ElementNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_next) + nodeStack.append(m_next.get()); + ASSERT(m_node); + nodeStack.append(m_node.get()); +} + +// ECMA 11.1.4 +JSValue* ElementNode::evaluate(ExecState* exec) +{ + JSObject* array = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()); + int length = 0; + for (ElementNode* n = this; n; n = n->m_next.get()) { + JSValue* val = n->m_node->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + length += n->m_elision; + array->put(exec, length++, val); + } + return array; +} + +// ------------------------------ ArrayNode ------------------------------------ + +void ArrayNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_element) + nodeStack.append(m_element.get()); +} + +// ECMA 11.1.4 +JSValue* ArrayNode::evaluate(ExecState* exec) +{ + JSObject* array; + int length; + + if (m_element) { + array = static_cast(m_element->evaluate(exec)); + KJS_CHECKEXCEPTIONVALUE + length = m_optional ? array->get(exec, exec->propertyNames().length)->toInt32(exec) : 0; + } else { + JSValue* newArr = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()); + array = static_cast(newArr); + length = 0; + } + + if (m_optional) + array->put(exec, exec->propertyNames().length, jsNumber(m_elision + length)); + + return array; +} + +// ------------------------------ ObjectLiteralNode ---------------------------- + +void ObjectLiteralNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_list) + nodeStack.append(m_list.get()); +} + +// ECMA 11.1.5 +JSValue* ObjectLiteralNode::evaluate(ExecState* exec) +{ + if (m_list) + return m_list->evaluate(exec); + + return exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList()); +} + +// ------------------------------ PropertyListNode ----------------------------- + +void PropertyListNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_next) + nodeStack.append(m_next.get()); + nodeStack.append(m_node.get()); +} + +// ECMA 11.1.5 +JSValue* PropertyListNode::evaluate(ExecState* exec) +{ + JSObject* obj = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList()); + + for (PropertyListNode* p = this; p; p = p->m_next.get()) { + JSValue* v = p->m_node->m_assign->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + switch (p->m_node->m_type) { + case PropertyNode::Getter: + ASSERT(v->isObject()); + obj->defineGetter(exec, p->m_node->name(), static_cast(v)); + break; + case PropertyNode::Setter: + ASSERT(v->isObject()); + obj->defineSetter(exec, p->m_node->name(), static_cast(v)); + break; + case PropertyNode::Constant: + obj->put(exec, p->m_node->name(), v); + break; + } + } + + return obj; +} + +// ------------------------------ PropertyNode ----------------------------- + +void PropertyNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_assign.get()); +} + +// ECMA 11.1.5 +JSValue* PropertyNode::evaluate(ExecState*) +{ + ASSERT(false); + return jsNull(); +} + +// ------------------------------ BracketAccessorNode -------------------------------- + +void BracketAccessorNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_subscript.get()); + nodeStack.append(m_base.get()); +} + +// ECMA 11.2.1a +JSValue* BracketAccessorNode::inlineEvaluate(ExecState* exec) +{ + JSValue* v1 = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* v2 = m_subscript->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSObject* o = v1->toObject(exec); + uint32_t i; + if (v2->getUInt32(i)) + return o->get(exec, i); + return o->get(exec, Identifier(v2->toString(exec))); +} + +JSValue* BracketAccessorNode::evaluate(ExecState* exec) +{ + return inlineEvaluate(exec); +} + +double BracketAccessorNode::evaluateToNumber(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toNumber(exec); +} + +bool BracketAccessorNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return v->toBoolean(exec); +} + +int32_t BracketAccessorNode::evaluateToInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toInt32(exec); +} + +uint32_t BracketAccessorNode::evaluateToUInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toUInt32(exec); +} + +// ------------------------------ DotAccessorNode -------------------------------- + +void DotAccessorNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_base.get()); +} + +// ECMA 11.2.1b +JSValue* DotAccessorNode::inlineEvaluate(ExecState* exec) +{ + JSValue* v = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + return v->toObject(exec)->get(exec, m_ident); +} + +JSValue* DotAccessorNode::evaluate(ExecState* exec) +{ + return inlineEvaluate(exec); +} + +double DotAccessorNode::evaluateToNumber(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toNumber(exec); +} + +bool DotAccessorNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return v->toBoolean(exec); +} + +int32_t DotAccessorNode::evaluateToInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toInt32(exec); +} + +uint32_t DotAccessorNode::evaluateToUInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toUInt32(exec); +} + +// ------------------------------ ArgumentListNode ----------------------------- + +void ArgumentListNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_next) + nodeStack.append(m_next.get()); + ASSERT(m_expr); + nodeStack.append(m_expr.get()); +} + +// ECMA 11.2.4 +void ArgumentListNode::evaluateList(ExecState* exec, List& list) +{ + for (ArgumentListNode* n = this; n; n = n->m_next.get()) { + JSValue* v = n->m_expr->evaluate(exec); + KJS_CHECKEXCEPTIONVOID + list.append(v); + } +} + +// ------------------------------ ArgumentsNode -------------------------------- + +void ArgumentsNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_listNode) + nodeStack.append(m_listNode.get()); +} + +// ------------------------------ NewExprNode ---------------------------------- + +void NewExprNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_args) + nodeStack.append(m_args.get()); + nodeStack.append(m_expr.get()); +} + +// ECMA 11.2.2 + +JSValue* NewExprNode::inlineEvaluate(ExecState* exec) +{ + JSValue* v = m_expr->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + List argList; + if (m_args) { + m_args->evaluateList(exec, argList); + KJS_CHECKEXCEPTIONVALUE + } + + if (!v->isObject()) + return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with new.", v, m_expr.get()); + + JSObject* constr = static_cast(v); + if (!constr->implementsConstruct()) + return throwError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", v, m_expr.get()); + + return constr->construct(exec, argList); +} + +JSValue* NewExprNode::evaluate(ExecState* exec) +{ + return inlineEvaluate(exec); +} + +double NewExprNode::evaluateToNumber(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toNumber(exec); +} + +bool NewExprNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return v->toBoolean(exec); +} + +int32_t NewExprNode::evaluateToInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toInt32(exec); +} + +uint32_t NewExprNode::evaluateToUInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toUInt32(exec); +} + +void FunctionCallValueNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_args.get()); + nodeStack.append(m_expr.get()); +} + +// ECMA 11.2.3 +JSValue* FunctionCallValueNode::evaluate(ExecState* exec) +{ + JSValue* v = m_expr->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + if (!v->isObject()) { + return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, m_expr.get()); + } + + JSObject* func = static_cast(v); + + if (!func->implementsCall()) { + return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, m_expr.get()); + } + + List argList; + m_args->evaluateList(exec, argList); + KJS_CHECKEXCEPTIONVALUE + + JSObject* thisObj = exec->dynamicGlobalObject(); + + return func->call(exec, thisObj, argList); +} + +void FunctionCallResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_args.get()); + + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) + new (this) LocalVarFunctionCallNode(index); +} + +// ECMA 11.2.3 +JSValue* FunctionCallResolveNode::inlineEvaluate(ExecState* exec) +{ + // Check for missed optimization opportunity. + ASSERT(!canSkipLookup(exec, m_ident)); + + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // we must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + JSObject* base; + do { + base = *iter; + if (base->getPropertySlot(exec, m_ident, slot)) { + JSValue* v = slot.getValue(exec, base, m_ident); + KJS_CHECKEXCEPTIONVALUE + + if (!v->isObject()) + return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, m_ident); + + JSObject* func = static_cast(v); + + if (!func->implementsCall()) + return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, m_ident); + + List argList; + m_args->evaluateList(exec, argList); + KJS_CHECKEXCEPTIONVALUE + + JSObject* thisObj = base; + // ECMA 11.2.3 says that in this situation the this value should be null. + // However, section 10.2.3 says that in the case where the value provided + // by the caller is null, the global object should be used. It also says + // that the section does not apply to internal functions, but for simplicity + // of implementation we use the global object anyway here. This guarantees + // that in host objects you always get a valid object for this. + if (thisObj->isActivationObject()) + thisObj = exec->dynamicGlobalObject(); + + return func->call(exec, thisObj, argList); + } + ++iter; + } while (iter != end); + + return throwUndefinedVariableError(exec, m_ident); +} + +JSValue* FunctionCallResolveNode::evaluate(ExecState* exec) +{ + return inlineEvaluate(exec); +} + +double FunctionCallResolveNode::evaluateToNumber(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toNumber(exec); +} + +bool FunctionCallResolveNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return v->toBoolean(exec); +} + +int32_t FunctionCallResolveNode::evaluateToInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toInt32(exec); +} + +uint32_t FunctionCallResolveNode::evaluateToUInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toUInt32(exec); +} + +JSValue* LocalVarFunctionCallNode::inlineEvaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + + JSValue* v = exec->localStorage()[m_index].value; + + if (!v->isObject()) + return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, m_ident); + + JSObject* func = static_cast(v); + if (!func->implementsCall()) + return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, m_ident); + + List argList; + m_args->evaluateList(exec, argList); + KJS_CHECKEXCEPTIONVALUE + + return func->call(exec, exec->dynamicGlobalObject(), argList); +} + +JSValue* LocalVarFunctionCallNode::evaluate(ExecState* exec) +{ + return inlineEvaluate(exec); +} + +double LocalVarFunctionCallNode::evaluateToNumber(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toNumber(exec); +} + +bool LocalVarFunctionCallNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return v->toBoolean(exec); +} + +int32_t LocalVarFunctionCallNode::evaluateToInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toInt32(exec); +} + +uint32_t LocalVarFunctionCallNode::evaluateToUInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toUInt32(exec); +} + +void FunctionCallBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_args.get()); + nodeStack.append(m_subscript.get()); + nodeStack.append(m_base.get()); +} + +// ECMA 11.2.3 +JSValue* FunctionCallBracketNode::evaluate(ExecState* exec) +{ + JSValue* baseVal = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSValue* subscriptVal = m_subscript->evaluate(exec); + + JSObject* baseObj = baseVal->toObject(exec); + uint32_t i; + PropertySlot slot; + + JSValue* funcVal; + if (subscriptVal->getUInt32(i)) { + if (baseObj->getPropertySlot(exec, i, slot)) + funcVal = slot.getValue(exec, baseObj, i); + else + funcVal = jsUndefined(); + } else { + Identifier ident(subscriptVal->toString(exec)); + if (baseObj->getPropertySlot(exec, ident, slot)) + funcVal = baseObj->get(exec, ident); + else + funcVal = jsUndefined(); + } + + KJS_CHECKEXCEPTIONVALUE + + if (!funcVal->isObject()) + return throwError(exec, TypeError, "Value %s (result of expression %s[%s]) is not object.", funcVal, m_base.get(), m_subscript.get()); + + JSObject* func = static_cast(funcVal); + + if (!func->implementsCall()) + return throwError(exec, TypeError, "Object %s (result of expression %s[%s]) does not allow calls.", funcVal, m_base.get(), m_subscript.get()); + + List argList; + m_args->evaluateList(exec, argList); + KJS_CHECKEXCEPTIONVALUE + + JSObject* thisObj = baseObj; + ASSERT(thisObj); + ASSERT(thisObj->isObject()); + ASSERT(!thisObj->isActivationObject()); + + return func->call(exec, thisObj, argList); +} + +static const char* dotExprNotAnObjectString() KJS_FAST_CALL; +static const char* dotExprNotAnObjectString() +{ + return "Value %s (result of expression %s.%s) is not object."; +} + +static const char* dotExprDoesNotAllowCallsString() KJS_FAST_CALL; +static const char* dotExprDoesNotAllowCallsString() +{ + return "Object %s (result of expression %s.%s) does not allow calls."; +} + +void FunctionCallDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_args.get()); + nodeStack.append(m_base.get()); +} + +// ECMA 11.2.3 +JSValue* FunctionCallDotNode::inlineEvaluate(ExecState* exec) +{ + JSValue* baseVal = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSObject* baseObj = baseVal->toObject(exec); + PropertySlot slot; + JSValue* funcVal = baseObj->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, baseObj, m_ident) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + if (!funcVal->isObject()) + return throwError(exec, TypeError, dotExprNotAnObjectString(), funcVal, m_base.get(), m_ident); + + JSObject* func = static_cast(funcVal); + + if (!func->implementsCall()) + return throwError(exec, TypeError, dotExprDoesNotAllowCallsString(), funcVal, m_base.get(), m_ident); + + List argList; + m_args->evaluateList(exec, argList); + KJS_CHECKEXCEPTIONVALUE + + JSObject* thisObj = baseObj; + ASSERT(thisObj); + ASSERT(thisObj->isObject()); + ASSERT(!thisObj->isActivationObject()); + + return func->call(exec, thisObj, argList); +} + +JSValue* FunctionCallDotNode::evaluate(ExecState* exec) +{ + return inlineEvaluate(exec); +} + +double FunctionCallDotNode::evaluateToNumber(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toNumber(exec); +} + +bool FunctionCallDotNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return v->toBoolean(exec); +} + +int32_t FunctionCallDotNode::evaluateToInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toInt32(exec); +} + +uint32_t FunctionCallDotNode::evaluateToUInt32(ExecState* exec) +{ + JSValue* v = inlineEvaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + return v->toUInt32(exec); +} + +// ECMA 11.3 + +// ------------------------------ PostfixResolveNode ---------------------------------- + +// Increment +void PostIncResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack&) +{ + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) { + if (isConstant(localStorage, index)) + new (this) PostIncConstNode(index); + else + new (this) PostIncLocalVarNode(index); + } +} + +JSValue* PostIncResolveNode::evaluate(ExecState* exec) +{ + // Check for missed optimization opportunity. + ASSERT(!canSkipLookup(exec, m_ident)); + + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // we must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + do { + if ((*iter)->getPropertySlot(exec, m_ident, slot)) { + // If m_ident is 'arguments', the base->getPropertySlot() may cause + // base (which must be an ActivationImp in such this case) to be torn + // off from the activation stack, in which case we need to get it again + // from the ScopeChainIterator. + + JSObject* base = *iter; + JSValue* v = slot.getValue(exec, base, m_ident)->toJSNumber(exec); + base->put(exec, m_ident, jsNumber(v->toNumber(exec) + 1)); + return v; + } + + ++iter; + } while (iter != end); + + return throwUndefinedVariableError(exec, m_ident); +} + +void PostIncResolveNode::optimizeForUnnecessaryResult() +{ + new (this) PreIncResolveNode(PlacementNewAdopt); +} + +JSValue* PostIncLocalVarNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + + JSValue** slot = &exec->localStorage()[m_index].value; + JSValue* v = (*slot)->toJSNumber(exec); + *slot = jsNumber(v->toNumber(exec) + 1); + return v; +} + +void PostIncLocalVarNode::optimizeForUnnecessaryResult() +{ + new (this) PreIncLocalVarNode(m_index); +} + +// Decrement +void PostDecResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack&) +{ + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) { + if (isConstant(localStorage, index)) + new (this) PostDecConstNode(index); + else + new (this) PostDecLocalVarNode(index); + } +} + +JSValue* PostDecResolveNode::evaluate(ExecState* exec) +{ + // Check for missed optimization opportunity. + ASSERT(!canSkipLookup(exec, m_ident)); + + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // we must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + do { + if ((*iter)->getPropertySlot(exec, m_ident, slot)) { + // See the comment in PostIncResolveNode::evaluate(). + + JSObject* base = *iter; + JSValue* v = slot.getValue(exec, base, m_ident)->toJSNumber(exec); + base->put(exec, m_ident, jsNumber(v->toNumber(exec) - 1)); + return v; + } + + ++iter; + } while (iter != end); + + return throwUndefinedVariableError(exec, m_ident); +} + +void PostDecResolveNode::optimizeForUnnecessaryResult() +{ + new (this) PreDecResolveNode(PlacementNewAdopt); +} + +JSValue* PostDecLocalVarNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + + JSValue** slot = &exec->localStorage()[m_index].value; + JSValue* v = (*slot)->toJSNumber(exec); + *slot = jsNumber(v->toNumber(exec) - 1); + return v; +} + +double PostDecLocalVarNode::inlineEvaluateToNumber(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + + JSValue** slot = &exec->localStorage()[m_index].value; + double n = (*slot)->toNumber(exec); + *slot = jsNumber(n - 1); + return n; +} + +double PostDecLocalVarNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToNumber(exec); +} + +bool PostDecLocalVarNode::evaluateToBoolean(ExecState* exec) +{ + double result = inlineEvaluateToNumber(exec); + return result > 0.0 || 0.0 > result; // NaN produces false as well +} + +int32_t PostDecLocalVarNode::evaluateToInt32(ExecState* exec) +{ + return JSValue::toInt32(inlineEvaluateToNumber(exec)); +} + +uint32_t PostDecLocalVarNode::evaluateToUInt32(ExecState* exec) +{ + return JSValue::toUInt32(inlineEvaluateToNumber(exec)); +} + +void PostDecLocalVarNode::optimizeForUnnecessaryResult() +{ + new (this) PreDecLocalVarNode(m_index); +} + +// ------------------------------ PostfixBracketNode ---------------------------------- + +void PostfixBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_subscript.get()); + nodeStack.append(m_base.get()); +} + +JSValue* PostIncBracketNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* subscript = m_subscript->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSObject* base = baseValue->toObject(exec); + + uint32_t propertyIndex; + if (subscript->getUInt32(propertyIndex)) { + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = v->toJSNumber(exec); + base->put(exec, propertyIndex, jsNumber(v2->toNumber(exec) + 1)); + + return v2; + } + + Identifier propertyName(subscript->toString(exec)); + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = v->toJSNumber(exec); + base->put(exec, propertyName, jsNumber(v2->toNumber(exec) + 1)); + return v2; +} + +JSValue* PostDecBracketNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* subscript = m_subscript->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSObject* base = baseValue->toObject(exec); + + uint32_t propertyIndex; + if (subscript->getUInt32(propertyIndex)) { + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = v->toJSNumber(exec); + base->put(exec, propertyIndex, jsNumber(v2->toNumber(exec) - 1)); + return v2; + } + + Identifier propertyName(subscript->toString(exec)); + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = v->toJSNumber(exec); + base->put(exec, propertyName, jsNumber(v2->toNumber(exec) - 1)); + return v2; +} + +// ------------------------------ PostfixDotNode ---------------------------------- + +void PostfixDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_base.get()); +} + +JSValue* PostIncDotNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSObject* base = baseValue->toObject(exec); + + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = v->toJSNumber(exec); + base->put(exec, m_ident, jsNumber(v2->toNumber(exec) + 1)); + return v2; +} + +JSValue* PostDecDotNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSObject* base = baseValue->toObject(exec); + + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = v->toJSNumber(exec); + base->put(exec, m_ident, jsNumber(v2->toNumber(exec) - 1)); + return v2; +} + +// ------------------------------ PostfixErrorNode ----------------------------------- + +JSValue* PostfixErrorNode::evaluate(ExecState* exec) +{ + throwError(exec, ReferenceError, "Postfix %s operator applied to value that is not a reference.", + m_operator == OpPlusPlus ? "++" : "--"); + handleException(exec); + return jsUndefined(); +} + +// ------------------------------ DeleteResolveNode ----------------------------------- + +void DeleteResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage&, NodeStack&) +{ + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) + new (this) LocalVarDeleteNode(); +} + +// ECMA 11.4.1 + +JSValue* DeleteResolveNode::evaluate(ExecState* exec) +{ + // Check for missed optimization opportunity. + ASSERT(!canSkipLookup(exec, m_ident)); + + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // We must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + JSObject* base; + do { + base = *iter; + if (base->getPropertySlot(exec, m_ident, slot)) + return jsBoolean(base->deleteProperty(exec, m_ident)); + + ++iter; + } while (iter != end); + + return jsBoolean(true); +} + +JSValue* LocalVarDeleteNode::evaluate(ExecState*) +{ + return jsBoolean(false); +} + +// ------------------------------ DeleteBracketNode ----------------------------------- + +void DeleteBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_subscript.get()); + nodeStack.append(m_base.get()); +} + +JSValue* DeleteBracketNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* subscript = m_subscript->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSObject* base = baseValue->toObject(exec); + + uint32_t propertyIndex; + if (subscript->getUInt32(propertyIndex)) + return jsBoolean(base->deleteProperty(exec, propertyIndex)); + + Identifier propertyName(subscript->toString(exec)); + return jsBoolean(base->deleteProperty(exec, propertyName)); +} + +// ------------------------------ DeleteDotNode ----------------------------------- + +void DeleteDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_base.get()); +} + +JSValue* DeleteDotNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + JSObject* base = baseValue->toObject(exec); + KJS_CHECKEXCEPTIONVALUE + + return jsBoolean(base->deleteProperty(exec, m_ident)); +} + +// ------------------------------ DeleteValueNode ----------------------------------- + +void DeleteValueNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr.get()); +} + +JSValue* DeleteValueNode::evaluate(ExecState* exec) +{ + m_expr->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + // delete on a non-location expression ignores the value and returns true + return jsBoolean(true); +} + +// ------------------------------ VoidNode ------------------------------------- + +void VoidNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr.get()); +} + +// ECMA 11.4.2 +JSValue* VoidNode::evaluate(ExecState* exec) +{ + m_expr->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + return jsUndefined(); +} + +// ECMA 11.4.3 + +// ------------------------------ TypeOfValueNode ----------------------------------- + +void TypeOfValueNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr.get()); +} + +static JSValue* typeStringForValue(JSValue* v) KJS_FAST_CALL; +static JSValue* typeStringForValue(JSValue* v) +{ + switch (v->type()) { + case UndefinedType: + return jsString("undefined"); + case NullType: + return jsString("object"); + case BooleanType: + return jsString("boolean"); + case NumberType: + return jsString("number"); + case StringType: + return jsString("string"); + default: + if (v->isObject()) { + // Return "undefined" for objects that should be treated + // as null when doing comparisons. + if (static_cast(v)->masqueradeAsUndefined()) + return jsString("undefined"); + else if (static_cast(v)->implementsCall()) + return jsString("function"); + } + + return jsString("object"); + } +} + +void TypeOfResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage&, NodeStack&) +{ + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) + new (this) LocalVarTypeOfNode(index); +} + +JSValue* LocalVarTypeOfNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + + return typeStringForValue(exec->localStorage()[m_index].value); +} + +JSValue* TypeOfResolveNode::evaluate(ExecState* exec) +{ + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // We must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + JSObject* base; + do { + base = *iter; + if (base->getPropertySlot(exec, m_ident, slot)) { + JSValue* v = slot.getValue(exec, base, m_ident); + return typeStringForValue(v); + } + + ++iter; + } while (iter != end); + + return jsString("undefined"); +} + +// ------------------------------ TypeOfValueNode ----------------------------------- + +JSValue* TypeOfValueNode::evaluate(ExecState* exec) +{ + JSValue* v = m_expr->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + return typeStringForValue(v); +} + +// ECMA 11.4.4 and 11.4.5 + +// ------------------------------ PrefixResolveNode ---------------------------------- + +void PreIncResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack&) +{ + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) { + if (isConstant(localStorage, index)) + new (this) PreIncConstNode(index); + else + new (this) PreIncLocalVarNode(index); + } +} + +JSValue* PreIncLocalVarNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + JSValue** slot = &exec->localStorage()[m_index].value; + + double n = (*slot)->toNumber(exec); + JSValue* n2 = jsNumber(n + 1); + *slot = n2; + return n2; +} + +JSValue* PreIncResolveNode::evaluate(ExecState* exec) +{ + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // we must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + do { + if ((*iter)->getPropertySlot(exec, m_ident, slot)) { + // See the comment in PostIncResolveNode::evaluate(). + + JSObject* base = *iter; + JSValue* v = slot.getValue(exec, base, m_ident); + + double n = v->toNumber(exec); + JSValue* n2 = jsNumber(n + 1); + base->put(exec, m_ident, n2); + + return n2; + } + + ++iter; + } while (iter != end); + + return throwUndefinedVariableError(exec, m_ident); +} + +void PreDecResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack&) +{ + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) { + if (isConstant(localStorage, index)) + new (this) PreDecConstNode(index); + else + new (this) PreDecLocalVarNode(index); + } +} + +JSValue* PreDecLocalVarNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + JSValue** slot = &exec->localStorage()[m_index].value; + + double n = (*slot)->toNumber(exec); + JSValue* n2 = jsNumber(n - 1); + *slot = n2; + return n2; +} + +JSValue* PreDecResolveNode::evaluate(ExecState* exec) +{ + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // we must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + do { + if ((*iter)->getPropertySlot(exec, m_ident, slot)) { + // See the comment in PostIncResolveNode::evaluate(). + + JSObject* base = *iter; + JSValue* v = slot.getValue(exec, base, m_ident); + + double n = v->toNumber(exec); + JSValue* n2 = jsNumber(n - 1); + base->put(exec, m_ident, n2); + + return n2; + } + + ++iter; + } while (iter != end); + + return throwUndefinedVariableError(exec, m_ident); +} + +// ------------------------------ PreIncConstNode ---------------------------------- + +JSValue* PreIncConstNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + return jsNumber(exec->localStorage()[m_index].value->toNumber(exec) + 1); +} + +// ------------------------------ PreDecConstNode ---------------------------------- + +JSValue* PreDecConstNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + return jsNumber(exec->localStorage()[m_index].value->toNumber(exec) - 1); +} + +// ------------------------------ PostIncConstNode ---------------------------------- + +JSValue* PostIncConstNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + return jsNumber(exec->localStorage()[m_index].value->toNumber(exec)); +} + +// ------------------------------ PostDecConstNode ---------------------------------- + +JSValue* PostDecConstNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + return jsNumber(exec->localStorage()[m_index].value->toNumber(exec)); +} + +// ------------------------------ PrefixBracketNode ---------------------------------- + +void PrefixBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_subscript.get()); + nodeStack.append(m_base.get()); +} + +JSValue* PreIncBracketNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* subscript = m_subscript->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSObject* base = baseValue->toObject(exec); + + uint32_t propertyIndex; + if (subscript->getUInt32(propertyIndex)) { + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* n2 = jsNumber(v->toNumber(exec) + 1); + base->put(exec, propertyIndex, n2); + + return n2; + } + + Identifier propertyName(subscript->toString(exec)); + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* n2 = jsNumber(v->toNumber(exec) + 1); + base->put(exec, propertyName, n2); + + return n2; +} + +JSValue* PreDecBracketNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* subscript = m_subscript->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSObject* base = baseValue->toObject(exec); + + uint32_t propertyIndex; + if (subscript->getUInt32(propertyIndex)) { + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* n2 = jsNumber(v->toNumber(exec) - 1); + base->put(exec, propertyIndex, n2); + + return n2; + } + + Identifier propertyName(subscript->toString(exec)); + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + JSValue* n2 = jsNumber(v->toNumber(exec) - 1); + base->put(exec, propertyName, n2); + + return n2; +} + +// ------------------------------ PrefixDotNode ---------------------------------- + +void PrefixDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_base.get()); +} + +JSValue* PreIncDotNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSObject* base = baseValue->toObject(exec); + + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + double n = v->toNumber(exec); + JSValue* n2 = jsNumber(n + 1); + base->put(exec, m_ident, n2); + + return n2; +} + +JSValue* PreDecDotNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSObject* base = baseValue->toObject(exec); + + PropertySlot slot; + JSValue* v = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + + double n = v->toNumber(exec); + JSValue* n2 = jsNumber(n - 1); + base->put(exec, m_ident, n2); + + return n2; +} + +// ------------------------------ PrefixErrorNode ----------------------------------- + +JSValue* PrefixErrorNode::evaluate(ExecState* exec) +{ + throwError(exec, ReferenceError, "Prefix %s operator applied to value that is not a reference.", + m_operator == OpPlusPlus ? "++" : "--"); + handleException(exec); + return jsUndefined(); +} + +// ------------------------------ UnaryPlusNode -------------------------------- + +void UnaryPlusNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr.get()); +} + +// ECMA 11.4.6 +JSValue* UnaryPlusNode::evaluate(ExecState* exec) +{ + JSValue* v = m_expr->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + return v->toJSNumber(exec); +} + +bool UnaryPlusNode::evaluateToBoolean(ExecState* exec) +{ + return m_expr->evaluateToBoolean(exec); +} + +double UnaryPlusNode::evaluateToNumber(ExecState* exec) +{ + return m_expr->evaluateToNumber(exec); +} + +int32_t UnaryPlusNode::evaluateToInt32(ExecState* exec) +{ + return m_expr->evaluateToInt32(exec); +} + +uint32_t UnaryPlusNode::evaluateToUInt32(ExecState* exec) +{ + return m_expr->evaluateToInt32(exec); +} + +// ------------------------------ NegateNode ----------------------------------- + +void NegateNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr.get()); +} + +// ECMA 11.4.7 +JSValue* NegateNode::evaluate(ExecState* exec) +{ + // No need to check exception, caller will do so right after evaluate() + return jsNumber(-m_expr->evaluateToNumber(exec)); +} + +double NegateNode::evaluateToNumber(ExecState* exec) +{ + // No need to check exception, caller will do so right after evaluateToNumber() + return -m_expr->evaluateToNumber(exec); +} + +// ------------------------------ BitwiseNotNode ------------------------------- + +void BitwiseNotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr.get()); +} + +// ECMA 11.4.8 +int32_t BitwiseNotNode::inlineEvaluateToInt32(ExecState* exec) +{ + return ~m_expr->evaluateToInt32(exec); +} + +JSValue* BitwiseNotNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToInt32(exec)); +} + +double BitwiseNotNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +bool BitwiseNotNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +int32_t BitwiseNotNode::evaluateToInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +uint32_t BitwiseNotNode::evaluateToUInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +// ------------------------------ LogicalNotNode ------------------------------- + +void LogicalNotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr.get()); +} + +// ECMA 11.4.9 +JSValue* LogicalNotNode::evaluate(ExecState* exec) +{ + return jsBoolean(!m_expr->evaluateToBoolean(exec)); +} + +bool LogicalNotNode::evaluateToBoolean(ExecState* exec) +{ + return !m_expr->evaluateToBoolean(exec); +} + +// ------------------------------ Multiplicative Nodes ----------------------------------- + +void MultNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_term1.get()); + nodeStack.append(m_term2.get()); +} + +// ECMA 11.5.1 +double MultNode::inlineEvaluateToNumber(ExecState* exec) +{ + double n1 = m_term1->evaluateToNumber(exec); + KJS_CHECKEXCEPTIONNUMBER + double n2 = m_term2->evaluateToNumber(exec); + return n1 * n2; +} + +JSValue* MultNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToNumber(exec)); +} + +double MultNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToNumber(exec); +} + +bool MultNode::evaluateToBoolean(ExecState* exec) +{ + double result = inlineEvaluateToNumber(exec); + return result > 0.0 || 0.0 > result; // NaN produces false as well +} + +int32_t MultNode::evaluateToInt32(ExecState* exec) +{ + return JSValue::toInt32(inlineEvaluateToNumber(exec)); +} + +uint32_t MultNode::evaluateToUInt32(ExecState* exec) +{ + return JSValue::toUInt32(inlineEvaluateToNumber(exec)); +} + +void DivNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_term1.get()); + nodeStack.append(m_term2.get()); +} + +// ECMA 11.5.2 +double DivNode::inlineEvaluateToNumber(ExecState* exec) +{ + double n1 = m_term1->evaluateToNumber(exec); + KJS_CHECKEXCEPTIONNUMBER + double n2 = m_term2->evaluateToNumber(exec); + return n1 / n2; +} + +JSValue* DivNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToNumber(exec)); +} + +double DivNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToNumber(exec); +} + +int32_t DivNode::evaluateToInt32(ExecState* exec) +{ + return JSValue::toInt32(inlineEvaluateToNumber(exec)); +} + +uint32_t DivNode::evaluateToUInt32(ExecState* exec) +{ + return JSValue::toUInt32(inlineEvaluateToNumber(exec)); +} + +void ModNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_term1.get()); + nodeStack.append(m_term2.get()); +} + +// ECMA 11.5.3 +double ModNode::inlineEvaluateToNumber(ExecState* exec) +{ + double n1 = m_term1->evaluateToNumber(exec); + KJS_CHECKEXCEPTIONNUMBER + double n2 = m_term2->evaluateToNumber(exec); + return fmod(n1, n2); +} + +JSValue* ModNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToNumber(exec)); +} + +double ModNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToNumber(exec); +} + +bool ModNode::evaluateToBoolean(ExecState* exec) +{ + double result = inlineEvaluateToNumber(exec); + return result > 0.0 || 0.0 > result; // NaN produces false as well +} + +int32_t ModNode::evaluateToInt32(ExecState* exec) +{ + return JSValue::toInt32(inlineEvaluateToNumber(exec)); +} + +uint32_t ModNode::evaluateToUInt32(ExecState* exec) +{ + return JSValue::toUInt32(inlineEvaluateToNumber(exec)); +} + +// ------------------------------ Additive Nodes -------------------------------------- + +static JSValue* throwOutOfMemoryError(ExecState* exec) +{ + JSObject* error = Error::create(exec, GeneralError, "Out of memory"); + exec->setException(error); + return error; +} + +static double throwOutOfMemoryErrorToNumber(ExecState* exec) +{ + JSObject* error = Error::create(exec, GeneralError, "Out of memory"); + exec->setException(error); + return 0.0; +} + +// ECMA 11.6 +static JSValue* addSlowCase(ExecState* exec, JSValue* v1, JSValue* v2) +{ + // exception for the Date exception in defaultValue() + JSValue* p1 = v1->toPrimitive(exec, UnspecifiedType); + JSValue* p2 = v2->toPrimitive(exec, UnspecifiedType); + + if (p1->isString() || p2->isString()) { + UString value = p1->toString(exec) + p2->toString(exec); + if (value.isNull()) + return throwOutOfMemoryError(exec); + return jsString(value); + } + + return jsNumber(p1->toNumber(exec) + p2->toNumber(exec)); +} + +static double addSlowCaseToNumber(ExecState* exec, JSValue* v1, JSValue* v2) +{ + // exception for the Date exception in defaultValue() + JSValue* p1 = v1->toPrimitive(exec, UnspecifiedType); + JSValue* p2 = v2->toPrimitive(exec, UnspecifiedType); + + if (p1->isString() || p2->isString()) { + UString value = p1->toString(exec) + p2->toString(exec); + if (value.isNull()) + return throwOutOfMemoryErrorToNumber(exec); + return value.toDouble(); + } + + return p1->toNumber(exec) + p2->toNumber(exec); +} + +// Fast-path choices here are based on frequency data from SunSpider: +// Add case: +// --------------------------- +// 5627160 Add case: 1 1 +// 247427 Add case: 5 5 +// 20901 Add case: 5 6 +// 13978 Add case: 5 1 +// 4000 Add case: 1 5 +// 1 Add case: 3 5 + +static inline JSValue* add(ExecState* exec, JSValue* v1, JSValue* v2) +{ + JSType t1 = v1->type(); + JSType t2 = v2->type(); + const unsigned bothTypes = (t1 << 3) | t2; + + if (bothTypes == ((NumberType << 3) | NumberType)) + return jsNumber(v1->toNumber(exec) + v2->toNumber(exec)); + if (bothTypes == ((StringType << 3) | StringType)) { + UString value = static_cast(v1)->value() + static_cast(v2)->value(); + if (value.isNull()) + return throwOutOfMemoryError(exec); + return jsString(value); + } + + // All other cases are pretty uncommon + return addSlowCase(exec, v1, v2); +} + +static inline double addToNumber(ExecState* exec, JSValue* v1, JSValue* v2) +{ + JSType t1 = v1->type(); + JSType t2 = v2->type(); + const unsigned bothTypes = (t1 << 3) | t2; + + if (bothTypes == ((NumberType << 3) | NumberType)) + return v1->toNumber(exec) + v2->toNumber(exec); + if (bothTypes == ((StringType << 3) | StringType)) { + UString value = static_cast(v1)->value() + static_cast(v2)->value(); + if (value.isNull()) + return throwOutOfMemoryErrorToNumber(exec); + return value.toDouble(); + } + + // All other cases are pretty uncommon + return addSlowCaseToNumber(exec, v1, v2); +} + +void AddNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_term1.get()); + nodeStack.append(m_term2.get()); +} + +// ECMA 11.6.1 +JSValue* AddNode::evaluate(ExecState* exec) +{ + JSValue* v1 = m_term1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = m_term2->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + return add(exec, v1, v2); +} + +double AddNode::inlineEvaluateToNumber(ExecState* exec) +{ + JSValue* v1 = m_term1->evaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + + JSValue* v2 = m_term2->evaluate(exec); + KJS_CHECKEXCEPTIONNUMBER + + return addToNumber(exec, v1, v2); +} + +double AddNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToNumber(exec); +} + +int32_t AddNode::evaluateToInt32(ExecState* exec) +{ + return JSValue::toInt32(inlineEvaluateToNumber(exec)); +} + +uint32_t AddNode::evaluateToUInt32(ExecState* exec) +{ + return JSValue::toUInt32(inlineEvaluateToNumber(exec)); +} + +double AddNumbersNode::inlineEvaluateToNumber(ExecState* exec) +{ + double n1 = m_term1->evaluateToNumber(exec); + KJS_CHECKEXCEPTIONNUMBER + double n2 = m_term2->evaluateToNumber(exec); + return n1 + n2; +} + +JSValue* AddNumbersNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToNumber(exec)); +} + +double AddNumbersNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToNumber(exec); +} + +int32_t AddNumbersNode::evaluateToInt32(ExecState* exec) +{ + return JSValue::toInt32(inlineEvaluateToNumber(exec)); +} + +uint32_t AddNumbersNode::evaluateToUInt32(ExecState* exec) +{ + return JSValue::toUInt32(inlineEvaluateToNumber(exec)); +} + +JSValue* AddStringsNode::evaluate(ExecState* exec) +{ + JSValue* v1 = m_term1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = m_term2->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + return jsString(static_cast(v1)->value() + static_cast(v2)->value()); +} + +JSValue* AddStringLeftNode::evaluate(ExecState* exec) +{ + JSValue* v1 = m_term1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = m_term2->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSValue* p2 = v2->toPrimitive(exec, UnspecifiedType); + return jsString(static_cast(v1)->value() + p2->toString(exec)); +} + +JSValue* AddStringRightNode::evaluate(ExecState* exec) +{ + JSValue* v1 = m_term1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSValue* v2 = m_term2->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSValue* p1 = v1->toPrimitive(exec, UnspecifiedType); + return jsString(p1->toString(exec) + static_cast(v2)->value()); +} + +void SubNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_term1.get()); + nodeStack.append(m_term2.get()); +} + +// ECMA 11.6.2 +double SubNode::inlineEvaluateToNumber(ExecState* exec) +{ + double n1 = m_term1->evaluateToNumber(exec); + KJS_CHECKEXCEPTIONNUMBER + double n2 = m_term2->evaluateToNumber(exec); + return n1 - n2; +} + +JSValue* SubNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToNumber(exec)); +} + +double SubNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToNumber(exec); +} + +int32_t SubNode::evaluateToInt32(ExecState* exec) +{ + return JSValue::toInt32(inlineEvaluateToNumber(exec)); +} + +uint32_t SubNode::evaluateToUInt32(ExecState* exec) +{ + return JSValue::toUInt32(inlineEvaluateToNumber(exec)); +} + +// ------------------------------ Shift Nodes ------------------------------------ + +void LeftShiftNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_term1.get()); + nodeStack.append(m_term2.get()); +} + +// ECMA 11.7.1 +int32_t LeftShiftNode::inlineEvaluateToInt32(ExecState* exec) +{ + int i1 = m_term1->evaluateToInt32(exec); + KJS_CHECKEXCEPTIONNUMBER + unsigned int i2 = m_term2->evaluateToUInt32(exec) & 0x1f; + return (i1 << i2); +} + +JSValue* LeftShiftNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToInt32(exec)); +} + +double LeftShiftNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +int32_t LeftShiftNode::evaluateToInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +uint32_t LeftShiftNode::evaluateToUInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +void RightShiftNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_term1.get()); + nodeStack.append(m_term2.get()); +} + +// ECMA 11.7.2 +int32_t RightShiftNode::inlineEvaluateToInt32(ExecState* exec) +{ + int i1 = m_term1->evaluateToInt32(exec); + KJS_CHECKEXCEPTIONNUMBER + unsigned int i2 = m_term2->evaluateToUInt32(exec) & 0x1f; + return (i1 >> i2); +} + +JSValue* RightShiftNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToInt32(exec)); +} + +double RightShiftNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +int32_t RightShiftNode::evaluateToInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +uint32_t RightShiftNode::evaluateToUInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +void UnsignedRightShiftNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_term1.get()); + nodeStack.append(m_term2.get()); +} + +// ECMA 11.7.3 +uint32_t UnsignedRightShiftNode::inlineEvaluateToUInt32(ExecState* exec) +{ + unsigned int i1 = m_term1->evaluateToUInt32(exec); + KJS_CHECKEXCEPTIONNUMBER + unsigned int i2 = m_term2->evaluateToUInt32(exec) & 0x1f; + return (i1 >> i2); +} + +JSValue* UnsignedRightShiftNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToUInt32(exec)); +} + +double UnsignedRightShiftNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToUInt32(exec); +} + +int32_t UnsignedRightShiftNode::evaluateToInt32(ExecState* exec) +{ + return inlineEvaluateToUInt32(exec); +} + +uint32_t UnsignedRightShiftNode::evaluateToUInt32(ExecState* exec) +{ + return inlineEvaluateToUInt32(exec); +} + +// ------------------------------ Relational Nodes ------------------------------- + +static inline bool lessThan(ExecState* exec, JSValue* v1, JSValue* v2) +{ + double n1; + double n2; + JSValue* p1; + JSValue* p2; + bool wasNotString1 = v1->getPrimitiveNumber(exec, n1, p1); + bool wasNotString2 = v2->getPrimitiveNumber(exec, n2, p2); + + if (wasNotString1 | wasNotString2) + return n1 < n2; + + return static_cast(p1)->value() < static_cast(p2)->value(); +} + +static inline bool lessThanEq(ExecState* exec, JSValue* v1, JSValue* v2) +{ + double n1; + double n2; + JSValue* p1; + JSValue* p2; + bool wasNotString1 = v1->getPrimitiveNumber(exec, n1, p1); + bool wasNotString2 = v2->getPrimitiveNumber(exec, n2, p2); + + if (wasNotString1 | wasNotString2) + return n1 <= n2; + + return !(static_cast(p2)->value() < static_cast(p1)->value()); +} + +void LessNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.8.1 +bool LessNode::inlineEvaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return lessThan(exec, v1, v2); +} + +JSValue* LessNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool LessNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +bool LessNumbersNode::inlineEvaluateToBoolean(ExecState* exec) +{ + double n1 = m_expr1->evaluateToNumber(exec); + KJS_CHECKEXCEPTIONVALUE + double n2 = m_expr2->evaluateToNumber(exec); + return n1 < n2; +} + +JSValue* LessNumbersNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool LessNumbersNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +bool LessStringsNode::inlineEvaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* v2 = m_expr2->evaluate(exec); + return static_cast(v1)->value() < static_cast(v2)->value(); +} + +JSValue* LessStringsNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool LessStringsNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +void GreaterNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.8.2 +bool GreaterNode::inlineEvaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return lessThan(exec, v2, v1); +} + +JSValue* GreaterNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool GreaterNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +void LessEqNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.8.3 +bool LessEqNode::inlineEvaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return lessThanEq(exec, v1, v2); +} + +JSValue* LessEqNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool LessEqNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +void GreaterEqNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.8.4 +bool GreaterEqNode::inlineEvaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return lessThanEq(exec, v2, v1); +} + +JSValue* GreaterEqNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool GreaterEqNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +void InstanceOfNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.8.6 +JSValue* InstanceOfNode::evaluate(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + if (!v2->isObject()) + return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, m_expr2.get()); + + JSObject* o2 = static_cast(v2); + + // According to the spec, only some types of objects "implement" the [[HasInstance]] property. + // But we are supposed to throw an exception where the object does not "have" the [[HasInstance]] + // property. It seems that all objects have the property, but not all implement it, so in this + // case we return false (consistent with Mozilla). + if (!o2->implementsHasInstance()) + return jsBoolean(false); + + return jsBoolean(o2->hasInstance(exec, v1)); +} + +bool InstanceOfNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + + if (!v2->isObject()) { + throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with 'instanceof' operator.", v2, m_expr2.get()); + return false; + } + + JSObject* o2 = static_cast(v2); + + // According to the spec, only some types of objects "implement" the [[HasInstance]] property. + // But we are supposed to throw an exception where the object does not "have" the [[HasInstance]] + // property. It seems that all objects have the property, but not all implement it, so in this + // case we return false (consistent with Mozilla). + if (!o2->implementsHasInstance()) + return false; + + return o2->hasInstance(exec, v1); +} + +void InNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.8.7 +JSValue* InNode::evaluate(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + if (!v2->isObject()) + return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with 'in' operator.", v2, m_expr2.get()); + + return jsBoolean(static_cast(v2)->hasProperty(exec, Identifier(v1->toString(exec)))); +} + +bool InNode::evaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + + if (!v2->isObject()) { + throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with 'in' operator.", v2, m_expr2.get()); + return false; + } + + return static_cast(v2)->hasProperty(exec, Identifier(v1->toString(exec))); +} + +// ------------------------------ Equality Nodes ------------------------------------ + +void EqualNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.9.1 +bool EqualNode::inlineEvaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + + return equal(exec, v1, v2); +} + +JSValue* EqualNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool EqualNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +void NotEqualNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.9.2 +bool NotEqualNode::inlineEvaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + + return !equal(exec,v1, v2); +} + +JSValue* NotEqualNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool NotEqualNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +void StrictEqualNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.9.4 +bool StrictEqualNode::inlineEvaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + + return strictEqual(exec,v1, v2); +} + +JSValue* StrictEqualNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool StrictEqualNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +void NotStrictEqualNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.9.5 +bool NotStrictEqualNode::inlineEvaluateToBoolean(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONBOOLEAN + + return !strictEqual(exec,v1, v2); +} + +JSValue* NotStrictEqualNode::evaluate(ExecState* exec) +{ + return jsBoolean(inlineEvaluateToBoolean(exec)); +} + +bool NotStrictEqualNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToBoolean(exec); +} + +// ------------------------------ Bit Operation Nodes ---------------------------------- + +void BitAndNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.10 +JSValue* BitAndNode::evaluate(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + return jsNumberFromAnd(exec, v1, v2); +} + +int32_t BitAndNode::inlineEvaluateToInt32(ExecState* exec) +{ + int32_t i1 = m_expr1->evaluateToInt32(exec); + KJS_CHECKEXCEPTIONNUMBER + int32_t i2 = m_expr2->evaluateToInt32(exec); + return (i1 & i2); +} + +double BitAndNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +bool BitAndNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +int32_t BitAndNode::evaluateToInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +uint32_t BitAndNode::evaluateToUInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +void BitXOrNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +int32_t BitXOrNode::inlineEvaluateToInt32(ExecState* exec) +{ + int i1 = m_expr1->evaluateToInt32(exec); + KJS_CHECKEXCEPTIONNUMBER + int i2 = m_expr2->evaluateToInt32(exec); + return (i1 ^ i2); +} + +JSValue* BitXOrNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToInt32(exec)); +} + +double BitXOrNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +bool BitXOrNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +int32_t BitXOrNode::evaluateToInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +uint32_t BitXOrNode::evaluateToUInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +void BitOrNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +int32_t BitOrNode::inlineEvaluateToInt32(ExecState* exec) +{ + int i1 = m_expr1->evaluateToInt32(exec); + KJS_CHECKEXCEPTIONNUMBER + int i2 = m_expr2->evaluateToInt32(exec); + return (i1 | i2); +} + +JSValue* BitOrNode::evaluate(ExecState* exec) +{ + return jsNumber(inlineEvaluateToInt32(exec)); +} + +double BitOrNode::evaluateToNumber(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +bool BitOrNode::evaluateToBoolean(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +int32_t BitOrNode::evaluateToInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +uint32_t BitOrNode::evaluateToUInt32(ExecState* exec) +{ + return inlineEvaluateToInt32(exec); +} + +// ------------------------------ Binary Logical Nodes ---------------------------- + +void LogicalAndNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.11 +JSValue* LogicalAndNode::evaluate(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + bool b1 = v1->toBoolean(exec); + KJS_CHECKEXCEPTIONVALUE + if (!b1) + return v1; + JSValue* v2 = m_expr2->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + return v2; +} + +bool LogicalAndNode::evaluateToBoolean(ExecState* exec) +{ + bool b = m_expr1->evaluateToBoolean(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return b && m_expr2->evaluateToBoolean(exec); +} + +void LogicalOrNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +JSValue* LogicalOrNode::evaluate(ExecState* exec) +{ + JSValue* v1 = m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + if (v1->toBoolean(exec)) + return v1; + return m_expr2->evaluate(exec); +} + +bool LogicalOrNode::evaluateToBoolean(ExecState* exec) +{ + bool b = m_expr1->evaluateToBoolean(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return b || m_expr2->evaluateToBoolean(exec); +} + +// ------------------------------ ConditionalNode ------------------------------ + +void ConditionalNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); + nodeStack.append(m_logical.get()); +} + +// ECMA 11.12 +JSValue* ConditionalNode::evaluate(ExecState* exec) +{ + bool b = m_logical->evaluateToBoolean(exec); + KJS_CHECKEXCEPTIONVALUE + return b ? m_expr1->evaluate(exec) : m_expr2->evaluate(exec); +} + +bool ConditionalNode::evaluateToBoolean(ExecState* exec) +{ + bool b = m_logical->evaluateToBoolean(exec); + KJS_CHECKEXCEPTIONBOOLEAN + return b ? m_expr1->evaluateToBoolean(exec) : m_expr2->evaluateToBoolean(exec); +} + +double ConditionalNode::evaluateToNumber(ExecState* exec) +{ + bool b = m_logical->evaluateToBoolean(exec); + KJS_CHECKEXCEPTIONNUMBER + return b ? m_expr1->evaluateToNumber(exec) : m_expr2->evaluateToNumber(exec); +} + +int32_t ConditionalNode::evaluateToInt32(ExecState* exec) +{ + bool b = m_logical->evaluateToBoolean(exec); + KJS_CHECKEXCEPTIONNUMBER + return b ? m_expr1->evaluateToInt32(exec) : m_expr2->evaluateToInt32(exec); +} + +uint32_t ConditionalNode::evaluateToUInt32(ExecState* exec) +{ + bool b = m_logical->evaluateToBoolean(exec); + KJS_CHECKEXCEPTIONNUMBER + return b ? m_expr1->evaluateToUInt32(exec) : m_expr2->evaluateToUInt32(exec); +} + +// ECMA 11.13 + +static ALWAYS_INLINE JSValue* valueForReadModifyAssignment(ExecState* exec, JSValue* current, ExpressionNode* right, Operator oper) KJS_FAST_CALL; +static ALWAYS_INLINE JSValue* valueForReadModifyAssignment(ExecState* exec, JSValue* current, ExpressionNode* right, Operator oper) +{ + JSValue* v; + int i1; + int i2; + unsigned int ui; + switch (oper) { + case OpMultEq: + v = jsNumber(current->toNumber(exec) * right->evaluateToNumber(exec)); + break; + case OpDivEq: + v = jsNumber(current->toNumber(exec) / right->evaluateToNumber(exec)); + break; + case OpPlusEq: + v = add(exec, current, right->evaluate(exec)); + break; + case OpMinusEq: + v = jsNumber(current->toNumber(exec) - right->evaluateToNumber(exec)); + break; + case OpLShift: + i1 = current->toInt32(exec); + i2 = right->evaluateToInt32(exec); + v = jsNumber(i1 << i2); + break; + case OpRShift: + i1 = current->toInt32(exec); + i2 = right->evaluateToInt32(exec); + v = jsNumber(i1 >> i2); + break; + case OpURShift: + ui = current->toUInt32(exec); + i2 = right->evaluateToInt32(exec); + v = jsNumber(ui >> i2); + break; + case OpAndEq: + i1 = current->toInt32(exec); + i2 = right->evaluateToInt32(exec); + v = jsNumber(i1 & i2); + break; + case OpXOrEq: + i1 = current->toInt32(exec); + i2 = right->evaluateToInt32(exec); + v = jsNumber(i1 ^ i2); + break; + case OpOrEq: + i1 = current->toInt32(exec); + i2 = right->evaluateToInt32(exec); + v = jsNumber(i1 | i2); + break; + case OpModEq: { + double d1 = current->toNumber(exec); + double d2 = right->evaluateToNumber(exec); + v = jsNumber(fmod(d1, d2)); + } + break; + default: + ASSERT_NOT_REACHED(); + v = jsUndefined(); + } + + return v; +} + +// ------------------------------ ReadModifyResolveNode ----------------------------------- + +void ReadModifyResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack& nodeStack) +{ + nodeStack.append(m_right.get()); + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) { + if (isConstant(localStorage, index)) + new (this) ReadModifyConstNode(index); + else + new (this) ReadModifyLocalVarNode(index); + } +} + +// ------------------------------ AssignResolveNode ----------------------------------- + +void AssignResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack& nodeStack) +{ + nodeStack.append(m_right.get()); + size_t index = symbolTable.get(m_ident.ustring().rep()); + if (index != missingSymbolMarker()) { + if (isConstant(localStorage, index)) + new (this) AssignConstNode; + else + new (this) AssignLocalVarNode(index); + } +} + +// ------------------------------ ReadModifyLocalVarNode ----------------------------------- + +JSValue* ReadModifyLocalVarNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + + ASSERT(m_operator != OpEqual); + JSValue* v = valueForReadModifyAssignment(exec, exec->localStorage()[m_index].value, m_right.get(), m_operator); + + KJS_CHECKEXCEPTIONVALUE + + // We can't store a pointer into localStorage() and use it throughout the function + // body, because valueForReadModifyAssignment() might cause an ActivationImp tear-off, + // changing the value of localStorage(). + + exec->localStorage()[m_index].value = v; + return v; +} + +// ------------------------------ AssignLocalVarNode ----------------------------------- + +JSValue* AssignLocalVarNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + JSValue* v = m_right->evaluate(exec); + + KJS_CHECKEXCEPTIONVALUE + + exec->localStorage()[m_index].value = v; + + return v; +} + +// ------------------------------ ReadModifyConstNode ----------------------------------- + +JSValue* ReadModifyConstNode::evaluate(ExecState* exec) +{ + ASSERT(exec->variableObject() == exec->scopeChain().top()); + JSValue* left = exec->localStorage()[m_index].value; + ASSERT(m_operator != OpEqual); + JSValue* result = valueForReadModifyAssignment(exec, left, m_right.get(), m_operator); + KJS_CHECKEXCEPTIONVALUE + return result; +} + +// ------------------------------ AssignConstNode ----------------------------------- + +JSValue* AssignConstNode::evaluate(ExecState* exec) +{ + return m_right->evaluate(exec); +} + +JSValue* ReadModifyResolveNode::evaluate(ExecState* exec) +{ + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // We must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + JSObject* base; + do { + base = *iter; + if (base->getPropertySlot(exec, m_ident, slot)) { + // See the comment in PostIncResolveNode::evaluate(). + + base = *iter; + goto found; + } + + ++iter; + } while (iter != end); + + ASSERT(m_operator != OpEqual); + return throwUndefinedVariableError(exec, m_ident); + +found: + JSValue* v; + + ASSERT(m_operator != OpEqual); + JSValue* v1 = slot.getValue(exec, base, m_ident); + KJS_CHECKEXCEPTIONVALUE + v = valueForReadModifyAssignment(exec, v1, m_right.get(), m_operator); + + KJS_CHECKEXCEPTIONVALUE + + // Since valueForReadModifyAssignment() might cause an ActivationImp tear-off, + // we need to get the base from the ScopeChainIterator again. + + (*iter)->put(exec, m_ident, v); + return v; +} + +JSValue* AssignResolveNode::evaluate(ExecState* exec) +{ + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // we must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + JSObject* base; + do { + base = *iter; + if (base->getPropertySlot(exec, m_ident, slot)) { + // See the comment in PostIncResolveNode::evaluate(). + + base = *iter; + goto found; + } + + ++iter; + } while (iter != end); + +found: + JSValue* v = m_right->evaluate(exec); + + KJS_CHECKEXCEPTIONVALUE + + base->put(exec, m_ident, v); + return v; +} + +// ------------------------------ ReadModifyDotNode ----------------------------------- + +void AssignDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_right.get()); + nodeStack.append(m_base.get()); +} + +JSValue* AssignDotNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSObject* base = baseValue->toObject(exec); + + JSValue* v = m_right->evaluate(exec); + + KJS_CHECKEXCEPTIONVALUE + + base->put(exec, m_ident, v); + return v; +} + +void ReadModifyDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_right.get()); + nodeStack.append(m_base.get()); +} + +JSValue* ReadModifyDotNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSObject* base = baseValue->toObject(exec); + + JSValue* v; + + ASSERT(m_operator != OpEqual); + PropertySlot slot; + JSValue* v1 = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + v = valueForReadModifyAssignment(exec, v1, m_right.get(), m_operator); + + KJS_CHECKEXCEPTIONVALUE + + base->put(exec, m_ident, v); + return v; +} + +// ------------------------------ AssignErrorNode ----------------------------------- + +JSValue* AssignErrorNode::evaluate(ExecState* exec) +{ + throwError(exec, ReferenceError, "Left side of assignment is not a reference."); + handleException(exec); + return jsUndefined(); +} + +// ------------------------------ AssignBracketNode ----------------------------------- + +void AssignBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_right.get()); + nodeStack.append(m_subscript.get()); + nodeStack.append(m_base.get()); +} + +JSValue* AssignBracketNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* subscript = m_subscript->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSObject* base = baseValue->toObject(exec); + + uint32_t propertyIndex; + if (subscript->getUInt32(propertyIndex)) { + JSValue* v = m_right->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + base->put(exec, propertyIndex, v); + return v; + } + + Identifier propertyName(subscript->toString(exec)); + JSValue* v = m_right->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + base->put(exec, propertyName, v); + return v; +} +void ReadModifyBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_right.get()); + nodeStack.append(m_subscript.get()); + nodeStack.append(m_base.get()); +} + +JSValue* ReadModifyBracketNode::evaluate(ExecState* exec) +{ + JSValue* baseValue = m_base->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + JSValue* subscript = m_subscript->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + JSObject* base = baseValue->toObject(exec); + + uint32_t propertyIndex; + if (subscript->getUInt32(propertyIndex)) { + JSValue* v; + ASSERT(m_operator != OpEqual); + PropertySlot slot; + JSValue* v1 = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + v = valueForReadModifyAssignment(exec, v1, m_right.get(), m_operator); + + KJS_CHECKEXCEPTIONVALUE + + base->put(exec, propertyIndex, v); + return v; + } + + Identifier propertyName(subscript->toString(exec)); + JSValue* v; + + ASSERT(m_operator != OpEqual); + PropertySlot slot; + JSValue* v1 = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); + KJS_CHECKEXCEPTIONVALUE + v = valueForReadModifyAssignment(exec, v1, m_right.get(), m_operator); + + KJS_CHECKEXCEPTIONVALUE + + base->put(exec, propertyName, v); + return v; +} + +// ------------------------------ CommaNode ------------------------------------ + +void CommaNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 11.14 +JSValue* CommaNode::evaluate(ExecState* exec) +{ + m_expr1->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + return m_expr2->evaluate(exec); +} + +// ------------------------------ ConstDeclNode ---------------------------------- + +ConstDeclNode::ConstDeclNode(const Identifier& ident, ExpressionNode* init) + : m_ident(ident) + , m_init(init) +{ +} + +void ConstDeclNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_next) + nodeStack.append(m_next.get()); + if (m_init) + nodeStack.append(m_init.get()); +} + +void ConstDeclNode::handleSlowCase(ExecState* exec, const ScopeChain& chain, JSValue* val) +{ + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // We must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + JSObject* base; + + do { + base = *iter; + if (base->getPropertySlot(exec, m_ident, slot)) + break; + + ++iter; + } while (iter != end); + + unsigned flags = 0; + base->getPropertyAttributes(m_ident, flags); + flags |= ReadOnly; + + base->put(exec, m_ident, val, flags); +} + +// ECMA 12.2 +inline void ConstDeclNode::evaluateSingle(ExecState* exec) +{ + ASSERT(exec->variableObject()->hasOwnProperty(exec, m_ident) || exec->codeType() == EvalCode); // Guaranteed by processDeclarations. + const ScopeChain& chain = exec->scopeChain(); + JSObject* variableObject = exec->variableObject(); + + ASSERT(!chain.isEmpty()); + + bool inGlobalScope = ++chain.begin() == chain.end(); + + if (m_init) { + if (inGlobalScope) { + JSValue* val = m_init->evaluate(exec); + int flags = Internal; + if (exec->codeType() != EvalCode) + flags |= DontDelete; + flags |= ReadOnly; + variableObject->put(exec, m_ident, val, flags); + } else { + JSValue* val = m_init->evaluate(exec); + KJS_CHECKEXCEPTIONVOID + + // if the variable object is the top of the scope chain, then that must + // be where this variable is declared, processVarDecls would have put + // it there. Don't search the scope chain, to optimize this very common case. + if (chain.top() != variableObject) + return handleSlowCase(exec, chain, val); + + unsigned flags = 0; + variableObject->getPropertyAttributes(m_ident, flags); + flags |= ReadOnly; + + variableObject->put(exec, m_ident, val, flags); + } + } +} + +JSValue* ConstDeclNode::evaluate(ExecState* exec) +{ + evaluateSingle(exec); + + if (ConstDeclNode* n = m_next.get()) { + do { + n->evaluateSingle(exec); + KJS_CHECKEXCEPTIONVALUE + n = n->m_next.get(); + } while (n); + } + return jsUndefined(); +} + +// ------------------------------ ConstStatementNode ----------------------------- + +void ConstStatementNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + ASSERT(m_next); + nodeStack.append(m_next.get()); +} + +// ECMA 12.2 +JSValue* ConstStatementNode::execute(ExecState* exec) +{ + m_next->evaluate(exec); + KJS_CHECKEXCEPTION + + return exec->setNormalCompletion(); +} + +// ------------------------------ Helper functions for handling Vectors of StatementNode ------------------------------- + +static inline void statementListPushFIFO(StatementVector& statements, DeclarationStacks::NodeStack& stack) +{ + StatementVector::iterator it = statements.end(); + StatementVector::iterator begin = statements.begin(); + while (it != begin) { + --it; + stack.append((*it).get()); + } +} + +static inline Node* statementListInitializeVariableAccessStack(StatementVector& statements, DeclarationStacks::NodeStack& stack) +{ + if (statements.isEmpty()) + return 0; + + StatementVector::iterator it = statements.end(); + StatementVector::iterator begin = statements.begin(); + StatementVector::iterator beginPlusOne = begin + 1; + + while (it != beginPlusOne) { + --it; + stack.append((*it).get()); + } + + return (*begin).get(); +} + +static inline JSValue* statementListExecute(StatementVector& statements, ExecState* exec) +{ + JSValue* value = 0; + size_t size = statements.size(); + for (size_t i = 0; i != size; ++i) { + JSValue* statementValue = statements[i]->execute(exec); + if (statementValue) + value = statementValue; + if (exec->completionType() != Normal) + return value; + } + return exec->setNormalCompletion(value); +} + +// ------------------------------ BlockNode ------------------------------------ + +BlockNode::BlockNode(SourceElements* children) +{ + if (children) + children->releaseContentsIntoVector(m_children); +} + +void BlockNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + statementListPushFIFO(m_children, nodeStack); +} + +// ECMA 12.1 +JSValue* BlockNode::execute(ExecState* exec) +{ + return statementListExecute(m_children, exec); +} + +// ------------------------------ EmptyStatementNode --------------------------- + +// ECMA 12.3 +JSValue* EmptyStatementNode::execute(ExecState* exec) +{ + return exec->setNormalCompletion(); +} + +// ------------------------------ ExprStatementNode ---------------------------- + +void ExprStatementNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + ASSERT(m_expr); + nodeStack.append(m_expr.get()); +} + +// ECMA 12.4 +JSValue* ExprStatementNode::execute(ExecState* exec) +{ + JSValue* value = m_expr->evaluate(exec); + KJS_CHECKEXCEPTION + + return exec->setNormalCompletion(value); +} + +// ------------------------------ VarStatementNode ---------------------------- + +void VarStatementNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + ASSERT(m_expr); + nodeStack.append(m_expr.get()); +} + +JSValue* VarStatementNode::execute(ExecState* exec) +{ + m_expr->evaluate(exec); + KJS_CHECKEXCEPTION + + return exec->setNormalCompletion(); +} + +// ------------------------------ IfNode --------------------------------------- + +void IfNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_ifBlock.get()); + nodeStack.append(m_condition.get()); +} + +// ECMA 12.5 +JSValue* IfNode::execute(ExecState* exec) +{ + bool b = m_condition->evaluateToBoolean(exec); + KJS_CHECKEXCEPTION + + if (b) + return m_ifBlock->execute(exec); + return exec->setNormalCompletion(); +} + +void IfElseNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack& nodeStack) +{ + nodeStack.append(m_elseBlock.get()); + IfNode::optimizeVariableAccess(symbolTable, localStorage, nodeStack); +} + +// ECMA 12.5 +JSValue* IfElseNode::execute(ExecState* exec) +{ + bool b = m_condition->evaluateToBoolean(exec); + KJS_CHECKEXCEPTION + + if (b) + return m_ifBlock->execute(exec); + return m_elseBlock->execute(exec); +} + +// ------------------------------ DoWhileNode ---------------------------------- + +void DoWhileNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_statement.get()); + nodeStack.append(m_expr.get()); +} + +// ECMA 12.6.1 +JSValue* DoWhileNode::execute(ExecState* exec) +{ + JSValue* value = 0; + + while (1) { + exec->pushIteration(); + JSValue* statementValue = m_statement->execute(exec); + exec->popIteration(); + + if (exec->dynamicGlobalObject()->timedOut()) + return setInterruptedCompletion(exec); + + if (statementValue) + value = statementValue; + + if (exec->completionType() != Normal) { + if (exec->completionType() == Continue && m_labelStack.contains(exec->breakOrContinueTarget())) + goto continueDoWhileLoop; + if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) + break; + return statementValue; + } + + continueDoWhileLoop: + bool b = m_expr->evaluateToBoolean(exec); + KJS_CHECKEXCEPTION + if (!b) + break; + } + + return exec->setNormalCompletion(value); +} + +// ------------------------------ WhileNode ------------------------------------ + +void WhileNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_statement.get()); + nodeStack.append(m_expr.get()); +} + +// ECMA 12.6.2 +JSValue* WhileNode::execute(ExecState* exec) +{ + JSValue* value = 0; + + while (1) { + bool b = m_expr->evaluateToBoolean(exec); + KJS_CHECKEXCEPTION + if (!b) + break; + + exec->pushIteration(); + JSValue* statementValue = m_statement->execute(exec); + exec->popIteration(); + + if (exec->dynamicGlobalObject()->timedOut()) + return setInterruptedCompletion(exec); + + if (statementValue) + value = statementValue; + + if (exec->completionType() != Normal) { + if (exec->completionType() == Continue && m_labelStack.contains(exec->breakOrContinueTarget())) + continue; + if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) + break; + return statementValue; + } + } + + return exec->setNormalCompletion(value); +} + +// ------------------------------ ForNode -------------------------------------- + +void ForNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_statement.get()); + nodeStack.append(m_expr3.get()); + nodeStack.append(m_expr2.get()); + nodeStack.append(m_expr1.get()); +} + +// ECMA 12.6.3 +JSValue* ForNode::execute(ExecState* exec) +{ + JSValue* value = 0; + + m_expr1->evaluate(exec); + KJS_CHECKEXCEPTION + + while (1) { + bool b = m_expr2->evaluateToBoolean(exec); + KJS_CHECKEXCEPTION + if (!b) + break; + + exec->pushIteration(); + JSValue* statementValue = m_statement->execute(exec); + exec->popIteration(); + if (statementValue) + value = statementValue; + + if (exec->dynamicGlobalObject()->timedOut()) + return setInterruptedCompletion(exec); + + if (exec->completionType() != Normal) { + if (exec->completionType() == Continue && m_labelStack.contains(exec->breakOrContinueTarget())) + goto continueForLoop; + if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) + break; + return statementValue; + } + + continueForLoop: + m_expr3->evaluate(exec); + KJS_CHECKEXCEPTION + } + + return exec->setNormalCompletion(value); +} + +// ------------------------------ ForInNode ------------------------------------ + +ForInNode::ForInNode(ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) + : m_init(0L) + , m_lexpr(l) + , m_expr(expr) + , m_statement(statement) + , m_identIsVarDecl(false) +{ +} + +ForInNode::ForInNode(const Identifier& ident, ExpressionNode* in, ExpressionNode* expr, StatementNode* statement) + : m_ident(ident) + , m_lexpr(new ResolveNode(ident)) + , m_expr(expr) + , m_statement(statement) + , m_identIsVarDecl(true) +{ + if (in) + m_init = new AssignResolveNode(ident, in); + // for( var foo = bar in baz ) +} + +void ForInNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_statement.get()); + nodeStack.append(m_expr.get()); + nodeStack.append(m_lexpr.get()); + if (m_init) + nodeStack.append(m_init.get()); +} + +// ECMA 12.6.4 +JSValue* ForInNode::execute(ExecState* exec) +{ + JSValue* value = 0; + + if (m_init) { + m_init->evaluate(exec); + KJS_CHECKEXCEPTION + } + + JSValue* e = m_expr->evaluate(exec); + KJS_CHECKEXCEPTION + + // For Null and Undefined, we want to make sure not to go through + // the loop at all, because toObject will throw an exception. + if (e->isUndefinedOrNull()) + return exec->setNormalCompletion(); + + JSObject* v = e->toObject(exec); + PropertyNameArray propertyNames; + v->getPropertyNames(exec, propertyNames); + + PropertyNameArray::const_iterator end = propertyNames.end(); + for (PropertyNameArray::const_iterator it = propertyNames.begin(); it != end; ++it) { + const Identifier& name = *it; + if (!v->hasProperty(exec, name)) + continue; + + JSValue* str = jsOwnedString(name.ustring()); + + if (m_lexpr->isResolveNode()) { + const Identifier& ident = static_cast(m_lexpr.get())->identifier(); + + const ScopeChain& chain = exec->scopeChain(); + ScopeChainIterator iter = chain.begin(); + ScopeChainIterator end = chain.end(); + + // we must always have something in the scope chain + ASSERT(iter != end); + + PropertySlot slot; + JSObject* o; + do { + o = *iter; + if (o->getPropertySlot(exec, ident, slot)) { + o->put(exec, ident, str); + break; + } + ++iter; + } while (iter != end); + + if (iter == end) + o->put(exec, ident, str); + } else if (m_lexpr->isDotAccessorNode()) { + const Identifier& ident = static_cast(m_lexpr.get())->identifier(); + JSValue* v = static_cast(m_lexpr.get())->base()->evaluate(exec); + KJS_CHECKEXCEPTION + JSObject* o = v->toObject(exec); + + o->put(exec, ident, str); + } else { + ASSERT(m_lexpr->isBracketAccessorNode()); + JSValue* v = static_cast(m_lexpr.get())->base()->evaluate(exec); + KJS_CHECKEXCEPTION + JSValue* v2 = static_cast(m_lexpr.get())->subscript()->evaluate(exec); + KJS_CHECKEXCEPTION + JSObject* o = v->toObject(exec); + + uint32_t i; + if (v2->getUInt32(i)) + o->put(exec, i, str); + o->put(exec, Identifier(v2->toString(exec)), str); + } + + KJS_CHECKEXCEPTION + + exec->pushIteration(); + JSValue* statementValue = m_statement->execute(exec); + exec->popIteration(); + if (statementValue) + value = statementValue; + + if (exec->completionType() != Normal) { + if (exec->completionType() == Continue && m_labelStack.contains(exec->breakOrContinueTarget())) + continue; + if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) + break; + return statementValue; + } + } + + return exec->setNormalCompletion(value); +} + +// ------------------------------ ContinueNode --------------------------------- + +// ECMA 12.7 +JSValue* ContinueNode::execute(ExecState* exec) +{ + if (m_ident.isEmpty() && !exec->inIteration()) + return setErrorCompletion(exec, SyntaxError, "Invalid continue statement."); + if (!m_ident.isEmpty() && !exec->seenLabels().contains(m_ident)) + return setErrorCompletion(exec, SyntaxError, "Label %s not found.", m_ident); + return exec->setContinueCompletion(&m_ident); +} + +// ------------------------------ BreakNode ------------------------------------ + +// ECMA 12.8 +JSValue* BreakNode::execute(ExecState* exec) +{ + if (m_ident.isEmpty() && !exec->inIteration() && !exec->inSwitch()) + return setErrorCompletion(exec, SyntaxError, "Invalid break statement."); + if (!m_ident.isEmpty() && !exec->seenLabels().contains(m_ident)) + return setErrorCompletion(exec, SyntaxError, "Label %s not found."); + return exec->setBreakCompletion(&m_ident); +} + +// ------------------------------ ReturnNode ----------------------------------- + +void ReturnNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_value) + nodeStack.append(m_value.get()); +} + +// ECMA 12.9 +JSValue* ReturnNode::execute(ExecState* exec) +{ + CodeType codeType = exec->codeType(); + if (codeType != FunctionCode) + return setErrorCompletion(exec, SyntaxError, "Invalid return statement."); + + if (!m_value) + return exec->setReturnValueCompletion(jsUndefined()); + + JSValue* v = m_value->evaluate(exec); + KJS_CHECKEXCEPTION + + return exec->setReturnValueCompletion(v); +} + +// ------------------------------ WithNode ------------------------------------- + +void WithNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + // Can't optimize within statement because "with" introduces a dynamic scope. + nodeStack.append(m_expr.get()); +} + +// ECMA 12.10 +JSValue* WithNode::execute(ExecState* exec) +{ + JSValue* v = m_expr->evaluate(exec); + KJS_CHECKEXCEPTION + JSObject* o = v->toObject(exec); + KJS_CHECKEXCEPTION + exec->dynamicGlobalObject()->tearOffActivation(exec); + exec->pushScope(o); + JSValue* value = m_statement->execute(exec); + exec->popScope(); + + return value; +} + +// ------------------------------ CaseClauseNode ------------------------------- + +void CaseClauseNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_expr) + nodeStack.append(m_expr.get()); + statementListPushFIFO(m_children, nodeStack); +} + +// ECMA 12.11 +JSValue* CaseClauseNode::evaluate(ExecState* exec) +{ + JSValue* v = m_expr->evaluate(exec); + KJS_CHECKEXCEPTIONVALUE + + return v; +} + +// ECMA 12.11 +JSValue* CaseClauseNode::executeStatements(ExecState* exec) +{ + return statementListExecute(m_children, exec); +} + +// ------------------------------ ClauseListNode ------------------------------- + +void ClauseListNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_next) + nodeStack.append(m_next.get()); + nodeStack.append(m_clause.get()); +} + +// ------------------------------ CaseBlockNode -------------------------------- + +CaseBlockNode::CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2) + : m_list1(list1) + , m_defaultClause(defaultClause) + , m_list2(list2) +{ +} + +void CaseBlockNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + if (m_list2) + nodeStack.append(m_list2.get()); + if (m_defaultClause) + nodeStack.append(m_defaultClause.get()); + if (m_list1) + nodeStack.append(m_list1.get()); +} + +// ECMA 12.11 +JSValue* CaseBlockNode::executeBlock(ExecState* exec, JSValue* input) +{ + ClauseListNode* a = m_list1.get(); + while (a) { + CaseClauseNode* clause = a->getClause(); + a = a->getNext(); + JSValue* v = clause->evaluate(exec); + KJS_CHECKEXCEPTION + if (strictEqual(exec, input, v)) { + JSValue* res = clause->executeStatements(exec); + if (exec->completionType() != Normal) + return res; + for (; a; a = a->getNext()) { + JSValue* res = a->getClause()->executeStatements(exec); + if (exec->completionType() != Normal) + return res; + } + break; + } + } + + ClauseListNode* b = m_list2.get(); + while (b) { + CaseClauseNode* clause = b->getClause(); + b = b->getNext(); + JSValue* v = clause->evaluate(exec); + KJS_CHECKEXCEPTION + if (strictEqual(exec, input, v)) { + JSValue* res = clause->executeStatements(exec); + if (exec->completionType() != Normal) + return res; + goto step18; + } + } + + // default clause + if (m_defaultClause) { + JSValue* res = m_defaultClause->executeStatements(exec); + if (exec->completionType() != Normal) + return res; + } + b = m_list2.get(); +step18: + while (b) { + CaseClauseNode* clause = b->getClause(); + JSValue* res = clause->executeStatements(exec); + if (exec->completionType() != Normal) + return res; + b = b->getNext(); + } + + // bail out on error + KJS_CHECKEXCEPTION + + return exec->setNormalCompletion(); +} + +// ------------------------------ SwitchNode ----------------------------------- + +void SwitchNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_block.get()); + nodeStack.append(m_expr.get()); +} + +// ECMA 12.11 +JSValue* SwitchNode::execute(ExecState* exec) +{ + JSValue* v = m_expr->evaluate(exec); + KJS_CHECKEXCEPTION + + exec->pushSwitch(); + JSValue* result = m_block->executeBlock(exec, v); + exec->popSwitch(); + + if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) + exec->setCompletionType(Normal); + return result; +} + +// ------------------------------ LabelNode ------------------------------------ + +void LabelNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_statement.get()); +} + +// ECMA 12.12 +JSValue* LabelNode::execute(ExecState* exec) +{ + if (!exec->seenLabels().push(m_label)) + return setErrorCompletion(exec, SyntaxError, "Duplicated label %s found.", m_label); + JSValue* result = m_statement->execute(exec); + exec->seenLabels().pop(); + + if (exec->completionType() == Break && exec->breakOrContinueTarget() == m_label) + exec->setCompletionType(Normal); + return result; +} + +// ------------------------------ ThrowNode ------------------------------------ + +void ThrowNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + nodeStack.append(m_expr.get()); +} + +// ECMA 12.13 +JSValue* ThrowNode::execute(ExecState* exec) +{ + JSValue* v = m_expr->evaluate(exec); + KJS_CHECKEXCEPTION + + handleException(exec, v); + return exec->setThrowCompletion(v); +} + +// ------------------------------ TryNode -------------------------------------- + +void TryNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) +{ + // Can't optimize within catchBlock because "catch" introduces a dynamic scope. + if (m_finallyBlock) + nodeStack.append(m_finallyBlock.get()); + nodeStack.append(m_tryBlock.get()); +} + +// ECMA 12.14 +JSValue* TryNode::execute(ExecState* exec) +{ + JSValue* result = m_tryBlock->execute(exec); + + if (m_catchBlock && exec->completionType() == Throw) { + JSObject* obj = new JSObject; + obj->put(exec, m_exceptionIdent, result, DontDelete); + exec->dynamicGlobalObject()->tearOffActivation(exec); + exec->pushScope(obj); + result = m_catchBlock->execute(exec); + exec->popScope(); + } + + if (m_finallyBlock) { + ComplType savedCompletionType = exec->completionType(); + JSValue* finallyResult = m_finallyBlock->execute(exec); + if (exec->completionType() != Normal) + result = finallyResult; + else + exec->setCompletionType(savedCompletionType); + } + + return result; +} + +// ------------------------------ FunctionBodyNode ----------------------------- + +ScopeNode::ScopeNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack) + : BlockNode(children) + , m_sourceURL(parser().sourceURL()) + , m_sourceId(parser().sourceId()) +{ + if (varStack) + m_varStack = *varStack; + if (funcStack) + m_functionStack = *funcStack; +} + +// ------------------------------ ProgramNode ----------------------------- + +ProgramNode::ProgramNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack) + : ScopeNode(children, varStack, funcStack) +{ +} + +ProgramNode* ProgramNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack) +{ + return new ProgramNode(children, varStack, funcStack); +} + +// ------------------------------ EvalNode ----------------------------- + +EvalNode::EvalNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack) + : ScopeNode(children, varStack, funcStack) +{ +} + +EvalNode* EvalNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack) +{ + return new EvalNode(children, varStack, funcStack); +} + +// ------------------------------ FunctionBodyNode ----------------------------- + +FunctionBodyNode::FunctionBodyNode(SourceElements* children, VarStack* varStack, FunctionStack* funcStack) + : ScopeNode(children, varStack, funcStack) + , m_initialized(false) +{ +} + +FunctionBodyNode* FunctionBodyNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack) +{ + if (Debugger::debuggersPresent) + return new FunctionBodyNodeWithDebuggerHooks(children, varStack, funcStack); + return new FunctionBodyNode(children, varStack, funcStack); +} + +void FunctionBodyNode::initializeSymbolTable(ExecState* exec) +{ + SymbolTable& symbolTable = exec->variableObject()->symbolTable(); + ASSERT(symbolTable.isEmpty()); + + size_t localStorageIndex = 0; + + // Order must match the order in processDeclarations. + + for (size_t i = 0, size = m_parameters.size(); i < size; ++i, ++localStorageIndex) { + UString::Rep* rep = m_parameters[i].ustring().rep(); + symbolTable.set(rep, localStorageIndex); + } + + for (size_t i = 0, size = m_functionStack.size(); i < size; ++i, ++localStorageIndex) { + UString::Rep* rep = m_functionStack[i]->m_ident.ustring().rep(); + symbolTable.set(rep, localStorageIndex); + } + + for (size_t i = 0, size = m_varStack.size(); i < size; ++i, ++localStorageIndex) { + Identifier& ident = m_varStack[i].first; + if (ident == exec->propertyNames().arguments) + continue; + symbolTable.add(ident.ustring().rep(), localStorageIndex); + } +} + +void ProgramNode::initializeSymbolTable(ExecState* exec) +{ + // If a previous script defined a symbol with the same name as one of our + // symbols, to avoid breaking previously optimized nodes, we need to reuse + // the symbol's existing storage index. So, we can't be as efficient as + // FunctionBodyNode::initializeSymbolTable, which knows that no bindings + // have yet been made. + + JSVariableObject* variableObject = exec->variableObject(); + SymbolTable& symbolTable = variableObject->symbolTable(); + + size_t localStorageIndex = symbolTable.size(); + size_t size; + + // Order must match the order in processDeclarations. + + size = m_functionStack.size(); + m_functionIndexes.resize(size); + for (size_t i = 0; i < size; ++i) { + UString::Rep* rep = m_functionStack[i]->m_ident.ustring().rep(); + pair result = symbolTable.add(rep, localStorageIndex); + m_functionIndexes[i] = result.first->second; + if (result.second) + ++localStorageIndex; + } + + size = m_varStack.size(); + m_varIndexes.resize(size); + for (size_t i = 0; i < size; ++i) { + const Identifier& ident = m_varStack[i].first; + if (variableObject->hasProperty(exec, ident)) { + m_varIndexes[i] = missingSymbolMarker(); // Signal not to initialize this declaration. + continue; + } + + UString::Rep* rep = ident.ustring().rep(); + pair result = symbolTable.add(rep, localStorageIndex); + if (!result.second) { + m_varIndexes[i] = missingSymbolMarker(); // Signal not to initialize this declaration. + continue; + } + + m_varIndexes[i] = result.first->second; + ++localStorageIndex; + } +} + +void ScopeNode::optimizeVariableAccess(ExecState* exec) +{ + NodeStack nodeStack; + Node* node = statementListInitializeVariableAccessStack(m_children, nodeStack); + if (!node) + return; + + const SymbolTable& symbolTable = exec->variableObject()->symbolTable(); + const LocalStorage& localStorage = exec->variableObject()->localStorage(); + while (true) { + node->optimizeVariableAccess(symbolTable, localStorage, nodeStack); + + size_t size = nodeStack.size(); + if (!size) + break; + --size; + node = nodeStack[size]; + nodeStack.shrink(size); + } +} + +void FunctionBodyNode::processDeclarations(ExecState* exec) +{ + if (!m_initialized) + initializeSymbolTable(exec); + + if (!m_functionStack.isEmpty()) + exec->dynamicGlobalObject()->tearOffActivation(exec); + + LocalStorage& localStorage = exec->variableObject()->localStorage(); + + // We can't just resize localStorage here because that would temporarily + // leave uninitialized entries, which would crash GC during the mark phase. + size_t totalSize = m_varStack.size() + m_parameters.size() + m_functionStack.size(); + if (totalSize > localStorage.capacity()) // Doing this check inline avoids function call overhead. + localStorage.reserveCapacity(totalSize); + + int minAttributes = Internal | DontDelete; + + // In order for our localStorage indexes to be correct, we must match the + // order of addition in initializeSymbolTable(). + + const List& args = *exec->arguments(); + for (size_t i = 0, size = m_parameters.size(); i < size; ++i) + localStorage.uncheckedAppend(LocalStorageEntry(args[i], DontDelete)); + + for (size_t i = 0, size = m_functionStack.size(); i < size; ++i) { + FuncDeclNode* node = m_functionStack[i]; + localStorage.uncheckedAppend(LocalStorageEntry(node->makeFunction(exec), minAttributes)); + } + + for (size_t i = 0, size = m_varStack.size(); i < size; ++i) { + int attributes = minAttributes; + if (m_varStack[i].second & DeclarationStacks::IsConstant) + attributes |= ReadOnly; + localStorage.uncheckedAppend(LocalStorageEntry(jsUndefined(), attributes)); + } + + if (!m_initialized) { + optimizeVariableAccess(exec); + m_initialized = true; + } +} + +static void gccIsCrazy() KJS_FAST_CALL; +static void gccIsCrazy() +{ +} + +void ProgramNode::processDeclarations(ExecState* exec) +{ + // If you remove this call, some SunSpider tests, including + // bitops-nsieve-bits.js, will regress substantially on Mac, due to a ~40% + // increase in L2 cache misses. FIXME: WTF? + gccIsCrazy(); + + initializeSymbolTable(exec); + + LocalStorage& localStorage = exec->variableObject()->localStorage(); + + // We can't just resize localStorage here because that would temporarily + // leave uninitialized entries, which would crash GC during the mark phase. + localStorage.reserveCapacity(localStorage.size() + m_varStack.size() + m_functionStack.size()); + + int minAttributes = Internal | DontDelete; + + // In order for our localStorage indexes to be correct, we must match the + // order of addition in initializeSymbolTable(). + + for (size_t i = 0, size = m_functionStack.size(); i < size; ++i) { + FuncDeclNode* node = m_functionStack[i]; + LocalStorageEntry entry = LocalStorageEntry(node->makeFunction(exec), minAttributes); + size_t index = m_functionIndexes[i]; + + if (index == localStorage.size()) + localStorage.uncheckedAppend(entry); + else { + ASSERT(index < localStorage.size()); + localStorage[index] = entry; + } + } + + for (size_t i = 0, size = m_varStack.size(); i < size; ++i) { + size_t index = m_varIndexes[i]; + if (index == missingSymbolMarker()) + continue; + + int attributes = minAttributes; + if (m_varStack[i].second & DeclarationStacks::IsConstant) + attributes |= ReadOnly; + LocalStorageEntry entry = LocalStorageEntry(jsUndefined(), attributes); + + ASSERT(index == localStorage.size()); + localStorage.uncheckedAppend(entry); + } + + optimizeVariableAccess(exec); +} + +void EvalNode::processDeclarations(ExecState* exec) +{ + // We could optimize access to pre-existing symbols here, but SunSpider + // reports that to be a net loss. + + size_t i; + size_t size; + + JSVariableObject* variableObject = exec->variableObject(); + + int minAttributes = Internal; + + for (i = 0, size = m_varStack.size(); i < size; ++i) { + Identifier& ident = m_varStack[i].first; + if (variableObject->hasProperty(exec, ident)) + continue; + int attributes = minAttributes; + if (m_varStack[i].second & DeclarationStacks::IsConstant) + attributes |= ReadOnly; + variableObject->put(exec, ident, jsUndefined(), attributes); + } + + for (i = 0, size = m_functionStack.size(); i < size; ++i) { + FuncDeclNode* node = m_functionStack[i]; + variableObject->put(exec, node->m_ident, node->makeFunction(exec), minAttributes); + } +} + +UString FunctionBodyNode::paramString() const +{ + UString s(""); + size_t count = m_parameters.size(); + for (size_t pos = 0; pos < count; ++pos) { + if (!s.isEmpty()) + s += ", "; + s += m_parameters[pos].ustring(); + } + + return s; +} + +JSValue* ProgramNode::execute(ExecState* exec) +{ + processDeclarations(exec); + return ScopeNode::execute(exec); +} + +JSValue* EvalNode::execute(ExecState* exec) +{ + processDeclarations(exec); + return ScopeNode::execute(exec); +} + +JSValue* FunctionBodyNode::execute(ExecState* exec) +{ + processDeclarations(exec); + return ScopeNode::execute(exec); +} + +// ------------------------------ FunctionBodyNodeWithDebuggerHooks --------------------------------- + +FunctionBodyNodeWithDebuggerHooks::FunctionBodyNodeWithDebuggerHooks(SourceElements* children, DeclarationStacks::VarStack* varStack, DeclarationStacks::FunctionStack* funcStack) + : FunctionBodyNode(children, varStack, funcStack) +{ +} + +JSValue* FunctionBodyNodeWithDebuggerHooks::execute(ExecState* exec) +{ + if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) { + if (!dbg->callEvent(exec, sourceId(), lineNo(), exec->function(), *exec->arguments())) { + dbg->imp()->abort(); + return exec->setInterruptedCompletion(); + } + } + + JSValue* result = FunctionBodyNode::execute(exec); + + if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) { + if (exec->completionType() == Throw) + exec->setException(result); + if (!dbg->returnEvent(exec, sourceId(), lastLine(), exec->function())) { + dbg->imp()->abort(); + return exec->setInterruptedCompletion(); + } + } + + return result; +} + +// ------------------------------ FuncDeclNode --------------------------------- + +void FuncDeclNode::addParams() +{ + for (ParameterNode* p = m_parameter.get(); p; p = p->nextParam()) + m_body->parameters().append(p->ident()); +} + +FunctionImp* FuncDeclNode::makeFunction(ExecState* exec) +{ + FunctionImp* func = new FunctionImp(exec, m_ident, m_body.get(), exec->scopeChain()); + + JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList()); + proto->putDirect(exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum); + func->putDirect(exec->propertyNames().prototype, proto, Internal | DontDelete); + func->putDirect(exec->propertyNames().length, jsNumber(m_body->parameters().size()), ReadOnly | DontDelete | DontEnum); + return func; +} + +JSValue* FuncDeclNode::execute(ExecState* exec) +{ + return exec->setNormalCompletion(); +} + +// ------------------------------ FuncExprNode --------------------------------- + +// ECMA 13 +void FuncExprNode::addParams() +{ + for (ParameterNode* p = m_parameter.get(); p; p = p->nextParam()) + m_body->parameters().append(p->ident()); +} + +JSValue* FuncExprNode::evaluate(ExecState* exec) +{ + exec->dynamicGlobalObject()->tearOffActivation(exec); + + bool named = !m_ident.isNull(); + JSObject* functionScopeObject = 0; + + if (named) { + // named FunctionExpressions can recursively call themselves, + // but they won't register with the current scope chain and should + // be contained as single property in an anonymous object. + functionScopeObject = new JSObject; + exec->pushScope(functionScopeObject); + } + + FunctionImp* func = new FunctionImp(exec, m_ident, m_body.get(), exec->scopeChain()); + JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList()); + proto->putDirect(exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum); + func->putDirect(exec->propertyNames().prototype, proto, Internal | DontDelete); + + if (named) { + functionScopeObject->putDirect(m_ident, func, Internal | ReadOnly | (exec->codeType() == EvalCode ? 0 : DontDelete)); + exec->popScope(); + } + + return func; +} + +} // namespace KJS diff --git a/kjs/nodes.h b/kjs/nodes.h new file mode 100644 index 0000000..c0fe509 --- /dev/null +++ b/kjs/nodes.h @@ -0,0 +1,2907 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) + * Copyright (C) 2007 Maks Orlovich + * Copyright (C) 2007 Eric Seidel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef NODES_H_ +#define NODES_H_ + +#include "internal.h" +#include "regexp.h" +#include "SymbolTable.h" +#include +#include +#include +#include + +#if PLATFORM(X86) && COMPILER(GCC) +#define KJS_FAST_CALL __attribute__((regparm(3))) +#else +#define KJS_FAST_CALL +#endif + +namespace KJS { + + class ConstDeclNode; + class FuncDeclNode; + class Node; + class PropertyListNode; + class SourceStream; + + enum Operator { + OpEqual, + OpPlusEq, + OpMinusEq, + OpMultEq, + OpDivEq, + OpPlusPlus, + OpMinusMinus, + OpAndEq, + OpXOrEq, + OpOrEq, + OpModEq, + OpLShift, + OpRShift, + OpURShift, + }; + + enum Precedence { + PrecPrimary, + PrecMember, + PrecCall, + PrecLeftHandSide, + PrecPostfix, + PrecUnary, + PrecMultiplicitave, + PrecAdditive, + PrecShift, + PrecRelational, + PrecEquality, + PrecBitwiseAnd, + PrecBitwiseXor, + PrecBitwiseOr, + PrecLogicalAnd, + PrecLogicalOr, + PrecConditional, + PrecAssignment, + PrecExpression + }; + + struct DeclarationStacks { + typedef Vector NodeStack; + enum { IsConstant = 1, HasInitializer = 2 } VarAttrs; + typedef Vector, 16> VarStack; + typedef Vector FunctionStack; + + DeclarationStacks(ExecState* e, NodeStack& n, VarStack& v, FunctionStack& f) + : exec(e) + , nodeStack(n) + , varStack(v) + , functionStack(f) + { + } + + ExecState* exec; + NodeStack& nodeStack; + VarStack& varStack; + FunctionStack& functionStack; + }; + + class ParserRefCounted : Noncopyable { + protected: + ParserRefCounted() KJS_FAST_CALL; + ParserRefCounted(PlacementNewAdoptType) KJS_FAST_CALL + { + } + + public: + void ref() KJS_FAST_CALL; + void deref() KJS_FAST_CALL; + unsigned refcount() KJS_FAST_CALL; + + static void deleteNewObjects() KJS_FAST_CALL; + + virtual ~ParserRefCounted(); + }; + + class Node : public ParserRefCounted { + public: + typedef DeclarationStacks::NodeStack NodeStack; + typedef DeclarationStacks::VarStack VarStack; + typedef DeclarationStacks::FunctionStack FunctionStack; + + Node() KJS_FAST_CALL; + Node(PlacementNewAdoptType placementAdopt) KJS_FAST_CALL + : ParserRefCounted(placementAdopt) + { + } + + UString toString() const KJS_FAST_CALL; + int lineNo() const KJS_FAST_CALL { return m_line; } + + // Serialization. + virtual void streamTo(SourceStream&) const KJS_FAST_CALL = 0; + virtual Precedence precedence() const = 0; + virtual bool needsParensIfLeftmost() const { return false; } + + // Used for iterative, depth-first traversal of the node tree. Does not cross function call boundaries. + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL { } + + protected: + JSValue* setInterruptedCompletion(ExecState*); + Node(JSType) KJS_FAST_CALL; // used by ExpressionNode + + // for use in execute() + JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL; + JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL; + + // for use in evaluate() + JSValue* throwError(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL; + JSValue* throwError(ExecState*, ErrorType, const char* msg, const char*) KJS_FAST_CALL; + JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*) KJS_FAST_CALL; + JSValue* throwError(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL; + JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, const Identifier&) KJS_FAST_CALL; + JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, Node*) KJS_FAST_CALL; + JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, const Identifier&) KJS_FAST_CALL; + + JSValue* throwUndefinedVariableError(ExecState*, const Identifier&) KJS_FAST_CALL; + + void handleException(ExecState*) KJS_FAST_CALL; + void handleException(ExecState*, JSValue*) KJS_FAST_CALL; + + // for use in execute() + JSValue* rethrowException(ExecState*) KJS_FAST_CALL; + + int m_line : 28; + unsigned m_expectedReturnType : 3; // JSType + }; + + class ExpressionNode : public Node { + public: + ExpressionNode() KJS_FAST_CALL : Node() {} + ExpressionNode(JSType expectedReturn) KJS_FAST_CALL + : Node(expectedReturn) + { + } + + // Special constructor for cases where we overwrite an object in place. + ExpressionNode(PlacementNewAdoptType) KJS_FAST_CALL + : Node(PlacementNewAdopt) + { + } + + virtual bool isNumber() const KJS_FAST_CALL { return false; } + virtual bool isLocation() const KJS_FAST_CALL { return false; } + virtual bool isResolveNode() const KJS_FAST_CALL { return false; } + virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return false; } + virtual bool isDotAccessorNode() const KJS_FAST_CALL { return false; } + + JSType expectedReturnType() const KJS_FAST_CALL { return static_cast(m_expectedReturnType); } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL = 0; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + + // Used to optimize those nodes that do extra work when returning a result, even if the result has no semantic relevance + virtual void optimizeForUnnecessaryResult() { } + }; + + class StatementNode : public Node { + public: + StatementNode() KJS_FAST_CALL; + void setLoc(int line0, int line1) KJS_FAST_CALL; + int firstLine() const KJS_FAST_CALL { return lineNo(); } + int lastLine() const KJS_FAST_CALL { return m_lastLine; } + virtual JSValue* execute(ExecState *exec) KJS_FAST_CALL = 0; + void pushLabel(const Identifier& ident) KJS_FAST_CALL { m_labelStack.push(ident); } + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + virtual bool isEmptyStatement() const KJS_FAST_CALL { return false; } + + protected: + LabelStack m_labelStack; + + private: + int m_lastLine; + }; + + class NullNode : public ExpressionNode { + public: + NullNode() KJS_FAST_CALL : ExpressionNode(NullType) {} + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPrimary; } + }; + + class FalseNode : public ExpressionNode { + public: + FalseNode() KJS_FAST_CALL + : ExpressionNode(BooleanType) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return false; } + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPrimary; } + }; + + class TrueNode : public ExpressionNode { + public: + TrueNode() KJS_FAST_CALL + : ExpressionNode(BooleanType) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return true; } + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPrimary; } + }; + + class PlaceholderTrueNode : public TrueNode { + public: + // Like TrueNode, but does not serialize as "true". + PlaceholderTrueNode() KJS_FAST_CALL + : TrueNode() + { + } + + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + }; + + class NumberNode : public ExpressionNode { + public: + NumberNode(double v) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_double(v) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return signbit(m_double) ? PrecUnary : PrecPrimary; } + + virtual bool isNumber() const KJS_FAST_CALL { return true; } + double value() const KJS_FAST_CALL { return m_double; } + virtual void setValue(double d) KJS_FAST_CALL { m_double = d; } + + protected: + double m_double; + }; + + class ImmediateNumberNode : public NumberNode { + public: + ImmediateNumberNode(JSValue* v, double d) KJS_FAST_CALL + : NumberNode(d) + , m_value(v) + { + ASSERT(v == JSImmediate::from(d)); + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + + virtual void setValue(double d) KJS_FAST_CALL { m_double = d; m_value = JSImmediate::from(d); ASSERT(m_value); } + + private: + JSValue* m_value; // This is never a JSCell, only JSImmediate, thus no ProtectedPtr + }; + + class StringNode : public ExpressionNode { + public: + StringNode(const UString* v) KJS_FAST_CALL + : ExpressionNode(StringType) + , m_value(*v) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPrimary; } + + private: + UString m_value; + }; + + class RegExpNode : public ExpressionNode { + public: + RegExpNode(const UString& pattern, const UString& flags) KJS_FAST_CALL + : m_regExp(new RegExp(pattern, flags)) + { + } + + JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPrimary; } + + private: + RefPtr m_regExp; + }; + + class ThisNode : public ExpressionNode { + public: + ThisNode() KJS_FAST_CALL + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPrimary; } + }; + + class ResolveNode : public ExpressionNode { + public: + ResolveNode(const Identifier& ident) KJS_FAST_CALL + : m_ident(ident) + { + } + + // Special constructor for cases where we overwrite an object in place. + ResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : ExpressionNode(PlacementNewAdopt) + , m_ident(PlacementNewAdopt) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPrimary; } + + virtual bool isLocation() const KJS_FAST_CALL { return true; } + virtual bool isResolveNode() const KJS_FAST_CALL { return true; } + const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } + + protected: + ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); + Identifier m_ident; + size_t m_index; // Used by LocalVarAccessNode. + }; + + class LocalVarAccessNode : public ResolveNode { + public: + // Overwrites a ResolveNode in place. + LocalVarAccessNode(size_t i) KJS_FAST_CALL + : ResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + + private: + ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); + }; + + class ElementNode : public Node { + public: + ElementNode(int elision, ExpressionNode* node) KJS_FAST_CALL + : m_elision(elision) + , m_node(node) + { + } + + ElementNode(ElementNode* l, int elision, ExpressionNode* node) KJS_FAST_CALL + : m_elision(elision) + , m_node(node) + { + l->m_next = this; + } + + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + + PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } + + JSValue* evaluate(ExecState*) KJS_FAST_CALL; + + private: + friend class ArrayNode; + ListRefPtr m_next; + int m_elision; + RefPtr m_node; + }; + + class ArrayNode : public ExpressionNode { + public: + ArrayNode(int elision) KJS_FAST_CALL + : m_elision(elision) + , m_optional(true) + { + } + + ArrayNode(ElementNode* element) KJS_FAST_CALL + : m_element(element) + , m_elision(0) + , m_optional(false) + { + } + + ArrayNode(int elision, ElementNode* element) KJS_FAST_CALL + : m_element(element) + , m_elision(elision) + , m_optional(true) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPrimary; } + + private: + RefPtr m_element; + int m_elision; + bool m_optional; + }; + + class PropertyNode : public Node { + public: + enum Type { Constant, Getter, Setter }; + + PropertyNode(const Identifier& name, ExpressionNode* assign, Type type) KJS_FAST_CALL + : m_name(name) + , m_assign(assign) + , m_type(type) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + + JSValue* evaluate(ExecState*) KJS_FAST_CALL; + const Identifier& name() const { return m_name; } + + private: + friend class PropertyListNode; + Identifier m_name; + RefPtr m_assign; + Type m_type; + }; + + class PropertyListNode : public Node { + public: + PropertyListNode(PropertyNode* node) KJS_FAST_CALL + : m_node(node) + { + } + + PropertyListNode(PropertyNode* node, PropertyListNode* list) KJS_FAST_CALL + : m_node(node) + { + list->m_next = this; + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + + JSValue* evaluate(ExecState*) KJS_FAST_CALL; + PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } + + private: + friend class ObjectLiteralNode; + RefPtr m_node; + ListRefPtr m_next; + }; + + class ObjectLiteralNode : public ExpressionNode { + public: + ObjectLiteralNode() KJS_FAST_CALL + { + } + + ObjectLiteralNode(PropertyListNode* list) KJS_FAST_CALL + : m_list(list) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPrimary; } + virtual bool needsParensIfLeftmost() const { return true; } + + private: + RefPtr m_list; + }; + + class BracketAccessorNode : public ExpressionNode { + public: + BracketAccessorNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL + : m_base(base) + , m_subscript(subscript) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecMember; } + + virtual bool isLocation() const KJS_FAST_CALL { return true; } + virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return true; } + ExpressionNode* base() KJS_FAST_CALL { return m_base.get(); } + ExpressionNode* subscript() KJS_FAST_CALL { return m_subscript.get(); } + + private: + ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); + + RefPtr m_base; + RefPtr m_subscript; + }; + + class DotAccessorNode : public ExpressionNode { + public: + DotAccessorNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL + : m_base(base) + , m_ident(ident) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecMember; } + + virtual bool isLocation() const KJS_FAST_CALL { return true; } + virtual bool isDotAccessorNode() const KJS_FAST_CALL { return true; } + ExpressionNode* base() const KJS_FAST_CALL { return m_base.get(); } + const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } + + private: + ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); + + RefPtr m_base; + Identifier m_ident; + }; + + class ArgumentListNode : public Node { + public: + ArgumentListNode(ExpressionNode* expr) KJS_FAST_CALL + : m_expr(expr) + { + } + + ArgumentListNode(ArgumentListNode* listNode, ExpressionNode* expr) KJS_FAST_CALL + : m_expr(expr) + { + listNode->m_next = this; + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + + void evaluateList(ExecState*, List&) KJS_FAST_CALL; + PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } + + private: + friend class ArgumentsNode; + ListRefPtr m_next; + RefPtr m_expr; + }; + + class ArgumentsNode : public Node { + public: + ArgumentsNode() KJS_FAST_CALL + { + } + + ArgumentsNode(ArgumentListNode* listNode) KJS_FAST_CALL + : m_listNode(listNode) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + + void evaluateList(ExecState* exec, List& list) KJS_FAST_CALL { if (m_listNode) m_listNode->evaluateList(exec, list); } + + private: + RefPtr m_listNode; + }; + + class NewExprNode : public ExpressionNode { + public: + NewExprNode(ExpressionNode* expr) KJS_FAST_CALL + : m_expr(expr) + { + } + + NewExprNode(ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL + : m_expr(expr) + , m_args(args) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecLeftHandSide; } + + private: + ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); + + RefPtr m_expr; + RefPtr m_args; + }; + + class FunctionCallValueNode : public ExpressionNode { + public: + FunctionCallValueNode(ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL + : m_expr(expr) + , m_args(args) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecCall; } + + private: + RefPtr m_expr; + RefPtr m_args; + }; + + class FunctionCallResolveNode : public ExpressionNode { + public: + FunctionCallResolveNode(const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL + : m_ident(ident) + , m_args(args) + { + } + + FunctionCallResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : ExpressionNode(PlacementNewAdopt) + , m_ident(PlacementNewAdopt) + , m_args(PlacementNewAdopt) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecCall; } + + protected: + ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); + + Identifier m_ident; + RefPtr m_args; + size_t m_index; // Used by LocalVarFunctionCallNode. + }; + + class LocalVarFunctionCallNode : public FunctionCallResolveNode { + public: + LocalVarFunctionCallNode(size_t i) KJS_FAST_CALL + : FunctionCallResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + + private: + ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); + }; + + class FunctionCallBracketNode : public ExpressionNode { + public: + FunctionCallBracketNode(ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args) KJS_FAST_CALL + : m_base(base) + , m_subscript(subscript) + , m_args(args) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecCall; } + + protected: + RefPtr m_base; + RefPtr m_subscript; + RefPtr m_args; + }; + + class FunctionCallDotNode : public ExpressionNode { + public: + FunctionCallDotNode(ExpressionNode* base, const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL + : m_base(base) + , m_ident(ident) + , m_args(args) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecCall; } + + private: + ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); + + RefPtr m_base; + Identifier m_ident; + RefPtr m_args; + }; + + class PrePostResolveNode : public ExpressionNode { + public: + PrePostResolveNode(const Identifier& ident) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_ident(ident) + { + } + + PrePostResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : ExpressionNode(PlacementNewAdopt) + , m_ident(PlacementNewAdopt) + { + } + + protected: + Identifier m_ident; + size_t m_index; // Used by LocalVarPostfixNode. + }; + + class PostIncResolveNode : public PrePostResolveNode { + public: + PostIncResolveNode(const Identifier& ident) KJS_FAST_CALL + : PrePostResolveNode(ident) + { + } + + PostIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : PrePostResolveNode(PlacementNewAdopt) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPostfix; } + virtual void optimizeForUnnecessaryResult(); + }; + + class PostIncLocalVarNode : public PostIncResolveNode { + public: + PostIncLocalVarNode(size_t i) KJS_FAST_CALL + : PostIncResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void optimizeForUnnecessaryResult(); + }; + + class PostIncConstNode : public PostIncResolveNode { + public: + PostIncConstNode(size_t i) KJS_FAST_CALL + : PostIncResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class PostDecResolveNode : public PrePostResolveNode { + public: + PostDecResolveNode(const Identifier& ident) KJS_FAST_CALL + : PrePostResolveNode(ident) + { + } + + PostDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : PrePostResolveNode(PlacementNewAdopt) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPostfix; } + virtual void optimizeForUnnecessaryResult(); + }; + + class PostDecLocalVarNode : public PostDecResolveNode { + public: + PostDecLocalVarNode(size_t i) KJS_FAST_CALL + : PostDecResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void optimizeForUnnecessaryResult(); + + private: + ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); + }; + + class PostDecConstNode : public PostDecResolveNode { + public: + PostDecConstNode(size_t i) KJS_FAST_CALL + : PostDecResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class PostfixBracketNode : public ExpressionNode { + public: + PostfixBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL + : m_base(base) + , m_subscript(subscript) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPostfix; } + + protected: + RefPtr m_base; + RefPtr m_subscript; + }; + + class PostIncBracketNode : public PostfixBracketNode { + public: + PostIncBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL + : PostfixBracketNode(base, subscript) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + }; + + class PostDecBracketNode : public PostfixBracketNode { + public: + PostDecBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL + : PostfixBracketNode(base, subscript) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + }; + + class PostfixDotNode : public ExpressionNode { + public: + PostfixDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL + : m_base(base) + , m_ident(ident) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPostfix; } + + protected: + RefPtr m_base; + Identifier m_ident; + }; + + class PostIncDotNode : public PostfixDotNode { + public: + PostIncDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL + : PostfixDotNode(base, ident) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + }; + + class PostDecDotNode : public PostfixDotNode { + public: + PostDecDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL + : PostfixDotNode(base, ident) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + }; + + class PostfixErrorNode : public ExpressionNode { + public: + PostfixErrorNode(ExpressionNode* expr, Operator oper) KJS_FAST_CALL + : m_expr(expr) + , m_operator(oper) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPostfix; } + + private: + RefPtr m_expr; + Operator m_operator; + }; + + class DeleteResolveNode : public ExpressionNode { + public: + DeleteResolveNode(const Identifier& ident) KJS_FAST_CALL + : m_ident(ident) + { + } + + DeleteResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : ExpressionNode(PlacementNewAdopt) + , m_ident(PlacementNewAdopt) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + Identifier m_ident; + }; + + class LocalVarDeleteNode : public DeleteResolveNode { + public: + LocalVarDeleteNode() KJS_FAST_CALL + : DeleteResolveNode(PlacementNewAdopt) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class DeleteBracketNode : public ExpressionNode { + public: + DeleteBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL + : m_base(base) + , m_subscript(subscript) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + RefPtr m_base; + RefPtr m_subscript; + }; + + class DeleteDotNode : public ExpressionNode { + public: + DeleteDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL + : m_base(base) + , m_ident(ident) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + RefPtr m_base; + Identifier m_ident; + }; + + class DeleteValueNode : public ExpressionNode { + public: + DeleteValueNode(ExpressionNode* expr) KJS_FAST_CALL + : m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + RefPtr m_expr; + }; + + class VoidNode : public ExpressionNode { + public: + VoidNode(ExpressionNode* expr) KJS_FAST_CALL + : m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + RefPtr m_expr; + }; + + class TypeOfResolveNode : public ExpressionNode { + public: + TypeOfResolveNode(const Identifier& ident) KJS_FAST_CALL + : ExpressionNode(StringType) + , m_ident(ident) + { + } + + TypeOfResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : ExpressionNode(PlacementNewAdopt) + , m_ident(PlacementNewAdopt) + { + m_expectedReturnType = StringType; + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } + + protected: + Identifier m_ident; + size_t m_index; // Used by LocalTypeOfNode. + }; + + class LocalVarTypeOfNode : public TypeOfResolveNode { + public: + LocalVarTypeOfNode(size_t i) KJS_FAST_CALL + : TypeOfResolveNode(PlacementNewAdopt) + { + m_expectedReturnType = StringType; + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class TypeOfValueNode : public ExpressionNode { + public: + TypeOfValueNode(ExpressionNode* expr) KJS_FAST_CALL + : ExpressionNode(StringType) + , m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + RefPtr m_expr; + }; + + class PreIncResolveNode : public PrePostResolveNode { + public: + PreIncResolveNode(const Identifier& ident) KJS_FAST_CALL + : PrePostResolveNode(ident) + { + } + + PreIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : PrePostResolveNode(PlacementNewAdopt) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + }; + + class PreIncLocalVarNode : public PreIncResolveNode { + public: + PreIncLocalVarNode(size_t i) KJS_FAST_CALL + : PreIncResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class PreIncConstNode : public PreIncResolveNode { + public: + PreIncConstNode(size_t i) KJS_FAST_CALL + : PreIncResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class PreDecResolveNode : public PrePostResolveNode { + public: + PreDecResolveNode(const Identifier& ident) KJS_FAST_CALL + : PrePostResolveNode(ident) + { + } + + PreDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : PrePostResolveNode(PlacementNewAdopt) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + }; + + class PreDecLocalVarNode : public PreDecResolveNode { + public: + PreDecLocalVarNode(size_t i) KJS_FAST_CALL + : PreDecResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class PreDecConstNode : public PreDecResolveNode { + public: + PreDecConstNode(size_t i) KJS_FAST_CALL + : PreDecResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class PrefixBracketNode : public ExpressionNode { + public: + PrefixBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL + : m_base(base) + , m_subscript(subscript) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + protected: + RefPtr m_base; + RefPtr m_subscript; + }; + + class PreIncBracketNode : public PrefixBracketNode { + public: + PreIncBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL + : PrefixBracketNode(base, subscript) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + }; + + class PreDecBracketNode : public PrefixBracketNode { + public: + PreDecBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL + : PrefixBracketNode(base, subscript) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + }; + + class PrefixDotNode : public ExpressionNode { + public: + PrefixDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL + : m_base(base) + , m_ident(ident) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecPostfix; } + + protected: + RefPtr m_base; + Identifier m_ident; + }; + + class PreIncDotNode : public PrefixDotNode { + public: + PreIncDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL + : PrefixDotNode(base, ident) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + }; + + class PreDecDotNode : public PrefixDotNode { + public: + PreDecDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL + : PrefixDotNode(base, ident) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + }; + + class PrefixErrorNode : public ExpressionNode { + public: + PrefixErrorNode(ExpressionNode* expr, Operator oper) KJS_FAST_CALL + : m_expr(expr) + , m_operator(oper) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + RefPtr m_expr; + Operator m_operator; + }; + + class UnaryPlusNode : public ExpressionNode { + public: + UnaryPlusNode(ExpressionNode* expr) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + RefPtr m_expr; + }; + + class NegateNode : public ExpressionNode { + public: + NegateNode(ExpressionNode* expr) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + RefPtr m_expr; + }; + + class BitwiseNotNode : public ExpressionNode { + public: + BitwiseNotNode(ExpressionNode* expr) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); + + RefPtr m_expr; + }; + + class LogicalNotNode : public ExpressionNode { + public: + LogicalNotNode(ExpressionNode* expr) KJS_FAST_CALL + : ExpressionNode(BooleanType) + , m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecUnary; } + + private: + RefPtr m_expr; + }; + + class MultNode : public ExpressionNode { + public: + MultNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_term1(term1) + , m_term2(term2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecMultiplicitave; } + + private: + ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); + + RefPtr m_term1; + RefPtr m_term2; + }; + + class DivNode : public ExpressionNode { + public: + DivNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_term1(term1) + , m_term2(term2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecMultiplicitave; } + + private: + ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); + + RefPtr m_term1; + RefPtr m_term2; + }; + + class ModNode : public ExpressionNode { + public: + ModNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_term1(term1) + , m_term2(term2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecMultiplicitave; } + + private: + ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); + + RefPtr m_term1; + RefPtr m_term2; + }; + + class AddNode : public ExpressionNode { + public: + AddNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : m_term1(term1) + , m_term2(term2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecAdditive; } + + protected: + AddNode(ExpressionNode* term1, ExpressionNode* term2, JSType expectedReturn) KJS_FAST_CALL + : ExpressionNode(expectedReturn) + , m_term1(term1) + , m_term2(term2) + { + } + + RefPtr m_term1; + RefPtr m_term2; + + private: + ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); + }; + + class AddNumbersNode : public AddNode { + public: + AddNumbersNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : AddNode(term1, term2, NumberType) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + + private: + ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*) KJS_FAST_CALL; + }; + + class AddStringLeftNode : public AddNode { + public: + AddStringLeftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : AddNode(term1, term2, StringType) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class AddStringRightNode : public AddNode { + public: + AddStringRightNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : AddNode(term1, term2, StringType) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class AddStringsNode : public AddNode { + public: + AddStringsNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : AddNode(term1, term2, StringType) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class SubNode : public ExpressionNode { + public: + SubNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_term1(term1) + , m_term2(term2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecAdditive; } + + private: + ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); + + RefPtr m_term1; + RefPtr m_term2; + }; + + class LeftShiftNode : public ExpressionNode { + public: + LeftShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_term1(term1) + , m_term2(term2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecShift; } + + private: + ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); + + RefPtr m_term1; + RefPtr m_term2; + }; + + class RightShiftNode : public ExpressionNode { + public: + RightShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_term1(term1) + , m_term2(term2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecShift; } + + private: + ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); + + RefPtr m_term1; + RefPtr m_term2; + }; + + class UnsignedRightShiftNode : public ExpressionNode { + public: + UnsignedRightShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_term1(term1) + , m_term2(term2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecShift; } + private: + ALWAYS_INLINE uint32_t inlineEvaluateToUInt32(ExecState*); + + RefPtr m_term1; + RefPtr m_term2; + }; + + class LessNode : public ExpressionNode { + public: + LessNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(BooleanType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecRelational; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + protected: + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class LessNumbersNode : public LessNode { + public: + LessNumbersNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : LessNode(expr1, expr2) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + }; + + class LessStringsNode : public LessNode { + public: + LessStringsNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : LessNode(expr1, expr2) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + }; + + class GreaterNode : public ExpressionNode { + public: + GreaterNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecRelational; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class LessEqNode : public ExpressionNode { + public: + LessEqNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecRelational; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class GreaterEqNode : public ExpressionNode { + public: + GreaterEqNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecRelational; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class InstanceOfNode : public ExpressionNode { + public: + InstanceOfNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(BooleanType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecRelational; } + + private: + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class InNode : public ExpressionNode { + public: + InNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecRelational; } + + private: + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class EqualNode : public ExpressionNode { + public: + EqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(BooleanType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecEquality; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class NotEqualNode : public ExpressionNode { + public: + NotEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(BooleanType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecEquality; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class StrictEqualNode : public ExpressionNode { + public: + StrictEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(BooleanType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecEquality; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class NotStrictEqualNode : public ExpressionNode { + public: + NotStrictEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(BooleanType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecEquality; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class BitAndNode : public ExpressionNode { + public: + BitAndNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecBitwiseAnd; } + + private: + ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class BitOrNode : public ExpressionNode { + public: + BitOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecBitwiseOr; } + + private: + ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class BitXOrNode : public ExpressionNode { + public: + BitXOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(NumberType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecBitwiseXor; } + + private: + ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + /** + * m_expr1 && m_expr2, m_expr1 || m_expr2 + */ + class LogicalAndNode : public ExpressionNode { + public: + LogicalAndNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(BooleanType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecLogicalAnd; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class LogicalOrNode : public ExpressionNode { + public: + LogicalOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : ExpressionNode(BooleanType) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecLogicalOr; } + + private: + ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); + + RefPtr m_expr1; + RefPtr m_expr2; + }; + + /** + * The ternary operator, "m_logical ? m_expr1 : m_expr2" + */ + class ConditionalNode : public ExpressionNode { + public: + ConditionalNode(ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : m_logical(logical) + , m_expr1(expr1) + , m_expr2(expr2) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; + virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; + virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; + virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecConditional; } + + private: + RefPtr m_logical; + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class ReadModifyResolveNode : public ExpressionNode { + public: + ReadModifyResolveNode(const Identifier& ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL + : m_ident(ident) + , m_operator(oper) + , m_right(right) + { + } + + ReadModifyResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : ExpressionNode(PlacementNewAdopt) + , m_ident(PlacementNewAdopt) + , m_right(PlacementNewAdopt) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecAssignment; } + + protected: + Identifier m_ident; + Operator m_operator; + RefPtr m_right; + size_t m_index; // Used by ReadModifyLocalVarNode. + }; + + class ReadModifyLocalVarNode : public ReadModifyResolveNode { + public: + ReadModifyLocalVarNode(size_t i) KJS_FAST_CALL + : ReadModifyResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class ReadModifyConstNode : public ReadModifyResolveNode { + public: + ReadModifyConstNode(size_t i) KJS_FAST_CALL + : ReadModifyResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class AssignResolveNode : public ExpressionNode { + public: + AssignResolveNode(const Identifier& ident, ExpressionNode* right) KJS_FAST_CALL + : m_ident(ident) + , m_right(right) + { + } + + AssignResolveNode(PlacementNewAdoptType) KJS_FAST_CALL + : ExpressionNode(PlacementNewAdopt) + , m_ident(PlacementNewAdopt) + , m_right(PlacementNewAdopt) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecAssignment; } + + protected: + Identifier m_ident; + RefPtr m_right; + size_t m_index; // Used by ReadModifyLocalVarNode. + }; + + class AssignLocalVarNode : public AssignResolveNode { + public: + AssignLocalVarNode(size_t i) KJS_FAST_CALL + : AssignResolveNode(PlacementNewAdopt) + { + ASSERT(i != missingSymbolMarker()); + m_index = i; + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class AssignConstNode : public AssignResolveNode { + public: + AssignConstNode() KJS_FAST_CALL + : AssignResolveNode(PlacementNewAdopt) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + }; + + class ReadModifyBracketNode : public ExpressionNode { + public: + ReadModifyBracketNode(ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right) KJS_FAST_CALL + : m_base(base) + , m_subscript(subscript) + , m_operator(oper) + , m_right(right) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecAssignment; } + + protected: + RefPtr m_base; + RefPtr m_subscript; + Operator m_operator; + RefPtr m_right; + }; + + class AssignBracketNode : public ExpressionNode { + public: + AssignBracketNode(ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right) KJS_FAST_CALL + : m_base(base) + , m_subscript(subscript) + , m_right(right) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecAssignment; } + + protected: + RefPtr m_base; + RefPtr m_subscript; + RefPtr m_right; + }; + + class AssignDotNode : public ExpressionNode { + public: + AssignDotNode(ExpressionNode* base, const Identifier& ident, ExpressionNode* right) KJS_FAST_CALL + : m_base(base) + , m_ident(ident) + , m_right(right) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecAssignment; } + + protected: + RefPtr m_base; + Identifier m_ident; + RefPtr m_right; + }; + + class ReadModifyDotNode : public ExpressionNode { + public: + ReadModifyDotNode(ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL + : m_base(base) + , m_ident(ident) + , m_operator(oper) + , m_right(right) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecAssignment; } + + protected: + RefPtr m_base; + Identifier m_ident; + Operator m_operator; + RefPtr m_right; + }; + + class AssignErrorNode : public ExpressionNode { + public: + AssignErrorNode(ExpressionNode* left, Operator oper, ExpressionNode* right) KJS_FAST_CALL + : m_left(left) + , m_operator(oper) + , m_right(right) + { + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecAssignment; } + + protected: + RefPtr m_left; + Operator m_operator; + RefPtr m_right; + }; + + class CommaNode : public ExpressionNode { + public: + CommaNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : m_expr1(expr1) + , m_expr2(expr2) + { + m_expr1->optimizeForUnnecessaryResult(); + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecExpression; } + + private: + RefPtr m_expr1; + RefPtr m_expr2; + }; + + class VarDeclCommaNode : public CommaNode { + public: + VarDeclCommaNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL + : CommaNode(expr1, expr2) + { + } + virtual Precedence precedence() const { return PrecAssignment; } + }; + + class ConstDeclNode : public ExpressionNode { + public: + ConstDeclNode(const Identifier& ident, ExpressionNode* in) KJS_FAST_CALL; + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual KJS::JSValue* evaluate(ExecState*) KJS_FAST_CALL; + void evaluateSingle(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } + + Identifier m_ident; + ListRefPtr m_next; + RefPtr m_init; + + private: + void handleSlowCase(ExecState*, const ScopeChain&, JSValue*) KJS_FAST_CALL NEVER_INLINE; + }; + + class ConstStatementNode : public StatementNode { + public: + ConstStatementNode(ConstDeclNode* next) KJS_FAST_CALL + : m_next(next) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_next; + }; + + typedef Vector > StatementVector; + + class SourceElements : public ParserRefCounted { + public: + void append(PassRefPtr); + void releaseContentsIntoVector(StatementVector& destination) + { + ASSERT(destination.isEmpty()); + m_statements.swap(destination); + } + + private: + StatementVector m_statements; + }; + + class BlockNode : public StatementNode { + public: + BlockNode(SourceElements* children) KJS_FAST_CALL; + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + protected: + StatementVector m_children; + }; + + class EmptyStatementNode : public StatementNode { + public: + EmptyStatementNode() KJS_FAST_CALL // debug + { + } + + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual bool isEmptyStatement() const KJS_FAST_CALL { return true; } + }; + + class ExprStatementNode : public StatementNode { + public: + ExprStatementNode(ExpressionNode* expr) KJS_FAST_CALL + : m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_expr; + }; + + class VarStatementNode : public StatementNode { + public: + VarStatementNode(ExpressionNode* expr) KJS_FAST_CALL + : m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_expr; + }; + + class IfNode : public StatementNode { + public: + IfNode(ExpressionNode* condition, StatementNode* ifBlock) KJS_FAST_CALL + : m_condition(condition) + , m_ifBlock(ifBlock) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + protected: + RefPtr m_condition; + RefPtr m_ifBlock; + }; + + class IfElseNode : public IfNode { + public: + IfElseNode(ExpressionNode* condtion, StatementNode* ifBlock, StatementNode* elseBlock) KJS_FAST_CALL + : IfNode(condtion, ifBlock) + , m_elseBlock(elseBlock) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_elseBlock; + }; + + class DoWhileNode : public StatementNode { + public: + DoWhileNode(StatementNode* statement, ExpressionNode* expr) KJS_FAST_CALL + : m_statement(statement) + , m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_statement; + RefPtr m_expr; + }; + + class WhileNode : public StatementNode { + public: + WhileNode(ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL + : m_expr(expr) + , m_statement(statement) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_expr; + RefPtr m_statement; + }; + + class ForNode : public StatementNode { + public: + ForNode(ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, bool expr1WasVarDecl) KJS_FAST_CALL + : m_expr1(expr1 ? expr1 : new PlaceholderTrueNode) + , m_expr2(expr2 ? expr2 : new PlaceholderTrueNode) + , m_expr3(expr3 ? expr3 : new PlaceholderTrueNode) + , m_statement(statement) + , m_expr1WasVarDecl(expr1 && expr1WasVarDecl) + { + ASSERT(m_expr1); + ASSERT(m_expr2); + ASSERT(m_expr3); + ASSERT(statement); + + m_expr1->optimizeForUnnecessaryResult(); + m_expr3->optimizeForUnnecessaryResult(); + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_expr1; + RefPtr m_expr2; + RefPtr m_expr3; + RefPtr m_statement; + bool m_expr1WasVarDecl; + }; + + class ForInNode : public StatementNode { + public: + ForInNode(ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL; + ForInNode(const Identifier&, ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL; + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + Identifier m_ident; + RefPtr m_init; + RefPtr m_lexpr; + RefPtr m_expr; + RefPtr m_statement; + bool m_identIsVarDecl; + }; + + class ContinueNode : public StatementNode { + public: + ContinueNode() KJS_FAST_CALL + { + } + + ContinueNode(const Identifier& ident) KJS_FAST_CALL + : m_ident(ident) + { + } + + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + Identifier m_ident; + }; + + class BreakNode : public StatementNode { + public: + BreakNode() KJS_FAST_CALL + { + } + + BreakNode(const Identifier& ident) KJS_FAST_CALL + : m_ident(ident) + { + } + + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + Identifier m_ident; + }; + + class ReturnNode : public StatementNode { + public: + ReturnNode(ExpressionNode* value) KJS_FAST_CALL + : m_value(value) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_value; + }; + + class WithNode : public StatementNode { + public: + WithNode(ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL + : m_expr(expr) + , m_statement(statement) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_expr; + RefPtr m_statement; + }; + + class LabelNode : public StatementNode { + public: + LabelNode(const Identifier& label, StatementNode* statement) KJS_FAST_CALL + : m_label(label) + , m_statement(statement) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + Identifier m_label; + RefPtr m_statement; + }; + + class ThrowNode : public StatementNode { + public: + ThrowNode(ExpressionNode* expr) KJS_FAST_CALL + : m_expr(expr) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_expr; + }; + + class TryNode : public StatementNode { + public: + TryNode(StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, StatementNode* finallyBlock) KJS_FAST_CALL + : m_tryBlock(tryBlock) + , m_exceptionIdent(exceptionIdent) + , m_catchBlock(catchBlock) + , m_finallyBlock(finallyBlock) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_tryBlock; + Identifier m_exceptionIdent; + RefPtr m_catchBlock; + RefPtr m_finallyBlock; + }; + + class ParameterNode : public Node { + public: + ParameterNode(const Identifier& ident) KJS_FAST_CALL + : m_ident(ident) + { + } + + ParameterNode(ParameterNode* l, const Identifier& ident) KJS_FAST_CALL + : m_ident(ident) + { + l->m_next = this; + } + + Identifier ident() KJS_FAST_CALL { return m_ident; } + ParameterNode *nextParam() KJS_FAST_CALL { return m_next.get(); } + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + + private: + friend class FuncDeclNode; + friend class FuncExprNode; + Identifier m_ident; + ListRefPtr m_next; + }; + + class ScopeNode : public BlockNode { + public: + ScopeNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; + + int sourceId() const KJS_FAST_CALL { return m_sourceId; } + const UString& sourceURL() const KJS_FAST_CALL { return m_sourceURL; } + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + protected: + void optimizeVariableAccess(ExecState*) KJS_FAST_CALL; + + VarStack m_varStack; + FunctionStack m_functionStack; + + private: + UString m_sourceURL; + int m_sourceId; + }; + + class ProgramNode : public ScopeNode { + public: + static ProgramNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; + + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + + private: + ProgramNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; + + void initializeSymbolTable(ExecState*) KJS_FAST_CALL; + ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; + + Vector m_varIndexes; // Storage indexes belonging to the nodes in m_varStack. (Recorded to avoid double lookup.) + Vector m_functionIndexes; // Storage indexes belonging to the nodes in m_functionStack. (Recorded to avoid double lookup.) + }; + + class EvalNode : public ScopeNode { + public: + static EvalNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; + + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + + private: + EvalNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; + + ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; + }; + + class FunctionBodyNode : public ScopeNode { + public: + static FunctionBodyNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; + + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + + SymbolTable& symbolTable() KJS_FAST_CALL { return m_symbolTable; } + + Vector& parameters() KJS_FAST_CALL { return m_parameters; } + UString paramString() const KJS_FAST_CALL; + + protected: + FunctionBodyNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; + + private: + void initializeSymbolTable(ExecState*) KJS_FAST_CALL; + ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; + + bool m_initialized; + Vector m_parameters; + SymbolTable m_symbolTable; + }; + + class FuncExprNode : public ExpressionNode { + public: + FuncExprNode(const Identifier& ident, FunctionBodyNode* body, ParameterNode* parameter = 0) KJS_FAST_CALL + : m_ident(ident) + , m_parameter(parameter) + , m_body(body) + { + addParams(); + } + + virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { return PrecMember; } + virtual bool needsParensIfLeftmost() const { return true; } + + private: + void addParams() KJS_FAST_CALL; + + // Used for streamTo + friend class PropertyNode; + Identifier m_ident; + RefPtr m_parameter; + RefPtr m_body; + }; + + class FuncDeclNode : public StatementNode { + public: + FuncDeclNode(const Identifier& ident, FunctionBodyNode* body) KJS_FAST_CALL + : m_ident(ident) + , m_body(body) + { + addParams(); + } + + FuncDeclNode(const Identifier& ident, ParameterNode* parameter, FunctionBodyNode* body) KJS_FAST_CALL + : m_ident(ident) + , m_parameter(parameter) + , m_body(body) + { + addParams(); + } + + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + ALWAYS_INLINE FunctionImp* makeFunction(ExecState*) KJS_FAST_CALL; + + Identifier m_ident; + + private: + void addParams() KJS_FAST_CALL; + + RefPtr m_parameter; + RefPtr m_body; + }; + + class CaseClauseNode : public Node { + public: + CaseClauseNode(ExpressionNode* expr) KJS_FAST_CALL + : m_expr(expr) + { + } + + CaseClauseNode(ExpressionNode* expr, SourceElements* children) KJS_FAST_CALL + : m_expr(expr) + { + if (children) + children->releaseContentsIntoVector(m_children); + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + + JSValue* evaluate(ExecState*) KJS_FAST_CALL; + JSValue* executeStatements(ExecState*) KJS_FAST_CALL; + + private: + RefPtr m_expr; + StatementVector m_children; + }; + + class ClauseListNode : public Node { + public: + ClauseListNode(CaseClauseNode* clause) KJS_FAST_CALL + : m_clause(clause) + { + } + + ClauseListNode(ClauseListNode* clauseList, CaseClauseNode* clause) KJS_FAST_CALL + : m_clause(clause) + { + clauseList->m_next = this; + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + CaseClauseNode* getClause() const KJS_FAST_CALL { return m_clause.get(); } + ClauseListNode* getNext() const KJS_FAST_CALL { return m_next.get(); } + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + + private: + friend class CaseBlockNode; + RefPtr m_clause; + ListRefPtr m_next; + }; + + class CaseBlockNode : public Node { + public: + CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2) KJS_FAST_CALL; + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + JSValue* executeBlock(ExecState*, JSValue *input) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } + + private: + RefPtr m_list1; + RefPtr m_defaultClause; + RefPtr m_list2; + }; + + class SwitchNode : public StatementNode { + public: + SwitchNode(ExpressionNode* expr, CaseBlockNode* block) KJS_FAST_CALL + : m_expr(expr) + , m_block(block) + { + } + + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + + private: + RefPtr m_expr; + RefPtr m_block; + }; + + class BreakpointCheckStatement : public StatementNode { + public: + BreakpointCheckStatement(PassRefPtr) KJS_FAST_CALL; + + virtual JSValue* execute(ExecState*) KJS_FAST_CALL; + virtual void streamTo(SourceStream&) const KJS_FAST_CALL; + virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; + + private: + RefPtr m_statement; + }; + + struct ElementList { + ElementNode* head; + ElementNode* tail; + }; + + struct PropertyList { + PropertyListNode* head; + PropertyListNode* tail; + }; + + struct ArgumentList { + ArgumentListNode* head; + ArgumentListNode* tail; + }; + + struct ConstDeclList { + ConstDeclNode* head; + ConstDeclNode* tail; + }; + + struct ParameterList { + ParameterNode* head; + ParameterNode* tail; + }; + + struct ClauseList { + ClauseListNode* head; + ClauseListNode* tail; + }; + +} // namespace KJS + +#endif // NODES_H_ diff --git a/kjs/nodes2string.cpp b/kjs/nodes2string.cpp new file mode 100644 index 0000000..b10e180 --- /dev/null +++ b/kjs/nodes2string.cpp @@ -0,0 +1,973 @@ +/* + * Copyright (C) 2002 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "nodes.h" + +#include +#include +#include + +using namespace WTF; +using namespace Unicode; + +namespace KJS { + +// A simple text streaming class that helps with code indentation. + +enum EndlType { Endl }; +enum IndentType { Indent }; +enum UnindentType { Unindent }; +enum DotExprType { DotExpr }; + +class SourceStream { +public: + SourceStream() + : m_numberNeedsParens(false) + , m_atStartOfStatement(true) + , m_precedence(PrecExpression) + { + } + + UString toString() const { return m_string; } + + SourceStream& operator<<(const Identifier&); + SourceStream& operator<<(const UString&); + SourceStream& operator<<(const char*); + SourceStream& operator<<(double); + SourceStream& operator<<(char); + SourceStream& operator<<(EndlType); + SourceStream& operator<<(IndentType); + SourceStream& operator<<(UnindentType); + SourceStream& operator<<(DotExprType); + SourceStream& operator<<(Precedence); + SourceStream& operator<<(const Node*); + template SourceStream& operator<<(const RefPtr& n) { return *this << n.get(); } + +private: + UString m_string; + UString m_spacesForIndentation; + bool m_numberNeedsParens; + bool m_atStartOfStatement; + Precedence m_precedence; +}; + +// -------- + +static UString escapeStringForPrettyPrinting(const UString& s) +{ + UString escapedString; + + for (int i = 0; i < s.size(); i++) { + unsigned short c = s.data()[i].unicode(); + switch (c) { + case '\"': + escapedString += "\\\""; + break; + case '\n': + escapedString += "\\n"; + break; + case '\r': + escapedString += "\\r"; + break; + case '\t': + escapedString += "\\t"; + break; + case '\\': + escapedString += "\\\\"; + break; + default: + if (c < 128 && isPrintableChar(c)) + escapedString.append(c); + else { + char hexValue[7]; + snprintf(hexValue, 7, "\\u%04x", c); + escapedString += hexValue; + } + } + } + + return escapedString; +} + +static const char* operatorString(Operator oper) +{ + switch (oper) { + case OpEqual: + return "="; + case OpMultEq: + return "*="; + case OpDivEq: + return "/="; + case OpPlusEq: + return "+="; + case OpMinusEq: + return "-="; + case OpLShift: + return "<<="; + case OpRShift: + return ">>="; + case OpURShift: + return ">>>="; + case OpAndEq: + return "&="; + case OpXOrEq: + return "^="; + case OpOrEq: + return "|="; + case OpModEq: + return "%="; + case OpPlusPlus: + return "++"; + case OpMinusMinus: + return "--"; + } + ASSERT_NOT_REACHED(); + return "???"; +} + +static bool isParserRoundTripNumber(const UString& string) +{ + double number = string.toDouble(false, false); + if (isnan(number) || isinf(number)) + return false; + return string == UString::from(number); +} + +// -------- + +SourceStream& SourceStream::operator<<(char c) +{ + m_numberNeedsParens = false; + m_atStartOfStatement = false; + UChar ch(c); + m_string.append(ch); + return *this; +} + +SourceStream& SourceStream::operator<<(const char* s) +{ + m_numberNeedsParens = false; + m_atStartOfStatement = false; + m_string += s; + return *this; +} + +SourceStream& SourceStream::operator<<(double value) +{ + bool needParens = m_numberNeedsParens; + m_numberNeedsParens = false; + m_atStartOfStatement = false; + + if (needParens) + m_string.append('('); + m_string += UString::from(value); + if (needParens) + m_string.append(')'); + + return *this; +} + +SourceStream& SourceStream::operator<<(const UString& s) +{ + m_numberNeedsParens = false; + m_atStartOfStatement = false; + m_string += s; + return *this; +} + +SourceStream& SourceStream::operator<<(const Identifier& s) +{ + m_numberNeedsParens = false; + m_atStartOfStatement = false; + m_string += s.ustring(); + return *this; +} + +SourceStream& SourceStream::operator<<(const Node* n) +{ + bool needParens = (m_precedence != PrecExpression && n->precedence() > m_precedence) || (m_atStartOfStatement && n->needsParensIfLeftmost()); + m_precedence = PrecExpression; + if (!n) + return *this; + if (needParens) { + m_numberNeedsParens = false; + m_string.append('('); + } + n->streamTo(*this); + if (needParens) + m_string.append(')'); + return *this; +} + +SourceStream& SourceStream::operator<<(EndlType) +{ + m_numberNeedsParens = false; + m_atStartOfStatement = true; + m_string.append('\n'); + m_string.append(m_spacesForIndentation); + return *this; +} + +SourceStream& SourceStream::operator<<(IndentType) +{ + m_numberNeedsParens = false; + m_atStartOfStatement = false; + m_spacesForIndentation += " "; + return *this; +} + +SourceStream& SourceStream::operator<<(UnindentType) +{ + m_numberNeedsParens = false; + m_atStartOfStatement = false; + m_spacesForIndentation = m_spacesForIndentation.substr(0, m_spacesForIndentation.size() - 2); + return *this; +} + +inline SourceStream& SourceStream::operator<<(DotExprType) +{ + m_numberNeedsParens = true; + return *this; +} + +inline SourceStream& SourceStream::operator<<(Precedence precedence) +{ + m_precedence = precedence; + return *this; +} + +static void streamLeftAssociativeBinaryOperator(SourceStream& s, Precedence precedence, + const char* operatorString, const Node* left, const Node* right) +{ + s << precedence << left + << ' ' << operatorString << ' ' + << static_cast(precedence - 1) << right; +} + +template static inline void streamLeftAssociativeBinaryOperator(SourceStream& s, + Precedence p, const char* o, const RefPtr& l, const RefPtr& r) +{ + streamLeftAssociativeBinaryOperator(s, p, o, l.get(), r.get()); +} + +static inline void bracketNodeStreamTo(SourceStream& s, const RefPtr& base, const RefPtr& subscript) +{ + s << PrecCall << base.get() << "[" << subscript.get() << "]"; +} + +static inline void dotNodeStreamTo(SourceStream& s, const RefPtr& base, const Identifier& ident) +{ + s << DotExpr << PrecCall << base.get() << "." << ident; +} + +// -------- + +UString Node::toString() const +{ + SourceStream stream; + streamTo(stream); + return stream.toString(); +} + +// -------- + +void NullNode::streamTo(SourceStream& s) const +{ + s << "null"; +} + +void FalseNode::streamTo(SourceStream& s) const +{ + s << "false"; +} + +void TrueNode::streamTo(SourceStream& s) const +{ + s << "true"; +} + +void PlaceholderTrueNode::streamTo(SourceStream&) const +{ +} + +void NumberNode::streamTo(SourceStream& s) const +{ + s << value(); +} + +void StringNode::streamTo(SourceStream& s) const +{ + s << '"' << escapeStringForPrettyPrinting(m_value) << '"'; +} + +void RegExpNode::streamTo(SourceStream& s) const +{ + s << '/' << m_regExp->pattern() << '/' << m_regExp->flags(); +} + +void ThisNode::streamTo(SourceStream& s) const +{ + s << "this"; +} + +void ResolveNode::streamTo(SourceStream& s) const +{ + s << m_ident; +} + +void ElementNode::streamTo(SourceStream& s) const +{ + for (const ElementNode* n = this; n; n = n->m_next.get()) { + for (int i = 0; i < n->m_elision; i++) + s << ','; + s << PrecAssignment << n->m_node; + if (n->m_next) + s << ','; + } +} + +void ArrayNode::streamTo(SourceStream& s) const +{ + s << '[' << m_element; + for (int i = 0; i < m_elision; i++) + s << ','; + // Parser consumes one elision comma if there's array elements + // present in the expression. + if (m_optional && m_element) + s << ','; + s << ']'; +} + +void ObjectLiteralNode::streamTo(SourceStream& s) const +{ + if (m_list) + s << "{ " << m_list << " }"; + else + s << "{ }"; +} + +void PropertyListNode::streamTo(SourceStream& s) const +{ + s << m_node; + for (const PropertyListNode* n = m_next.get(); n; n = n->m_next.get()) + s << ", " << n->m_node; +} + +void PropertyNode::streamTo(SourceStream& s) const +{ + switch (m_type) { + case Constant: { + UString propertyName = name().ustring(); + if (isParserRoundTripNumber(propertyName)) + s << propertyName; + else + s << '"' << escapeStringForPrettyPrinting(propertyName) << '"'; + s << ": " << PrecAssignment << m_assign; + break; + } + case Getter: + case Setter: { + const FuncExprNode* func = static_cast(m_assign.get()); + if (m_type == Getter) + s << "get "; + else + s << "set "; + s << escapeStringForPrettyPrinting(name().ustring()) + << "(" << func->m_parameter << ')' << func->m_body; + break; + } + } +} + +void BracketAccessorNode::streamTo(SourceStream& s) const +{ + bracketNodeStreamTo(s, m_base, m_subscript); +} + +void DotAccessorNode::streamTo(SourceStream& s) const +{ + dotNodeStreamTo(s, m_base, m_ident); +} + +void ArgumentListNode::streamTo(SourceStream& s) const +{ + s << PrecAssignment << m_expr; + for (ArgumentListNode* n = m_next.get(); n; n = n->m_next.get()) + s << ", " << PrecAssignment << n->m_expr; +} + +void ArgumentsNode::streamTo(SourceStream& s) const +{ + s << '(' << m_listNode << ')'; +} + +void NewExprNode::streamTo(SourceStream& s) const +{ + s << "new " << PrecMember << m_expr << m_args; +} + +void FunctionCallValueNode::streamTo(SourceStream& s) const +{ + s << PrecCall << m_expr << m_args; +} + +void FunctionCallResolveNode::streamTo(SourceStream& s) const +{ + s << m_ident << m_args; +} + +void FunctionCallBracketNode::streamTo(SourceStream& s) const +{ + bracketNodeStreamTo(s, m_base, m_subscript); + s << m_args; +} + +void FunctionCallDotNode::streamTo(SourceStream& s) const +{ + dotNodeStreamTo(s, m_base, m_ident); + s << m_args; +} + +void PostIncResolveNode::streamTo(SourceStream& s) const +{ + s << m_ident << "++"; +} + +void PostDecResolveNode::streamTo(SourceStream& s) const +{ + s << m_ident << "--"; +} + +void PostIncBracketNode::streamTo(SourceStream& s) const +{ + bracketNodeStreamTo(s, m_base, m_subscript); + s << "++"; +} + +void PostDecBracketNode::streamTo(SourceStream& s) const +{ + bracketNodeStreamTo(s, m_base, m_subscript); + s << "--"; +} + +void PostIncDotNode::streamTo(SourceStream& s) const +{ + dotNodeStreamTo(s, m_base, m_ident); + s << "++"; +} + +void PostDecDotNode::streamTo(SourceStream& s) const +{ + dotNodeStreamTo(s, m_base, m_ident); + s << "--"; +} + +void PostfixErrorNode::streamTo(SourceStream& s) const +{ + s << PrecLeftHandSide << m_expr; + if (m_operator == OpPlusPlus) + s << "++"; + else + s << "--"; +} + +void DeleteResolveNode::streamTo(SourceStream& s) const +{ + s << "delete " << m_ident; +} + +void DeleteBracketNode::streamTo(SourceStream& s) const +{ + s << "delete "; + bracketNodeStreamTo(s, m_base, m_subscript); +} + +void DeleteDotNode::streamTo(SourceStream& s) const +{ + s << "delete "; + dotNodeStreamTo(s, m_base, m_ident); +} + +void DeleteValueNode::streamTo(SourceStream& s) const +{ + s << "delete " << PrecUnary << m_expr; +} + +void VoidNode::streamTo(SourceStream& s) const +{ + s << "void " << PrecUnary << m_expr; +} + +void TypeOfValueNode::streamTo(SourceStream& s) const +{ + s << "typeof " << PrecUnary << m_expr; +} + +void TypeOfResolveNode::streamTo(SourceStream& s) const +{ + s << "typeof " << m_ident; +} + +void PreIncResolveNode::streamTo(SourceStream& s) const +{ + s << "++" << m_ident; +} + +void PreDecResolveNode::streamTo(SourceStream& s) const +{ + s << "--" << m_ident; +} + +void PreIncBracketNode::streamTo(SourceStream& s) const +{ + s << "++"; + bracketNodeStreamTo(s, m_base, m_subscript); +} + +void PreDecBracketNode::streamTo(SourceStream& s) const +{ + s << "--"; + bracketNodeStreamTo(s, m_base, m_subscript); +} + +void PreIncDotNode::streamTo(SourceStream& s) const +{ + s << "++"; + dotNodeStreamTo(s, m_base, m_ident); +} + +void PreDecDotNode::streamTo(SourceStream& s) const +{ + s << "--"; + dotNodeStreamTo(s, m_base, m_ident); +} + +void PrefixErrorNode::streamTo(SourceStream& s) const +{ + if (m_operator == OpPlusPlus) + s << "++" << PrecUnary << m_expr; + else + s << "--" << PrecUnary << m_expr; +} + +void UnaryPlusNode::streamTo(SourceStream& s) const +{ + s << "+ " << PrecUnary << m_expr; +} + +void NegateNode::streamTo(SourceStream& s) const +{ + s << "- " << PrecUnary << m_expr; +} + +void BitwiseNotNode::streamTo(SourceStream& s) const +{ + s << "~" << PrecUnary << m_expr; +} + +void LogicalNotNode::streamTo(SourceStream& s) const +{ + s << "!" << PrecUnary << m_expr; +} + +void MultNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "*", m_term1, m_term2); +} + +void DivNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "/", m_term1, m_term2); +} + +void ModNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "%", m_term1, m_term2); +} + +void AddNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "+", m_term1, m_term2); +} + +void SubNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "-", m_term1, m_term2); +} + +void LeftShiftNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "<<", m_term1, m_term2); +} + +void RightShiftNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), ">>", m_term1, m_term2); +} + +void UnsignedRightShiftNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), ">>>", m_term1, m_term2); +} + +void LessNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "<", m_expr1, m_expr2); +} + +void GreaterNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), ">", m_expr1, m_expr2); +} + +void LessEqNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "<=", m_expr1, m_expr2); +} + +void GreaterEqNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), ">=", m_expr1, m_expr2); +} + +void InstanceOfNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "instanceof", m_expr1, m_expr2); +} + +void InNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "in", m_expr1, m_expr2); +} + +void EqualNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "==", m_expr1, m_expr2); +} + +void NotEqualNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "!=", m_expr1, m_expr2); +} + +void StrictEqualNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "===", m_expr1, m_expr2); +} + +void NotStrictEqualNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "!==", m_expr1, m_expr2); +} + +void BitAndNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "&", m_expr1, m_expr2); +} + +void BitXOrNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "^", m_expr1, m_expr2); +} + +void BitOrNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "|", m_expr1, m_expr2); +} + +void LogicalAndNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "&&", m_expr1, m_expr2); +} + +void LogicalOrNode::streamTo(SourceStream& s) const +{ + streamLeftAssociativeBinaryOperator(s, precedence(), "||", m_expr1, m_expr2); +} + +void ConditionalNode::streamTo(SourceStream& s) const +{ + s << PrecLogicalOr << m_logical + << " ? " << PrecAssignment << m_expr1 + << " : " << PrecAssignment << m_expr2; +} + +void ReadModifyResolveNode::streamTo(SourceStream& s) const +{ + s << m_ident << ' ' << operatorString(m_operator) << ' ' << PrecAssignment << m_right; +} + +void AssignResolveNode::streamTo(SourceStream& s) const +{ + s << m_ident << " = " << PrecAssignment << m_right; +} + +void ReadModifyBracketNode::streamTo(SourceStream& s) const +{ + bracketNodeStreamTo(s, m_base, m_subscript); + s << ' ' << operatorString(m_operator) << ' ' << PrecAssignment << m_right; +} + +void AssignBracketNode::streamTo(SourceStream& s) const +{ + bracketNodeStreamTo(s, m_base, m_subscript); + s << " = " << PrecAssignment << m_right; +} + +void ReadModifyDotNode::streamTo(SourceStream& s) const +{ + dotNodeStreamTo(s, m_base, m_ident); + s << ' ' << operatorString(m_operator) << ' ' << PrecAssignment << m_right; +} + +void AssignDotNode::streamTo(SourceStream& s) const +{ + dotNodeStreamTo(s, m_base, m_ident); + s << " = " << PrecAssignment << m_right; +} + +void AssignErrorNode::streamTo(SourceStream& s) const +{ + s << PrecLeftHandSide << m_left << ' ' + << operatorString(m_operator) << ' ' << PrecAssignment << m_right; +} + +void CommaNode::streamTo(SourceStream& s) const +{ + s << PrecAssignment << m_expr1 << ", " << PrecAssignment << m_expr2; +} + +void ConstDeclNode::streamTo(SourceStream& s) const +{ + s << m_ident; + if (m_init) + s << " = " << m_init; + for (ConstDeclNode* n = m_next.get(); n; n = n->m_next.get()) { + s << ", " << m_ident; + if (m_init) + s << " = " << m_init; + } +} + +void ConstStatementNode::streamTo(SourceStream& s) const +{ + s << Endl << "const " << m_next << ';'; +} + +static inline void statementListStreamTo(const Vector >& nodes, SourceStream& s) +{ + for (Vector >::const_iterator ptr = nodes.begin(); ptr != nodes.end(); ptr++) + s << *ptr; +} + +void BlockNode::streamTo(SourceStream& s) const +{ + s << Endl << "{" << Indent; + statementListStreamTo(m_children, s); + s << Unindent << Endl << "}"; +} + +void ScopeNode::streamTo(SourceStream& s) const +{ + s << Endl << "{" << Indent; + + bool printedVar = false; + for (size_t i = 0; i < m_varStack.size(); ++i) { + if (m_varStack[i].second == 0) { + if (!printedVar) { + s << Endl << "var "; + printedVar = true; + } else + s << ", "; + s << m_varStack[i].first; + } + } + if (printedVar) + s << ';'; + + statementListStreamTo(m_children, s); + s << Unindent << Endl << "}"; +} + +void EmptyStatementNode::streamTo(SourceStream& s) const +{ + s << Endl << ';'; +} + +void ExprStatementNode::streamTo(SourceStream& s) const +{ + s << Endl << m_expr << ';'; +} + +void VarStatementNode::streamTo(SourceStream& s) const +{ + s << Endl << "var " << m_expr << ';'; +} + +void IfNode::streamTo(SourceStream& s) const +{ + s << Endl << "if (" << m_condition << ')' << Indent << m_ifBlock << Unindent; +} + +void IfElseNode::streamTo(SourceStream& s) const +{ + IfNode::streamTo(s); + s << Endl << "else" << Indent << m_elseBlock << Unindent; +} + +void DoWhileNode::streamTo(SourceStream& s) const +{ + s << Endl << "do " << Indent << m_statement << Unindent << Endl + << "while (" << m_expr << ");"; +} + +void WhileNode::streamTo(SourceStream& s) const +{ + s << Endl << "while (" << m_expr << ')' << Indent << m_statement << Unindent; +} + +void ForNode::streamTo(SourceStream& s) const +{ + s << Endl << "for (" + << (m_expr1WasVarDecl ? "var " : "") + << m_expr1 + << "; " << m_expr2 + << "; " << m_expr3 + << ')' << Indent << m_statement << Unindent; +} + +void ForInNode::streamTo(SourceStream& s) const +{ + s << Endl << "for ("; + if (m_identIsVarDecl) { + s << "var "; + if (m_init) + s << m_init; + else + s << PrecLeftHandSide << m_lexpr; + } else + s << PrecLeftHandSide << m_lexpr; + + s << " in " << m_expr << ')' << Indent << m_statement << Unindent; +} + +void ContinueNode::streamTo(SourceStream& s) const +{ + s << Endl << "continue"; + if (!m_ident.isNull()) + s << ' ' << m_ident; + s << ';'; +} + +void BreakNode::streamTo(SourceStream& s) const +{ + s << Endl << "break"; + if (!m_ident.isNull()) + s << ' ' << m_ident; + s << ';'; +} + +void ReturnNode::streamTo(SourceStream& s) const +{ + s << Endl << "return"; + if (m_value) + s << ' ' << m_value; + s << ';'; +} + +void WithNode::streamTo(SourceStream& s) const +{ + s << Endl << "with (" << m_expr << ") " << m_statement; +} + +void CaseClauseNode::streamTo(SourceStream& s) const +{ + s << Endl; + if (m_expr) + s << "case " << m_expr; + else + s << "default"; + s << ":" << Indent; + statementListStreamTo(m_children, s); + s << Unindent; +} + +void ClauseListNode::streamTo(SourceStream& s) const +{ + for (const ClauseListNode* n = this; n; n = n->getNext()) + s << n->getClause(); +} + +void CaseBlockNode::streamTo(SourceStream& s) const +{ + for (const ClauseListNode* n = m_list1.get(); n; n = n->getNext()) + s << n->getClause(); + s << m_defaultClause; + for (const ClauseListNode* n = m_list2.get(); n; n = n->getNext()) + s << n->getClause(); +} + +void SwitchNode::streamTo(SourceStream& s) const +{ + s << Endl << "switch (" << m_expr << ") {" + << Indent << m_block << Unindent + << Endl << "}"; +} + +void LabelNode::streamTo(SourceStream& s) const +{ + s << Endl << m_label << ":" << Indent << m_statement << Unindent; +} + +void ThrowNode::streamTo(SourceStream& s) const +{ + s << Endl << "throw " << m_expr << ';'; +} + +void TryNode::streamTo(SourceStream& s) const +{ + s << Endl << "try " << m_tryBlock; + if (m_catchBlock) + s << Endl << "catch (" << m_exceptionIdent << ')' << m_catchBlock; + if (m_finallyBlock) + s << Endl << "finally " << m_finallyBlock; +} + +void ParameterNode::streamTo(SourceStream& s) const +{ + s << m_ident; + for (ParameterNode* n = m_next.get(); n; n = n->m_next.get()) + s << ", " << n->m_ident; +} + +void FuncDeclNode::streamTo(SourceStream& s) const +{ + s << Endl << "function " << m_ident << '(' << m_parameter << ')' << m_body; +} + +void FuncExprNode::streamTo(SourceStream& s) const +{ + s << "function " << m_ident << '(' << m_parameter << ')' << m_body; +} + +} // namespace KJS diff --git a/kjs/number_object.cpp b/kjs/number_object.cpp new file mode 100644 index 0000000..f17447e --- /dev/null +++ b/kjs/number_object.cpp @@ -0,0 +1,525 @@ +/* + * Copyright (C) 1999-2000,2003 Harri Porten (porten@kde.org) + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + */ + +#include "config.h" +#include "number_object.h" +#include "number_object.lut.h" + +#include "dtoa.h" +#include "error_object.h" +#include "operations.h" +#include +#include +#include + +namespace KJS { + +// ------------------------------ NumberInstance ---------------------------- + +const ClassInfo NumberInstance::info = { "Number", 0, 0 }; + +NumberInstance::NumberInstance(JSObject* proto) + : JSWrapperObject(proto) +{ +} + +// ------------------------------ NumberPrototype --------------------------- + +static JSValue* numberProtoFuncToString(ExecState*, JSObject*, const List&); +static JSValue* numberProtoFuncToLocaleString(ExecState*, JSObject*, const List&); +static JSValue* numberProtoFuncValueOf(ExecState*, JSObject*, const List&); +static JSValue* numberProtoFuncToFixed(ExecState*, JSObject*, const List&); +static JSValue* numberProtoFuncToExponential(ExecState*, JSObject*, const List&); +static JSValue* numberProtoFuncToPrecision(ExecState*, JSObject*, const List&); + +// ECMA 15.7.4 + +NumberPrototype::NumberPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype) + : NumberInstance(objectPrototype) +{ + setInternalValue(jsNumber(0)); + + // The constructor will be added later, after NumberObjectImp has been constructed + + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum); +} + +// ------------------------------ Functions --------------------------- + +// ECMA 15.7.4.2 - 15.7.4.7 + +static UString integer_part_noexp(double d) +{ + int decimalPoint; + int sign; + char* result = kjs_dtoa(d, 0, 0, &decimalPoint, &sign, NULL); + bool resultIsInfOrNan = (decimalPoint == 9999); + size_t length = strlen(result); + + UString str = sign ? "-" : ""; + if (resultIsInfOrNan) + str += result; + else if (decimalPoint <= 0) + str += "0"; + else { + Vector buf(decimalPoint + 1); + + // FIXME: Remove use of strcpy() and strncpy() + if (static_cast(length) <= decimalPoint) { + strcpy(buf.data(), result); + memset(buf.data() + length, '0', decimalPoint - length); + } else + strncpy(buf.data(), result, decimalPoint); + + buf[decimalPoint] = '\0'; + str += UString(buf.data()); + } + + kjs_freedtoa(result); + + return str; +} + +static UString char_sequence(char c, int count) +{ + Vector buf(count + 1, c); + buf[count] = '\0'; + + return UString(buf.data()); +} + +static double intPow10(int e) +{ + // This function uses the "exponentiation by squaring" algorithm and + // long double to quickly and precisely calculate integer powers of 10.0. + + // This is a handy workaround for + + if (e == 0) + return 1.0; + + bool negative = e < 0; + unsigned exp = negative ? -e : e; + + long double result = 10.0; + bool foundOne = false; + for (int bit = 31; bit >= 0; bit--) { + if (!foundOne) { + if ((exp >> bit) & 1) + foundOne = true; + } else { + result = result * result; + if ((exp >> bit) & 1) + result = result * 10.0; + } + } + + if (negative) + return static_cast(1.0 / result); + return static_cast(result); +} + + +JSValue* numberProtoFuncToString(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&NumberInstance::info)) + return throwError(exec, TypeError); + + JSValue* v = static_cast(thisObj)->internalValue(); + + double radixAsDouble = args[0]->toInteger(exec); // nan -> 0 + if (radixAsDouble == 10 || args[0]->isUndefined()) + return jsString(v->toString(exec)); + + if (radixAsDouble < 2 || radixAsDouble > 36) + return throwError(exec, RangeError, "toString() radix argument must be between 2 and 36"); + + int radix = static_cast(radixAsDouble); + const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; + // INT_MAX results in 1024 characters left of the dot with radix 2 + // give the same space on the right side. safety checks are in place + // unless someone finds a precise rule. + char s[2048 + 3]; + const char* lastCharInString = s + sizeof(s) - 1; + double x = v->toNumber(exec); + if (isnan(x) || isinf(x)) + return jsString(UString::from(x)); + + bool isNegative = x < 0.0; + if (isNegative) + x = -x; + + double integerPart = floor(x); + char* decimalPoint = s + sizeof(s) / 2; + + // convert integer portion + char* p = decimalPoint; + double d = integerPart; + do { + int remainderDigit = static_cast(fmod(d, radix)); + *--p = digits[remainderDigit]; + d /= radix; + } while ((d <= -1.0 || d >= 1.0) && s < p); + + if (isNegative) + *--p = '-'; + char* startOfResultString = p; + ASSERT(s <= startOfResultString); + + d = x - integerPart; + p = decimalPoint; + const double epsilon = 0.001; // TODO: guessed. base on radix ? + bool hasFractionalPart = (d < -epsilon || d > epsilon); + if (hasFractionalPart) { + *p++ = '.'; + do { + d *= radix; + const int digit = static_cast(d); + *p++ = digits[digit]; + d -= digit; + } while ((d < -epsilon || d > epsilon) && p < lastCharInString); + } + *p = '\0'; + ASSERT(p < s + sizeof(s)); + + return jsString(startOfResultString); +} + +JSValue* numberProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&NumberInstance::info)) + return throwError(exec, TypeError); + + // TODO + return jsString(static_cast(thisObj)->internalValue()->toString(exec)); +} + +JSValue* numberProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&NumberInstance::info)) + return throwError(exec, TypeError); + + return static_cast(thisObj)->internalValue()->toJSNumber(exec); +} + +JSValue* numberProtoFuncToFixed(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&NumberInstance::info)) + return throwError(exec, TypeError); + + JSValue* v = static_cast(thisObj)->internalValue(); + + JSValue* fractionDigits = args[0]; + double df = fractionDigits->toInteger(exec); + if (!(df >= 0 && df <= 20)) + return throwError(exec, RangeError, "toFixed() digits argument must be between 0 and 20"); + int f = (int)df; + + double x = v->toNumber(exec); + if (isnan(x)) + return jsString("NaN"); + + UString s; + if (x < 0) { + s.append('-'); + x = -x; + } else if (x == -0.0) + x = 0; + + if (x >= pow(10.0, 21.0)) + return jsString(s + UString::from(x)); + + const double tenToTheF = pow(10.0, f); + double n = floor(x * tenToTheF); + if (fabs(n / tenToTheF - x) >= fabs((n + 1) / tenToTheF - x)) + n++; + + UString m = integer_part_noexp(n); + + int k = m.size(); + if (k <= f) { + UString z; + for (int i = 0; i < f + 1 - k; i++) + z.append('0'); + m = z + m; + k = f + 1; + ASSERT(k == m.size()); + } + int kMinusf = k - f; + if (kMinusf < m.size()) + return jsString(s + m.substr(0, kMinusf) + "." + m.substr(kMinusf)); + return jsString(s + m.substr(0, kMinusf)); +} + +static void fractionalPartToString(char* buf, int& i, const char* result, int resultLength, int fractionalDigits) +{ + if (fractionalDigits <= 0) + return; + + int fDigitsInResult = static_cast(resultLength) - 1; + buf[i++] = '.'; + if (fDigitsInResult > 0) { + if (fractionalDigits < fDigitsInResult) { + strncpy(buf + i, result + 1, fractionalDigits); + i += fractionalDigits; + } else { + // FIXME: Remove use of strcpy() + strcpy(buf + i, result + 1); + i += static_cast(resultLength) - 1; + } + } + + for (int j = 0; j < fractionalDigits - fDigitsInResult; j++) + buf[i++] = '0'; +} + +static void exponentialPartToString(char* buf, int& i, int decimalPoint) +{ + buf[i++] = 'e'; + buf[i++] = (decimalPoint >= 0) ? '+' : '-'; + // decimalPoint can't be more than 3 digits decimal given the + // nature of float representation + int exponential = decimalPoint - 1; + if (exponential < 0) + exponential *= -1; + if (exponential >= 100) + buf[i++] = static_cast('0' + exponential / 100); + if (exponential >= 10) + buf[i++] = static_cast('0' + (exponential % 100) / 10); + buf[i++] = static_cast('0' + exponential % 10); +} + +JSValue* numberProtoFuncToExponential(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&NumberInstance::info)) + return throwError(exec, TypeError); + + JSValue* v = static_cast(thisObj)->internalValue(); + + double x = v->toNumber(exec); + + if (isnan(x) || isinf(x)) + return jsString(UString::from(x)); + + JSValue* fractionalDigitsValue = args[0]; + double df = fractionalDigitsValue->toInteger(exec); + if (!(df >= 0 && df <= 20)) + return throwError(exec, RangeError, "toExponential() argument must between 0 and 20"); + int fractionalDigits = (int)df; + bool includeAllDigits = fractionalDigitsValue->isUndefined(); + + int decimalAdjust = 0; + if (x && !includeAllDigits) { + double logx = floor(log10(fabs(x))); + x /= pow(10.0, logx); + const double tenToTheF = pow(10.0, fractionalDigits); + double fx = floor(x * tenToTheF) / tenToTheF; + double cx = ceil(x * tenToTheF) / tenToTheF; + + if (fabs(fx - x) < fabs(cx - x)) + x = fx; + else + x = cx; + + decimalAdjust = static_cast(logx); + } + + if (isnan(x)) + return jsString("NaN"); + + if (x == -0.0) // (-0.0).toExponential() should print as 0 instead of -0 + x = 0; + + int decimalPoint; + int sign; + char* result = kjs_dtoa(x, 0, 0, &decimalPoint, &sign, NULL); + size_t resultLength = strlen(result); + decimalPoint += decimalAdjust; + + int i = 0; + char buf[80]; // digit + '.' + fractionDigits (max 20) + 'e' + sign + exponent (max?) + if (sign) + buf[i++] = '-'; + + if (decimalPoint == 999) // ? 9999 is the magical "result is Inf or NaN" value. what's 999?? + // FIXME: Remove magic number 80 + strlcpy(buf + i, result, 80 - i); + else { + buf[i++] = result[0]; + + if (includeAllDigits) + fractionalDigits = static_cast(resultLength) - 1; + + fractionalPartToString(buf, i, result, resultLength, fractionalDigits); + exponentialPartToString(buf, i, decimalPoint); + buf[i++] = '\0'; + } + ASSERT(i <= 80); + + kjs_freedtoa(result); + + return jsString(buf); +} + +JSValue* numberProtoFuncToPrecision(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&NumberInstance::info)) + return throwError(exec, TypeError); + + JSValue* v = static_cast(thisObj)->internalValue(); + + double doublePrecision = args[0]->toIntegerPreserveNaN(exec); + double x = v->toNumber(exec); + if (args[0]->isUndefined() || isnan(x) || isinf(x)) + return jsString(v->toString(exec)); + + UString s; + if (x < 0) { + s = "-"; + x = -x; + } + + if (!(doublePrecision >= 1 && doublePrecision <= 21)) // true for NaN + return throwError(exec, RangeError, "toPrecision() argument must be between 1 and 21"); + int precision = (int)doublePrecision; + + int e = 0; + UString m; + if (x) { + e = static_cast(log10(x)); + double tens = intPow10(e - precision + 1); + double n = floor(x / tens); + if (n < intPow10(precision - 1)) { + e = e - 1; + tens = intPow10(e - precision + 1); + n = floor(x / tens); + } + + if (fabs((n + 1.0) * tens - x) <= fabs(n * tens - x)) + ++n; + // maintain n < 10^(precision) + if (n >= intPow10(precision)) { + n /= 10.0; + e += 1; + } + ASSERT(intPow10(precision - 1) <= n); + ASSERT(n < intPow10(precision)); + + m = integer_part_noexp(n); + if (e < -6 || e >= precision) { + if (m.size() > 1) + m = m.substr(0, 1) + "." + m.substr(1); + if (e >= 0) + return jsString(s + m + "e+" + UString::from(e)); + return jsString(s + m + "e-" + UString::from(-e)); + } + } else { + m = char_sequence('0', precision); + e = 0; + } + + if (e == precision - 1) + return jsString(s + m); + if (e >= 0) { + if (e + 1 < m.size()) + return jsString(s + m.substr(0, e + 1) + "." + m.substr(e + 1)); + return jsString(s + m); + } + return jsString(s + "0." + char_sequence('0', -(e + 1)) + m); +} + +// ------------------------------ NumberObjectImp ------------------------------ + +const ClassInfo NumberObjectImp::info = { "Function", &InternalFunctionImp::info, &numberTable }; + +/* Source for number_object.lut.h +@begin numberTable 5 + NaN NumberObjectImp::NaNValue DontEnum|DontDelete|ReadOnly + NEGATIVE_INFINITY NumberObjectImp::NegInfinity DontEnum|DontDelete|ReadOnly + POSITIVE_INFINITY NumberObjectImp::PosInfinity DontEnum|DontDelete|ReadOnly + MAX_VALUE NumberObjectImp::MaxValue DontEnum|DontDelete|ReadOnly + MIN_VALUE NumberObjectImp::MinValue DontEnum|DontDelete|ReadOnly +@end +*/ +NumberObjectImp::NumberObjectImp(ExecState* exec, FunctionPrototype* funcProto, NumberPrototype* numberProto) + : InternalFunctionImp(funcProto, numberProto->classInfo()->className) +{ + // Number.Prototype + putDirect(exec->propertyNames().prototype, numberProto, DontEnum|DontDelete|ReadOnly); + + // no. of arguments for constructor + putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); +} + +bool NumberObjectImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &numberTable, this, propertyName, slot); +} + +JSValue* NumberObjectImp::getValueProperty(ExecState*, int token) const +{ + // ECMA 15.7.3 + switch (token) { + case NaNValue: + return jsNaN(); + case NegInfinity: + return jsNumberCell(-Inf); + case PosInfinity: + return jsNumberCell(Inf); + case MaxValue: + return jsNumberCell(1.7976931348623157E+308); + case MinValue: + return jsNumberCell(5E-324); + } + ASSERT_NOT_REACHED(); + return jsNull(); +} + +bool NumberObjectImp::implementsConstruct() const +{ + return true; +} + +// ECMA 15.7.1 +JSObject* NumberObjectImp::construct(ExecState* exec, const List& args) +{ + JSObject* proto = exec->lexicalGlobalObject()->numberPrototype(); + NumberInstance* obj = new NumberInstance(proto); + + // FIXME: Check args[0]->isUndefined() instead of args.isEmpty()? + double n = args.isEmpty() ? 0 : args[0]->toNumber(exec); + obj->setInternalValue(jsNumber(n)); + return obj; +} + +// ECMA 15.7.2 +JSValue* NumberObjectImp::callAsFunction(ExecState* exec, JSObject*, const List& args) +{ + // FIXME: Check args[0]->isUndefined() instead of args.isEmpty()? + return jsNumber(args.isEmpty() ? 0 : args[0]->toNumber(exec)); +} + +} // namespace KJS diff --git a/kjs/number_object.h b/kjs/number_object.h new file mode 100644 index 0000000..36befed --- /dev/null +++ b/kjs/number_object.h @@ -0,0 +1,76 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef NUMBER_OBJECT_H_ +#define NUMBER_OBJECT_H_ + +#include "function_object.h" +#include "JSWrapperObject.h" + +namespace KJS { + + class NumberInstance : public JSWrapperObject { + public: + NumberInstance(JSObject* prototype); + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + }; + + /** + * @internal + * + * The initial value of Number.prototype (and thus all objects created + * with the Number constructor + */ + class NumberPrototype : public NumberInstance { + public: + NumberPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*); + }; + + /** + * @internal + * + * The initial value of the the global variable's "Number" property + */ + class NumberObjectImp : public InternalFunctionImp { + public: + NumberObjectImp(ExecState*, FunctionPrototype*, NumberPrototype*); + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List&); + + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + + bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + JSValue* getValueProperty(ExecState*, int token) const; + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + + enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue }; + + JSObject* construct(const List&); + }; + +} // namespace KJS + +#endif // NUMBER_OBJECT_H_ diff --git a/kjs/object.cpp b/kjs/object.cpp new file mode 100644 index 0000000..8c6a154 --- /dev/null +++ b/kjs/object.cpp @@ -0,0 +1,681 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2007 Eric Seidel (eric@webkit.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "object.h" + +#include "date_object.h" +#include "error_object.h" +#include "lookup.h" +#include "nodes.h" +#include "operations.h" +#include "PropertyNameArray.h" +#include +#include + +// maximum global call stack size. Protects against accidental or +// malicious infinite recursions. Define to -1 if you want no limit. +// In real-world testing it appears ok to bump the stack depth count to 500. +// This of course is dependent on stack frame size. +#define KJS_MAX_STACK 500 + +#define JAVASCRIPT_CALL_TRACING 0 +#define JAVASCRIPT_MARK_TRACING 0 + +#if JAVASCRIPT_CALL_TRACING +static bool _traceJavaScript = false; + +extern "C" { + void setTraceJavaScript(bool f) + { + _traceJavaScript = f; + } + + static bool traceJavaScript() + { + return _traceJavaScript; + } +} +#endif + +namespace KJS { + +// ------------------------------ Object --------------------------------------- + +JSValue *JSObject::call(ExecState *exec, JSObject *thisObj, const List &args) +{ + ASSERT(implementsCall()); + +#if KJS_MAX_STACK > 0 + static int depth = 0; // sum of all extant function calls + +#if JAVASCRIPT_CALL_TRACING + static bool tracing = false; + if (traceJavaScript() && !tracing) { + tracing = true; + for (int i = 0; i < depth; i++) + putchar (' '); + printf ("*** calling: %s\n", toString(exec).ascii()); + for (int j = 0; j < args.size(); j++) { + for (int i = 0; i < depth; i++) + putchar (' '); + printf ("*** arg[%d] = %s\n", j, args[j]->toString(exec).ascii()); + } + tracing = false; + } +#endif + + if (++depth > KJS_MAX_STACK) { + --depth; + return throwError(exec, RangeError, "Maximum call stack size exceeded."); + } +#endif + + JSValue *ret = callAsFunction(exec,thisObj,args); + +#if KJS_MAX_STACK > 0 + --depth; +#endif + +#if JAVASCRIPT_CALL_TRACING + if (traceJavaScript() && !tracing) { + tracing = true; + for (int i = 0; i < depth; i++) + putchar (' '); + printf ("*** returning: %s\n", ret->toString(exec).ascii()); + tracing = false; + } +#endif + + return ret; +} + +// ------------------------------ JSObject ------------------------------------ + +void JSObject::mark() +{ + JSCell::mark(); + +#if JAVASCRIPT_MARK_TRACING + static int markStackDepth = 0; + markStackDepth++; + for (int i = 0; i < markStackDepth; i++) + putchar('-'); + + printf("%s (%p)\n", className().UTF8String().c_str(), this); +#endif + + JSValue *proto = _proto; + if (!proto->marked()) + proto->mark(); + + _prop.mark(); + +#if JAVASCRIPT_MARK_TRACING + markStackDepth--; +#endif +} + +JSType JSObject::type() const +{ + return ObjectType; +} + +const ClassInfo *JSObject::classInfo() const +{ + return 0; +} + +UString JSObject::className() const +{ + const ClassInfo *ci = classInfo(); + if ( ci ) + return ci->className; + return "Object"; +} + +JSValue *JSObject::get(ExecState *exec, const Identifier &propertyName) const +{ + PropertySlot slot; + + if (const_cast(this)->getPropertySlot(exec, propertyName, slot)) + return slot.getValue(exec, const_cast(this), propertyName); + + return jsUndefined(); +} + +JSValue *JSObject::get(ExecState *exec, unsigned propertyName) const +{ + PropertySlot slot; + if (const_cast(this)->getPropertySlot(exec, propertyName, slot)) + return slot.getValue(exec, const_cast(this), propertyName); + + return jsUndefined(); +} + +bool JSObject::getPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot) +{ + JSObject *imp = this; + + while (true) { + if (imp->getOwnPropertySlot(exec, propertyName, slot)) + return true; + + JSValue *proto = imp->_proto; + if (!proto->isObject()) + break; + + imp = static_cast(proto); + } + + return false; +} + +bool JSObject::getOwnPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot) +{ + return getOwnPropertySlot(exec, Identifier::from(propertyName), slot); +} + +static void throwSetterError(ExecState *exec) +{ + throwError(exec, TypeError, "setting a property that has only a getter"); +} + +// ECMA 8.6.2.2 +void JSObject::put(ExecState* exec, const Identifier &propertyName, JSValue *value, int attr) +{ + ASSERT(value); + + if (propertyName == exec->propertyNames().underscoreProto) { + JSObject* proto = value->getObject(); + while (proto) { + if (proto == this) + throwError(exec, GeneralError, "cyclic __proto__ value"); + proto = proto->prototype() ? proto->prototype()->getObject() : 0; + } + + setPrototype(value); + return; + } + + // The put calls from JavaScript execution either have no attributes set, or in some cases + // have DontDelete set. For those calls, respect the ReadOnly flag. + bool checkReadOnly = !(attr & ~DontDelete); + + // Check if there are any setters or getters in the prototype chain + JSObject *obj = this; + bool hasGettersOrSetters = false; + while (true) { + if (obj->_prop.hasGetterSetterProperties()) { + hasGettersOrSetters = true; + break; + } + + if (!obj->_proto->isObject()) + break; + + obj = static_cast(obj->_proto); + } + + if (hasGettersOrSetters) { + if (checkReadOnly && !canPut(exec, propertyName)) + return; + + obj = this; + while (true) { + unsigned attributes; + if (JSValue *gs = obj->_prop.get(propertyName, attributes)) { + if (attributes & GetterSetter) { + JSObject *setterFunc = static_cast(gs)->getSetter(); + + if (!setterFunc) { + throwSetterError(exec); + return; + } + + List args; + args.append(value); + + setterFunc->call(exec, this, args); + return; + } else { + // If there's an existing property on the object or one of its + // prototype it should be replaced, so we just break here. + break; + } + } + + if (!obj->_proto->isObject()) + break; + + obj = static_cast(obj->_proto); + } + } + + _prop.put(propertyName, value, attr, checkReadOnly); +} + +void JSObject::put(ExecState *exec, unsigned propertyName, + JSValue *value, int attr) +{ + put(exec, Identifier::from(propertyName), value, attr); +} + +// ECMA 8.6.2.3 +bool JSObject::canPut(ExecState *, const Identifier &propertyName) const +{ + unsigned attributes; + + // Don't look in the prototype here. We can always put an override + // in the object, even if the prototype has a ReadOnly property. + // Also, there is no need to check the static property table, as this + // would have been done by the subclass already. + + if (!_prop.get(propertyName, attributes)) + return true; + + return !(attributes & ReadOnly); +} + +// ECMA 8.6.2.4 +bool JSObject::hasProperty(ExecState *exec, const Identifier &propertyName) const +{ + PropertySlot slot; + return const_cast(this)->getPropertySlot(exec, propertyName, slot); +} + +bool JSObject::hasProperty(ExecState *exec, unsigned propertyName) const +{ + PropertySlot slot; + return const_cast(this)->getPropertySlot(exec, propertyName, slot); +} + +// ECMA 8.6.2.5 +bool JSObject::deleteProperty(ExecState* /*exec*/, const Identifier &propertyName) +{ + unsigned attributes; + JSValue *v = _prop.get(propertyName, attributes); + if (v) { + if ((attributes & DontDelete)) + return false; + _prop.remove(propertyName); + if (attributes & GetterSetter) + _prop.setHasGetterSetterProperties(_prop.containsGettersOrSetters()); + return true; + } + + // Look in the static hashtable of properties + const HashEntry* entry = findPropertyHashEntry(propertyName); + if (entry && entry->attr & DontDelete) + return false; // this builtin property can't be deleted + return true; +} + +bool JSObject::hasOwnProperty(ExecState* exec, const Identifier& propertyName) const +{ + PropertySlot slot; + return const_cast(this)->getOwnPropertySlot(exec, propertyName, slot); +} + +bool JSObject::deleteProperty(ExecState *exec, unsigned propertyName) +{ + return deleteProperty(exec, Identifier::from(propertyName)); +} + +static ALWAYS_INLINE JSValue *tryGetAndCallProperty(ExecState *exec, const JSObject *object, const Identifier &propertyName) { + JSValue *v = object->get(exec, propertyName); + if (v->isObject()) { + JSObject *o = static_cast(v); + if (o->implementsCall()) { // spec says "not primitive type" but ... + JSObject *thisObj = const_cast(object); + JSValue* def = o->call(exec, thisObj, exec->emptyList()); + JSType defType = def->type(); + ASSERT(defType != GetterSetterType); + if (defType != ObjectType) + return def; + } + } + return NULL; +} + +bool JSObject::getPrimitiveNumber(ExecState* exec, double& number, JSValue*& result) +{ + result = defaultValue(exec, NumberType); + number = result->toNumber(exec); + return !result->isString(); +} + +// ECMA 8.6.2.6 +JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const +{ + /* Prefer String for Date objects */ + if ((hint == StringType) || (hint != NumberType && _proto == exec->lexicalGlobalObject()->datePrototype())) { + if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().toString)) + return v; + if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().valueOf)) + return v; + } else { + if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().valueOf)) + return v; + if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().toString)) + return v; + } + + if (exec->hadException()) + return exec->exception(); + + return throwError(exec, TypeError, "No default value"); +} + +const HashEntry* JSObject::findPropertyHashEntry(const Identifier& propertyName) const +{ + for (const ClassInfo *info = classInfo(); info; info = info->parentClass) { + if (const HashTable *propHashTable = info->propHashTable) { + if (const HashEntry *e = Lookup::findEntry(propHashTable, propertyName)) + return e; + } + } + return 0; +} + +void JSObject::defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunc) +{ + JSValue *o = getDirect(propertyName); + GetterSetterImp *gs; + + if (o && o->type() == GetterSetterType) { + gs = static_cast(o); + } else { + gs = new GetterSetterImp; + putDirect(propertyName, gs, GetterSetter); + } + + _prop.setHasGetterSetterProperties(true); + gs->setGetter(getterFunc); +} + +void JSObject::defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunc) +{ + JSValue *o = getDirect(propertyName); + GetterSetterImp *gs; + + if (o && o->type() == GetterSetterType) { + gs = static_cast(o); + } else { + gs = new GetterSetterImp; + putDirect(propertyName, gs, GetterSetter); + } + + _prop.setHasGetterSetterProperties(true); + gs->setSetter(setterFunc); +} + +bool JSObject::implementsConstruct() const +{ + return false; +} + +JSObject* JSObject::construct(ExecState*, const List& /*args*/) +{ + ASSERT(false); + return NULL; +} + +JSObject* JSObject::construct(ExecState* exec, const List& args, const Identifier& /*functionName*/, const UString& /*sourceURL*/, int /*lineNumber*/) +{ + return construct(exec, args); +} + +bool JSObject::implementsCall() const +{ + return false; +} + +JSValue *JSObject::callAsFunction(ExecState* /*exec*/, JSObject* /*thisObj*/, const List &/*args*/) +{ + ASSERT(false); + return NULL; +} + +bool JSObject::implementsHasInstance() const +{ + return false; +} + +bool JSObject::hasInstance(ExecState* exec, JSValue* value) +{ + JSValue* proto = get(exec, exec->propertyNames().prototype); + if (!proto->isObject()) { + throwError(exec, TypeError, "intanceof called on an object with an invalid prototype property."); + return false; + } + + if (!value->isObject()) + return false; + + JSObject* o = static_cast(value); + while ((o = o->prototype()->getObject())) { + if (o == proto) + return true; + } + return false; +} + +bool JSObject::propertyIsEnumerable(ExecState*, const Identifier& propertyName) const +{ + unsigned attributes; + + if (!getPropertyAttributes(propertyName, attributes)) + return false; + else + return !(attributes & DontEnum); +} + +bool JSObject::getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const +{ + if (_prop.get(propertyName, attributes)) + return true; + + // Look in the static hashtable of properties + const HashEntry* e = findPropertyHashEntry(propertyName); + if (e) { + attributes = e->attr; + return true; + } + + return false; +} + +void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +{ + _prop.getEnumerablePropertyNames(propertyNames); + + // Add properties from the static hashtable of properties + const ClassInfo *info = classInfo(); + while (info) { + if (info->propHashTable) { + int size = info->propHashTable->size; + const HashEntry *e = info->propHashTable->entries; + for (int i = 0; i < size; ++i, ++e) { + if (e->s && !(e->attr & DontEnum)) + propertyNames.add(e->s); + } + } + info = info->parentClass; + } + if (_proto->isObject()) + static_cast(_proto)->getPropertyNames(exec, propertyNames); +} + +bool JSObject::toBoolean(ExecState*) const +{ + return true; +} + +double JSObject::toNumber(ExecState *exec) const +{ + JSValue *prim = toPrimitive(exec,NumberType); + if (exec->hadException()) // should be picked up soon in nodes.cpp + return 0.0; + return prim->toNumber(exec); +} + +UString JSObject::toString(ExecState *exec) const +{ + JSValue *prim = toPrimitive(exec,StringType); + if (exec->hadException()) // should be picked up soon in nodes.cpp + return ""; + return prim->toString(exec); +} + +JSObject *JSObject::toObject(ExecState*) const +{ + return const_cast(this); +} + +void JSObject::putDirect(const Identifier &propertyName, JSValue *value, int attr) +{ + _prop.put(propertyName, value, attr); +} + +void JSObject::putDirect(const Identifier &propertyName, int value, int attr) +{ + _prop.put(propertyName, jsNumber(value), attr); +} + +void JSObject::removeDirect(const Identifier &propertyName) +{ + _prop.remove(propertyName); +} + +void JSObject::putDirectFunction(InternalFunctionImp* func, int attr) +{ + putDirect(func->functionName(), func, attr); +} + +void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue **location) +{ + GetterSetterImp *gs = static_cast(*location); + JSObject *getterFunc = gs->getGetter(); + if (getterFunc) + slot.setGetterSlot(this, getterFunc); + else + slot.setUndefined(this); +} + +// ------------------------------ Error ---------------------------------------- + +const char * const errorNamesArr[] = { + I18N_NOOP("Error"), // GeneralError + I18N_NOOP("Evaluation error"), // EvalError + I18N_NOOP("Range error"), // RangeError + I18N_NOOP("Reference error"), // ReferenceError + I18N_NOOP("Syntax error"), // SyntaxError + I18N_NOOP("Type error"), // TypeError + I18N_NOOP("URI error"), // URIError +}; + +const char * const * const Error::errorNames = errorNamesArr; + +JSObject *Error::create(ExecState *exec, ErrorType errtype, const UString &message, + int lineno, int sourceId, const UString &sourceURL) +{ + JSObject *cons; + switch (errtype) { + case EvalError: + cons = exec->lexicalGlobalObject()->evalErrorConstructor(); + break; + case RangeError: + cons = exec->lexicalGlobalObject()->rangeErrorConstructor(); + break; + case ReferenceError: + cons = exec->lexicalGlobalObject()->referenceErrorConstructor(); + break; + case SyntaxError: + cons = exec->lexicalGlobalObject()->syntaxErrorConstructor(); + break; + case TypeError: + cons = exec->lexicalGlobalObject()->typeErrorConstructor(); + break; + case URIError: + cons = exec->lexicalGlobalObject()->URIErrorConstructor(); + break; + default: + cons = exec->lexicalGlobalObject()->errorConstructor(); + break; + } + + List args; + if (message.isEmpty()) + args.append(jsString(errorNames[errtype])); + else + args.append(jsString(message)); + JSObject *err = static_cast(cons->construct(exec,args)); + + if (lineno != -1) + err->put(exec, "line", jsNumber(lineno)); + if (sourceId != -1) + err->put(exec, "sourceId", jsNumber(sourceId)); + + if(!sourceURL.isNull()) + err->put(exec, "sourceURL", jsString(sourceURL)); + + return err; +} + +JSObject *Error::create(ExecState *exec, ErrorType type, const char *message) +{ + return create(exec, type, message, -1, -1, NULL); +} + +JSObject *throwError(ExecState *exec, ErrorType type) +{ + JSObject *error = Error::create(exec, type, UString(), -1, -1, NULL); + exec->setException(error); + return error; +} + +JSObject *throwError(ExecState *exec, ErrorType type, const UString &message) +{ + JSObject *error = Error::create(exec, type, message, -1, -1, NULL); + exec->setException(error); + return error; +} + +JSObject *throwError(ExecState *exec, ErrorType type, const char *message) +{ + JSObject *error = Error::create(exec, type, message, -1, -1, NULL); + exec->setException(error); + return error; +} + +JSObject *throwError(ExecState *exec, ErrorType type, const UString &message, int line, int sourceId, const UString &sourceURL) +{ + JSObject *error = Error::create(exec, type, message, line, sourceId, sourceURL); + exec->setException(error); + return error; +} + +} // namespace KJS diff --git a/kjs/object.h b/kjs/object.h new file mode 100644 index 0000000..3807bed --- /dev/null +++ b/kjs/object.h @@ -0,0 +1,605 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_OBJECT_H +#define KJS_OBJECT_H + +#include "CommonIdentifiers.h" +#include "ExecState.h" +#include "JSType.h" +#include "list.h" +#include "property_map.h" +#include "property_slot.h" +#include "scope_chain.h" + +namespace KJS { + + class InternalFunctionImp; + class PropertyNameArray; + + struct HashEntry; + struct HashTable; + + // ECMA 262-3 8.6.1 + // Property attributes + enum Attribute { None = 0, + ReadOnly = 1 << 1, // property can be only read, not written + DontEnum = 1 << 2, // property doesn't appear in (for .. in ..) + DontDelete = 1 << 3, // property can't be deleted + Internal = 1 << 4, // an internal property, set to bypass checks + Function = 1 << 5, // property is a function - only used by static hashtables + GetterSetter = 1 << 6 }; // property is a getter or setter + + /** + * Class Information + */ + struct ClassInfo { + /** + * A string denoting the class name. Example: "Window". + */ + const char* className; + /** + * Pointer to the class information of the base class. + * 0L if there is none. + */ + const ClassInfo* parentClass; + /** + * Static hash-table of properties. + */ + const HashTable* propHashTable; + }; + + // This is an internal value object which stores getter and setter functions + // for a property. + class GetterSetterImp : public JSCell { + public: + JSType type() const { return GetterSetterType; } + + GetterSetterImp() : getter(0), setter(0) { } + + virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const; + virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); + virtual bool toBoolean(ExecState *exec) const; + virtual double toNumber(ExecState *exec) const; + virtual UString toString(ExecState *exec) const; + virtual JSObject *toObject(ExecState *exec) const; + + virtual void mark(); + + JSObject *getGetter() { return getter; } + void setGetter(JSObject *g) { getter = g; } + JSObject *getSetter() { return setter; } + void setSetter(JSObject *s) { setter = s; } + + private: + JSObject *getter; + JSObject *setter; + }; + + class JSObject : public JSCell { + public: + /** + * Creates a new JSObject with the specified prototype + * + * @param proto The prototype + */ + JSObject(JSValue* proto); + + /** + * Creates a new JSObject with a prototype of jsNull() + * (that is, the ECMAScript "null" value, not a null object pointer). + */ + JSObject(); + + virtual void mark(); + virtual JSType type() const; + + /** + * A pointer to a ClassInfo struct for this class. This provides a basic + * facility for run-time type information, and can be used to check an + * object's class an inheritance (see inherits()). This should + * always return a statically declared pointer, or 0 to indicate that + * there is no class information. + * + * This is primarily useful if you have application-defined classes that you + * wish to check against for casting purposes. + * + * For example, to specify the class info for classes FooImp and BarImp, + * where FooImp inherits from BarImp, you would add the following in your + * class declarations: + * + * \code + * class BarImp : public JSObject { + * virtual const ClassInfo *classInfo() const { return &info; } + * static const ClassInfo info; + * // ... + * }; + * + * class FooImp : public JSObject { + * virtual const ClassInfo *classInfo() const { return &info; } + * static const ClassInfo info; + * // ... + * }; + * \endcode + * + * And in your source file: + * + * \code + * const ClassInfo BarImp::info = { "Bar", 0, 0 }; // no parent class + * const ClassInfo FooImp::info = { "Foo", &BarImp::info, 0 }; + * \endcode + * + * @see inherits() + */ + virtual const ClassInfo *classInfo() const; + + /** + * Checks whether this object inherits from the class with the specified + * classInfo() pointer. This requires that both this class and the other + * class return a non-NULL pointer for their classInfo() methods (otherwise + * it will return false). + * + * For example, for two JSObject pointers obj1 and obj2, you can check + * if obj1's class inherits from obj2's class using the following: + * + * if (obj1->inherits(obj2->classInfo())) { + * // ... + * } + * + * If you have a handle to a statically declared ClassInfo, such as in the + * classInfo() example, you can check for inheritance without needing + * an instance of the other class: + * + * if (obj1->inherits(FooImp::info)) { + * // ... + * } + * + * @param cinfo The ClassInfo pointer for the class you want to check + * inheritance against. + * @return true if this object's class inherits from class with the + * ClassInfo pointer specified in cinfo + */ + bool inherits(const ClassInfo *cinfo) const; + + // internal properties (ECMA 262-3 8.6.2) + + /** + * Returns the prototype of this object. Note that this is not the same as + * the "prototype" property. + * + * See ECMA 8.6.2 + * + * @return The object's prototype + */ + JSValue *prototype() const; + void setPrototype(JSValue *proto); + + /** + * Returns the class name of the object + * + * See ECMA 8.6.2 + * + * @return The object's class name + */ + /** + * Implementation of the [[Class]] internal property (implemented by all + * Objects) + * + * The default implementation uses classInfo(). + * You should either implement classInfo(), or + * if you simply need a classname, you can reimplement className() + * instead. + */ + virtual UString className() const; + + /** + * Retrieves the specified property from the object. If neither the object + * or any other object in it's prototype chain have the property, this + * function will return Undefined. + * + * See ECMA 8.6.2.1 + * + * @param exec The current execution state + * @param propertyName The name of the property to retrieve + * + * @return The specified property, or Undefined + */ + JSValue *get(ExecState *exec, const Identifier &propertyName) const; + JSValue *get(ExecState *exec, unsigned propertyName) const; + + bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&); + bool getPropertySlot(ExecState *, unsigned, PropertySlot&); + + virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); + virtual bool getOwnPropertySlot(ExecState *, unsigned index, PropertySlot&); + + /** + * Sets the specified property. + * + * See ECMA 8.6.2.2 + * + * @param exec The current execution state + * @param propertyName The name of the property to set + * @param propertyValue The value to set + */ + virtual void put(ExecState* exec, const Identifier &propertyName, JSValue* value, int attr = None); + virtual void put(ExecState* exec, unsigned propertyName, JSValue* value, int attr = None); + + /** + * Used to check whether or not a particular property is allowed to be set + * on an object + * + * See ECMA 8.6.2.3 + * + * @param exec The current execution state + * @param propertyName The name of the property + * @return true if the property can be set, otherwise false + */ + /** + * Implementation of the [[CanPut]] internal property (implemented by all + * Objects) + */ + virtual bool canPut(ExecState *exec, const Identifier &propertyName) const; + + /** + * Checks if a property is enumerable, that is if it doesn't have the DontEnum + * flag set + * + * See ECMA 15.2.4 + * @param exec The current execution state + * @param propertyName The name of the property + * @return true if the property is enumerable, otherwise false + */ + bool propertyIsEnumerable(ExecState *exec, const Identifier &propertyName) const; + + /** + * Checks to see whether the object (or any object in it's prototype chain) + * has a property with the specified name. + * + * See ECMA 8.6.2.4 + * + * @param exec The current execution state + * @param propertyName The name of the property to check for + * @return true if the object has the property, otherwise false + */ + bool hasProperty(ExecState*, const Identifier&) const; + bool hasProperty(ExecState*, unsigned) const; + bool hasOwnProperty(ExecState*, const Identifier&) const; + + /** + * Removes the specified property from the object. + * + * See ECMA 8.6.2.5 + * + * @param exec The current execution state + * @param propertyName The name of the property to delete + * @return true if the property was successfully deleted or did not + * exist on the object. false if deleting the specified property is not + * allowed. + */ + virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); + virtual bool deleteProperty(ExecState *exec, unsigned propertyName); + + /** + * Converts the object into a primitive value. The value return may differ + * depending on the supplied hint + * + * See ECMA 8.6.2.6 + * + * @param exec The current execution state + * @param hint The desired primitive type to convert to + * @return A primitive value converted from the objetc. Note that the + * type of primitive value returned may not be the same as the requested + * hint. + */ + /** + * Implementation of the [[DefaultValue]] internal property (implemented by + * all Objects) + */ + virtual JSValue *defaultValue(ExecState *exec, JSType hint) const; + + /** + * Whether or not the object implements the construct() method. If this + * returns false you should not call the construct() method on this + * object (typically, an assertion will fail to indicate this). + * + * @return true if this object implements the construct() method, otherwise + * false + */ + virtual bool implementsConstruct() const; + + /** + * Creates a new object based on this object. Typically this means the + * following: + * 1. A new object is created + * 2. The prototype of the new object is set to the value of this object's + * "prototype" property + * 3. The call() method of this object is called, with the new object + * passed as the this value + * 4. The new object is returned + * + * In some cases, Host objects may differ from these semantics, although + * this is discouraged. + * + * If an error occurs during construction, the execution state's exception + * will be set. This can be tested for with ExecState::hadException(). + * Under some circumstances, the exception object may also be returned. + * + * Note: This function should not be called if implementsConstruct() returns + * false, in which case it will result in an assertion failure. + * + * @param exec The current execution state + * @param args The arguments to be passed to call() once the new object has + * been created + * @return The newly created & initialized object + */ + /** + * Implementation of the [[Construct]] internal property + */ + virtual JSObject* construct(ExecState* exec, const List& args); + virtual JSObject* construct(ExecState* exec, const List& args, const Identifier& functionName, const UString& sourceURL, int lineNumber); + + /** + * Whether or not the object implements the call() method. If this returns + * false you should not call the call() method on this object (typically, + * an assertion will fail to indicate this). + * + * @return true if this object implements the call() method, otherwise + * false + */ + virtual bool implementsCall() const; + + /** + * Calls this object as if it is a function. + * + * Note: This function should not be called if implementsCall() returns + * false, in which case it will result in an assertion failure. + * + * See ECMA 8.6.2.3 + * + * @param exec The current execution state + * @param thisObj The obj to be used as "this" within function execution. + * Note that in most cases this will be different from the C++ "this" + * object. For example, if the ECMAScript code "window.location->toString()" + * is executed, call() will be invoked on the C++ object which implements + * the toString method, with the thisObj being window.location + * @param args List of arguments to be passed to the function + * @return The return value from the function + */ + JSValue *call(ExecState *exec, JSObject *thisObj, const List &args); + virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); + + /** + * Whether or not the object implements the hasInstance() method. If this + * returns false you should not call the hasInstance() method on this + * object (typically, an assertion will fail to indicate this). + * + * @return true if this object implements the hasInstance() method, + * otherwise false + */ + virtual bool implementsHasInstance() const; + + /** + * Checks whether value delegates behavior to this object. Used by the + * instanceof operator. + * + * @param exec The current execution state + * @param value The value to check + * @return true if value delegates behavior to this object, otherwise + * false + */ + virtual bool hasInstance(ExecState *exec, JSValue *value); + + virtual void getPropertyNames(ExecState*, PropertyNameArray&); + + virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const; + virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); + virtual bool toBoolean(ExecState *exec) const; + virtual double toNumber(ExecState *exec) const; + virtual UString toString(ExecState *exec) const; + virtual JSObject *toObject(ExecState *exec) const; + + bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const; + + // WebCore uses this to make document.all and style.filter undetectable + virtual bool masqueradeAsUndefined() const { return false; } + + // This get function only looks at the property map. + // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want + // to look up in the prototype, it might already exist there) + JSValue *getDirect(const Identifier& propertyName) const + { return _prop.get(propertyName); } + JSValue **getDirectLocation(const Identifier& propertyName) + { return _prop.getLocation(propertyName); } + void putDirect(const Identifier &propertyName, JSValue *value, int attr = 0); + void putDirect(const Identifier &propertyName, int value, int attr = 0); + void removeDirect(const Identifier &propertyName); + + // convenience to add a function property under the function's own built-in name + void putDirectFunction(InternalFunctionImp*, int attr = 0); + + void fillGetterPropertySlot(PropertySlot& slot, JSValue **location); + + void defineGetter(ExecState *exec, const Identifier& propertyName, JSObject *getterFunc); + void defineSetter(ExecState *exec, const Identifier& propertyName, JSObject *setterFunc); + + void saveProperties(SavedProperties &p) const { _prop.save(p); } + void restoreProperties(const SavedProperties &p) { _prop.restore(p); } + + virtual bool isActivationObject() { return false; } + virtual bool isGlobalObject() const { return false; } + + protected: + PropertyMap _prop; + + private: + const HashEntry* findPropertyHashEntry( const Identifier& propertyName ) const; + JSValue *_proto; + }; + + /** + * Types of Native Errors available. For custom errors, GeneralError + * should be used. + */ + enum ErrorType { GeneralError = 0, + EvalError = 1, + RangeError = 2, + ReferenceError = 3, + SyntaxError = 4, + TypeError = 5, + URIError = 6, + TimeoutError = 7 + }; + + /** + * @short Factory methods for error objects. + */ + class Error { + public: + /** + * Factory method for error objects. + * + * @param exec The current execution state + * @param errtype Type of error. + * @param message Optional error message. + * @param lineNumber Optional line number. + * @param sourceId Optional source id. + * @param sourceURL Optional source URL. + */ + static JSObject *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString &sourceURL); + static JSObject *create(ExecState *, ErrorType, const char *message); + + /** + * Array of error names corresponding to ErrorType + */ + static const char * const * const errorNames; + }; + +JSObject *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString &sourceURL); +JSObject *throwError(ExecState *, ErrorType, const UString &message); +JSObject *throwError(ExecState *, ErrorType, const char *message); +JSObject *throwError(ExecState *, ErrorType); + +inline JSObject::JSObject(JSValue* proto) + : _proto(proto) +{ + ASSERT(proto); +} + +inline JSObject::JSObject() + : _proto(jsNull()) +{ +} + +inline JSValue *JSObject::prototype() const +{ + return _proto; +} + +inline void JSObject::setPrototype(JSValue *proto) +{ + ASSERT(proto); + _proto = proto; +} + +inline bool JSObject::inherits(const ClassInfo *info) const +{ + for (const ClassInfo *ci = classInfo(); ci; ci = ci->parentClass) + if (ci == info) + return true; + return false; +} + +// this method is here to be after the inline declaration of JSObject::inherits +inline bool JSCell::isObject(const ClassInfo *info) const +{ + return isObject() && static_cast(this)->inherits(info); +} + +// this method is here to be after the inline declaration of JSCell::isObject +inline bool JSValue::isObject(const ClassInfo *c) const +{ + return !JSImmediate::isImmediate(this) && asCell()->isObject(c); +} + +// It may seem crazy to inline a function this large but it makes a big difference +// since this is function very hot in variable lookup +inline bool JSObject::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSObject *object = this; + while (true) { + if (object->getOwnPropertySlot(exec, propertyName, slot)) + return true; + + JSValue *proto = object->_proto; + if (!proto->isObject()) + return false; + + object = static_cast(proto); + } +} + +// It may seem crazy to inline a function this large, especially a virtual function, +// but it makes a big difference to property lookup that derived classes can inline their +// base class call to this. +ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + if (JSValue **location = getDirectLocation(propertyName)) { + if (_prop.hasGetterSetterProperties() && location[0]->type() == GetterSetterType) + fillGetterPropertySlot(slot, location); + else + slot.setValueSlot(this, location); + return true; + } + + // non-standard Netscape extension + if (propertyName == exec->propertyNames().underscoreProto) { + slot.setValueSlot(this, &_proto); + return true; + } + + return false; +} + +inline void ScopeChain::release() +{ + // This function is only called by deref(), + // Deref ensures these conditions are true. + ASSERT(_node && _node->refCount == 0); + ScopeChainNode *n = _node; + do { + ScopeChainNode *next = n->next; + delete n; + n = next; + } while (n && --n->refCount == 0); +} + +inline JSValue* JSObject::toPrimitive(ExecState* exec, JSType preferredType) const +{ + return defaultValue(exec, preferredType); +} + +} // namespace + +#endif // KJS_OBJECT_H diff --git a/kjs/object_object.cpp b/kjs/object_object.cpp new file mode 100644 index 0000000..90eaa93 --- /dev/null +++ b/kjs/object_object.cpp @@ -0,0 +1,216 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "object_object.h" + +#include "JSGlobalObject.h" +#include "operations.h" +#include "function_object.h" +#include + +namespace KJS { + +// ------------------------------ ObjectPrototype -------------------------------- + +static JSValue* objectProtoFuncValueOf(ExecState*, JSObject*, const List&); +static JSValue* objectProtoFuncHasOwnProperty(ExecState*, JSObject*, const List&); +static JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject*, const List&); +static JSValue* objectProtoFuncDefineGetter(ExecState*, JSObject*, const List&); +static JSValue* objectProtoFuncDefineSetter(ExecState*, JSObject*, const List&); +static JSValue* objectProtoFuncLookupGetter(ExecState*, JSObject*, const List&); +static JSValue* objectProtoFuncLookupSetter(ExecState*, JSObject*, const List&); +static JSValue* objectProtoFuncPropertyIsEnumerable(ExecState*, JSObject*, const List&); +static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, const List&); + +ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* functionPrototype) + : JSObject() // [[Prototype]] is null +{ + static const Identifier* hasOwnPropertyPropertyName = new Identifier("hasOwnProperty"); + static const Identifier* propertyIsEnumerablePropertyName = new Identifier("propertyIsEnumerable"); + static const Identifier* isPrototypeOfPropertyName = new Identifier("isPrototypeOf"); + static const Identifier* defineGetterPropertyName = new Identifier("__defineGetter__"); + static const Identifier* defineSetterPropertyName = new Identifier("__defineSetter__"); + static const Identifier* lookupGetterPropertyName = new Identifier("__lookupGetter__"); + static const Identifier* lookupSetterPropertyName = new Identifier("__lookupSetter__"); + + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *hasOwnPropertyPropertyName, objectProtoFuncHasOwnProperty), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *propertyIsEnumerablePropertyName, objectProtoFuncPropertyIsEnumerable), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *isPrototypeOfPropertyName, objectProtoFuncIsPrototypeOf), DontEnum); + + // Mozilla extensions + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, *defineGetterPropertyName, objectProtoFuncDefineGetter), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, *defineSetterPropertyName, objectProtoFuncDefineSetter), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *lookupGetterPropertyName, objectProtoFuncLookupGetter), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *lookupSetterPropertyName, objectProtoFuncLookupSetter), DontEnum); +} + + +// ------------------------------ Functions -------------------------------- + +// ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5, 15.2.4.7 + +JSValue* objectProtoFuncValueOf(ExecState*, JSObject* thisObj, const List&) +{ + return thisObj; +} + +JSValue* objectProtoFuncHasOwnProperty(ExecState* exec, JSObject* thisObj, const List& args) +{ + return jsBoolean(thisObj->hasOwnProperty(exec, Identifier(args[0]->toString(exec)))); +} + +JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject* thisObj, const List& args) +{ + if (!args[0]->isObject()) + return jsBoolean(false); + + JSValue* v = static_cast(args[0])->prototype(); + + while (true) { + if (!v->isObject()) + return jsBoolean(false); + if (thisObj == static_cast(v)) + return jsBoolean(true); + v = static_cast(v)->prototype(); + } +} + +JSValue* objectProtoFuncDefineGetter(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!args[1]->isObject() || !static_cast(args[1])->implementsCall()) + return throwError(exec, SyntaxError, "invalid getter usage"); + + thisObj->defineGetter(exec, Identifier(args[0]->toString(exec)), static_cast(args[1])); + return jsUndefined(); +} + +JSValue* objectProtoFuncDefineSetter(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!args[1]->isObject() || !static_cast(args[1])->implementsCall()) + return throwError(exec, SyntaxError, "invalid setter usage"); + + thisObj->defineSetter(exec, Identifier(args[0]->toString(exec)), static_cast(args[1])); + return jsUndefined(); +} + +JSValue* objectProtoFuncLookupGetter(ExecState* exec, JSObject* thisObj, const List& args) +{ + Identifier propertyName = Identifier(args[0]->toString(exec)); + JSObject* obj = thisObj; + while (true) { + JSValue* v = obj->getDirect(propertyName); + if (v) { + if (v->type() != GetterSetterType) + return jsUndefined(); + JSObject* funcObj = static_cast(v)->getGetter(); + if (!funcObj) + return jsUndefined(); + return funcObj; + } + + if (!obj->prototype() || !obj->prototype()->isObject()) + return jsUndefined(); + obj = static_cast(obj->prototype()); + } +} + +JSValue* objectProtoFuncLookupSetter(ExecState* exec, JSObject* thisObj, const List& args) +{ + Identifier propertyName = Identifier(args[0]->toString(exec)); + JSObject* obj = thisObj; + while (true) { + JSValue* v = obj->getDirect(propertyName); + if (v) { + if (v->type() != GetterSetterType) + return jsUndefined(); + JSObject* funcObj = static_cast(v)->getSetter(); + if (!funcObj) + return jsUndefined(); + return funcObj; + } + + if (!obj->prototype() || !obj->prototype()->isObject()) + return jsUndefined(); + obj = static_cast(obj->prototype()); + } +} + +JSValue* objectProtoFuncPropertyIsEnumerable(ExecState* exec, JSObject* thisObj, const List& args) +{ + return jsBoolean(thisObj->propertyIsEnumerable(exec, Identifier(args[0]->toString(exec)))); +} + +JSValue* objectProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const List&) +{ + return jsString(thisObj->toString(exec)); +} + +JSValue* objectProtoFuncToString(ExecState*, JSObject* thisObj, const List&) +{ + return jsString("[object " + thisObj->className() + "]"); +} + +// ------------------------------ ObjectObjectImp -------------------------------- + +ObjectObjectImp::ObjectObjectImp(ExecState* exec, ObjectPrototype* objProto, FunctionPrototype* funcProto) + : InternalFunctionImp(funcProto, "Object") +{ + // ECMA 15.2.3.1 + putDirect(exec->propertyNames().prototype, objProto, DontEnum|DontDelete|ReadOnly); + + // no. of arguments for constructor + putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); +} + + +bool ObjectObjectImp::implementsConstruct() const +{ + return true; +} + +// ECMA 15.2.2 +JSObject* ObjectObjectImp::construct(ExecState* exec, const List& args) +{ + JSValue* arg = args[0]; + switch (arg->type()) { + case StringType: + case BooleanType: + case NumberType: + case ObjectType: + return arg->toObject(exec); + case NullType: + case UndefinedType: + return new JSObject(exec->lexicalGlobalObject()->objectPrototype()); + default: + ASSERT_NOT_REACHED(); + return 0; + } +} + +JSValue* ObjectObjectImp::callAsFunction(ExecState* exec, JSObject* /*thisObj*/, const List &args) +{ + return construct(exec, args); +} + +} // namespace KJS diff --git a/kjs/object_object.h b/kjs/object_object.h new file mode 100644 index 0000000..0ee5482 --- /dev/null +++ b/kjs/object_object.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _OBJECT_OBJECT_H_ +#define _OBJECT_OBJECT_H_ + +#include "function.h" + +namespace KJS { + + /** + * @internal + * + * The initial value of Object.prototype (and thus all objects created + * with the Object constructor + */ + class ObjectPrototype : public JSObject { + public: + ObjectPrototype(ExecState*, FunctionPrototype*); + }; + + JSValue* objectProtoFuncToString(ExecState*, JSObject*, const List&); + + /** + * @internal + * + * The initial value of the the global variable's "Object" property + */ + class ObjectObjectImp : public InternalFunctionImp { + public: + ObjectObjectImp(ExecState*, ObjectPrototype*, FunctionPrototype*); + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List&); + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + }; + +} // namespace KJS + +#endif // _OBJECT_OBJECT_H_ diff --git a/kjs/operations.cpp b/kjs/operations.cpp new file mode 100644 index 0000000..d2b3892 --- /dev/null +++ b/kjs/operations.cpp @@ -0,0 +1,128 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "operations.h" + +#include "internal.h" +#include "object.h" +#include +#include +#include + +#if HAVE(FLOAT_H) +#include +#endif + +namespace KJS { + +// ECMA 11.9.3 +bool equal(ExecState *exec, JSValue *v1, JSValue *v2) +{ + JSType t1 = v1->type(); + JSType t2 = v2->type(); + + if (t1 != t2) { + if (t1 == UndefinedType) + t1 = NullType; + if (t2 == UndefinedType) + t2 = NullType; + + if (t1 == BooleanType) + t1 = NumberType; + if (t2 == BooleanType) + t2 = NumberType; + + if (t1 == NumberType && t2 == StringType) { + // use toNumber + } else if (t1 == StringType && t2 == NumberType) + t1 = NumberType; + // use toNumber + else { + if ((t1 == StringType || t1 == NumberType) && t2 == ObjectType) { + v2 = v2->toPrimitive(exec); + if (exec->hadException()) + return false; + return equal(exec, v1, v2); + } + if (t1 == NullType && t2 == ObjectType) + return static_cast(v2)->masqueradeAsUndefined(); + if (t1 == ObjectType && (t2 == StringType || t2 == NumberType)) { + v1 = v1->toPrimitive(exec); + if (exec->hadException()) + return false; + return equal(exec, v1, v2); + } + if (t1 == ObjectType && t2 == NullType) + return static_cast(v1)->masqueradeAsUndefined(); + if (t1 != t2) + return false; + } + } + + if (t1 == UndefinedType || t1 == NullType) + return true; + + if (t1 == NumberType) { + double d1 = v1->toNumber(exec); + double d2 = v2->toNumber(exec); + return d1 == d2; + } + + if (t1 == StringType) + return static_cast(v1)->value() == static_cast(v2)->value(); + + if (t1 == BooleanType) + return v1->toBoolean(exec) == v2->toBoolean(exec); + + // types are Object + return v1 == v2; +} + +bool strictEqual(ExecState *exec, JSValue *v1, JSValue *v2) +{ + JSType t1 = v1->type(); + JSType t2 = v2->type(); + + if (t1 != t2) + return false; + if (t1 == UndefinedType || t1 == NullType) + return true; + if (t1 == NumberType) { + double n1 = v1->toNumber(exec); + double n2 = v2->toNumber(exec); + if (n1 == n2) + return true; + return false; + } else if (t1 == StringType) + return v1->toString(exec) == v2->toString(exec); + else if (t2 == BooleanType) + return v1->toBoolean(exec) == v2->toBoolean(exec); + + if (v1 == v2) + return true; + /* TODO: joined objects */ + + return false; +} + +} diff --git a/kjs/operations.h b/kjs/operations.h new file mode 100644 index 0000000..96656f0 --- /dev/null +++ b/kjs/operations.h @@ -0,0 +1,35 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef _KJS_OPERATIONS_H_ +#define _KJS_OPERATIONS_H_ + +namespace KJS { + + class ExecState; + class JSValue; + + bool equal(ExecState *exec, JSValue *v1, JSValue *v2); + bool strictEqual(ExecState *exec, JSValue *v1, JSValue *v2); +} + +#endif diff --git a/kjs/property_map.cpp b/kjs/property_map.cpp new file mode 100644 index 0000000..1da4917 --- /dev/null +++ b/kjs/property_map.cpp @@ -0,0 +1,850 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "property_map.h" + +#include "object.h" +#include "protect.h" +#include "PropertyNameArray.h" +#include +#include +#include +#include +#include + +using std::max; +using WTF::doubleHash; + +#ifndef NDEBUG +#define DO_PROPERTYMAP_CONSTENCY_CHECK 0 +#define DUMP_PROPERTYMAP_STATS 0 +#else +#define DO_PROPERTYMAP_CONSTENCY_CHECK 0 +#define DUMP_PROPERTYMAP_STATS 0 +#endif + +#define USE_SINGLE_ENTRY 1 + +// 2/28/2006 ggaren: command-line JS iBench says that USE_SINGLE_ENTRY is a +// 3.2% performance boost. + +namespace KJS { + +// Choose a number for the following so that most property maps are smaller, +// but it's not going to blow out the stack to allocate this number of pointers. +static const int smallMapThreshold = 1024; + +// The point at which the function call overhead of the qsort implementation +// becomes small compared to the inefficiency of insertion sort. +static const unsigned tinyMapThreshold = 20; + +#if DUMP_PROPERTYMAP_STATS + +static int numProbes; +static int numCollisions; +static int numRehashes; +static int numRemoves; + +struct PropertyMapStatisticsExitLogger { ~PropertyMapStatisticsExitLogger(); }; + +static PropertyMapStatisticsExitLogger logger; + +PropertyMapStatisticsExitLogger::~PropertyMapStatisticsExitLogger() +{ + printf("\nKJS::PropertyMap statistics\n\n"); + printf("%d probes\n", numProbes); + printf("%d collisions (%.1f%%)\n", numCollisions, 100.0 * numCollisions / numProbes); + printf("%d rehashes\n", numRehashes); + printf("%d removes\n", numRemoves); +} + +#endif + +struct PropertyMapEntry { + UString::Rep* key; + JSValue* value; + unsigned attributes; + unsigned index; + + PropertyMapEntry(UString::Rep* k, JSValue* v, int a) + : key(k), value(v), attributes(a), index(0) + { + } +}; + +// lastIndexUsed is an ever-increasing index used to identify the order items +// were inserted into the property map. It's required that getEnumerablePropertyNames +// return the properties in the order they were added for compatibility with other +// browsers' JavaScript implementations. +struct PropertyMapHashTable { + unsigned sizeMask; + unsigned size; + unsigned keyCount; + unsigned deletedSentinelCount; + unsigned lastIndexUsed; + unsigned entryIndicies[1]; + + PropertyMapEntry* entries() + { + // The entries vector comes after the indices vector. + // The 0th item in the entries vector is not really used; it has to + // have a 0 in its key to allow the hash table lookup to handle deleted + // sentinels without any special-case code, but the other fields are unused. + return reinterpret_cast(&entryIndicies[size]); + } + + static size_t allocationSize(unsigned size) + { + // We never let a hash table get more than half full, + // So the number of indices we need is the size of the hash table. + // But the number of entries is half that (plus one for the deleted sentinel). + return sizeof(PropertyMapHashTable) + + (size - 1) * sizeof(unsigned) + + (1 + size / 2) * sizeof(PropertyMapEntry); + } +}; + +static const unsigned emptyEntryIndex = 0; +static const unsigned deletedSentinelIndex = 1; + +SavedProperties::SavedProperties() + : count(0) +{ +} + +SavedProperties::~SavedProperties() +{ +} + +#if !DO_PROPERTYMAP_CONSTENCY_CHECK + +inline void PropertyMap::checkConsistency() +{ +} + +#endif + +PropertyMap::~PropertyMap() +{ + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + if (m_singleEntryKey) + m_singleEntryKey->deref(); +#endif + return; + } + + unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; + for (unsigned i = 1; i <= entryCount; i++) { + if (UString::Rep* key = m_u.table->entries()[i].key) + key->deref(); + } + fastFree(m_u.table); +} + +void PropertyMap::clear() +{ + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + if (m_singleEntryKey) { + m_singleEntryKey->deref(); + m_singleEntryKey = 0; + } +#endif + return; + } + + unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; + for (unsigned i = 1; i <= entryCount; i++) { + if (UString::Rep* key = m_u.table->entries()[i].key) + key->deref(); + } + for (unsigned i = 0; i < m_u.table->size; i++) + m_u.table->entryIndicies[i] = emptyEntryIndex; + m_u.table->keyCount = 0; + m_u.table->deletedSentinelCount = 0; +} + +JSValue* PropertyMap::get(const Identifier& name, unsigned& attributes) const +{ + ASSERT(!name.isNull()); + + UString::Rep* rep = name._ustring.rep(); + + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + if (rep == m_singleEntryKey) { + attributes = m_singleEntryAttributes; + return m_u.singleEntryValue; + } +#endif + return 0; + } + + unsigned i = rep->computedHash(); + +#if DUMP_PROPERTYMAP_STATS + ++numProbes; +#endif + + unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + if (entryIndex == emptyEntryIndex) + return 0; + + if (rep == m_u.table->entries()[entryIndex - 1].key) { + attributes = m_u.table->entries()[entryIndex - 1].attributes; + return m_u.table->entries()[entryIndex - 1].value; + } + +#if DUMP_PROPERTYMAP_STATS + ++numCollisions; +#endif + + unsigned k = 1 | doubleHash(rep->computedHash()); + + while (1) { + i += k; + +#if DUMP_PROPERTYMAP_STATS + ++numRehashes; +#endif + + entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + if (entryIndex == emptyEntryIndex) + return 0; + + if (rep == m_u.table->entries()[entryIndex - 1].key) { + attributes = m_u.table->entries()[entryIndex - 1].attributes; + return m_u.table->entries()[entryIndex - 1].value; + } + } +} + +JSValue* PropertyMap::get(const Identifier& name) const +{ + ASSERT(!name.isNull()); + + UString::Rep* rep = name._ustring.rep(); + + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + if (rep == m_singleEntryKey) + return m_u.singleEntryValue; +#endif + return 0; + } + + unsigned i = rep->computedHash(); + +#if DUMP_PROPERTYMAP_STATS + ++numProbes; +#endif + + unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + if (entryIndex == emptyEntryIndex) + return 0; + + if (rep == m_u.table->entries()[entryIndex - 1].key) + return m_u.table->entries()[entryIndex - 1].value; + +#if DUMP_PROPERTYMAP_STATS + ++numCollisions; +#endif + + unsigned k = 1 | doubleHash(rep->computedHash()); + + while (1) { + i += k; + +#if DUMP_PROPERTYMAP_STATS + ++numRehashes; +#endif + + entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + if (entryIndex == emptyEntryIndex) + return 0; + + if (rep == m_u.table->entries()[entryIndex - 1].key) + return m_u.table->entries()[entryIndex - 1].value; + } +} + +JSValue** PropertyMap::getLocation(const Identifier& name) +{ + ASSERT(!name.isNull()); + + UString::Rep* rep = name._ustring.rep(); + + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + if (rep == m_singleEntryKey) + return &m_u.singleEntryValue; +#endif + return 0; + } + + unsigned i = rep->computedHash(); + +#if DUMP_PROPERTYMAP_STATS + ++numProbes; +#endif + + unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + if (entryIndex == emptyEntryIndex) + return 0; + + if (rep == m_u.table->entries()[entryIndex - 1].key) + return &m_u.table->entries()[entryIndex - 1].value; + +#if DUMP_PROPERTYMAP_STATS + ++numCollisions; +#endif + + unsigned k = 1 | doubleHash(rep->computedHash()); + + while (1) { + i += k; + +#if DUMP_PROPERTYMAP_STATS + ++numRehashes; +#endif + + entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + if (entryIndex == emptyEntryIndex) + return 0; + + if (rep == m_u.table->entries()[entryIndex - 1].key) + return &m_u.table->entries()[entryIndex - 1].value; + } +} + +void PropertyMap::put(const Identifier& name, JSValue* value, unsigned attributes, bool checkReadOnly) +{ + ASSERT(!name.isNull()); + ASSERT(value); + + checkConsistency(); + + UString::Rep* rep = name._ustring.rep(); + +#if USE_SINGLE_ENTRY + if (!m_usingTable) { + if (!m_singleEntryKey) { + rep->ref(); + m_singleEntryKey = rep; + m_u.singleEntryValue = value; + m_singleEntryAttributes = static_cast(attributes); + checkConsistency(); + return; + } + if (rep == m_singleEntryKey && !(checkReadOnly && (m_singleEntryAttributes & ReadOnly))) { + m_u.singleEntryValue = value; + return; + } + } +#endif + + if (!m_usingTable || (m_u.table->keyCount + m_u.table->deletedSentinelCount) * 2 >= m_u.table->size) + expand(); + + // FIXME: Consider a fast case for tables with no deleted sentinels. + + unsigned i = rep->computedHash(); + unsigned k = 0; + bool foundDeletedElement = false; + unsigned deletedElementIndex = 0; // initialize to make the compiler happy + +#if DUMP_PROPERTYMAP_STATS + ++numProbes; +#endif + + while (1) { + unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + if (entryIndex == emptyEntryIndex) + break; + + if (m_u.table->entries()[entryIndex - 1].key == rep) { + if (checkReadOnly && (m_u.table->entries()[entryIndex - 1].attributes & ReadOnly)) + return; + // Put a new value in an existing hash table entry. + m_u.table->entries()[entryIndex - 1].value = value; + // Attributes are intentionally not updated. + return; + } else if (entryIndex == deletedSentinelIndex) { + // If we find a deleted-element sentinel, remember it for use later. + if (!foundDeletedElement) { + foundDeletedElement = true; + deletedElementIndex = i; + } + } + + if (k == 0) { + k = 1 | doubleHash(rep->computedHash()); +#if DUMP_PROPERTYMAP_STATS + ++numCollisions; +#endif + } + + i += k; + +#if DUMP_PROPERTYMAP_STATS + ++numRehashes; +#endif + } + + // Figure out which entry to use. + unsigned entryIndex = m_u.table->keyCount + m_u.table->deletedSentinelCount + 2; + if (foundDeletedElement) { + i = deletedElementIndex; + --m_u.table->deletedSentinelCount; + + // Since we're not making the table bigger, we can't use the entry one past + // the end that we were planning on using, so search backwards for the empty + // slot that we can use. We know it will be there because we did at least one + // deletion in the past that left an entry empty. + while (m_u.table->entries()[--entryIndex - 1].key) + ; + } + + + // Create a new hash table entry. + m_u.table->entryIndicies[i & m_u.table->sizeMask] = entryIndex; + + // Create a new hash table entry. + rep->ref(); + m_u.table->entries()[entryIndex - 1].key = rep; + m_u.table->entries()[entryIndex - 1].value = value; + m_u.table->entries()[entryIndex - 1].attributes = attributes; + m_u.table->entries()[entryIndex - 1].index = ++m_u.table->lastIndexUsed; + ++m_u.table->keyCount; + + checkConsistency(); +} + +void PropertyMap::insert(const Entry& entry) +{ + ASSERT(m_u.table); + + unsigned i = entry.key->computedHash(); + unsigned k = 0; + +#if DUMP_PROPERTYMAP_STATS + ++numProbes; +#endif + + while (1) { + unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + if (entryIndex == emptyEntryIndex) + break; + + if (k == 0) { + k = 1 | doubleHash(entry.key->computedHash()); +#if DUMP_PROPERTYMAP_STATS + ++numCollisions; +#endif + } + + i += k; + +#if DUMP_PROPERTYMAP_STATS + ++numRehashes; +#endif + } + + unsigned entryIndex = m_u.table->keyCount + 2; + m_u.table->entryIndicies[i & m_u.table->sizeMask] = entryIndex; + m_u.table->entries()[entryIndex - 1] = entry; + ++m_u.table->keyCount; +} + +void PropertyMap::expand() +{ + if (!m_usingTable) + createTable(); + else + rehash(m_u.table->size * 2); +} + +void PropertyMap::rehash() +{ + ASSERT(m_usingTable); + ASSERT(m_u.table); + ASSERT(m_u.table->size); + rehash(m_u.table->size); +} + +void PropertyMap::createTable() +{ + const unsigned newTableSize = 16; + + ASSERT(!m_usingTable); + + checkConsistency(); + +#if USE_SINGLE_ENTRY + JSValue* oldSingleEntryValue = m_u.singleEntryValue; +#endif + + m_u.table = static_cast(fastZeroedMalloc(Table::allocationSize(newTableSize))); + m_u.table->size = newTableSize; + m_u.table->sizeMask = newTableSize - 1; + m_usingTable = true; + +#if USE_SINGLE_ENTRY + if (m_singleEntryKey) { + insert(Entry(m_singleEntryKey, oldSingleEntryValue, m_singleEntryAttributes)); + m_singleEntryKey = 0; + } +#endif + + checkConsistency(); +} + +void PropertyMap::rehash(unsigned newTableSize) +{ + ASSERT(!m_singleEntryKey); + ASSERT(m_u.table); + ASSERT(m_usingTable); + + checkConsistency(); + + Table* oldTable = m_u.table; + + m_u.table = static_cast(fastZeroedMalloc(Table::allocationSize(newTableSize))); + m_u.table->size = newTableSize; + m_u.table->sizeMask = newTableSize - 1; + + unsigned lastIndexUsed = 0; + unsigned entryCount = oldTable->keyCount + oldTable->deletedSentinelCount; + for (unsigned i = 1; i <= entryCount; ++i) { + if (oldTable->entries()[i].key) { + lastIndexUsed = max(oldTable->entries()[i].index, lastIndexUsed); + insert(oldTable->entries()[i]); + } + } + m_u.table->lastIndexUsed = lastIndexUsed; + + fastFree(oldTable); + + checkConsistency(); +} + +void PropertyMap::remove(const Identifier& name) +{ + ASSERT(!name.isNull()); + + checkConsistency(); + + UString::Rep* rep = name._ustring.rep(); + + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + if (rep == m_singleEntryKey) { + m_singleEntryKey->deref(); + m_singleEntryKey = 0; + checkConsistency(); + } +#endif + return; + } + +#if DUMP_PROPERTYMAP_STATS + ++numProbes; + ++numRemoves; +#endif + + // Find the thing to remove. + unsigned i = rep->computedHash(); + unsigned k = 0; + unsigned entryIndex; + UString::Rep* key = 0; + while (1) { + entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + if (entryIndex == emptyEntryIndex) + return; + + key = m_u.table->entries()[entryIndex - 1].key; + if (rep == key) + break; + + if (k == 0) { + k = 1 | doubleHash(rep->computedHash()); +#if DUMP_PROPERTYMAP_STATS + ++numCollisions; +#endif + } + + i += k; + +#if DUMP_PROPERTYMAP_STATS + ++numRehashes; +#endif + } + + // Replace this one element with the deleted sentinel. Also clear out + // the entry so we can iterate all the entries as needed. + m_u.table->entryIndicies[i & m_u.table->sizeMask] = deletedSentinelIndex; + key->deref(); + m_u.table->entries()[entryIndex - 1].key = 0; + m_u.table->entries()[entryIndex - 1].value = jsUndefined(); + m_u.table->entries()[entryIndex - 1].attributes = 0; + ASSERT(m_u.table->keyCount >= 1); + --m_u.table->keyCount; + ++m_u.table->deletedSentinelCount; + + if (m_u.table->deletedSentinelCount * 4 >= m_u.table->size) + rehash(); + + checkConsistency(); +} + +void PropertyMap::mark() const +{ + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + if (m_singleEntryKey) { + JSValue* v = m_u.singleEntryValue; + if (!v->marked()) + v->mark(); + } +#endif + return; + } + + unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; + for (unsigned i = 1; i <= entryCount; i++) { + JSValue* v = m_u.table->entries()[i].value; + if (!v->marked()) + v->mark(); + } +} + +static int comparePropertyMapEntryIndices(const void* a, const void* b) +{ + unsigned ia = static_cast(a)[0]->index; + unsigned ib = static_cast(b)[0]->index; + if (ia < ib) + return -1; + if (ia > ib) + return +1; + return 0; +} + +bool PropertyMap::containsGettersOrSetters() const +{ + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + return !!(m_singleEntryAttributes & GetterSetter); +#else + return false; +#endif + } + + unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; + for (unsigned i = 1; i <= entryCount; i++) { + if (m_u.table->entries()[i].attributes & GetterSetter) + return true; + } + + return false; +} + +void PropertyMap::getEnumerablePropertyNames(PropertyNameArray& propertyNames) const +{ + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + UString::Rep* key = m_singleEntryKey; + if (key && !(m_singleEntryAttributes & DontEnum)) + propertyNames.add(Identifier(key)); +#endif + return; + } + + if (m_u.table->keyCount < tinyMapThreshold) { + Entry* a[tinyMapThreshold]; + int i = 0; + unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; + for (unsigned k = 1; k <= entryCount; k++) { + if (m_u.table->entries()[k].key && !(m_u.table->entries()[k].attributes & DontEnum)) { + Entry* value = &m_u.table->entries()[k]; + int j; + for (j = i - 1; j >= 0 && a[j]->index > value->index; --j) + a[j + 1] = a[j]; + a[j + 1] = value; + ++i; + } + } + for (int k = 0; k < i; ++k) + propertyNames.add(Identifier(a[k]->key)); + return; + } + + // Allocate a buffer to use to sort the keys. + Vector sortedEnumerables(m_u.table->keyCount); + + // Get pointers to the enumerable entries in the buffer. + Entry** p = sortedEnumerables.data(); + unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; + for (unsigned i = 1; i <= entryCount; i++) { + if (m_u.table->entries()[i].key && !(m_u.table->entries()[i].attributes & DontEnum)) + *p++ = &m_u.table->entries()[i]; + } + + // Sort the entries by index. + qsort(sortedEnumerables.data(), p - sortedEnumerables.data(), sizeof(Entry*), comparePropertyMapEntryIndices); + + // Put the keys of the sorted entries into the list. + for (Entry** q = sortedEnumerables.data(); q != p; ++q) + propertyNames.add(Identifier(q[0]->key)); +} + +void PropertyMap::save(SavedProperties& s) const +{ + unsigned count = 0; + + if (!m_usingTable) { +#if USE_SINGLE_ENTRY + if (m_singleEntryKey && !(m_singleEntryAttributes & (ReadOnly | Function))) + ++count; +#endif + } else { + unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; + for (unsigned i = 1; i <= entryCount; ++i) + if (m_u.table->entries()[i].key && !(m_u.table->entries()[i].attributes & (ReadOnly | Function))) + ++count; + } + + s.properties.clear(); + s.count = count; + + if (count == 0) + return; + + s.properties.set(new SavedProperty[count]); + + SavedProperty* prop = s.properties.get(); + +#if USE_SINGLE_ENTRY + if (!m_usingTable) { + prop->init(m_singleEntryKey, m_u.singleEntryValue, m_singleEntryAttributes); + return; + } +#endif + + // Save in the right order so we don't lose the order. + // Another possibility would be to save the indices. + + // Allocate a buffer to use to sort the keys. + Vector sortedEntries(count); + + // Get pointers to the entries in the buffer. + Entry** p = sortedEntries.data(); + unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; + for (unsigned i = 1; i <= entryCount; ++i) { + if (m_u.table->entries()[i].key && !(m_u.table->entries()[i].attributes & (ReadOnly | Function))) + *p++ = &m_u.table->entries()[i]; + } + ASSERT(p == sortedEntries.data() + count); + + // Sort the entries by index. + qsort(sortedEntries.data(), p - sortedEntries.data(), sizeof(Entry*), comparePropertyMapEntryIndices); + + // Put the sorted entries into the saved properties list. + for (Entry** q = sortedEntries.data(); q != p; ++q, ++prop) { + Entry* e = *q; + prop->init(e->key, e->value, e->attributes); + } +} + +void PropertyMap::restore(const SavedProperties& p) +{ + for (unsigned i = 0; i != p.count; ++i) + put(Identifier(p.properties[i].name()), p.properties[i].value(), p.properties[i].attributes()); +} + +#if DO_PROPERTYMAP_CONSTENCY_CHECK + +void PropertyMap::checkConsistency() +{ + if (!m_usingTable) + return; + + ASSERT(m_u.table->size >= 16); + ASSERT(m_u.table->sizeMask); + ASSERT(m_u.table->size == m_u.table->sizeMask + 1); + ASSERT(!(m_u.table->size & m_u.table->sizeMask)); + + ASSERT(m_u.table->keyCount <= m_u.table->size / 2); + ASSERT(m_u.table->deletedSentinelCount <= m_u.table->size / 4); + + ASSERT(m_u.table->keyCount + m_u.table->deletedSentinelCount <= m_u.table->size / 2); + + unsigned indexCount = 0; + unsigned deletedIndexCount = 0; + for (unsigned a = 0; a != m_u.table->size; ++a) { + unsigned entryIndex = m_u.table->entryIndicies[a]; + if (entryIndex == emptyEntryIndex) + continue; + if (entryIndex == deletedSentinelIndex) { + ++deletedIndexCount; + continue; + } + ASSERT(entryIndex > deletedSentinelIndex); + ASSERT(entryIndex - 1 <= m_u.table->keyCount + m_u.table->deletedSentinelCount); + ++indexCount; + + for (unsigned b = a + 1; b != m_u.table->size; ++b) + ASSERT(m_u.table->entryIndicies[b] != entryIndex); + } + ASSERT(indexCount == m_u.table->keyCount); + ASSERT(deletedIndexCount == m_u.table->deletedSentinelCount); + + ASSERT(m_u.table->entries()[0].key == 0); + + unsigned nonEmptyEntryCount = 0; + for (unsigned c = 1; c <= m_u.table->keyCount + m_u.table->deletedSentinelCount; ++c) { + UString::Rep* rep = m_u.table->entries()[c].key; + if (!rep) { + ASSERT(m_u.table->entries()[c].value->isUndefined()); + continue; + } + ++nonEmptyEntryCount; + unsigned i = rep->computedHash(); + unsigned k = 0; + unsigned entryIndex; + while (1) { + entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; + ASSERT(entryIndex != emptyEntryIndex); + if (rep == m_u.table->entries()[entryIndex - 1].key) + break; + if (k == 0) + k = 1 | doubleHash(rep->computedHash()); + i += k; + } + ASSERT(entryIndex == c + 1); + } + + ASSERT(nonEmptyEntryCount == m_u.table->keyCount); +} + +#endif // DO_PROPERTYMAP_CONSTENCY_CHECK + +} // namespace KJS diff --git a/kjs/property_map.h b/kjs/property_map.h new file mode 100644 index 0000000..269e911 --- /dev/null +++ b/kjs/property_map.h @@ -0,0 +1,184 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_PROPERTY_MAP_H_ +#define KJS_PROPERTY_MAP_H_ + +#include "identifier.h" +#include "protect.h" +#include + +namespace KJS { + + class JSObject; + class JSValue; + class PropertyNameArray; + + struct PropertyMapEntry; + struct PropertyMapHashTable; + + class SavedProperty : Noncopyable { + public: + // Since we use this in arrays, we allocate it uninitialized + // and then explicitly initialize. This means we can allocate + // the array without initializing every saved property in the + // array twice. To accomplish this, the class uses data members + // with types that don't have constructors. + SavedProperty(); + void init(UString::Rep* name, JSValue*, unsigned attributes); + ~SavedProperty(); + + UString::Rep* name() const; + JSValue* value() const; + unsigned attributes() const; + + private: + UString::Rep* m_name; + JSValue* m_value; + unsigned m_attributes; + }; + + struct SavedProperties { + SavedProperties(); + ~SavedProperties(); + + unsigned count; + OwnArrayPtr properties; + }; + + class PropertyMap : Noncopyable { + public: + PropertyMap(); + ~PropertyMap(); + + void clear(); + + void put(const Identifier&, JSValue*, unsigned attributes, bool checkReadOnly = false); + void remove(const Identifier&); + JSValue* get(const Identifier&) const; + JSValue* get(const Identifier&, unsigned& attributes) const; + JSValue** getLocation(const Identifier& name); + + void mark() const; + void getEnumerablePropertyNames(PropertyNameArray&) const; + + void save(SavedProperties&) const; + void restore(const SavedProperties&); + + bool hasGetterSetterProperties() const { return m_getterSetterFlag; } + void setHasGetterSetterProperties(bool f) { m_getterSetterFlag = f; } + + bool containsGettersOrSetters() const; + + private: + typedef PropertyMapEntry Entry; + typedef PropertyMapHashTable Table; + + static bool keysMatch(const UString::Rep*, const UString::Rep*); + void expand(); + void rehash(); + void rehash(unsigned newTableSize); + void createTable(); + + void insert(const Entry&); + + void checkConsistency(); + + UString::Rep* m_singleEntryKey; + union { + JSValue* singleEntryValue; + Table* table; + } m_u; + + short m_singleEntryAttributes; + bool m_getterSetterFlag : 1; + bool m_usingTable : 1; + }; + + inline PropertyMap::PropertyMap() + : m_singleEntryKey(0) + , m_getterSetterFlag(false) + , m_usingTable(false) + + { + } + + inline SavedProperty::SavedProperty() +#ifndef NDEBUG + : m_name(0) + , m_value(0) + , m_attributes(0) +#endif + { + } + + inline void SavedProperty::init(UString::Rep* name, JSValue* value, unsigned attributes) + { + ASSERT(name); + ASSERT(value); + + ASSERT(!m_name); + ASSERT(!m_value); + ASSERT(!m_attributes); + + m_name = name; + m_value = value; + m_attributes = attributes; + name->ref(); + gcProtect(value); + } + + inline SavedProperty::~SavedProperty() + { + ASSERT(m_name); + ASSERT(m_value); + + m_name->deref(); + gcUnprotect(m_value); + } + + inline UString::Rep* SavedProperty::name() const + { + ASSERT(m_name); + ASSERT(m_value); + + return m_name; + } + + inline JSValue* SavedProperty::value() const + { + ASSERT(m_name); + ASSERT(m_value); + + return m_value; + } + + inline unsigned SavedProperty::attributes() const + { + ASSERT(m_name); + ASSERT(m_value); + + return m_attributes; + } + +} // namespace + +#endif // _KJS_PROPERTY_MAP_H_ diff --git a/kjs/property_slot.cpp b/kjs/property_slot.cpp new file mode 100644 index 0000000..ef2525f --- /dev/null +++ b/kjs/property_slot.cpp @@ -0,0 +1,46 @@ +// -*- c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2005 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + + +#include "config.h" +#include "property_slot.h" +#include "object.h" + +namespace KJS { + +JSValue *PropertySlot::undefinedGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&) +{ + return jsUndefined(); +} + +JSValue* PropertySlot::ungettableGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&) +{ + ASSERT_NOT_REACHED(); + return jsUndefined(); +} + +JSValue *PropertySlot::functionGetter(ExecState* exec, JSObject* originalObject, const Identifier&, const PropertySlot& slot) +{ + return slot.m_data.getterFunc->call(exec, originalObject, exec->emptyList()); +} + +} diff --git a/kjs/property_slot.h b/kjs/property_slot.h new file mode 100644 index 0000000..4ec8b46 --- /dev/null +++ b/kjs/property_slot.h @@ -0,0 +1,142 @@ +// -*- c-basic-offset: 4 -*- +/* + * Copyright (C) 2005, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_PROPERTY_SLOT_H +#define KJS_PROPERTY_SLOT_H + +#include "identifier.h" +#include "value.h" +#include + +namespace KJS { + +class ExecState; +class JSObject; + +struct HashEntry; + +#define KJS_VALUE_SLOT_MARKER 0 +#define KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER reinterpret_cast(1) + +class PropertySlot { +public: + typedef JSValue* (*GetValueFunc)(ExecState*, JSObject* originalObject, const Identifier&, const PropertySlot&); + typedef JSValue* (*GetValueNumericFunc)(ExecState*, JSObject* originalObject, unsigned index, const PropertySlot&); + + JSValue* getValue(ExecState* exec, JSObject* originalObject, const Identifier& propertyName) const + { + if (m_getValue == KJS_VALUE_SLOT_MARKER) + return *m_data.valueSlot; + ASSERT(m_getValue != KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER); + return m_getValue(exec, originalObject, propertyName, *this); + } + + JSValue* getValue(ExecState* exec, JSObject* originalObject, unsigned propertyName) const + { + if (m_getValue == KJS_VALUE_SLOT_MARKER) + return *m_data.valueSlot; + if (m_getValue == KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER) + return m_data.numericFunc(exec, originalObject, propertyName, *this); + return m_getValue(exec, originalObject, Identifier::from(propertyName), *this); + } + + void setValueSlot(JSObject* slotBase, JSValue** valueSlot) + { + m_getValue = KJS_VALUE_SLOT_MARKER; + m_slotBase = slotBase; + m_data.valueSlot = valueSlot; + } + + void setStaticEntry(JSObject* slotBase, const HashEntry* staticEntry, GetValueFunc getValue) + { + ASSERT(getValue); + m_getValue = getValue; + m_slotBase = slotBase; + m_data.staticEntry = staticEntry; + } + + void setCustom(JSObject* slotBase, GetValueFunc getValue) + { + ASSERT(getValue); + m_getValue = getValue; + m_slotBase = slotBase; + } + + void setCustomIndex(JSObject* slotBase, unsigned index, GetValueFunc getValue) + { + ASSERT(getValue); + m_getValue = getValue; + m_slotBase = slotBase; + m_data.index = index; + } + + void setCustomNumeric(JSObject* slotBase, GetValueNumericFunc getValue) + { + ASSERT(getValue); + m_slotBase = slotBase; + m_getValue = KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER; + m_data.numericFunc = getValue; + } + + void setGetterSlot(JSObject* slotBase, JSObject* getterFunc) + { + m_getValue = functionGetter; + m_slotBase = slotBase; + m_data.getterFunc = getterFunc; + } + + void setUndefined(JSObject *slotBase) + { + m_slotBase = slotBase; + m_getValue = undefinedGetter; + } + + void setUngettable(JSObject* slotBase) // Used to signal that you have a property, but trying to get it at this time is an error. + { + m_slotBase = slotBase; + m_getValue = ungettableGetter; + } + + JSObject* slotBase() const { return m_slotBase; } + + const HashEntry* staticEntry() const { return m_data.staticEntry; } + unsigned index() const { return m_data.index; } + +private: + static JSValue* undefinedGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + static JSValue* ungettableGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + static JSValue* functionGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); + + GetValueFunc m_getValue; + + JSObject* m_slotBase; + union { + JSObject* getterFunc; + JSValue** valueSlot; + const HashEntry* staticEntry; + unsigned index; + GetValueNumericFunc numericFunc; + } m_data; +}; + +} + +#endif // KJS_PROPERTY_SLOT_H diff --git a/kjs/protect.h b/kjs/protect.h new file mode 100644 index 0000000..912e45c --- /dev/null +++ b/kjs/protect.h @@ -0,0 +1,143 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2004 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + + +#ifndef _KJS_PROTECT_H_ +#define _KJS_PROTECT_H_ + +#include "value.h" +#include "collector.h" +#include "JSLock.h" + +namespace KJS { + + inline void gcProtect(JSValue *val) + { + Collector::protect(val); + } + + inline void gcUnprotect(JSValue *val) + { + Collector::unprotect(val); + } + + inline void gcProtectNullTolerant(JSValue *val) + { + if (val) + gcProtect(val); + } + + inline void gcUnprotectNullTolerant(JSValue *val) + { + if (val) + gcUnprotect(val); + } + + // FIXME: Share more code with RefPtr template? The only differences are the ref/deref operation + // and the implicit conversion to raw pointer + template class ProtectedPtr { + public: + ProtectedPtr() : m_ptr(NULL) { } + ProtectedPtr(T *ptr); + ProtectedPtr(const ProtectedPtr &); + ~ProtectedPtr(); + + template ProtectedPtr(const ProtectedPtr &); + + T *get() const { return m_ptr; } + operator T *() const { return m_ptr; } + T *operator->() const { return m_ptr; } + + bool operator!() const { return m_ptr == NULL; } + + ProtectedPtr &operator=(const ProtectedPtr &); + ProtectedPtr &operator=(T *); + + private: + T *m_ptr; + }; + + template ProtectedPtr::ProtectedPtr(T *ptr) + : m_ptr(ptr) + { + if (ptr) { + JSLock lock; + gcProtect(ptr); + } + } + + template ProtectedPtr::ProtectedPtr(const ProtectedPtr &o) + : m_ptr(o.get()) + { + if (T *ptr = m_ptr) { + JSLock lock; + gcProtect(ptr); + } + } + + template ProtectedPtr::~ProtectedPtr() + { + if (T *ptr = m_ptr) { + JSLock lock; + gcUnprotect(ptr); + } + } + + template template ProtectedPtr::ProtectedPtr(const ProtectedPtr &o) + : m_ptr(o.get()) + { + if (T *ptr = m_ptr) { + JSLock lock; + gcProtect(ptr); + } + } + + template ProtectedPtr &ProtectedPtr::operator=(const ProtectedPtr &o) + { + JSLock lock; + T *optr = o.m_ptr; + gcProtectNullTolerant(optr); + gcUnprotectNullTolerant(m_ptr); + m_ptr = optr; + return *this; + } + + template inline ProtectedPtr &ProtectedPtr::operator=(T *optr) + { + JSLock lock; + gcProtectNullTolerant(optr); + gcUnprotectNullTolerant(m_ptr); + m_ptr = optr; + return *this; + } + + template inline bool operator==(const ProtectedPtr &a, const ProtectedPtr &b) { return a.get() == b.get(); } + template inline bool operator==(const ProtectedPtr &a, const T *b) { return a.get() == b; } + template inline bool operator==(const T *a, const ProtectedPtr &b) { return a == b.get(); } + + template inline bool operator!=(const ProtectedPtr &a, const ProtectedPtr &b) { return a.get() != b.get(); } + template inline bool operator!=(const ProtectedPtr &a, const T *b) { return a.get() != b; } + template inline bool operator!=(const T *a, const ProtectedPtr &b) { return a != b.get(); } + +} // namespace + +#endif diff --git a/kjs/regexp.cpp b/kjs/regexp.cpp new file mode 100644 index 0000000..4839c86 --- /dev/null +++ b/kjs/regexp.cpp @@ -0,0 +1,120 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001, 2004 Harri Porten (porten@kde.org) + * Copyright (c) 2007, Apple Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "regexp.h" + +#include "lexer.h" +#include +#include +#include +#include + +namespace KJS { + +RegExp::RegExp(const UString& pattern) + : m_pattern(pattern) + , m_flagBits(0) + , m_constructionError(0) + , m_numSubpatterns(0) +{ + m_regExp = jsRegExpCompile(reinterpret_cast(pattern.data()), pattern.size(), + JSRegExpDoNotIgnoreCase, JSRegExpSingleLine, &m_numSubpatterns, &m_constructionError); +} + +RegExp::RegExp(const UString& pattern, const UString& flags) + : m_pattern(pattern) + , m_flags(flags) + , m_flagBits(0) + , m_constructionError(0) + , m_numSubpatterns(0) +{ + // NOTE: The global flag is handled on a case-by-case basis by functions like + // String::match and RegExpImp::match. + if (flags.find('g') != -1) + m_flagBits |= Global; + + // FIXME: Eliminate duplication by adding a way ask a JSRegExp what its flags are? + JSRegExpIgnoreCaseOption ignoreCaseOption = JSRegExpDoNotIgnoreCase; + if (flags.find('i') != -1) { + m_flagBits |= IgnoreCase; + ignoreCaseOption = JSRegExpIgnoreCase; + } + + JSRegExpMultilineOption multilineOption = JSRegExpSingleLine; + if (flags.find('m') != -1) { + m_flagBits |= Multiline; + multilineOption = JSRegExpMultiline; + } + + m_regExp = jsRegExpCompile(reinterpret_cast(pattern.data()), pattern.size(), + ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError); +} + +RegExp::~RegExp() +{ + jsRegExpFree(m_regExp); +} + +int RegExp::match(const UString& s, int i, OwnArrayPtr* ovector) +{ + if (i < 0) + i = 0; + if (ovector) + ovector->clear(); + + if (i > s.size() || s.isNull()) + return -1; + + if (!m_regExp) + return -1; + + // Set up the offset vector for the result. + // First 2/3 used for result, the last third used by PCRE. + int* offsetVector; + int offsetVectorSize; + int fixedSizeOffsetVector[3]; + if (!ovector) { + offsetVectorSize = 3; + offsetVector = fixedSizeOffsetVector; + } else { + offsetVectorSize = (m_numSubpatterns + 1) * 3; + offsetVector = new int [offsetVectorSize]; + ovector->set(offsetVector); + } + + int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast(s.data()), s.size(), i, offsetVector, offsetVectorSize); + + if (numMatches < 0) { +#ifndef NDEBUG + if (numMatches != JSRegExpErrorNoMatch) + fprintf(stderr, "jsRegExpExecute failed with result %d\n", numMatches); +#endif + if (ovector) + ovector->clear(); + return -1; + } + + return offsetVector[0]; +} + +} // namespace KJS diff --git a/kjs/regexp.h b/kjs/regexp.h new file mode 100644 index 0000000..2c62085 --- /dev/null +++ b/kjs/regexp.h @@ -0,0 +1,75 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef KJS_REGEXP_H +#define KJS_REGEXP_H + +#include "ustring.h" +#include +#include +#include +#include + +namespace KJS { + + class RegExp : public RefCounted { + private: + enum { + Global = 1, + IgnoreCase = 2, + Multiline = 4 + }; + + public: + RegExp(const UString& pattern); + RegExp(const UString& pattern, const UString& flags); + ~RegExp(); + + bool global() const { return m_flagBits & Global; } + bool ignoreCase() const { return m_flagBits & IgnoreCase; } + bool multiline() const { return m_flagBits & Multiline; } + + const UString& pattern() const { return m_pattern; } + const UString& flags() const { return m_flags; } + + bool isValid() const { return !m_constructionError; } + const char* errorMessage() const { return m_constructionError; } + + int match(const UString&, int offset, OwnArrayPtr* ovector = 0); + unsigned numSubpatterns() const { return m_numSubpatterns; } + + private: + void compile(); + + // Data supplied by caller. + UString m_pattern; // FIXME: Just decompile m_regExp instead of storing this. + UString m_flags; // FIXME: Just decompile m_regExp instead of storing this. + int m_flagBits; + + // Data supplied by PCRE. + JSRegExp* m_regExp; + const char* m_constructionError; + unsigned m_numSubpatterns; + }; + +} // namespace + +#endif diff --git a/kjs/regexp_object.cpp b/kjs/regexp_object.cpp new file mode 100644 index 0000000..217c8db --- /dev/null +++ b/kjs/regexp_object.cpp @@ -0,0 +1,475 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2007, 2008 Apple Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "regexp_object.h" +#include "regexp_object.lut.h" + +#include "array_instance.h" +#include "array_object.h" +#include "error_object.h" +#include "internal.h" +#include "object.h" +#include "operations.h" +#include "regexp.h" +#include "types.h" +#include "value.h" +#include "UnusedParam.h" + +#include + +namespace KJS { + +// ------------------------------ RegExpPrototype --------------------------- + +static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, const List&); +static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, const List&); +static JSValue* regExpProtoFuncCompile(ExecState*, JSObject*, const List&); +static JSValue* regExpProtoFuncToString(ExecState*, JSObject*, const List&); + +// ECMA 15.10.5 + +const ClassInfo RegExpPrototype::info = { "RegExpPrototype", 0, 0 }; + +RegExpPrototype::RegExpPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype) + : JSObject(objectPrototype) +{ + static const Identifier* compilePropertyName = new Identifier("compile"); + static const Identifier* execPropertyName = new Identifier("exec"); + static const Identifier* testPropertyName = new Identifier("test"); + + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *compilePropertyName, regExpProtoFuncCompile), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *execPropertyName, regExpProtoFuncExec), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *testPropertyName, regExpProtoFuncTest), DontEnum); + putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum); +} + +// ------------------------------ Functions --------------------------- + +JSValue* regExpProtoFuncTest(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&RegExpImp::info)) + return throwError(exec, TypeError); + + return static_cast(thisObj)->test(exec, args); +} + +JSValue* regExpProtoFuncExec(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&RegExpImp::info)) + return throwError(exec, TypeError); + + return static_cast(thisObj)->exec(exec, args); +} + +JSValue* regExpProtoFuncCompile(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (!thisObj->inherits(&RegExpImp::info)) + return throwError(exec, TypeError); + + RefPtr regExp; + JSValue* arg0 = args[0]; + JSValue* arg1 = args[1]; + + if (arg0->isObject(&RegExpImp::info)) { + if (!arg1->isUndefined()) + return throwError(exec, TypeError, "Cannot supply flags when constructing one RegExp from another."); + regExp = static_cast(arg0)->regExp(); + } else { + UString pattern = args.isEmpty() ? UString("") : arg0->toString(exec); + UString flags = arg1->isUndefined() ? UString("") : arg1->toString(exec); + regExp = new RegExp(pattern, flags); + } + + if (!regExp->isValid()) + return throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage())); + + static_cast(thisObj)->setRegExp(regExp.release()); + static_cast(thisObj)->setLastIndex(0); + return jsUndefined(); +} + +JSValue* regExpProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&RegExpImp::info)) { + if (thisObj->inherits(&RegExpPrototype::info)) + return jsString("//"); + return throwError(exec, TypeError); + } + + UString result = "/" + thisObj->get(exec, exec->propertyNames().source)->toString(exec) + "/"; + if (thisObj->get(exec, exec->propertyNames().global)->toBoolean(exec)) + result += "g"; + if (thisObj->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec)) + result += "i"; + if (thisObj->get(exec, exec->propertyNames().multiline)->toBoolean(exec)) + result += "m"; + return jsString(result); +} + +// ------------------------------ RegExpImp ------------------------------------ + +const ClassInfo RegExpImp::info = { "RegExp", 0, &RegExpImpTable }; + +/* Source for regexp_object.lut.h +@begin RegExpImpTable 5 + global RegExpImp::Global DontDelete|ReadOnly|DontEnum + ignoreCase RegExpImp::IgnoreCase DontDelete|ReadOnly|DontEnum + multiline RegExpImp::Multiline DontDelete|ReadOnly|DontEnum + source RegExpImp::Source DontDelete|ReadOnly|DontEnum + lastIndex RegExpImp::LastIndex DontDelete|DontEnum +@end +*/ + +RegExpImp::RegExpImp(RegExpPrototype* regexpProto, PassRefPtr regExp) + : JSObject(regexpProto) + , m_regExp(regExp) + , m_lastIndex(0) +{ +} + +RegExpImp::~RegExpImp() +{ +} + +bool RegExpImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &RegExpImpTable, this, propertyName, slot); +} + +JSValue* RegExpImp::getValueProperty(ExecState*, int token) const +{ + switch (token) { + case Global: + return jsBoolean(m_regExp->global()); + case IgnoreCase: + return jsBoolean(m_regExp->ignoreCase()); + case Multiline: + return jsBoolean(m_regExp->multiline()); + case Source: + return jsString(m_regExp->pattern()); + case LastIndex: + return jsNumber(m_lastIndex); + } + + ASSERT_NOT_REACHED(); + return 0; +} + +void RegExpImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attributes) +{ + lookupPut(exec, propertyName, value, attributes, &RegExpImpTable, this); +} + +void RegExpImp::putValueProperty(ExecState* exec, int token, JSValue* value, int) +{ + UNUSED_PARAM(token); + ASSERT(token == LastIndex); + m_lastIndex = value->toInteger(exec); +} + +bool RegExpImp::match(ExecState* exec, const List& args) +{ + RegExpObjectImp* regExpObj = exec->lexicalGlobalObject()->regExpConstructor(); + + UString input; + if (!args.isEmpty()) + input = args[0]->toString(exec); + else { + input = regExpObj->input(); + if (input.isNull()) { + throwError(exec, GeneralError, "No input."); + return false; + } + } + + bool global = get(exec, exec->propertyNames().global)->toBoolean(exec); + int lastIndex = 0; + if (global) { + if (m_lastIndex < 0 || m_lastIndex > input.size()) { + m_lastIndex = 0; + return false; + } + lastIndex = static_cast(m_lastIndex); + } + + int foundIndex; + int foundLength; + regExpObj->performMatch(m_regExp.get(), input, lastIndex, foundIndex, foundLength); + + if (global) { + lastIndex = foundIndex < 0 ? 0 : foundIndex + foundLength; + m_lastIndex = lastIndex; + } + + return foundIndex >= 0; +} + +JSValue* RegExpImp::test(ExecState* exec, const List& args) +{ + return jsBoolean(match(exec, args)); +} + +JSValue* RegExpImp::exec(ExecState* exec, const List& args) +{ + return match(exec, args) + ? exec->lexicalGlobalObject()->regExpConstructor()->arrayOfMatches(exec) + : jsNull(); +} + +bool RegExpImp::implementsCall() const +{ + return true; +} + +JSValue* RegExpImp::callAsFunction(ExecState* exec, JSObject*, const List& args) +{ + return RegExpImp::exec(exec, args); +} + +// ------------------------------ RegExpObjectImp ------------------------------ + +const ClassInfo RegExpObjectImp::info = { "Function", &InternalFunctionImp::info, &RegExpObjectImpTable }; + +/* Source for regexp_object.lut.h +@begin RegExpObjectImpTable 21 + input RegExpObjectImp::Input None + $_ RegExpObjectImp::Input DontEnum + multiline RegExpObjectImp::Multiline None + $* RegExpObjectImp::Multiline DontEnum + lastMatch RegExpObjectImp::LastMatch DontDelete|ReadOnly + $& RegExpObjectImp::LastMatch DontDelete|ReadOnly|DontEnum + lastParen RegExpObjectImp::LastParen DontDelete|ReadOnly + $+ RegExpObjectImp::LastParen DontDelete|ReadOnly|DontEnum + leftContext RegExpObjectImp::LeftContext DontDelete|ReadOnly + $` RegExpObjectImp::LeftContext DontDelete|ReadOnly|DontEnum + rightContext RegExpObjectImp::RightContext DontDelete|ReadOnly + $' RegExpObjectImp::RightContext DontDelete|ReadOnly|DontEnum + $1 RegExpObjectImp::Dollar1 DontDelete|ReadOnly + $2 RegExpObjectImp::Dollar2 DontDelete|ReadOnly + $3 RegExpObjectImp::Dollar3 DontDelete|ReadOnly + $4 RegExpObjectImp::Dollar4 DontDelete|ReadOnly + $5 RegExpObjectImp::Dollar5 DontDelete|ReadOnly + $6 RegExpObjectImp::Dollar6 DontDelete|ReadOnly + $7 RegExpObjectImp::Dollar7 DontDelete|ReadOnly + $8 RegExpObjectImp::Dollar8 DontDelete|ReadOnly + $9 RegExpObjectImp::Dollar9 DontDelete|ReadOnly +@end +*/ + +struct RegExpObjectImpPrivate { + // Global search cache / settings + RegExpObjectImpPrivate() : lastNumSubPatterns(0), multiline(false) { } + UString lastInput; + OwnArrayPtr lastOvector; + unsigned lastNumSubPatterns : 31; + bool multiline : 1; +}; + +RegExpObjectImp::RegExpObjectImp(ExecState* exec, FunctionPrototype* funcProto, RegExpPrototype* regProto) + : InternalFunctionImp(funcProto, "RegExp") + , d(new RegExpObjectImpPrivate) +{ + // ECMA 15.10.5.1 RegExp.prototype + putDirect(exec->propertyNames().prototype, regProto, DontEnum | DontDelete | ReadOnly); + + // no. of arguments for constructor + putDirect(exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum); +} + +/* + To facilitate result caching, exec(), test(), match(), search(), and replace() dipatch regular + expression matching through the performMatch function. We use cached results to calculate, + e.g., RegExp.lastMatch and RegExp.leftParen. +*/ +void RegExpObjectImp::performMatch(RegExp* r, const UString& s, int startOffset, int& position, int& length, int** ovector) +{ + OwnArrayPtr tmpOvector; + position = r->match(s, startOffset, &tmpOvector); + + if (ovector) + *ovector = tmpOvector.get(); + + if (position != -1) { + ASSERT(tmpOvector); + + length = tmpOvector[1] - tmpOvector[0]; + + d->lastInput = s; + d->lastOvector.set(tmpOvector.release()); + d->lastNumSubPatterns = r->numSubpatterns(); + } +} + +JSObject* RegExpObjectImp::arrayOfMatches(ExecState* exec) const +{ + unsigned lastNumSubpatterns = d->lastNumSubPatterns; + ArrayInstance* arr = new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), lastNumSubpatterns + 1); + for (unsigned i = 0; i <= lastNumSubpatterns; ++i) { + int start = d->lastOvector[2 * i]; + if (start >= 0) + arr->put(exec, i, jsString(d->lastInput.substr(start, d->lastOvector[2 * i + 1] - start))); + } + arr->put(exec, exec->propertyNames().index, jsNumber(d->lastOvector[0])); + arr->put(exec, exec->propertyNames().input, jsString(d->lastInput)); + return arr; +} + +JSValue* RegExpObjectImp::getBackref(unsigned i) const +{ + if (d->lastOvector && i <= d->lastNumSubPatterns) + return jsString(d->lastInput.substr(d->lastOvector[2 * i], d->lastOvector[2 * i + 1] - d->lastOvector[2 * i])); + return jsString(""); +} + +JSValue* RegExpObjectImp::getLastParen() const +{ + unsigned i = d->lastNumSubPatterns; + if (i > 0) { + ASSERT(d->lastOvector); + return jsString(d->lastInput.substr(d->lastOvector[2 * i], d->lastOvector[2 * i + 1] - d->lastOvector[2 * i])); + } + return jsString(""); +} + +JSValue *RegExpObjectImp::getLeftContext() const +{ + if (d->lastOvector) + return jsString(d->lastInput.substr(0, d->lastOvector[0])); + return jsString(""); +} + +JSValue *RegExpObjectImp::getRightContext() const +{ + if (d->lastOvector) { + UString s = d->lastInput; + return jsString(s.substr(d->lastOvector[1], s.size() - d->lastOvector[1])); + } + return jsString(""); +} + +bool RegExpObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &RegExpObjectImpTable, this, propertyName, slot); +} + +JSValue *RegExpObjectImp::getValueProperty(ExecState*, int token) const +{ + switch (token) { + case Dollar1: + return getBackref(1); + case Dollar2: + return getBackref(2); + case Dollar3: + return getBackref(3); + case Dollar4: + return getBackref(4); + case Dollar5: + return getBackref(5); + case Dollar6: + return getBackref(6); + case Dollar7: + return getBackref(7); + case Dollar8: + return getBackref(8); + case Dollar9: + return getBackref(9); + case Input: + return jsString(d->lastInput); + case Multiline: + return jsBoolean(d->multiline); + case LastMatch: + return getBackref(0); + case LastParen: + return getLastParen(); + case LeftContext: + return getLeftContext(); + case RightContext: + return getRightContext(); + default: + ASSERT(0); + } + + return jsString(""); +} + +void RegExpObjectImp::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr) +{ + lookupPut(exec, propertyName, value, attr, &RegExpObjectImpTable, this); +} + +void RegExpObjectImp::putValueProperty(ExecState *exec, int token, JSValue *value, int) +{ + switch (token) { + case Input: + d->lastInput = value->toString(exec); + break; + case Multiline: + d->multiline = value->toBoolean(exec); + break; + default: + ASSERT(0); + } +} + +bool RegExpObjectImp::implementsConstruct() const +{ + return true; +} + +// ECMA 15.10.4 +JSObject *RegExpObjectImp::construct(ExecState *exec, const List &args) +{ + JSValue* arg0 = args[0]; + JSValue* arg1 = args[1]; + + if (arg0->isObject(&RegExpImp::info)) { + if (!arg1->isUndefined()) + return throwError(exec, TypeError, "Cannot supply flags when constructing one RegExp from another."); + return static_cast(arg0); + } + + UString pattern = arg0->isUndefined() ? UString("") : arg0->toString(exec); + UString flags = arg1->isUndefined() ? UString("") : arg1->toString(exec); + + return createRegExpImp(exec, new RegExp(pattern, flags)); +} + +JSObject* RegExpObjectImp::createRegExpImp(ExecState* exec, PassRefPtr regExp) +{ + return regExp->isValid() + ? new RegExpImp(static_cast(exec->lexicalGlobalObject()->regExpPrototype()), regExp) + : throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage())); +} + +// ECMA 15.10.3 +JSValue *RegExpObjectImp::callAsFunction(ExecState *exec, JSObject * /*thisObj*/, const List &args) +{ + return construct(exec, args); +} + +const UString& RegExpObjectImp::input() const +{ + // Can detect a distinct initial state that is invisible to JavaScript, by checking for null + // state (since jsString turns null strings to empty strings). + return d->lastInput; +} + +} diff --git a/kjs/regexp_object.h b/kjs/regexp_object.h new file mode 100644 index 0000000..1ce2f16 --- /dev/null +++ b/kjs/regexp_object.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2003, 2007, 2008 Apple Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef REGEXP_OBJECT_H_ +#define REGEXP_OBJECT_H_ + +#include "function_object.h" +#include "regexp.h" + +namespace KJS { + + struct RegExpObjectImpPrivate; + + class RegExpPrototype : public JSObject { + public: + RegExpPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*); + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + }; + + class RegExpImp : public JSObject { + public: + enum { Global, IgnoreCase, Multiline, Source, LastIndex }; + + RegExpImp(RegExpPrototype*, PassRefPtr); + virtual ~RegExpImp(); + + void setRegExp(PassRefPtr r) { m_regExp = r; } + RegExp* regExp() const { return m_regExp.get(); } + + JSValue* test(ExecState*, const List& args); + JSValue* exec(ExecState*, const List& args); + + virtual bool implementsCall() const; + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + JSValue* getValueProperty(ExecState*, int token) const; + void put(ExecState*, const Identifier&, JSValue*, int attributes = None); + void putValueProperty(ExecState*, int token, JSValue*, int attributes); + + virtual const ClassInfo* classInfo() const { return &info; } + static const ClassInfo info; + + void setLastIndex(double lastIndex) { m_lastIndex = lastIndex; } + + private: + bool match(ExecState*, const List& args); + + RefPtr m_regExp; + double m_lastIndex; + }; + + class RegExpObjectImp : public InternalFunctionImp { + public: + enum { Dollar1, Dollar2, Dollar3, Dollar4, Dollar5, Dollar6, Dollar7, Dollar8, Dollar9, + Input, Multiline, LastMatch, LastParen, LeftContext, RightContext }; + + RegExpObjectImp(ExecState*, FunctionPrototype*, RegExpPrototype*); + + virtual bool implementsConstruct() const; + virtual JSObject* construct(ExecState*, const List&); + JSObject* createRegExpImp(ExecState*, PassRefPtr); + virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); + virtual void put(ExecState*, const Identifier&, JSValue*, int attributes = None); + void putValueProperty(ExecState*, int token, JSValue*, int attributes); + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + JSValue* getValueProperty(ExecState*, int token) const; + virtual const ClassInfo* classInfo() const { return &info; } + + void performMatch(RegExp*, const UString&, int startOffset, int& position, int& length, int** ovector = 0); + JSObject* arrayOfMatches(ExecState*) const; + const UString& input() const; + + private: + JSValue* getBackref(unsigned) const; + JSValue* getLastParen() const; + JSValue* getLeftContext() const; + JSValue* getRightContext() const; + + OwnPtr d; + + static const ClassInfo info; + }; + +} // namespace + +#endif diff --git a/kjs/scope_chain.cpp b/kjs/scope_chain.cpp new file mode 100644 index 0000000..aba066a --- /dev/null +++ b/kjs/scope_chain.cpp @@ -0,0 +1,63 @@ +/* + * This file is part of the KDE libraries + * Copyright (C) 2003, 2006 Apple Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "scope_chain.h" +#include "PropertyNameArray.h" +#include +#include "object.h" + +namespace KJS { + +void ScopeChain::push(const ScopeChain &c) +{ + ScopeChainNode **tail = &_node; + for (ScopeChainNode *n = c._node; n; n = n->next) { + ScopeChainNode *newNode = new ScopeChainNode(*tail, n->object); + *tail = newNode; + tail = &newNode->next; + } +} + +#ifndef NDEBUG + +void ScopeChain::print() +{ + ScopeChainIterator scopeEnd = end(); + for (ScopeChainIterator scopeIter = begin(); scopeIter != scopeEnd; ++scopeIter) { + JSObject* o = *scopeIter; + PropertyNameArray propertyNames; + // FIXME: should pass ExecState here! + o->getPropertyNames(0, propertyNames); + PropertyNameArray::const_iterator propEnd = propertyNames.end(); + + fprintf(stderr, "----- [scope %p] -----\n", o); + for (PropertyNameArray::const_iterator propIter = propertyNames.begin(); propIter != propEnd; propIter++) { + Identifier name = *propIter; + fprintf(stderr, "%s, ", name.ascii()); + } + fprintf(stderr, "\n"); + } +} + +#endif + +} // namespace KJS diff --git a/kjs/scope_chain.h b/kjs/scope_chain.h new file mode 100644 index 0000000..7441cb8 --- /dev/null +++ b/kjs/scope_chain.h @@ -0,0 +1,156 @@ +/* + * This file is part of the KDE libraries + * Copyright (C) 2003 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_SCOPE_CHAIN_H +#define KJS_SCOPE_CHAIN_H + +#include + +namespace KJS { + + class JSObject; + class ExecState; + + class ScopeChainNode { + public: + ScopeChainNode(ScopeChainNode *n, JSObject *o) + : next(n), object(o), refCount(1) { } + + ScopeChainNode *next; + JSObject *object; + int refCount; + }; + + class ScopeChainIterator { + public: + ScopeChainIterator(ScopeChainNode *node) : m_node(node) {} + + JSObject * const & operator*() const { return m_node->object; } + JSObject * const * operator->() const { return &(operator*()); } + + ScopeChainIterator& operator++() { m_node = m_node->next; return *this; } + + // postfix ++ intentionally omitted + + bool operator==(const ScopeChainIterator& other) const { return m_node == other.m_node; } + bool operator!=(const ScopeChainIterator& other) const { return m_node != other.m_node; } + + private: + ScopeChainNode *m_node; + }; + + class ScopeChain { + public: + typedef ScopeChainIterator const_iterator; + typedef JSObject* ValueType; + + ScopeChain() : _node(0) { } + ~ScopeChain() { deref(); } + + ScopeChain(const ScopeChain &c) : _node(c._node) + { if (_node) ++_node->refCount; } + ScopeChain &operator=(const ScopeChain &); + + bool isEmpty() const { return !_node; } + JSObject *top() const { return _node->object; } + + JSObject *bottom() const; + + ScopeChainIterator begin() const { return ScopeChainIterator(_node); } + ScopeChainIterator end() const { return ScopeChainIterator(0); } + + void clear() { deref(); _node = 0; } + void push(JSObject *); + void push(const ScopeChain &); + void replaceTop(JSObject*); + void pop(); + + void mark(); + +#ifndef NDEBUG + void print(); +#endif + + private: + ScopeChainNode *_node; + + void deref() { if (_node && --_node->refCount == 0) release(); } + void ref() const; + + void release(); + }; + +inline void ScopeChain::ref() const +{ + for (ScopeChainNode *n = _node; n; n = n->next) { + if (n->refCount++ != 0) + break; + } +} + +inline ScopeChain &ScopeChain::operator=(const ScopeChain &c) +{ + c.ref(); + deref(); + _node = c._node; + return *this; +} + +inline JSObject *ScopeChain::bottom() const +{ + ScopeChainNode *last = 0; + for (ScopeChainNode *n = _node; n; n = n->next) + last = n; + if (!last) + return 0; + return last->object; +} + +inline void ScopeChain::push(JSObject *o) +{ + ASSERT(o); + _node = new ScopeChainNode(_node, o); +} + +inline void ScopeChain::replaceTop(JSObject* o) +{ + ASSERT(o); + _node->object = o; +} + +inline void ScopeChain::pop() +{ + ScopeChainNode *oldNode = _node; + ASSERT(oldNode); + ScopeChainNode *newNode = oldNode->next; + _node = newNode; + + if (--oldNode->refCount != 0) { + if (newNode) + ++newNode->refCount; + } else { + delete oldNode; + } +} + +} // namespace KJS + +#endif // KJS_SCOPE_CHAIN_H diff --git a/kjs/scope_chain_mark.h b/kjs/scope_chain_mark.h new file mode 100644 index 0000000..bc4d5f8 --- /dev/null +++ b/kjs/scope_chain_mark.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef scope_chain_mark_h +#define scope_chain_mark_h + +#include "Activation.h" +#include "scope_chain.h" + +namespace KJS { + + inline void ScopeChain::mark() + { + for (ScopeChainNode* n = _node; n; n = n->next) { + JSObject* o = n->object; + + // An ActivationImp that is on the activation stack can't have the + // JSObject::marked() method called on it, because it doesn't have an + // entry in a GC mark bitmap, so we check here whether it is on the + // stack and directly call the portion of the marking code that is + // still relevant. + + if (o->isActivationObject() && static_cast(o)->isOnStack()) + static_cast(o)->markChildren(); + else if (!o->marked()) + o->mark(); + } + } + +} // namespace KJS + +#endif diff --git a/kjs/string_object.cpp b/kjs/string_object.cpp new file mode 100644 index 0000000..53b6ada --- /dev/null +++ b/kjs/string_object.cpp @@ -0,0 +1,1055 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" +#include "string_object.h" +#include "string_object.lut.h" + +#include "JSWrapperObject.h" +#include "PropertyNameArray.h" +#include "array_object.h" +#include "error_object.h" +#include "operations.h" +#include "regexp_object.h" +#include +#include + +#if PLATFORM(CF) +#include +#elif PLATFORM(WIN_OS) +#include +#endif + +using namespace WTF; + +namespace KJS { + +// ------------------------------ StringInstance ---------------------------- + +const ClassInfo StringInstance::info = { "String", 0, 0 }; + +StringInstance::StringInstance(JSObject *proto) + : JSWrapperObject(proto) +{ + setInternalValue(jsString("")); +} + +StringInstance::StringInstance(JSObject *proto, StringImp* string) + : JSWrapperObject(proto) +{ + setInternalValue(string); +} + +StringInstance::StringInstance(JSObject *proto, const UString &string) + : JSWrapperObject(proto) +{ + setInternalValue(jsString(string)); +} + +JSValue *StringInstance::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot &slot) +{ + return jsNumber(static_cast(slot.slotBase())->internalValue()->value().size()); +} + +JSValue* StringInstance::indexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) +{ + return jsString(static_cast(slot.slotBase())->internalValue()->value().substr(slot.index(), 1)); +} + +static JSValue* stringInstanceNumericPropertyGetter(ExecState*, JSObject*, unsigned index, const PropertySlot& slot) +{ + return jsString(static_cast(slot.slotBase())->internalValue()->value().substr(index, 1)); +} + +bool StringInstance::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + if (propertyName == exec->propertyNames().length) { + slot.setCustom(this, lengthGetter); + return true; + } + + bool isStrictUInt32; + unsigned i = propertyName.toStrictUInt32(&isStrictUInt32); + unsigned length = internalValue()->value().size(); + if (isStrictUInt32 && i < length) { + slot.setCustomIndex(this, i, indexGetter); + return true; + } + + return JSObject::getOwnPropertySlot(exec, propertyName, slot); +} + +bool StringInstance::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + unsigned length = internalValue()->value().size(); + if (propertyName < length) { + slot.setCustomNumeric(this, stringInstanceNumericPropertyGetter); + return true; + } + + return JSObject::getOwnPropertySlot(exec, Identifier::from(propertyName), slot); +} + +void StringInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr) +{ + if (propertyName == exec->propertyNames().length) + return; + JSObject::put(exec, propertyName, value, attr); +} + +bool StringInstance::deleteProperty(ExecState *exec, const Identifier &propertyName) +{ + if (propertyName == exec->propertyNames().length) + return false; + return JSObject::deleteProperty(exec, propertyName); +} + +void StringInstance::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +{ + int size = internalValue()->getString().size(); + for (int i = 0; i < size; i++) + propertyNames.add(Identifier(UString::from(i))); + return JSObject::getPropertyNames(exec, propertyNames); +} + +// ------------------------------ StringPrototype --------------------------- +const ClassInfo StringPrototype::info = { "String", &StringInstance::info, &stringTable }; +/* Source for string_object.lut.h +@begin stringTable 26 + toString &stringProtoFuncToString DontEnum|Function 0 + valueOf &stringProtoFuncValueOf DontEnum|Function 0 + charAt &stringProtoFuncCharAt DontEnum|Function 1 + charCodeAt &stringProtoFuncCharCodeAt DontEnum|Function 1 + concat &stringProtoFuncConcat DontEnum|Function 1 + indexOf &stringProtoFuncIndexOf DontEnum|Function 1 + lastIndexOf &stringProtoFuncLastIndexOf DontEnum|Function 1 + match &stringProtoFuncMatch DontEnum|Function 1 + replace &stringProtoFuncReplace DontEnum|Function 2 + search &stringProtoFuncSearch DontEnum|Function 1 + slice &stringProtoFuncSlice DontEnum|Function 2 + split &stringProtoFuncSplit DontEnum|Function 2 + substr &stringProtoFuncSubstr DontEnum|Function 2 + substring &stringProtoFuncSubstring DontEnum|Function 2 + toLowerCase &stringProtoFuncToLowerCase DontEnum|Function 0 + toUpperCase &stringProtoFuncToUpperCase DontEnum|Function 0 + toLocaleLowerCase &stringProtoFuncToLocaleLowerCase DontEnum|Function 0 + toLocaleUpperCase &stringProtoFuncToLocaleUpperCase DontEnum|Function 0 + localeCompare &stringProtoFuncLocaleCompare DontEnum|Function 1 + + big &stringProtoFuncBig DontEnum|Function 0 + small &stringProtoFuncSmall DontEnum|Function 0 + blink &stringProtoFuncBlink DontEnum|Function 0 + bold &stringProtoFuncBold DontEnum|Function 0 + fixed &stringProtoFuncFixed DontEnum|Function 0 + italics &stringProtoFuncItalics DontEnum|Function 0 + strike &stringProtoFuncStrike DontEnum|Function 0 + sub &stringProtoFuncSub DontEnum|Function 0 + sup &stringProtoFuncSup DontEnum|Function 0 + fontcolor &stringProtoFuncFontcolor DontEnum|Function 1 + fontsize &stringProtoFuncFontsize DontEnum|Function 1 + anchor &stringProtoFuncAnchor DontEnum|Function 1 + link &stringProtoFuncLink DontEnum|Function 1 +@end +*/ +// ECMA 15.5.4 +StringPrototype::StringPrototype(ExecState* exec, ObjectPrototype* objProto) + : StringInstance(objProto) +{ + // The constructor will be added later, after StringObjectImp has been built + putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum); +} + +bool StringPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot) +{ + return getStaticFunctionSlot(exec, &stringTable, this, propertyName, slot); +} + +// ------------------------------ Functions -------------------------- + +static inline void expandSourceRanges(UString::Range * & array, int& count, int& capacity) +{ + int newCapacity; + if (capacity == 0) { + newCapacity = 16; + } else { + newCapacity = capacity * 2; + } + + UString::Range *newArray = new UString::Range[newCapacity]; + for (int i = 0; i < count; i++) { + newArray[i] = array[i]; + } + + delete [] array; + + capacity = newCapacity; + array = newArray; +} + +static void pushSourceRange(UString::Range * & array, int& count, int& capacity, UString::Range range) +{ + if (count + 1 > capacity) + expandSourceRanges(array, count, capacity); + + array[count] = range; + count++; +} + +static inline void expandReplacements(UString * & array, int& count, int& capacity) +{ + int newCapacity; + if (capacity == 0) { + newCapacity = 16; + } else { + newCapacity = capacity * 2; + } + + UString *newArray = new UString[newCapacity]; + for (int i = 0; i < count; i++) { + newArray[i] = array[i]; + } + + delete [] array; + + capacity = newCapacity; + array = newArray; +} + +static void pushReplacement(UString * & array, int& count, int& capacity, UString replacement) +{ + if (count + 1 > capacity) + expandReplacements(array, count, capacity); + + array[count] = replacement; + count++; +} + +static inline UString substituteBackreferences(const UString &replacement, const UString &source, int *ovector, RegExp *reg) +{ + UString substitutedReplacement = replacement; + + int i = -1; + while ((i = substitutedReplacement.find(UString("$"), i + 1)) != -1) { + if (i+1 == substitutedReplacement.size()) + break; + + unsigned short ref = substitutedReplacement[i+1].unicode(); + int backrefStart = 0; + int backrefLength = 0; + int advance = 0; + + if (ref == '$') { // "$$" -> "$" + substitutedReplacement = substitutedReplacement.substr(0, i + 1) + substitutedReplacement.substr(i + 2); + continue; + } else if (ref == '&') { + backrefStart = ovector[0]; + backrefLength = ovector[1] - backrefStart; + } else if (ref == '`') { + backrefStart = 0; + backrefLength = ovector[0]; + } else if (ref == '\'') { + backrefStart = ovector[1]; + backrefLength = source.size() - backrefStart; + } else if (ref >= '0' && ref <= '9') { + // 1- and 2-digit back references are allowed + unsigned backrefIndex = ref - '0'; + if (backrefIndex > reg->numSubpatterns()) + continue; + if (substitutedReplacement.size() > i + 2) { + ref = substitutedReplacement[i+2].unicode(); + if (ref >= '0' && ref <= '9') { + backrefIndex = 10 * backrefIndex + ref - '0'; + if (backrefIndex > reg->numSubpatterns()) + backrefIndex = backrefIndex / 10; // Fall back to the 1-digit reference + else + advance = 1; + } + } + backrefStart = ovector[2 * backrefIndex]; + backrefLength = ovector[2 * backrefIndex + 1] - backrefStart; + } else + continue; + + substitutedReplacement = substitutedReplacement.substr(0, i) + source.substr(backrefStart, backrefLength) + substitutedReplacement.substr(i + 2 + advance); + i += backrefLength - 1; // - 1 offsets 'i + 1' + } + + return substitutedReplacement; +} +static inline int localeCompare(const UString& a, const UString& b) +{ +#if PLATFORM(WIN_OS) + int retval = CompareStringW(LOCALE_USER_DEFAULT, 0, + reinterpret_cast(a.data()), a.size(), + reinterpret_cast(b.data()), b.size()); + return !retval ? retval : retval - 2; +#elif PLATFORM(CF) + CFStringRef sa = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast(a.data()), a.size(), kCFAllocatorNull); + CFStringRef sb = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast(b.data()), b.size(), kCFAllocatorNull); + + int retval = CFStringCompare(sa, sb, kCFCompareLocalized); + + CFRelease(sa); + CFRelease(sb); + + return retval; +#else + return compare(a, b); +#endif +} + +static JSValue *replace(ExecState *exec, StringImp* sourceVal, JSValue *pattern, JSValue *replacement) +{ + UString source = sourceVal->value(); + JSObject *replacementFunction = 0; + UString replacementString; + + if (replacement->isObject() && replacement->toObject(exec)->implementsCall()) + replacementFunction = replacement->toObject(exec); + else + replacementString = replacement->toString(exec); + + if (pattern->isObject() && static_cast(pattern)->inherits(&RegExpImp::info)) { + RegExp *reg = static_cast(pattern)->regExp(); + bool global = reg->global(); + + RegExpObjectImp* regExpObj = static_cast(exec->lexicalGlobalObject()->regExpConstructor()); + + int lastIndex = 0; + int startPosition = 0; + + UString::Range *sourceRanges = 0; + int sourceRangeCount = 0; + int sourceRangeCapacity = 0; + UString *replacements = 0; + int replacementCount = 0; + int replacementCapacity = 0; + + // This is either a loop (if global is set) or a one-way (if not). + do { + int matchIndex; + int matchLen; + int* ovector; + regExpObj->performMatch(reg, source, startPosition, matchIndex, matchLen, &ovector); + if (matchIndex < 0) + break; + + pushSourceRange(sourceRanges, sourceRangeCount, sourceRangeCapacity, UString::Range(lastIndex, matchIndex - lastIndex)); + + UString substitutedReplacement; + if (replacementFunction) { + int completeMatchStart = ovector[0]; + List args; + + for (unsigned i = 0; i < reg->numSubpatterns() + 1; i++) { + int matchStart = ovector[i * 2]; + int matchLen = ovector[i * 2 + 1] - matchStart; + + if (matchStart < 0) + args.append(jsUndefined()); + else + args.append(jsString(source.substr(matchStart, matchLen))); + } + + args.append(jsNumber(completeMatchStart)); + args.append(sourceVal); + + substitutedReplacement = replacementFunction->call(exec, exec->dynamicGlobalObject(), + args)->toString(exec); + } else + substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg); + + pushReplacement(replacements, replacementCount, replacementCapacity, substitutedReplacement); + + lastIndex = matchIndex + matchLen; + startPosition = lastIndex; + + // special case of empty match + if (matchLen == 0) { + startPosition++; + if (startPosition > source.size()) + break; + } + } while (global); + + if (lastIndex < source.size()) + pushSourceRange(sourceRanges, sourceRangeCount, sourceRangeCapacity, UString::Range(lastIndex, source.size() - lastIndex)); + + UString result; + + if (sourceRanges) + result = source.spliceSubstringsWithSeparators(sourceRanges, sourceRangeCount, replacements, replacementCount); + + delete [] sourceRanges; + delete [] replacements; + + if (result == source) + return sourceVal; + + return jsString(result); + } + + // First arg is a string + UString patternString = pattern->toString(exec); + int matchPos = source.find(patternString); + int matchLen = patternString.size(); + // Do the replacement + if (matchPos == -1) + return sourceVal; + + if (replacementFunction) { + List args; + + args.append(jsString(source.substr(matchPos, matchLen))); + args.append(jsNumber(matchPos)); + args.append(sourceVal); + + replacementString = replacementFunction->call(exec, exec->dynamicGlobalObject(), + args)->toString(exec); + } + + return jsString(source.substr(0, matchPos) + replacementString + source.substr(matchPos + matchLen)); +} + +JSValue* stringProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&StringInstance::info)) + return throwError(exec, TypeError); + + return static_cast(thisObj)->internalValue(); +} + +JSValue* stringProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const List&) +{ + if (!thisObj->inherits(&StringInstance::info)) + return throwError(exec, TypeError); + + return static_cast(thisObj)->internalValue(); +} + +JSValue* stringProtoFuncCharAt(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + int len = s.size(); + + UString u; + JSValue* a0 = args[0]; + double dpos = a0->toInteger(exec); + if (dpos >= 0 && dpos < len) + u = s.substr(static_cast(dpos), 1); + else + u = ""; + return jsString(u); +} + +JSValue* stringProtoFuncCharCodeAt(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + int len = s.size(); + + JSValue* result = 0; + + JSValue* a0 = args[0]; + double dpos = a0->toInteger(exec); + if (dpos >= 0 && dpos < len) + result = jsNumber(s[static_cast(dpos)].unicode()); + else + result = jsNaN(); + return result; +} + +JSValue* stringProtoFuncConcat(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + + List::const_iterator end = args.end(); + for (List::const_iterator it = args.begin(); it != end; ++it) { + s += (*it)->toString(exec); + } + return jsString(s); +} + +JSValue* stringProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + int len = s.size(); + + JSValue* a0 = args[0]; + JSValue* a1 = args[1]; + UString u2 = a0->toString(exec); + double dpos = a1->toInteger(exec); + if (dpos < 0) + dpos = 0; + else if (dpos > len) + dpos = len; + return jsNumber(s.find(u2, static_cast(dpos))); +} + +JSValue* stringProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + int len = s.size(); + + JSValue* a0 = args[0]; + JSValue* a1 = args[1]; + + UString u2 = a0->toString(exec); + double dpos = a1->toIntegerPreserveNaN(exec); + if (dpos < 0) + dpos = 0; + else if (!(dpos <= len)) // true for NaN + dpos = len; + return jsNumber(s.rfind(u2, static_cast(dpos))); +} + +JSValue* stringProtoFuncMatch(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + + JSValue* a0 = args[0]; + + UString u = s; + RegExp* reg; + RegExp* tmpReg = 0; + RegExpImp* imp = 0; + if (a0->isObject() && static_cast(a0)->inherits(&RegExpImp::info)) { + reg = static_cast(a0)->regExp(); + } else { + /* + * ECMA 15.5.4.12 String.prototype.search (regexp) + * If regexp is not an object whose [[Class]] property is "RegExp", it is + * replaced with the result of the expression new RegExp(regexp). + */ + reg = tmpReg = new RegExp(a0->toString(exec)); + } + RegExpObjectImp* regExpObj = static_cast(exec->lexicalGlobalObject()->regExpConstructor()); + int pos; + int matchLength; + regExpObj->performMatch(reg, u, 0, pos, matchLength); + JSValue* result; + if (!(reg->global())) { + // case without 'g' flag is handled like RegExp.prototype.exec + if (pos < 0) + result = jsNull(); + else + result = regExpObj->arrayOfMatches(exec); + } else { + // return array of matches + List list; + int lastIndex = 0; + while (pos >= 0) { + list.append(jsString(u.substr(pos, matchLength))); + lastIndex = pos; + pos += matchLength == 0 ? 1 : matchLength; + regExpObj->performMatch(reg, u, pos, pos, matchLength); + } + if (imp) + imp->setLastIndex(lastIndex); + if (list.isEmpty()) { + // if there are no matches at all, it's important to return + // Null instead of an empty array, because this matches + // other browsers and because Null is a false value. + result = jsNull(); + } else { + result = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, list); + } + } + delete tmpReg; + return result; +} + +JSValue* stringProtoFuncSearch(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + + JSValue* a0 = args[0]; + + UString u = s; + RegExp* reg; + RegExp* tmpReg = 0; + if (a0->isObject() && static_cast(a0)->inherits(&RegExpImp::info)) { + reg = static_cast(a0)->regExp(); + } else { + /* + * ECMA 15.5.4.12 String.prototype.search (regexp) + * If regexp is not an object whose [[Class]] property is "RegExp", it is + * replaced with the result of the expression new RegExp(regexp). + */ + reg = tmpReg = new RegExp(a0->toString(exec)); + } + RegExpObjectImp* regExpObj = static_cast(exec->lexicalGlobalObject()->regExpConstructor()); + int pos; + int matchLength; + regExpObj->performMatch(reg, u, 0, pos, matchLength); + delete tmpReg; + return jsNumber(pos); +} + +JSValue* stringProtoFuncReplace(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + + StringImp* sVal = thisObj->inherits(&StringInstance::info) ? + static_cast(thisObj)->internalValue() : + static_cast(jsString(s)); + + JSValue* a0 = args[0]; + JSValue* a1 = args[1]; + + return replace(exec, sVal, a0, a1); +} + +JSValue* stringProtoFuncSlice(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + int len = s.size(); + + JSValue* a0 = args[0]; + JSValue* a1 = args[1]; + + // The arg processing is very much like ArrayProtoFunc::Slice + double start = a0->toInteger(exec); + double end = a1->isUndefined() ? len : a1->toInteger(exec); + double from = start < 0 ? len + start : start; + double to = end < 0 ? len + end : end; + if (to > from && to > 0 && from < len) { + if (from < 0) + from = 0; + if (to > len) + to = len; + return jsString(s.substr(static_cast(from), static_cast(to - from))); + } + + return jsString(""); +} + +JSValue* stringProtoFuncSplit(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + + JSValue* a0 = args[0]; + JSValue* a1 = args[1]; + + JSObject *constructor = exec->lexicalGlobalObject()->arrayConstructor(); + JSObject* res = static_cast(constructor->construct(exec, exec->emptyList())); + JSValue* result = res; + UString u = s; + int pos; + int i = 0; + int p0 = 0; + uint32_t limit = a1->isUndefined() ? 0xFFFFFFFFU : a1->toUInt32(exec); + if (a0->isObject() && static_cast(a0)->inherits(&RegExpImp::info)) { + RegExp *reg = static_cast(a0)->regExp(); + if (u.isEmpty() && reg->match(u, 0) >= 0) { + // empty string matched by regexp -> empty array + res->put(exec, exec->propertyNames().length, jsNumber(0)); + return result; + } + pos = 0; + while (static_cast(i) != limit && pos < u.size()) { + OwnArrayPtr ovector; + int mpos = reg->match(u, pos, &ovector); + if (mpos < 0) + break; + int mlen = ovector[1] - ovector[0]; + pos = mpos + (mlen == 0 ? 1 : mlen); + if (mpos != p0 || mlen) { + res->put(exec,i, jsString(u.substr(p0, mpos-p0))); + p0 = mpos + mlen; + i++; + } + for (unsigned si = 1; si <= reg->numSubpatterns(); ++si) { + int spos = ovector[si * 2]; + if (spos < 0) + res->put(exec, i++, jsUndefined()); + else + res->put(exec, i++, jsString(u.substr(spos, ovector[si * 2 + 1] - spos))); + } + } + } else { + UString u2 = a0->toString(exec); + if (u2.isEmpty()) { + if (u.isEmpty()) { + // empty separator matches empty string -> empty array + res->put(exec, exec->propertyNames().length, jsNumber(0)); + return result; + } else { + while (static_cast(i) != limit && i < u.size()-1) + res->put(exec, i++, jsString(u.substr(p0++, 1))); + } + } else { + while (static_cast(i) != limit && (pos = u.find(u2, p0)) >= 0) { + res->put(exec, i, jsString(u.substr(p0, pos-p0))); + p0 = pos + u2.size(); + i++; + } + } + } + // add remaining string, if any + if (static_cast(i) != limit) + res->put(exec, i++, jsString(u.substr(p0))); + res->put(exec, exec->propertyNames().length, jsNumber(i)); + return result; +} + +JSValue* stringProtoFuncSubstr(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + int len = s.size(); + + JSValue* a0 = args[0]; + JSValue* a1 = args[1]; + + double start = a0->toInteger(exec); + double length = a1->isUndefined() ? len : a1->toInteger(exec); + if (start >= len) + return jsString(""); + if (length < 0) + return jsString(""); + if (start < 0) { + start += len; + if (start < 0) + start = 0; + } + if (length > len) + length = len; + return jsString(s.substr(static_cast(start), static_cast(length))); +} + +JSValue* stringProtoFuncSubstring(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + int len = s.size(); + + JSValue* a0 = args[0]; + JSValue* a1 = args[1]; + + double start = a0->toNumber(exec); + double end = a1->toNumber(exec); + if (isnan(start)) + start = 0; + if (isnan(end)) + end = 0; + if (start < 0) + start = 0; + if (end < 0) + end = 0; + if (start > len) + start = len; + if (end > len) + end = len; + if (a1->isUndefined()) + end = len; + if (start > end) { + double temp = end; + end = start; + start = temp; + } + return jsString(s.substr((int)start, (int)end-(int)start)); +} + +JSValue* stringProtoFuncToLowerCase(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + + StringImp* sVal = thisObj->inherits(&StringInstance::info) + ? static_cast(thisObj)->internalValue() + : static_cast(jsString(s)); + int ssize = s.size(); + if (!ssize) + return sVal; + Vector< ::UChar> buffer(ssize); + bool error; + int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast(s.data()), ssize, &error); + if (error) { + buffer.resize(length); + length = Unicode::toLower(buffer.data(), length, reinterpret_cast(s.data()), ssize, &error); + if (error) + return sVal; + } + if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) + return sVal; + return jsString(UString(reinterpret_cast(buffer.releaseBuffer()), length, false)); +} + +JSValue* stringProtoFuncToUpperCase(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + + StringImp* sVal = thisObj->inherits(&StringInstance::info) + ? static_cast(thisObj)->internalValue() + : static_cast(jsString(s)); + int ssize = s.size(); + if (!ssize) + return sVal; + Vector< ::UChar> buffer(ssize); + bool error; + int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast(s.data()), ssize, &error); + if (error) { + buffer.resize(length); + length = Unicode::toUpper(buffer.data(), length, reinterpret_cast(s.data()), ssize, &error); + if (error) + return sVal; + } + if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) + return sVal; + return jsString(UString(reinterpret_cast(buffer.releaseBuffer()), length, false)); +} + +JSValue* stringProtoFuncToLocaleLowerCase(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + + // FIXME: See http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt for locale-sensitive mappings that aren't implemented. + StringImp* sVal = thisObj->inherits(&StringInstance::info) + ? static_cast(thisObj)->internalValue() + : static_cast(jsString(s)); + int ssize = s.size(); + if (!ssize) + return sVal; + Vector< ::UChar> buffer(ssize); + bool error; + int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast(s.data()), ssize, &error); + if (error) { + buffer.resize(length); + length = Unicode::toLower(buffer.data(), length, reinterpret_cast(s.data()), ssize, &error); + if (error) + return sVal; + } + if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) + return sVal; + return jsString(UString(reinterpret_cast(buffer.releaseBuffer()), length, false)); +} + +JSValue* stringProtoFuncToLocaleUpperCase(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + + StringImp* sVal = thisObj->inherits(&StringInstance::info) + ? static_cast(thisObj)->internalValue() + : static_cast(jsString(s)); + int ssize = s.size(); + if (!ssize) + return sVal; + Vector< ::UChar> buffer(ssize); + bool error; + int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast(s.data()), ssize, &error); + if (error) { + buffer.resize(length); + length = Unicode::toUpper(buffer.data(), length, reinterpret_cast(s.data()), ssize, &error); + if (error) + return sVal; + } + if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) + return sVal; + return jsString(UString(reinterpret_cast(buffer.releaseBuffer()), length, false)); +} + +JSValue* stringProtoFuncLocaleCompare(ExecState* exec, JSObject* thisObj, const List& args) +{ + if (args.size() < 1) + return jsNumber(0); + + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + JSValue* a0 = args[0]; + return jsNumber(localeCompare(s, a0->toString(exec))); +} + +JSValue* stringProtoFuncBig(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + return jsString("" + s + ""); +} + +JSValue* stringProtoFuncSmall(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + return jsString("" + s + ""); +} + +JSValue* stringProtoFuncBlink(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + return jsString("" + s + ""); +} + +JSValue* stringProtoFuncBold(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + return jsString("" + s + ""); +} + +JSValue* stringProtoFuncFixed(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + return jsString("" + s + ""); +} + +JSValue* stringProtoFuncItalics(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + return jsString("" + s + ""); +} + +JSValue* stringProtoFuncStrike(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + return jsString("" + s + ""); +} + +JSValue* stringProtoFuncSub(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + return jsString("" + s + ""); +} + +JSValue* stringProtoFuncSup(ExecState* exec, JSObject* thisObj, const List&) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + return jsString("" + s + ""); +} + +JSValue* stringProtoFuncFontcolor(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + JSValue* a0 = args[0]; + return jsString("toString(exec) + "\">" + s + ""); +} + +JSValue* stringProtoFuncFontsize(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + JSValue* a0 = args[0]; + return jsString("toString(exec) + "\">" + s + ""); +} + +JSValue* stringProtoFuncAnchor(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + JSValue* a0 = args[0]; + return jsString("toString(exec) + "\">" + s + ""); +} + +JSValue* stringProtoFuncLink(ExecState* exec, JSObject* thisObj, const List& args) +{ + // This optimizes the common case that thisObj is a StringInstance + UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); + JSValue* a0 = args[0]; + return jsString("toString(exec) + "\">" + s + ""); +} + +// ------------------------------ StringObjectImp ------------------------------ + +StringObjectImp::StringObjectImp(ExecState* exec, FunctionPrototype* funcProto, StringPrototype* stringProto) + : InternalFunctionImp(funcProto, stringProto->classInfo()->className) +{ + // ECMA 15.5.3.1 String.prototype + putDirect(exec->propertyNames().prototype, stringProto, DontEnum|DontDelete|ReadOnly); + + putDirectFunction(new StringObjectFuncImp(exec, funcProto, exec->propertyNames().fromCharCode), DontEnum); + + // no. of arguments for constructor + putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); +} + + +bool StringObjectImp::implementsConstruct() const +{ + return true; +} + +// ECMA 15.5.2 +JSObject *StringObjectImp::construct(ExecState *exec, const List &args) +{ + JSObject *proto = exec->lexicalGlobalObject()->stringPrototype(); + if (args.size() == 0) + return new StringInstance(proto); + return new StringInstance(proto, args[0]->toString(exec)); +} + +// ECMA 15.5.1 +JSValue *StringObjectImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args) +{ + if (args.isEmpty()) + return jsString(""); + else { + JSValue *v = args[0]; + return jsString(v->toString(exec)); + } +} + +// ------------------------------ StringObjectFuncImp -------------------------- + +// ECMA 15.5.3.2 fromCharCode() +StringObjectFuncImp::StringObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name) + : InternalFunctionImp(funcProto, name) +{ + putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); +} + +JSValue *StringObjectFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args) +{ + UString s; + if (args.size()) { + UChar *buf = static_cast(fastMalloc(args.size() * sizeof(UChar))); + UChar *p = buf; + List::const_iterator end = args.end(); + for (List::const_iterator it = args.begin(); it != end; ++it) { + unsigned short u = static_cast((*it)->toUInt32(exec)); + *p++ = UChar(u); + } + s = UString(buf, args.size(), false); + } else + s = ""; + + return jsString(s); +} + +} // namespace KJS diff --git a/kjs/string_object.h b/kjs/string_object.h new file mode 100644 index 0000000..3bc9cb2 --- /dev/null +++ b/kjs/string_object.h @@ -0,0 +1,153 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef STRING_OBJECT_H_ +#define STRING_OBJECT_H_ + +#include "function_object.h" +#include "JSWrapperObject.h" +#include "internal.h" +#include "lookup.h" + +namespace KJS { + + class StringInstance : public JSWrapperObject { + public: + StringInstance(JSObject *proto); + StringInstance(JSObject *proto, StringImp*); + StringInstance(JSObject *proto, const UString&); + + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); + + virtual void put(ExecState* exec, const Identifier& propertyName, JSValue*, int attr = None); + virtual bool deleteProperty(ExecState* exec, const Identifier& propertyName); + virtual void getPropertyNames(ExecState*, PropertyNameArray&); + + virtual const ClassInfo *classInfo() const { return &info; } + static const ClassInfo info; + + StringImp* internalValue() const { return static_cast(JSWrapperObject::internalValue());} + + private: + bool inlineGetOwnPropertySlot(ExecState*, unsigned, PropertySlot&); + + static JSValue* lengthGetter(ExecState*, JSObject *, const Identifier&, const PropertySlot&); + static JSValue* indexGetter(ExecState*, JSObject *, const Identifier&, const PropertySlot&); + }; + + // WebCore uses this to make style.filter undetectable + class StringInstanceThatMasqueradesAsUndefined : public StringInstance { + public: + StringInstanceThatMasqueradesAsUndefined(JSObject* proto, const UString& string) + : StringInstance(proto, string) { } + virtual bool masqueradeAsUndefined() const { return true; } + virtual bool toBoolean(ExecState*) const { return false; } + }; + + /** + * @internal + * + * The initial value of String.prototype (and thus all objects created + * with the String constructor + */ + class StringPrototype : public StringInstance { + public: + StringPrototype(ExecState *exec, + ObjectPrototype *objProto); + virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); + virtual const ClassInfo *classInfo() const { return &info; } + static const ClassInfo info; + }; + + /** + * @internal + * + * Functions to implement all methods that are properties of the + * String.prototype object + */ + + JSValue* stringProtoFuncToString(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncValueOf(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncCharAt(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncCharCodeAt(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncConcat(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncIndexOf(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncLastIndexOf(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncMatch(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncReplace(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncSearch(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncSlice(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncSplit(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncSubstr(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncSubstring(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncToLowerCase(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncToUpperCase(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncToLocaleLowerCase(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncToLocaleUpperCase(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncLocaleCompare(ExecState*, JSObject*, const List&); + + JSValue* stringProtoFuncBig(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncSmall(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncBlink(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncBold(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncFixed(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncItalics(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncStrike(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncSub(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncSup(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncFontcolor(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncFontsize(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncAnchor(ExecState*, JSObject*, const List&); + JSValue* stringProtoFuncLink(ExecState*, JSObject*, const List&); + + /** + * @internal + * + * The initial value of the the global variable's "String" property + */ + class StringObjectImp : public InternalFunctionImp { + public: + StringObjectImp(ExecState *exec, + FunctionPrototype *funcProto, + StringPrototype *stringProto); + + virtual bool implementsConstruct() const; + virtual JSObject *construct(ExecState *exec, const List &args); + virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); + }; + + /** + * @internal + * + * Class to implement all methods that are properties of the + * String object + */ + class StringObjectFuncImp : public InternalFunctionImp { + public: + StringObjectFuncImp(ExecState*, FunctionPrototype*, const Identifier&); + virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); + }; + +} // namespace + +#endif + diff --git a/kjs/testkjs.cpp b/kjs/testkjs.cpp new file mode 100644 index 0000000..25c807e --- /dev/null +++ b/kjs/testkjs.cpp @@ -0,0 +1,344 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2004-2007 Apple Inc. + * Copyright (C) 2006 Bjoern Graf (bjoern.graf@gmail.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" + +#include "JSGlobalObject.h" +#include "JSLock.h" +#include "Parser.h" +#include "collector.h" +#include "interpreter.h" +#include "nodes.h" +#include "object.h" +#include "protect.h" +#include +#include +#include +#include +#include + +#if HAVE(SYS_TIME_H) +#include +#endif + +#if PLATFORM(WIN_OS) +#include +#include +#endif + +#if PLATFORM(QT) +#include +#endif + +using namespace KJS; +using namespace WTF; + +static bool fillBufferWithContentsOfFile(const UString& fileName, Vector& buffer); + +class StopWatch +{ +public: + void start(); + void stop(); + long getElapsedMS(); // call stop() first + +private: +#if PLATFORM(QT) + uint m_startTime; + uint m_stopTime; +#elif PLATFORM(WIN_OS) + DWORD m_startTime; + DWORD m_stopTime; +#else + // Windows does not have timeval, disabling this class for now (bug 7399) + timeval m_startTime; + timeval m_stopTime; +#endif +}; + +void StopWatch::start() +{ +#if PLATFORM(QT) + QDateTime t = QDateTime::currentDateTime(); + m_startTime = t.toTime_t() * 1000 + t.time().msec(); +#elif PLATFORM(WIN_OS) + m_startTime = timeGetTime(); +#else + gettimeofday(&m_startTime, 0); +#endif +} + +void StopWatch::stop() +{ +#if PLATFORM(QT) + QDateTime t = QDateTime::currentDateTime(); + m_stopTime = t.toTime_t() * 1000 + t.time().msec(); +#elif PLATFORM(WIN_OS) + m_stopTime = timeGetTime(); +#else + gettimeofday(&m_stopTime, 0); +#endif +} + +long StopWatch::getElapsedMS() +{ +#if PLATFORM(WIN_OS) || PLATFORM(QT) + return m_stopTime - m_startTime; +#else + timeval elapsedTime; + timersub(&m_stopTime, &m_startTime, &elapsedTime); + + return elapsedTime.tv_sec * 1000 + lroundf(elapsedTime.tv_usec / 1000.0f); +#endif +} + +class GlobalImp : public JSGlobalObject { +public: + virtual UString className() const { return "global"; } +}; +COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_GlobalImp_false); + +class TestFunctionImp : public JSObject { +public: + enum TestFunctionType { Print, Debug, Quit, GC, Version, Run, Load }; + + TestFunctionImp(TestFunctionType i, int length); + virtual bool implementsCall() const { return true; } + virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List &args); + +private: + TestFunctionType m_type; +}; + +TestFunctionImp::TestFunctionImp(TestFunctionType i, int length) + : JSObject() + , m_type(i) +{ + putDirect(Identifier("length"), length, DontDelete | ReadOnly | DontEnum); +} + +JSValue* TestFunctionImp::callAsFunction(ExecState* exec, JSObject*, const List &args) +{ + switch (m_type) { + case Print: + printf("%s\n", args[0]->toString(exec).UTF8String().c_str()); + return jsUndefined(); + case Debug: + fprintf(stderr, "--> %s\n", args[0]->toString(exec).UTF8String().c_str()); + return jsUndefined(); + case GC: + { + JSLock lock; + Collector::collect(); + return jsUndefined(); + } + case Version: + // We need this function for compatibility with the Mozilla JS tests but for now + // we don't actually do any version-specific handling + return jsUndefined(); + case Run: + { + StopWatch stopWatch; + UString fileName = args[0]->toString(exec); + Vector script; + if (!fillBufferWithContentsOfFile(fileName, script)) + return throwError(exec, GeneralError, "Could not open file."); + + stopWatch.start(); + Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), fileName, 0, script.data()); + stopWatch.stop(); + + return jsNumber(stopWatch.getElapsedMS()); + } + case Load: + { + UString fileName = args[0]->toString(exec); + Vector script; + if (!fillBufferWithContentsOfFile(fileName, script)) + return throwError(exec, GeneralError, "Could not open file."); + + Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), fileName, 0, script.data()); + + return jsUndefined(); + } + case Quit: + exit(0); + default: + abort(); + } + return 0; +} + +// Use SEH for Release builds only to get rid of the crash report dialog +// (luckily the same tests fail in Release and Debug builds so far). Need to +// be in a separate main function because the kjsmain function requires object +// unwinding. + +#if PLATFORM(WIN_OS) && !defined(_DEBUG) +#define TRY __try { +#define EXCEPT(x) } __except (EXCEPTION_EXECUTE_HANDLER) { x; } +#else +#define TRY +#define EXCEPT(x) +#endif + +int kjsmain(int argc, char** argv); + +int main(int argc, char** argv) +{ +#if defined(_DEBUG) && PLATFORM(WIN_OS) + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); +#endif + + int res = 0; + TRY + res = kjsmain(argc, argv); + EXCEPT(res = 3) + return res; +} + +static GlobalImp* createGlobalObject() +{ + GlobalImp* global = new GlobalImp; + + // add debug() function + global->put(global->globalExec(), "debug", new TestFunctionImp(TestFunctionImp::Debug, 1)); + // add "print" for compatibility with the mozilla js shell + global->put(global->globalExec(), "print", new TestFunctionImp(TestFunctionImp::Print, 1)); + // add "quit" for compatibility with the mozilla js shell + global->put(global->globalExec(), "quit", new TestFunctionImp(TestFunctionImp::Quit, 0)); + // add "gc" for compatibility with the mozilla js shell + global->put(global->globalExec(), "gc", new TestFunctionImp(TestFunctionImp::GC, 0)); + // add "version" for compatibility with the mozilla js shell + global->put(global->globalExec(), "version", new TestFunctionImp(TestFunctionImp::Version, 1)); + global->put(global->globalExec(), "run", new TestFunctionImp(TestFunctionImp::Run, 1)); + global->put(global->globalExec(), "load", new TestFunctionImp(TestFunctionImp::Load, 1)); + + Interpreter::setShouldPrintExceptions(true); + return global; +} + +static bool prettyPrintScript(const UString& fileName, const Vector& script) +{ + int errLine = 0; + UString errMsg; + UString scriptUString(script.data()); + RefPtr programNode = parser().parse(fileName, 0, scriptUString.data(), scriptUString.size(), 0, &errLine, &errMsg); + if (!programNode) { + fprintf(stderr, "%s:%d: %s.\n", fileName.UTF8String().c_str(), errLine, errMsg.UTF8String().c_str()); + return false; + } + + printf("%s\n", programNode->toString().UTF8String().c_str()); + return true; +} + +static bool runWithScripts(const Vector& fileNames, bool prettyPrint) +{ + GlobalImp* globalObject = createGlobalObject(); + Vector script; + + bool success = true; + + for (size_t i = 0; i < fileNames.size(); i++) { + UString fileName = fileNames[i]; + + if (!fillBufferWithContentsOfFile(fileName, script)) + return false; // fail early so we can catch missing files + + if (prettyPrint) + prettyPrintScript(fileName, script); + else { + Completion completion = Interpreter::evaluate(globalObject->globalExec(), fileName, 0, script.data()); + success = success && completion.complType() != Throw; + } + } + return success; +} + +static void parseArguments(int argc, char** argv, Vector& fileNames, bool& prettyPrint) +{ + if (argc < 2) { + fprintf(stderr, "Usage: testkjs file1 [file2...]\n"); + exit(-1); + } + + for (int i = 1; i < argc; i++) { + const char* fileName = argv[i]; + if (strcmp(fileName, "-f") == 0) // mozilla test driver script uses "-f" prefix for files + continue; + if (strcmp(fileName, "-p") == 0) { + prettyPrint = true; + continue; + } + fileNames.append(fileName); + } +} + +int kjsmain(int argc, char** argv) +{ + JSLock lock; + + bool prettyPrint = false; + Vector fileNames; + parseArguments(argc, argv, fileNames, prettyPrint); + + bool success = runWithScripts(fileNames, prettyPrint); + +#ifndef NDEBUG + Collector::collect(); +#endif + + return success ? 0 : 3; +} + +static bool fillBufferWithContentsOfFile(const UString& fileName, Vector& buffer) +{ + FILE* f = fopen(fileName.UTF8String().c_str(), "r"); + if (!f) { + fprintf(stderr, "Could not open file: %s\n", fileName.UTF8String().c_str()); + return false; + } + + size_t buffer_size = 0; + size_t buffer_capacity = 1024; + + buffer.resize(buffer_capacity); + + while (!feof(f) && !ferror(f)) { + buffer_size += fread(buffer.data() + buffer_size, 1, buffer_capacity - buffer_size, f); + if (buffer_size == buffer_capacity) { // guarantees space for trailing '\0' + buffer_capacity *= 2; + buffer.resize(buffer_capacity); + } + } + fclose(f); + buffer[buffer_size] = '\0'; + + return true; +} diff --git a/kjs/testkjs.pro b/kjs/testkjs.pro new file mode 100644 index 0000000..ab3016b --- /dev/null +++ b/kjs/testkjs.pro @@ -0,0 +1,34 @@ +TEMPLATE = app +TARGET = testkjs +DESTDIR = .. +SOURCES = testkjs.cpp +QT -= gui +DEFINES -= KJS_IDENTIFIER_HIDE_GLOBALS +INCLUDEPATH += $$PWD/.. $$PWD $$PWD/../bindings $$PWD/../bindings/c $$PWD/../wtf +CONFIG -= app_bundle +qt-port:DEFINES += BUILDING_QT__ +#qt-port:LIBS += -L$$OUTPUT_DIR/lib -lQtWebKit +gtk-port { + QMAKE_CXXFLAGS += $$system(icu-config --cppflags) + LIBS += $$system(icu-config --ldflags) +} +QMAKE_RPATHDIR += $$OUTPUT_DIR/lib + +isEmpty(OUTPUT_DIR):OUTPUT_DIR=$$PWD/../.. +include($$OUTPUT_DIR/config.pri) +OBJECTS_DIR = tmp +OBJECTS_DIR_WTR = $$OBJECTS_DIR/ +win32-*: OBJECTS_DIR_WTR ~= s|/|\| +include($$PWD/../JavaScriptCore.pri) + +# Hack! Fix this. +SOURCES -= API/JSBase.cpp \ + API/JSCallbackConstructor.cpp \ + API/JSCallbackFunction.cpp \ + API/JSCallbackObject.cpp \ + API/JSClassRef.cpp \ + API/JSContextRef.cpp \ + API/JSObjectRef.cpp \ + API/JSStringRef.cpp \ + API/JSValueRef.cpp + diff --git a/kjs/types.h b/kjs/types.h new file mode 100644 index 0000000..603b2a2 --- /dev/null +++ b/kjs/types.h @@ -0,0 +1,25 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "completion.h" +#include "list.h" diff --git a/kjs/ustring.cpp b/kjs/ustring.cpp new file mode 100644 index 0000000..888eb2d --- /dev/null +++ b/kjs/ustring.cpp @@ -0,0 +1,1288 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "ustring.h" + +#include "JSLock.h" +#include "collector.h" +#include "dtoa.h" +#include "function.h" +#include "identifier.h" +#include "operations.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if HAVE(STRING_H) +#include +#endif +#if HAVE(STRINGS_H) +#include +#endif + +using namespace WTF; +using namespace WTF::Unicode; +using namespace std; + +namespace KJS { + +extern const double NaN; +extern const double Inf; + +static inline const size_t overflowIndicator() { return std::numeric_limits::max(); } +static inline const size_t maxUChars() { return std::numeric_limits::max() / sizeof(UChar); } + +static inline UChar* allocChars(size_t length) +{ + ASSERT(length); + if (length > maxUChars()) + return 0; + return static_cast(fastMalloc(sizeof(UChar) * length)); +} + +static inline UChar* reallocChars(UChar* buffer, size_t length) +{ + ASSERT(length); + if (length > maxUChars()) + return 0; + return static_cast(fastRealloc(buffer, sizeof(UChar) * length)); +} + +COMPILE_ASSERT(sizeof(UChar) == 2, uchar_is_2_bytes) + +CString::CString(const char *c) +{ + length = strlen(c); + data = new char[length+1]; + memcpy(data, c, length + 1); +} + +CString::CString(const char *c, size_t len) +{ + length = len; + data = new char[len+1]; + memcpy(data, c, len); + data[len] = 0; +} + +CString::CString(const CString &b) +{ + length = b.length; + if (b.data) { + data = new char[length+1]; + memcpy(data, b.data, length + 1); + } + else + data = 0; +} + +CString::~CString() +{ + delete [] data; +} + +CString &CString::append(const CString &t) +{ + char *n; + n = new char[length+t.length+1]; + if (length) + memcpy(n, data, length); + if (t.length) + memcpy(n+length, t.data, t.length); + length += t.length; + n[length] = 0; + + delete [] data; + data = n; + + return *this; +} + +CString &CString::operator=(const char *c) +{ + if (data) + delete [] data; + length = strlen(c); + data = new char[length+1]; + memcpy(data, c, length + 1); + + return *this; +} + +CString &CString::operator=(const CString &str) +{ + if (this == &str) + return *this; + + if (data) + delete [] data; + length = str.length; + if (str.data) { + data = new char[length + 1]; + memcpy(data, str.data, length + 1); + } + else + data = 0; + + return *this; +} + +bool operator==(const CString& c1, const CString& c2) +{ + size_t len = c1.size(); + return len == c2.size() && (len == 0 || memcmp(c1.c_str(), c2.c_str(), len) == 0); +} + +// Hack here to avoid a global with a constructor; point to an unsigned short instead of a UChar. +static unsigned short almostUChar; +UString::Rep UString::Rep::null = { 0, 0, 1, 0, 0, &UString::Rep::null, 0, 0, 0, 0, 0, 0 }; +UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, &UString::Rep::empty, 0, reinterpret_cast(&almostUChar), 0, 0, 0, 0 }; +const int normalStatBufferSize = 4096; +static char *statBuffer = 0; // FIXME: This buffer is never deallocated. +static int statBufferSize = 0; + +PassRefPtr UString::Rep::createCopying(const UChar *d, int l) +{ + ASSERT(JSLock::lockCount() > 0); + + int sizeInBytes = l * sizeof(UChar); + UChar *copyD = static_cast(fastMalloc(sizeInBytes)); + memcpy(copyD, d, sizeInBytes); + + return create(copyD, l); +} + +PassRefPtr UString::Rep::create(UChar *d, int l) +{ + ASSERT(JSLock::lockCount() > 0); + + Rep* r = new Rep; + r->offset = 0; + r->len = l; + r->rc = 1; + r->_hash = 0; + r->isIdentifier = 0; + r->baseString = r; + r->reportedCost = 0; + r->buf = d; + r->usedCapacity = l; + r->capacity = l; + r->usedPreCapacity = 0; + r->preCapacity = 0; + + // steal the single reference this Rep was created with + return adoptRef(r); +} + +PassRefPtr UString::Rep::create(PassRefPtr base, int offset, int length) +{ + ASSERT(JSLock::lockCount() > 0); + ASSERT(base); + + int baseOffset = base->offset; + + base = base->baseString; + + ASSERT(-(offset + baseOffset) <= base->usedPreCapacity); + ASSERT(offset + baseOffset + length <= base->usedCapacity); + + Rep *r = new Rep; + r->offset = baseOffset + offset; + r->len = length; + r->rc = 1; + r->_hash = 0; + r->isIdentifier = 0; + r->baseString = base.releaseRef(); + r->reportedCost = 0; + r->buf = 0; + r->usedCapacity = 0; + r->capacity = 0; + r->usedPreCapacity = 0; + r->preCapacity = 0; + + // steal the single reference this Rep was created with + return adoptRef(r); +} + +void UString::Rep::destroy() +{ + ASSERT(JSLock::lockCount() > 0); + + if (isIdentifier) + Identifier::remove(this); + if (baseString != this) { + baseString->deref(); + } else { + fastFree(buf); + } + delete this; +} + +// Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's +// or anything like that. +const unsigned PHI = 0x9e3779b9U; + +// Paul Hsieh's SuperFastHash +// http://www.azillionmonkeys.com/qed/hash.html +unsigned UString::Rep::computeHash(const UChar *s, int len) +{ + unsigned l = len; + uint32_t hash = PHI; + uint32_t tmp; + + int rem = l & 1; + l >>= 1; + + // Main loop + for (; l > 0; l--) { + hash += s[0].uc; + tmp = (s[1].uc << 11) ^ hash; + hash = (hash << 16) ^ tmp; + s += 2; + hash += hash >> 11; + } + + // Handle end case + if (rem) { + hash += s[0].uc; + hash ^= hash << 11; + hash += hash >> 17; + } + + // Force "avalanching" of final 127 bits + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 2; + hash += hash >> 15; + hash ^= hash << 10; + + // this avoids ever returning a hash code of 0, since that is used to + // signal "hash not computed yet", using a value that is likely to be + // effectively the same as 0 when the low bits are masked + if (hash == 0) + hash = 0x80000000; + + return hash; +} + +// Paul Hsieh's SuperFastHash +// http://www.azillionmonkeys.com/qed/hash.html +unsigned UString::Rep::computeHash(const char *s) +{ + // This hash is designed to work on 16-bit chunks at a time. But since the normal case + // (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they + // were 16-bit chunks, which should give matching results + + uint32_t hash = PHI; + uint32_t tmp; + size_t l = strlen(s); + + size_t rem = l & 1; + l >>= 1; + + // Main loop + for (; l > 0; l--) { + hash += (unsigned char)s[0]; + tmp = ((unsigned char)s[1] << 11) ^ hash; + hash = (hash << 16) ^ tmp; + s += 2; + hash += hash >> 11; + } + + // Handle end case + if (rem) { + hash += (unsigned char)s[0]; + hash ^= hash << 11; + hash += hash >> 17; + } + + // Force "avalanching" of final 127 bits + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 2; + hash += hash >> 15; + hash ^= hash << 10; + + // this avoids ever returning a hash code of 0, since that is used to + // signal "hash not computed yet", using a value that is likely to be + // effectively the same as 0 when the low bits are masked + if (hash == 0) + hash = 0x80000000; + + return hash; +} + +// put these early so they can be inlined +inline size_t UString::expandedSize(size_t size, size_t otherSize) const +{ + // Do the size calculation in two parts, returning overflowIndicator if + // we overflow the maximum value that we can handle. + + if (size > maxUChars()) + return overflowIndicator(); + + size_t expandedSize = ((size + 10) / 10 * 11) + 1; + if (maxUChars() - expandedSize < otherSize) + return overflowIndicator(); + + return expandedSize + otherSize; +} + +inline int UString::usedCapacity() const +{ + return m_rep->baseString->usedCapacity; +} + +inline int UString::usedPreCapacity() const +{ + return m_rep->baseString->usedPreCapacity; +} + +void UString::expandCapacity(int requiredLength) +{ + Rep* r = m_rep->baseString; + + if (requiredLength > r->capacity) { + size_t newCapacity = expandedSize(requiredLength, r->preCapacity); + UChar* oldBuf = r->buf; + r->buf = reallocChars(r->buf, newCapacity); + if (!r->buf) { + r->buf = oldBuf; + m_rep = &Rep::null; + return; + } + r->capacity = newCapacity - r->preCapacity; + } + if (requiredLength > r->usedCapacity) { + r->usedCapacity = requiredLength; + } +} + +void UString::expandPreCapacity(int requiredPreCap) +{ + Rep* r = m_rep->baseString; + + if (requiredPreCap > r->preCapacity) { + size_t newCapacity = expandedSize(requiredPreCap, r->capacity); + int delta = newCapacity - r->capacity - r->preCapacity; + + UChar* newBuf = allocChars(newCapacity); + if (!newBuf) { + m_rep = &Rep::null; + return; + } + memcpy(newBuf + delta, r->buf, (r->capacity + r->preCapacity) * sizeof(UChar)); + fastFree(r->buf); + r->buf = newBuf; + + r->preCapacity = newCapacity - r->capacity; + } + if (requiredPreCap > r->usedPreCapacity) { + r->usedPreCapacity = requiredPreCap; + } +} + +UString::UString(const char *c) +{ + if (!c) { + m_rep = &Rep::null; + return; + } + + if (!c[0]) { + m_rep = &Rep::empty; + return; + } + + size_t length = strlen(c); + UChar *d = allocChars(length); + if (!d) + m_rep = &Rep::null; + else { + for (size_t i = 0; i < length; i++) + d[i].uc = c[i]; + m_rep = Rep::create(d, static_cast(length)); + } +} + +UString::UString(const UChar *c, int length) +{ + if (length == 0) + m_rep = &Rep::empty; + else + m_rep = Rep::createCopying(c, length); +} + +UString::UString(UChar *c, int length, bool copy) +{ + if (length == 0) + m_rep = &Rep::empty; + else if (copy) + m_rep = Rep::createCopying(c, length); + else + m_rep = Rep::create(c, length); +} + +UString::UString(const Vector& buffer) +{ + if (!buffer.size()) + m_rep = &Rep::empty; + else + m_rep = Rep::createCopying(buffer.data(), buffer.size()); +} + + +UString::UString(const UString &a, const UString &b) +{ + int aSize = a.size(); + int aOffset = a.m_rep->offset; + int bSize = b.size(); + int bOffset = b.m_rep->offset; + int length = aSize + bSize; + + // possible cases: + + if (aSize == 0) { + // a is empty + m_rep = b.m_rep; + } else if (bSize == 0) { + // b is empty + m_rep = a.m_rep; + } else if (aOffset + aSize == a.usedCapacity() && aSize >= minShareSize && 4 * aSize >= bSize && + (-bOffset != b.usedPreCapacity() || aSize >= bSize)) { + // - a reaches the end of its buffer so it qualifies for shared append + // - also, it's at least a quarter the length of b - appending to a much shorter + // string does more harm than good + // - however, if b qualifies for prepend and is longer than a, we'd rather prepend + UString x(a); + x.expandCapacity(aOffset + length); + if (a.data() && x.data()) { + memcpy(const_cast(a.data() + aSize), b.data(), bSize * sizeof(UChar)); + m_rep = Rep::create(a.m_rep, 0, length); + } else + m_rep = &Rep::null; + } else if (-bOffset == b.usedPreCapacity() && bSize >= minShareSize && 4 * bSize >= aSize) { + // - b reaches the beginning of its buffer so it qualifies for shared prepend + // - also, it's at least a quarter the length of a - prepending to a much shorter + // string does more harm than good + UString y(b); + y.expandPreCapacity(-bOffset + aSize); + if (b.data() && y.data()) { + memcpy(const_cast(b.data() - aSize), a.data(), aSize * sizeof(UChar)); + m_rep = Rep::create(b.m_rep, -aSize, length); + } else + m_rep = &Rep::null; + } else { + // a does not qualify for append, and b does not qualify for prepend, gotta make a whole new string + size_t newCapacity = expandedSize(length, 0); + UChar* d = allocChars(newCapacity); + if (!d) + m_rep = &Rep::null; + else { + memcpy(d, a.data(), aSize * sizeof(UChar)); + memcpy(d + aSize, b.data(), bSize * sizeof(UChar)); + m_rep = Rep::create(d, length); + m_rep->capacity = newCapacity; + } + } +} + +const UString& UString::null() +{ + static UString* n = new UString; + return *n; +} + +UString UString::from(int i) +{ + UChar buf[1 + sizeof(i) * 3]; + UChar *end = buf + sizeof(buf) / sizeof(UChar); + UChar *p = end; + + if (i == 0) { + *--p = '0'; + } else if (i == INT_MIN) { + char minBuf[1 + sizeof(i) * 3]; + snprintf(minBuf, 1 + sizeof(i) * 3, "%d", INT_MIN); + return UString(minBuf); + } else { + bool negative = false; + if (i < 0) { + negative = true; + i = -i; + } + while (i) { + *--p = (unsigned short)((i % 10) + '0'); + i /= 10; + } + if (negative) { + *--p = '-'; + } + } + + return UString(p, static_cast(end - p)); +} + +UString UString::from(unsigned int u) +{ + UChar buf[sizeof(u) * 3]; + UChar *end = buf + sizeof(buf) / sizeof(UChar); + UChar *p = end; + + if (u == 0) { + *--p = '0'; + } else { + while (u) { + *--p = (unsigned short)((u % 10) + '0'); + u /= 10; + } + } + + return UString(p, static_cast(end - p)); +} + +UString UString::from(long l) +{ + UChar buf[1 + sizeof(l) * 3]; + UChar *end = buf + sizeof(buf) / sizeof(UChar); + UChar *p = end; + + if (l == 0) { + *--p = '0'; + } else if (l == LONG_MIN) { + char minBuf[1 + sizeof(l) * 3]; + snprintf(minBuf, 1 + sizeof(l) * 3, "%ld", LONG_MIN); + return UString(minBuf); + } else { + bool negative = false; + if (l < 0) { + negative = true; + l = -l; + } + while (l) { + *--p = (unsigned short)((l % 10) + '0'); + l /= 10; + } + if (negative) { + *--p = '-'; + } + } + + return UString(p, static_cast(end - p)); +} + +UString UString::from(double d) +{ + // avoid ever printing -NaN, in JS conceptually there is only one NaN value + if (isnan(d)) + return "NaN"; + + int buflength= 80; + char buf[buflength]; + int decimalPoint; + int sign; + + char *result = kjs_dtoa(d, 0, 0, &decimalPoint, &sign, NULL); + int length = static_cast(strlen(result)); + + int i = 0; + if (sign) { + buf[i++] = '-'; + } + + if (decimalPoint <= 0 && decimalPoint > -6) { + buf[i++] = '0'; + buf[i++] = '.'; + for (int j = decimalPoint; j < 0; j++) { + buf[i++] = '0'; + } + strlcpy(buf + i, result, buflength - i); + } else if (decimalPoint <= 21 && decimalPoint > 0) { + if (length <= decimalPoint) { + strlcpy(buf + i, result, buflength - i); + i += length; + for (int j = 0; j < decimalPoint - length; j++) { + buf[i++] = '0'; + } + buf[i] = '\0'; + } else { + int len = (decimalPoint <= buflength - i ? decimalPoint : buflength - i); + strncpy(buf + i, result, len); + i += len; + buf[i++] = '.'; + strlcpy(buf + i, result + decimalPoint, buflength - i); + } + } else if (result[0] < '0' || result[0] > '9') { + strlcpy(buf + i, result, buflength - i); + } else { + buf[i++] = result[0]; + if (length > 1) { + buf[i++] = '.'; + strlcpy(buf + i, result + 1, buflength - i); + i += length - 1; + } + + buf[i++] = 'e'; + buf[i++] = (decimalPoint >= 0) ? '+' : '-'; + // decimalPoint can't be more than 3 digits decimal given the + // nature of float representation + int exponential = decimalPoint - 1; + if (exponential < 0) + exponential = -exponential; + if (exponential >= 100) + buf[i++] = static_cast('0' + exponential / 100); + if (exponential >= 10) + buf[i++] = static_cast('0' + (exponential % 100) / 10); + buf[i++] = static_cast('0' + exponential % 10); + buf[i++] = '\0'; + assert(i <= buflength); + } + + kjs_freedtoa(result); + + return UString(buf); +} + +UString UString::spliceSubstringsWithSeparators(const Range* substringRanges, int rangeCount, const UString* separators, int separatorCount) const +{ + if (rangeCount == 1 && separatorCount == 0) { + int thisSize = size(); + int position = substringRanges[0].position; + int length = substringRanges[0].length; + if (position <= 0 && length >= thisSize) + return *this; + return UString::Rep::create(m_rep, max(0, position), min(thisSize, length)); + } + + int totalLength = 0; + for (int i = 0; i < rangeCount; i++) + totalLength += substringRanges[i].length; + for (int i = 0; i < separatorCount; i++) + totalLength += separators[i].size(); + + if (totalLength == 0) + return ""; + + UChar* buffer = allocChars(totalLength); + if (!buffer) + return null(); + + int maxCount = max(rangeCount, separatorCount); + int bufferPos = 0; + for (int i = 0; i < maxCount; i++) { + if (i < rangeCount) { + memcpy(buffer + bufferPos, data() + substringRanges[i].position, substringRanges[i].length * sizeof(UChar)); + bufferPos += substringRanges[i].length; + } + if (i < separatorCount) { + memcpy(buffer + bufferPos, separators[i].data(), separators[i].size() * sizeof(UChar)); + bufferPos += separators[i].size(); + } + } + + return UString::Rep::create(buffer, totalLength); +} + +UString &UString::append(const UString &t) +{ + int thisSize = size(); + int thisOffset = m_rep->offset; + int tSize = t.size(); + int length = thisSize + tSize; + + // possible cases: + if (thisSize == 0) { + // this is empty + *this = t; + } else if (tSize == 0) { + // t is empty + } else if (m_rep->baseIsSelf() && m_rep->rc == 1) { + // this is direct and has refcount of 1 (so we can just alter it directly) + expandCapacity(thisOffset + length); + if (data()) { + memcpy(const_cast(data() + thisSize), t.data(), tSize * sizeof(UChar)); + m_rep->len = length; + m_rep->_hash = 0; + } + } else if (thisOffset + thisSize == usedCapacity() && thisSize >= minShareSize) { + // this reaches the end of the buffer - extend it if it's long enough to append to + expandCapacity(thisOffset + length); + if (data()) { + memcpy(const_cast(data() + thisSize), t.data(), tSize * sizeof(UChar)); + m_rep = Rep::create(m_rep, 0, length); + } + } else { + // this is shared with someone using more capacity, gotta make a whole new string + size_t newCapacity = expandedSize(length, 0); + UChar* d = allocChars(newCapacity); + if (!d) + m_rep = &Rep::null; + else { + memcpy(d, data(), thisSize * sizeof(UChar)); + memcpy(const_cast(d + thisSize), t.data(), tSize * sizeof(UChar)); + m_rep = Rep::create(d, length); + m_rep->capacity = newCapacity; + } + } + + return *this; +} + +UString &UString::append(const char *t) +{ + int thisSize = size(); + int thisOffset = m_rep->offset; + int tSize = static_cast(strlen(t)); + int length = thisSize + tSize; + + // possible cases: + if (thisSize == 0) { + // this is empty + *this = t; + } else if (tSize == 0) { + // t is empty, we'll just return *this below. + } else if (m_rep->baseIsSelf() && m_rep->rc == 1) { + // this is direct and has refcount of 1 (so we can just alter it directly) + expandCapacity(thisOffset + length); + UChar *d = const_cast(data()); + if (d) { + for (int i = 0; i < tSize; ++i) + d[thisSize + i] = t[i]; + m_rep->len = length; + m_rep->_hash = 0; + } + } else if (thisOffset + thisSize == usedCapacity() && thisSize >= minShareSize) { + // this string reaches the end of the buffer - extend it + expandCapacity(thisOffset + length); + UChar *d = const_cast(data()); + if (d) { + for (int i = 0; i < tSize; ++i) + d[thisSize + i] = t[i]; + m_rep = Rep::create(m_rep, 0, length); + } + } else { + // this is shared with someone using more capacity, gotta make a whole new string + size_t newCapacity = expandedSize(length, 0); + UChar* d = allocChars(newCapacity); + if (!d) + m_rep = &Rep::null; + else { + memcpy(d, data(), thisSize * sizeof(UChar)); + for (int i = 0; i < tSize; ++i) + d[thisSize + i] = t[i]; + m_rep = Rep::create(d, length); + m_rep->capacity = newCapacity; + } + } + + return *this; +} + +UString &UString::append(unsigned short c) +{ + int thisOffset = m_rep->offset; + int length = size(); + + // possible cases: + if (length == 0) { + // this is empty - must make a new m_rep because we don't want to pollute the shared empty one + size_t newCapacity = expandedSize(1, 0); + UChar* d = allocChars(newCapacity); + if (!d) + m_rep = &Rep::null; + else { + d[0] = c; + m_rep = Rep::create(d, 1); + m_rep->capacity = newCapacity; + } + } else if (m_rep->baseIsSelf() && m_rep->rc == 1) { + // this is direct and has refcount of 1 (so we can just alter it directly) + expandCapacity(thisOffset + length + 1); + UChar *d = const_cast(data()); + if (d) { + d[length] = c; + m_rep->len = length + 1; + m_rep->_hash = 0; + } + } else if (thisOffset + length == usedCapacity() && length >= minShareSize) { + // this reaches the end of the string - extend it and share + expandCapacity(thisOffset + length + 1); + UChar *d = const_cast(data()); + if (d) { + d[length] = c; + m_rep = Rep::create(m_rep, 0, length + 1); + } + } else { + // this is shared with someone using more capacity, gotta make a whole new string + size_t newCapacity = expandedSize(length + 1, 0); + UChar* d = allocChars(newCapacity); + if (!d) + m_rep = &Rep::null; + else { + memcpy(d, data(), length * sizeof(UChar)); + d[length] = c; + m_rep = Rep::create(d, length + 1); + m_rep->capacity = newCapacity; + } + } + + return *this; +} + +CString UString::cstring() const +{ + return ascii(); +} + +char *UString::ascii() const +{ + // Never make the buffer smaller than normalStatBufferSize. + // Thus we almost never need to reallocate. + int length = size(); + int neededSize = length + 1; + if (neededSize < normalStatBufferSize) { + neededSize = normalStatBufferSize; + } + if (neededSize != statBufferSize) { + delete [] statBuffer; + statBuffer = new char [neededSize]; + statBufferSize = neededSize; + } + + const UChar *p = data(); + char *q = statBuffer; + const UChar *limit = p + length; + while (p != limit) { + *q = static_cast(p->uc); + ++p; + ++q; + } + *q = '\0'; + + return statBuffer; +} + +UString &UString::operator=(const char *c) +{ + if (!c) { + m_rep = &Rep::null; + return *this; + } + + if (!c[0]) { + m_rep = &Rep::empty; + return *this; + } + + int l = static_cast(strlen(c)); + UChar *d; + if (m_rep->rc == 1 && l <= m_rep->capacity && m_rep->baseIsSelf() && m_rep->offset == 0 && m_rep->preCapacity == 0) { + d = m_rep->buf; + m_rep->_hash = 0; + m_rep->len = l; + } else { + d = allocChars(l); + if (!d) { + m_rep = &Rep::null; + return *this; + } + m_rep = Rep::create(d, l); + } + for (int i = 0; i < l; i++) + d[i].uc = c[i]; + + return *this; +} + +bool UString::is8Bit() const +{ + const UChar *u = data(); + const UChar *limit = u + size(); + while (u < limit) { + if (u->uc > 0xFF) + return false; + ++u; + } + + return true; +} + +const UChar UString::operator[](int pos) const +{ + if (pos >= size()) + return '\0'; + return data()[pos]; +} + +double UString::toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const +{ + double d; + + // FIXME: If tolerateTrailingJunk is true, then we want to tolerate non-8-bit junk + // after the number, so is8Bit is too strict a check. + if (!is8Bit()) + return NaN; + + const char *c = ascii(); + + // skip leading white space + while (isASCIISpace(*c)) + c++; + + // empty string ? + if (*c == '\0') + return tolerateEmptyString ? 0.0 : NaN; + + // hex number ? + if (*c == '0' && (*(c+1) == 'x' || *(c+1) == 'X')) { + const char* firstDigitPosition = c + 2; + c++; + d = 0.0; + while (*(++c)) { + if (*c >= '0' && *c <= '9') + d = d * 16.0 + *c - '0'; + else if ((*c >= 'A' && *c <= 'F') || (*c >= 'a' && *c <= 'f')) + d = d * 16.0 + (*c & 0xdf) - 'A' + 10.0; + else + break; + } + + if (d >= mantissaOverflowLowerBound) + d = parseIntOverflow(firstDigitPosition, c - firstDigitPosition, 16); + } else { + // regular number ? + char *end; + d = kjs_strtod(c, &end); + if ((d != 0.0 || end != c) && d != Inf && d != -Inf) { + c = end; + } else { + double sign = 1.0; + + if (*c == '+') + c++; + else if (*c == '-') { + sign = -1.0; + c++; + } + + // We used strtod() to do the conversion. However, strtod() handles + // infinite values slightly differently than JavaScript in that it + // converts the string "inf" with any capitalization to infinity, + // whereas the ECMA spec requires that it be converted to NaN. + + if (c[0] == 'I' && c[1] == 'n' && c[2] == 'f' && c[3] == 'i' && c[4] == 'n' && c[5] == 'i' && c[6] == 't' && c[7] == 'y') { + d = sign * Inf; + c += 8; + } else if ((d == Inf || d == -Inf) && *c != 'I' && *c != 'i') + c = end; + else + return NaN; + } + } + + // allow trailing white space + while (isASCIISpace(*c)) + c++; + // don't allow anything after - unless tolerant=true + if (!tolerateTrailingJunk && *c != '\0') + d = NaN; + + return d; +} + +double UString::toDouble(bool tolerateTrailingJunk) const +{ + return toDouble(tolerateTrailingJunk, true); +} + +double UString::toDouble() const +{ + return toDouble(false, true); +} + +uint32_t UString::toUInt32(bool *ok) const +{ + double d = toDouble(); + bool b = true; + + if (d != static_cast(d)) { + b = false; + d = 0; + } + + if (ok) + *ok = b; + + return static_cast(d); +} + +uint32_t UString::toUInt32(bool *ok, bool tolerateEmptyString) const +{ + double d = toDouble(false, tolerateEmptyString); + bool b = true; + + if (d != static_cast(d)) { + b = false; + d = 0; + } + + if (ok) + *ok = b; + + return static_cast(d); +} + +uint32_t UString::toStrictUInt32(bool *ok) const +{ + if (ok) + *ok = false; + + // Empty string is not OK. + int len = m_rep->len; + if (len == 0) + return 0; + const UChar *p = m_rep->data(); + unsigned short c = p->unicode(); + + // If the first digit is 0, only 0 itself is OK. + if (c == '0') { + if (len == 1 && ok) + *ok = true; + return 0; + } + + // Convert to UInt32, checking for overflow. + uint32_t i = 0; + while (1) { + // Process character, turning it into a digit. + if (c < '0' || c > '9') + return 0; + const unsigned d = c - '0'; + + // Multiply by 10, checking for overflow out of 32 bits. + if (i > 0xFFFFFFFFU / 10) + return 0; + i *= 10; + + // Add in the digit, checking for overflow out of 32 bits. + const unsigned max = 0xFFFFFFFFU - d; + if (i > max) + return 0; + i += d; + + // Handle end of string. + if (--len == 0) { + if (ok) + *ok = true; + return i; + } + + // Get next character. + c = (++p)->unicode(); + } +} + +int UString::find(const UString &f, int pos) const +{ + int sz = size(); + int fsz = f.size(); + if (sz < fsz) + return -1; + if (pos < 0) + pos = 0; + if (fsz == 0) + return pos; + const UChar *end = data() + sz - fsz; + int fsizeminusone = (fsz - 1) * sizeof(UChar); + const UChar *fdata = f.data(); + unsigned short fchar = fdata->uc; + ++fdata; + for (const UChar *c = data() + pos; c <= end; c++) + if (c->uc == fchar && !memcmp(c + 1, fdata, fsizeminusone)) + return static_cast(c - data()); + + return -1; +} + +int UString::find(UChar ch, int pos) const +{ + if (pos < 0) + pos = 0; + const UChar *end = data() + size(); + for (const UChar *c = data() + pos; c < end; c++) + if (*c == ch) + return static_cast(c - data()); + + return -1; +} + +int UString::rfind(const UString &f, int pos) const +{ + int sz = size(); + int fsz = f.size(); + if (sz < fsz) + return -1; + if (pos < 0) + pos = 0; + if (pos > sz - fsz) + pos = sz - fsz; + if (fsz == 0) + return pos; + int fsizeminusone = (fsz - 1) * sizeof(UChar); + const UChar *fdata = f.data(); + for (const UChar *c = data() + pos; c >= data(); c--) { + if (*c == *fdata && !memcmp(c + 1, fdata + 1, fsizeminusone)) + return static_cast(c - data()); + } + + return -1; +} + +int UString::rfind(UChar ch, int pos) const +{ + if (isEmpty()) + return -1; + if (pos + 1 >= size()) + pos = size() - 1; + for (const UChar *c = data() + pos; c >= data(); c--) { + if (*c == ch) + return static_cast(c-data()); + } + + return -1; +} + +UString UString::substr(int pos, int len) const +{ + int s = size(); + + if (pos < 0) + pos = 0; + else if (pos >= s) + pos = s; + if (len < 0) + len = s; + if (pos + len >= s) + len = s - pos; + + if (pos == 0 && len == s) + return *this; + + return UString(Rep::create(m_rep, pos, len)); +} + +bool operator==(const UString& s1, const UString& s2) +{ + if (s1.m_rep->len != s2.m_rep->len) + return false; + + return (memcmp(s1.m_rep->data(), s2.m_rep->data(), + s1.m_rep->len * sizeof(UChar)) == 0); +} + +bool operator==(const UString& s1, const char *s2) +{ + if (s2 == 0) { + return s1.isEmpty(); + } + + const UChar *u = s1.data(); + const UChar *uend = u + s1.size(); + while (u != uend && *s2) { + if (u->uc != (unsigned char)*s2) + return false; + s2++; + u++; + } + + return u == uend && *s2 == 0; +} + +bool operator<(const UString& s1, const UString& s2) +{ + const int l1 = s1.size(); + const int l2 = s2.size(); + const int lmin = l1 < l2 ? l1 : l2; + const UChar *c1 = s1.data(); + const UChar *c2 = s2.data(); + int l = 0; + while (l < lmin && *c1 == *c2) { + c1++; + c2++; + l++; + } + if (l < lmin) + return (c1->uc < c2->uc); + + return (l1 < l2); +} + +int compare(const UString& s1, const UString& s2) +{ + const int l1 = s1.size(); + const int l2 = s2.size(); + const int lmin = l1 < l2 ? l1 : l2; + const UChar *c1 = s1.data(); + const UChar *c2 = s2.data(); + int l = 0; + while (l < lmin && *c1 == *c2) { + c1++; + c2++; + l++; + } + + if (l < lmin) + return (c1->uc > c2->uc) ? 1 : -1; + + if (l1 == l2) + return 0; + + return (l1 > l2) ? 1 : -1; +} + +CString UString::UTF8String(bool strict) const +{ + // Allocate a buffer big enough to hold all the characters. + const int length = size(); + Vector buffer(length * 3); + + // Convert to runs of 8-bit characters. + char* p = buffer.data(); + const ::UChar* d = reinterpret_cast(&data()->uc); + ConversionResult result = convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), strict); + if (result != conversionOK) + return CString(); + + return CString(buffer.data(), p - buffer.data()); +} + +} // namespace KJS diff --git a/kjs/ustring.h b/kjs/ustring.h new file mode 100644 index 0000000..7faa86a --- /dev/null +++ b/kjs/ustring.h @@ -0,0 +1,470 @@ +// -*- c-basic-offset: 2 -*- +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef _KJS_USTRING_H_ +#define _KJS_USTRING_H_ + +#include "JSLock.h" +#include "collector.h" +#include +#include +#include +#include +#include +#include + +/* On some ARM platforms GCC won't pack structures by default so sizeof(UChar) + will end up being != 2 which causes crashes since the code depends on that. */ +#if COMPILER(GCC) && PLATFORM(FORCE_PACK) +#define PACK_STRUCT __attribute__((packed)) +#else +#define PACK_STRUCT +#endif + +/** + * @internal + */ +namespace DOM { + class DOMString; + class AtomicString; +} +class KJScript; + +namespace KJS { + + using WTF::PlacementNewAdoptType; + using WTF::PlacementNewAdopt; + + class UString; + + /** + * @short Unicode character. + * + * UChar represents a 16 bit Unicode character. It's internal data + * representation is compatible to XChar2b and QChar. It's therefore + * possible to exchange data with X and Qt with shallow copies. + */ + struct UChar { + /** + * Construct a character with uninitialized value. + */ + UChar(); + /** + * Construct a character with the value denoted by the arguments. + * @param h higher byte + * @param l lower byte + */ + UChar(unsigned char h , unsigned char l); + /** + * Construct a character with the given value. + * @param u 16 bit Unicode value + */ + UChar(char u); + UChar(unsigned char u); + UChar(unsigned short u); + /** + * @return The higher byte of the character. + */ + unsigned char high() const { return static_cast(uc >> 8); } + /** + * @return The lower byte of the character. + */ + unsigned char low() const { return static_cast(uc); } + /** + * @return the 16 bit Unicode value of the character + */ + unsigned short unicode() const { return uc; } + + unsigned short uc; + } PACK_STRUCT; + + inline UChar::UChar() { } + inline UChar::UChar(unsigned char h , unsigned char l) : uc(h << 8 | l) { } + inline UChar::UChar(char u) : uc((unsigned char)u) { } + inline UChar::UChar(unsigned char u) : uc(u) { } + inline UChar::UChar(unsigned short u) : uc(u) { } + + /** + * @short 8 bit char based string class + */ + class CString { + public: + CString() : data(0), length(0) { } + CString(const char *c); + CString(const char *c, size_t len); + CString(const CString &); + + ~CString(); + + CString &append(const CString &); + CString &operator=(const char *c); + CString &operator=(const CString &); + CString &operator+=(const CString &c) { return append(c); } + + size_t size() const { return length; } + const char *c_str() const { return data; } + private: + char *data; + size_t length; + }; + + /** + * @short Unicode string class + */ + class UString { + friend bool operator==(const UString&, const UString&); + + public: + /** + * @internal + */ + struct Rep { + + static PassRefPtr create(UChar *d, int l); + static PassRefPtr createCopying(const UChar *d, int l); + static PassRefPtr create(PassRefPtr base, int offset, int length); + + void destroy(); + + bool baseIsSelf() const { return baseString == this; } + UChar* data() const { return baseString->buf + baseString->preCapacity + offset; } + int size() const { return len; } + + unsigned hash() const { if (_hash == 0) _hash = computeHash(data(), len); return _hash; } + unsigned computedHash() const { ASSERT(_hash); return _hash; } // fast path for Identifiers + + static unsigned computeHash(const UChar *, int length); + static unsigned computeHash(const char *); + + Rep* ref() { ASSERT(JSLock::lockCount() > 0); ++rc; return this; } + ALWAYS_INLINE void deref() { ASSERT(JSLock::lockCount() > 0); if (--rc == 0) destroy(); } + + // unshared data + int offset; + int len; + int rc; + mutable unsigned _hash; + bool isIdentifier; + UString::Rep* baseString; + size_t reportedCost; + + // potentially shared data + UChar *buf; + int usedCapacity; + int capacity; + int usedPreCapacity; + int preCapacity; + + static Rep null; + static Rep empty; + }; + + public: + + /** + * Constructs a null string. + */ + UString(); + /** + * Constructs a string from a classical zero-terminated char string. + */ + UString(const char *c); + /** + * Constructs a string from an array of Unicode characters of the specified + * length. + */ + UString(const UChar *c, int length); + /** + * If copy is false the string data will be adopted. + * That means that the data will NOT be copied and the pointer will + * be deleted when the UString object is modified or destroyed. + * Behaviour defaults to a deep copy if copy is true. + */ + UString(UChar *c, int length, bool copy); + /** + * Copy constructor. Makes a shallow copy only. + */ + UString(const UString &s) : m_rep(s.m_rep) {} + + UString(const Vector& buffer); + + /** + * Convenience declaration only ! You'll be on your own to write the + * implementation for a construction from DOM::DOMString. + * + * Note: feel free to contact me if you want to see a dummy header for + * your favorite FooString class here ! + */ + UString(const DOM::DOMString&); + /** + * Convenience declaration only ! See UString(const DOM::DOMString&). + */ + UString(const DOM::AtomicString&); + + /** + * Concatenation constructor. Makes operator+ more efficient. + */ + UString(const UString &, const UString &); + /** + * Destructor. + */ + ~UString() {} + + // Special constructor for cases where we overwrite an object in place. + UString(PlacementNewAdoptType) : m_rep(PlacementNewAdopt) { } + + /** + * Constructs a string from an int. + */ + static UString from(int i); + /** + * Constructs a string from an unsigned int. + */ + static UString from(unsigned int u); + /** + * Constructs a string from a long int. + */ + static UString from(long u); + /** + * Constructs a string from a double. + */ + static UString from(double d); + + struct Range { + public: + Range(int pos, int len) : position(pos), length(len) {} + Range() {} + int position; + int length; + }; + + UString spliceSubstringsWithSeparators(const Range *substringRanges, int rangeCount, const UString *separators, int separatorCount) const; + + /** + * Append another string. + */ + UString &append(const UString &); + UString &append(const char *); + UString &append(unsigned short); + UString &append(char c) { return append(static_cast(static_cast(c))); } + UString &append(UChar c) { return append(c.uc); } + + /** + * @return The string converted to the 8-bit string type CString(). + * This method is not Unicode safe and shouldn't be used unless the string + * is known to be ASCII. + */ + CString cstring() const; + /** + * Convert the Unicode string to plain ASCII chars chopping of any higher + * bytes. This method should only be used for *debugging* purposes as it + * is neither Unicode safe nor free from side effects. In order not to + * waste any memory the char buffer is static and *shared* by all UString + * instances. + */ + char *ascii() const; + + /** + * Convert the string to UTF-8, assuming it is UTF-16 encoded. + * In non-strict mode, this function is tolerant of badly formed UTF-16, it + * can create UTF-8 strings that are invalid because they have characters in + * the range U+D800-U+DDFF, U+FFFE, or U+FFFF, but the UTF-8 string is + * guaranteed to be otherwise valid. + * In strict mode, error is returned as null CString. + */ + CString UTF8String(bool strict = false) const; + + /** + * @see UString(const DOM::DOMString&). + */ + DOM::DOMString domString() const; + + /** + * Assignment operator. + */ + UString &operator=(const char *c); + /** + * Appends the specified string. + */ + UString &operator+=(const UString &s) { return append(s); } + UString &operator+=(const char *s) { return append(s); } + + /** + * @return A pointer to the internal Unicode data. + */ + const UChar* data() const { return m_rep->data(); } + /** + * @return True if null. + */ + bool isNull() const { return (m_rep == &Rep::null); } + /** + * @return True if null or zero length. + */ + bool isEmpty() const { return (!m_rep->len); } + /** + * Use this if you want to make sure that this string is a plain ASCII + * string. For example, if you don't want to lose any information when + * using cstring() or ascii(). + * + * @return True if the string doesn't contain any non-ASCII characters. + */ + bool is8Bit() const; + /** + * @return The length of the string. + */ + int size() const { return m_rep->size(); } + /** + * Const character at specified position. + */ + const UChar operator[](int pos) const; + + /** + * Attempts an conversion to a number. Apart from floating point numbers, + * the algorithm will recognize hexadecimal representations (as + * indicated by a 0x or 0X prefix) and +/- Infinity. + * Returns NaN if the conversion failed. + * @param tolerateTrailingJunk if true, toDouble can tolerate garbage after the number. + * @param tolerateEmptyString if false, toDouble will turn an empty string into NaN rather than 0. + */ + double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const; + double toDouble(bool tolerateTrailingJunk) const; + double toDouble() const; + + /** + * Attempts an conversion to a 32-bit integer. ok will be set + * according to the success. + * @param tolerateEmptyString if false, toUInt32 will return false for *ok for an empty string. + */ + uint32_t toUInt32(bool *ok = 0) const; + uint32_t toUInt32(bool *ok, bool tolerateEmptyString) const; + uint32_t toStrictUInt32(bool *ok = 0) const; + + /** + * Attempts an conversion to an array index. The "ok" boolean will be set + * to true if it is a valid array index according to the rule from + * ECMA 15.2 about what an array index is. It must exactly match the string + * form of an unsigned integer, and be less than 2^32 - 1. + */ + unsigned toArrayIndex(bool *ok = 0) const; + + /** + * @return Position of first occurrence of f starting at position pos. + * -1 if the search was not successful. + */ + int find(const UString &f, int pos = 0) const; + int find(UChar, int pos = 0) const; + /** + * @return Position of first occurrence of f searching backwards from + * position pos. + * -1 if the search was not successful. + */ + int rfind(const UString &f, int pos) const; + int rfind(UChar, int pos) const; + /** + * @return The sub string starting at position pos and length len. + */ + UString substr(int pos = 0, int len = -1) const; + /** + * Static instance of a null string. + */ + static const UString &null(); + + Rep* rep() const { return m_rep.get(); } + UString(PassRefPtr r) : m_rep(r) { ASSERT(m_rep); } + + size_t cost() const; + + private: + size_t expandedSize(size_t size, size_t otherSize) const; + int usedCapacity() const; + int usedPreCapacity() const; + void expandCapacity(int requiredLength); + void expandPreCapacity(int requiredPreCap); + + RefPtr m_rep; + }; + + inline bool operator==(const UChar &c1, const UChar &c2) { + return (c1.uc == c2.uc); + } + bool operator==(const UString& s1, const UString& s2); + inline bool operator!=(const UString& s1, const UString& s2) { + return !KJS::operator==(s1, s2); + } + bool operator<(const UString& s1, const UString& s2); + bool operator==(const UString& s1, const char *s2); + inline bool operator!=(const UString& s1, const char *s2) { + return !KJS::operator==(s1, s2); + } + inline bool operator==(const char *s1, const UString& s2) { + return operator==(s2, s1); + } + inline bool operator!=(const char *s1, const UString& s2) { + return !KJS::operator==(s1, s2); + } + bool operator==(const CString& s1, const CString& s2); + inline UString operator+(const UString& s1, const UString& s2) { + return UString(s1, s2); + } + + int compare(const UString &, const UString &); + +inline UString::UString() + : m_rep(&Rep::null) +{ +} + +// Rule from ECMA 15.2 about what an array index is. +// Must exactly match string form of an unsigned integer, and be less than 2^32 - 1. +inline unsigned UString::toArrayIndex(bool *ok) const +{ + unsigned i = toStrictUInt32(ok); + if (ok && i >= 0xFFFFFFFFU) + *ok = false; + return i; +} + +// We'd rather not do shared substring append for small strings, since +// this runs too much risk of a tiny initial string holding down a +// huge buffer. +// FIXME: this should be size_t but that would cause warnings until we +// fix UString sizes to be size_t instead of int +static const int minShareSize = Collector::minExtraCostSize / sizeof(UChar); + +inline size_t UString::cost() const +{ + size_t capacity = (m_rep->baseString->capacity + m_rep->baseString->preCapacity) * sizeof(UChar); + size_t reportedCost = m_rep->baseString->reportedCost; + ASSERT(capacity >= reportedCost); + + size_t capacityDelta = capacity - reportedCost; + + if (capacityDelta < static_cast(minShareSize)) + return 0; + + m_rep->baseString->reportedCost = capacity; + return capacityDelta; +} + +} // namespace + +#endif diff --git a/kjs/value.cpp b/kjs/value.cpp new file mode 100644 index 0000000..55da40b --- /dev/null +++ b/kjs/value.cpp @@ -0,0 +1,232 @@ +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "value.h" + +#include "error_object.h" +#include "nodes.h" +#include +#include +#include + +namespace KJS { + +#if defined NAN && defined INFINITY + +extern const double NaN = NAN; +extern const double Inf = INFINITY; + +#else // !(defined NAN && defined INFINITY) + +// The trick is to define the NaN and Inf globals with a different type than the declaration. +// This trick works because the mangled name of the globals does not include the type, although +// I'm not sure that's guaranteed. There could be alignment issues with this, since arrays of +// characters don't necessarily need the same alignment doubles do, but for now it seems to work. +// It would be good to figure out a 100% clean way that still avoids code that runs at init time. + +// Note, we have to use union to ensure alignment. Otherwise, NaN_Bytes can start anywhere, +// while NaN_double has to be 4-byte aligned for 32-bits. +// With -fstrict-aliasing enabled, unions are the only safe way to do type masquerading. + +static const union { + struct { + unsigned char NaN_Bytes[8]; + unsigned char Inf_Bytes[8]; + } bytes; + + struct { + double NaN_Double; + double Inf_Double; + } doubles; + +} NaNInf = { { +#if PLATFORM(BIG_ENDIAN) + { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }, + { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } +#elif PLATFORM(MIDDLE_ENDIAN) + { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 }, + { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } +#else + { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }, + { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } +#endif +} } ; + +extern const double NaN = NaNInf.doubles.NaN_Double; +extern const double Inf = NaNInf.doubles.Inf_Double; + +#endif // !(defined NAN && defined INFINITY) + +static const double D16 = 65536.0; +static const double D32 = 4294967296.0; + +void *JSCell::operator new(size_t size) +{ + return Collector::allocate(size); +} + +bool JSCell::getUInt32(uint32_t&) const +{ + return false; +} + +bool JSCell::getTruncatedInt32(int32_t&) const +{ + return false; +} + +bool JSCell::getTruncatedUInt32(uint32_t&) const +{ + return false; +} + +// ECMA 9.4 +double JSValue::toInteger(ExecState *exec) const +{ + int32_t i; + if (getTruncatedInt32(i)) + return i; + double d = toNumber(exec); + return isnan(d) ? 0.0 : trunc(d); +} + +double JSValue::toIntegerPreserveNaN(ExecState *exec) const +{ + int32_t i; + if (getTruncatedInt32(i)) + return i; + return trunc(toNumber(exec)); +} + +int32_t JSValue::toInt32SlowCase(double d, bool& ok) +{ + ok = true; + + if (d >= -D32 / 2 && d < D32 / 2) + return static_cast(d); + + if (isnan(d) || isinf(d)) { + ok = false; + return 0; + } + + double d32 = fmod(trunc(d), D32); + if (d32 >= D32 / 2) + d32 -= D32; + else if (d32 < -D32 / 2) + d32 += D32; + return static_cast(d32); +} + +int32_t JSValue::toInt32SlowCase(ExecState* exec, bool& ok) const +{ + return JSValue::toInt32SlowCase(toNumber(exec), ok); +} + +uint32_t JSValue::toUInt32SlowCase(double d, bool& ok) +{ + ok = true; + + if (d >= 0.0 && d < D32) + return static_cast(d); + + if (isnan(d) || isinf(d)) { + ok = false; + return 0; + } + + double d32 = fmod(trunc(d), D32); + if (d32 < 0) + d32 += D32; + return static_cast(d32); +} + +uint32_t JSValue::toUInt32SlowCase(ExecState* exec, bool& ok) const +{ + return JSValue::toUInt32SlowCase(toNumber(exec), ok); +} + +float JSValue::toFloat(ExecState* exec) const +{ + return static_cast(toNumber(exec)); +} + +bool JSCell::getNumber(double &numericValue) const +{ + if (!isNumber()) + return false; + numericValue = static_cast(this)->value(); + return true; +} + +double JSCell::getNumber() const +{ + return isNumber() ? static_cast(this)->value() : NaN; +} + +bool JSCell::getString(UString &stringValue) const +{ + if (!isString()) + return false; + stringValue = static_cast(this)->value(); + return true; +} + +UString JSCell::getString() const +{ + return isString() ? static_cast(this)->value() : UString(); +} + +JSObject *JSCell::getObject() +{ + return isObject() ? static_cast(this) : 0; +} + +const JSObject *JSCell::getObject() const +{ + return isObject() ? static_cast(this) : 0; +} + +JSCell* jsString(const char* s) +{ + return new StringImp(s ? s : ""); +} + +JSCell* jsString(const UString& s) +{ + return s.isNull() ? new StringImp("") : new StringImp(s); +} + +JSCell* jsOwnedString(const UString& s) +{ + return s.isNull() ? new StringImp("", StringImp::HasOtherOwner) : new StringImp(s, StringImp::HasOtherOwner); +} + +// This method includes a PIC branch to set up the NumberImp's vtable, so we quarantine +// it in a separate function to keep the normal case speedy. +JSValue *jsNumberCell(double d) +{ + return new NumberImp(d); +} + +} // namespace KJS diff --git a/kjs/value.h b/kjs/value.h new file mode 100644 index 0000000..5ebb575 --- /dev/null +++ b/kjs/value.h @@ -0,0 +1,523 @@ +/* + * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2004, 2005, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_VALUE_H +#define KJS_VALUE_H + +#include "JSImmediate.h" +#include "collector.h" +#include "ustring.h" +#include // for size_t + +namespace KJS { + +class ExecState; +class JSObject; +class JSCell; + +struct ClassInfo; + +/** + * JSValue is the base type for all primitives (Undefined, Null, Boolean, + * String, Number) and objects in ECMAScript. + * + * Note: you should never inherit from JSValue as it is for primitive types + * only (all of which are provided internally by KJS). Instead, inherit from + * JSObject. + */ +class JSValue : Noncopyable { + friend class JSCell; // so it can derive from this class + friend class Collector; // so it can call asCell() + +private: + JSValue(); + virtual ~JSValue(); + +public: + // Querying the type. + JSType type() const; + bool isUndefined() const; + bool isNull() const; + bool isUndefinedOrNull() const; + bool isBoolean() const; + bool isNumber() const; + bool isString() const; + bool isObject() const; + bool isObject(const ClassInfo *) const; + + // Extracting the value. + bool getBoolean(bool&) const; + bool getBoolean() const; // false if not a boolean + bool getNumber(double&) const; + double getNumber() const; // NaN if not a number + bool getString(UString&) const; + UString getString() const; // null string if not a string + JSObject *getObject(); // NULL if not an object + const JSObject *getObject() const; // NULL if not an object + + // Extracting integer values. + bool getUInt32(uint32_t&) const; + bool getTruncatedInt32(int32_t&) const; + bool getTruncatedUInt32(uint32_t&) const; + + // Basic conversions. + JSValue* toPrimitive(ExecState* exec, JSType preferredType = UnspecifiedType) const; + bool getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value); + + bool toBoolean(ExecState *exec) const; + double toNumber(ExecState *exec) const; + JSValue* toJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number. + UString toString(ExecState *exec) const; + JSObject *toObject(ExecState *exec) const; + + // Integer conversions. + double toInteger(ExecState*) const; + double toIntegerPreserveNaN(ExecState*) const; + int32_t toInt32(ExecState*) const; + int32_t toInt32(ExecState*, bool& ok) const; + uint32_t toUInt32(ExecState*) const; + uint32_t toUInt32(ExecState*, bool& ok) const; + + // These are identical logic to above, and faster than jsNumber(number)->toInt32(exec) + static int32_t toInt32(double); + static int32_t toUInt32(double); + + // Floating point conversions. + float toFloat(ExecState*) const; + + // Garbage collection. + void mark(); + bool marked() const; + + static int32_t toInt32SlowCase(double, bool& ok); + static uint32_t toUInt32SlowCase(double, bool& ok); + +private: + int32_t toInt32SlowCase(ExecState*, bool& ok) const; + uint32_t toUInt32SlowCase(ExecState*, bool& ok) const; + + // Implementation details. + JSCell *asCell(); + const JSCell *asCell() const; + + // Give a compile time error if we try to copy one of these. + JSValue(const JSValue&); + JSValue& operator=(const JSValue&); +}; + +class JSCell : public JSValue { + friend class Collector; + friend class NumberImp; + friend class StringImp; + friend class JSObject; + friend class GetterSetterImp; +private: + JSCell(); + virtual ~JSCell(); +public: + // Querying the type. + virtual JSType type() const = 0; + bool isNumber() const; + bool isString() const; + bool isObject() const; + bool isObject(const ClassInfo *) const; + + // Extracting the value. + bool getNumber(double&) const; + double getNumber() const; // NaN if not a number + bool getString(UString&) const; + UString getString() const; // null string if not a string + JSObject *getObject(); // NULL if not an object + const JSObject *getObject() const; // NULL if not an object + + // Extracting integer values. + virtual bool getUInt32(uint32_t&) const; + virtual bool getTruncatedInt32(int32_t&) const; + virtual bool getTruncatedUInt32(uint32_t&) const; + + // Basic conversions. + virtual JSValue *toPrimitive(ExecState *exec, JSType preferredType = UnspecifiedType) const = 0; + virtual bool getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value) = 0; + virtual bool toBoolean(ExecState *exec) const = 0; + virtual double toNumber(ExecState *exec) const = 0; + virtual UString toString(ExecState *exec) const = 0; + virtual JSObject *toObject(ExecState *exec) const = 0; + + // Garbage collection. + void *operator new(size_t); + virtual void mark(); + bool marked() const; +}; + +JSValue *jsNumberCell(double); + +JSCell *jsString(const UString&); // returns empty string if passed null string +JSCell *jsString(const char* = ""); // returns empty string if passed 0 + +// should be used for strings that are owned by an object that will +// likely outlive the JSValue this makes, such as the parse tree or a +// DOM object that contains a UString +JSCell *jsOwnedString(const UString&); + +extern const double NaN; +extern const double Inf; + +inline JSValue *jsUndefined() +{ + return JSImmediate::undefinedImmediate(); +} + +inline JSValue *jsNull() +{ + return JSImmediate::nullImmediate(); +} + +inline JSValue *jsNaN() +{ + static const union { + uint64_t bits; + double d; + } nan = { 0x7ff80000ULL << 32 }; + return jsNumberCell(nan.d); +} + +inline JSValue *jsBoolean(bool b) +{ + return b ? JSImmediate::trueImmediate() : JSImmediate::falseImmediate(); +} + +ALWAYS_INLINE JSValue* jsNumber(double d) +{ + JSValue* v = JSImmediate::from(d); + return v ? v : jsNumberCell(d); +} + +ALWAYS_INLINE JSValue* jsNumber(int i) +{ + JSValue* v = JSImmediate::from(i); + return v ? v : jsNumberCell(i); +} + +ALWAYS_INLINE JSValue* jsNumber(unsigned i) +{ + JSValue* v = JSImmediate::from(i); + return v ? v : jsNumberCell(i); +} + +ALWAYS_INLINE JSValue* jsNumber(long i) +{ + JSValue* v = JSImmediate::from(i); + return v ? v : jsNumberCell(i); +} + +ALWAYS_INLINE JSValue* jsNumber(unsigned long i) +{ + JSValue* v = JSImmediate::from(i); + return v ? v : jsNumberCell(i); +} + +ALWAYS_INLINE JSValue* jsNumber(long long i) +{ + JSValue* v = JSImmediate::from(i); + return v ? v : jsNumberCell(static_cast(i)); +} + +ALWAYS_INLINE JSValue* jsNumber(unsigned long long i) +{ + JSValue* v = JSImmediate::from(i); + return v ? v : jsNumberCell(static_cast(i)); +} + +ALWAYS_INLINE JSValue* jsNumberFromAnd(ExecState *exec, JSValue* v1, JSValue* v2) +{ + if (JSImmediate::areBothImmediateNumbers(v1, v2)) + return JSImmediate::andImmediateNumbers(v1, v2); + return jsNumber(v1->toInt32(exec) & v2->toInt32(exec)); +} + +inline JSValue::JSValue() +{ +} + +inline JSValue::~JSValue() +{ +} + +inline JSCell::JSCell() +{ +} + +inline JSCell::~JSCell() +{ +} + +inline bool JSCell::isNumber() const +{ + return type() == NumberType; +} + +inline bool JSCell::isString() const +{ + return type() == StringType; +} + +inline bool JSCell::isObject() const +{ + return type() == ObjectType; +} + +inline bool JSCell::marked() const +{ + return Collector::isCellMarked(this); +} + +inline void JSCell::mark() +{ + return Collector::markCell(this); +} + +ALWAYS_INLINE JSCell* JSValue::asCell() +{ + ASSERT(!JSImmediate::isImmediate(this)); + return static_cast(this); +} + +ALWAYS_INLINE const JSCell* JSValue::asCell() const +{ + ASSERT(!JSImmediate::isImmediate(this)); + return static_cast(this); +} + +inline bool JSValue::isUndefined() const +{ + return this == jsUndefined(); +} + +inline bool JSValue::isNull() const +{ + return this == jsNull(); +} + +inline bool JSValue::isUndefinedOrNull() const +{ + return JSImmediate::isUndefinedOrNull(this); +} + +inline bool JSValue::isBoolean() const +{ + return JSImmediate::isBoolean(this); +} + +inline bool JSValue::isNumber() const +{ + return JSImmediate::isNumber(this) || (!JSImmediate::isImmediate(this) && asCell()->isNumber()); +} + +inline bool JSValue::isString() const +{ + return !JSImmediate::isImmediate(this) && asCell()->isString(); +} + +inline bool JSValue::isObject() const +{ + return !JSImmediate::isImmediate(this) && asCell()->isObject(); +} + +inline bool JSValue::getBoolean(bool& v) const +{ + if (JSImmediate::isBoolean(this)) { + v = JSImmediate::toBoolean(this); + return true; + } + + return false; +} + +inline bool JSValue::getBoolean() const +{ + return JSImmediate::isBoolean(this) ? JSImmediate::toBoolean(this) : false; +} + +inline bool JSValue::getNumber(double& v) const +{ + if (JSImmediate::isImmediate(this)) { + v = JSImmediate::toDouble(this); + return true; + } + return asCell()->getNumber(v); +} + +inline double JSValue::getNumber() const +{ + return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->getNumber(); +} + +inline bool JSValue::getString(UString& s) const +{ + return !JSImmediate::isImmediate(this) && asCell()->getString(s); +} + +inline UString JSValue::getString() const +{ + return JSImmediate::isImmediate(this) ? UString() : asCell()->getString(); +} + +inline JSObject *JSValue::getObject() +{ + return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject(); +} + +inline const JSObject *JSValue::getObject() const +{ + return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject(); +} + +ALWAYS_INLINE bool JSValue::getUInt32(uint32_t& v) const +{ + return JSImmediate::isImmediate(this) ? JSImmediate::getUInt32(this, v) : asCell()->getUInt32(v); +} + +ALWAYS_INLINE bool JSValue::getTruncatedInt32(int32_t& v) const +{ + return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedInt32(this, v) : asCell()->getTruncatedInt32(v); +} + +inline bool JSValue::getTruncatedUInt32(uint32_t& v) const +{ + return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedUInt32(this, v) : asCell()->getTruncatedUInt32(v); +} + +inline void JSValue::mark() +{ + ASSERT(!JSImmediate::isImmediate(this)); // callers should check !marked() before calling mark() + asCell()->mark(); +} + +inline bool JSValue::marked() const +{ + return JSImmediate::isImmediate(this) || asCell()->marked(); +} + +inline JSType JSValue::type() const +{ + return JSImmediate::isImmediate(this) ? JSImmediate::type(this) : asCell()->type(); +} + +inline JSValue* JSValue::toPrimitive(ExecState* exec, JSType preferredType) const +{ + return JSImmediate::isImmediate(this) ? const_cast(this) : asCell()->toPrimitive(exec, preferredType); +} + +inline bool JSValue::getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value) +{ + if (JSImmediate::isImmediate(this)) { + number = JSImmediate::toDouble(this); + value = this; + return true; + } + return asCell()->getPrimitiveNumber(exec, number, value); +} + +inline bool JSValue::toBoolean(ExecState *exec) const +{ + return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean(exec); +} + +ALWAYS_INLINE double JSValue::toNumber(ExecState *exec) const +{ + return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->toNumber(exec); +} + +ALWAYS_INLINE JSValue* JSValue::toJSNumber(ExecState* exec) const +{ + return JSImmediate::isNumber(this) ? const_cast(this) : jsNumber(this->toNumber(exec)); +} + +inline UString JSValue::toString(ExecState *exec) const +{ + return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : asCell()->toString(exec); +} + +inline JSObject* JSValue::toObject(ExecState* exec) const +{ + return JSImmediate::isImmediate(this) ? JSImmediate::toObject(this, exec) : asCell()->toObject(exec); +} + +ALWAYS_INLINE int32_t JSValue::toInt32(ExecState* exec) const +{ + int32_t i; + if (getTruncatedInt32(i)) + return i; + bool ok; + return toInt32SlowCase(exec, ok); +} + +inline uint32_t JSValue::toUInt32(ExecState* exec) const +{ + uint32_t i; + if (getTruncatedUInt32(i)) + return i; + bool ok; + return toUInt32SlowCase(exec, ok); +} + +inline int32_t JSValue::toInt32(double val) +{ + if (!(val >= -2147483648.0 && val < 2147483648.0)) { + bool ignored; + return toInt32SlowCase(val, ignored); + } + return static_cast(val); +} + +inline int32_t JSValue::toUInt32(double val) +{ + if (!(val >= 0.0 && val < 4294967296.0)) { + bool ignored; + return toUInt32SlowCase(val, ignored); + } + return static_cast(val); +} + +inline int32_t JSValue::toInt32(ExecState* exec, bool& ok) const +{ + int32_t i; + if (getTruncatedInt32(i)) { + ok = true; + return i; + } + return toInt32SlowCase(exec, ok); +} + +inline uint32_t JSValue::toUInt32(ExecState* exec, bool& ok) const +{ + uint32_t i; + if (getTruncatedUInt32(i)) { + ok = true; + return i; + } + return toUInt32SlowCase(exec, ok); +} + +} // namespace + +#endif // KJS_VALUE_H diff --git a/make-generated-sources.sh b/make-generated-sources.sh new file mode 100755 index 0000000..e1e247b --- /dev/null +++ b/make-generated-sources.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +export SRCROOT=$PWD +export WebCore=$PWD +export CREATE_HASH_TABLE="$SRCROOT/kjs/create_hash_table" + +mkdir -p DerivedSources/JavaScriptCore +cd DerivedSources/JavaScriptCore + +make -f ../../DerivedSources.make JavaScriptCore=../.. BUILT_PRODUCTS_DIR=../.. +cd ../.. diff --git a/os-win32/stdbool.h b/os-win32/stdbool.h new file mode 100644 index 0000000..8e7bace --- /dev/null +++ b/os-win32/stdbool.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2005, 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef STDBOOL_WIN32_H +#define STDBOOL_WIN32_H + +#if !PLATFORM(WIN_OS) +#error "This stdbool.h file should only be compiled under Windows" +#endif + +#ifndef __cplusplus + +typedef unsigned char bool; + +#define true 1 +#define false 0 + +#ifndef CASSERT +#define CASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; +#endif + +CASSERT(sizeof(bool) == 1, bool_is_one_byte) +CASSERT(true, true_is_true) +CASSERT(!false, false_is_false) + +#endif + +#endif diff --git a/os-win32/stdint.h b/os-win32/stdint.h new file mode 100644 index 0000000..48ae474 --- /dev/null +++ b/os-win32/stdint.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2005, 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef STDINT_WIN32_H +#define STDINT_WIN32_H + +#include + +/* This file emulates enough of stdint.h on Windows to make JavaScriptCore and WebCore compile. */ + +#if !PLATFORM(WIN_OS) +#error "This stdint.h file should only be compiled under Windows" +#endif + +typedef unsigned char uint8_t; +typedef signed char int8_t; +typedef unsigned short uint16_t; +typedef short int16_t; +typedef unsigned int uint32_t; +typedef int int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; + +#ifndef CASSERT +#define CASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; +#endif + +CASSERT(sizeof(int8_t) == 1, int8_t_is_one_byte) +CASSERT(sizeof(uint8_t) == 1, uint8_t_is_one_byte) +CASSERT(sizeof(int16_t) == 2, int16_t_is_two_bytes) +CASSERT(sizeof(uint16_t) == 2, uint16_t_is_two_bytes) +CASSERT(sizeof(int32_t) == 4, int32_t_is_four_bytes) +CASSERT(sizeof(uint32_t) == 4, uint32_t_is_four_bytes) +CASSERT(sizeof(int64_t) == 8, int64_t_is_four_bytes) +CASSERT(sizeof(uint64_t) == 8, uint64_t_is_four_bytes) + +#endif diff --git a/pcre/AUTHORS b/pcre/AUTHORS new file mode 100644 index 0000000..dbac2a5 --- /dev/null +++ b/pcre/AUTHORS @@ -0,0 +1,12 @@ +Originally written by: Philip Hazel +Email local part: ph10 +Email domain: cam.ac.uk + +University of Cambridge Computing Service, +Cambridge, England. Phone: +44 1223 334714. + +Copyright (c) 1997-2005 University of Cambridge. All rights reserved. + +Adapted for JavaScriptCore and WebKit by Apple Inc. + +Copyright (c) 2005, 2006, 2007 Apple Inc. All rights reserved. diff --git a/pcre/COPYING b/pcre/COPYING new file mode 100644 index 0000000..6ffdc24 --- /dev/null +++ b/pcre/COPYING @@ -0,0 +1,35 @@ +PCRE is a library of functions to support regular expressions whose syntax +and semantics are as close as possible to those of the Perl 5 language. + +This is JavaScriptCore's variant of the PCRE library. While this library +started out as a copy of PCRE, many of the features of PCRE have been +removed. + +Copyright (c) 1997-2005 University of Cambridge. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the name of Apple + Inc. nor the names of their contributors may be used to endorse or + promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/pcre/dftables b/pcre/dftables new file mode 100755 index 0000000..fbd51e6 --- /dev/null +++ b/pcre/dftables @@ -0,0 +1,264 @@ +#!/usr/bin/perl -w +# +# This is JavaScriptCore's variant of the PCRE library. While this library +# started out as a copy of PCRE, many of the features of PCRE have been +# removed. This library now supports only the regular expression features +# required by the JavaScript language specification, and has only the functions +# needed by JavaScriptCore and the rest of WebKit. +# +# Originally written by Philip Hazel +# Copyright (c) 1997-2006 University of Cambridge +# Copyright (C) 2002, 2004, 2006, 2007, 2008 Apple Inc. All rights reserved. +# +# ----------------------------------------------------------------------------- +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the University of Cambridge nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------------------------- + +# This is a freestanding support program to generate a file containing +# character tables. The tables are built according to the default C +# locale. + +use strict; + +use File::Basename; +use File::Spec; +use File::Temp; + +sub readHeaderValues(); + +my %pcre_internal; + +if (scalar(@ARGV) != 1) { + print STDERR "Usage: ", basename($0), " output-file\n"; + exit 1; +} + +my $outputFile = shift @ARGV; + +readHeaderValues(); + +open(OUT, ">", $outputFile) or die "$!"; +binmode(OUT); + +printf(OUT + "/*************************************************\n" . + "* Perl-Compatible Regular Expressions *\n" . + "*************************************************/\n\n" . + "/* This file is automatically written by the dftables auxiliary \n" . + "program. If you edit it by hand, you might like to edit the Makefile to \n" . + "prevent its ever being regenerated.\n\n"); +printf(OUT + "This file contains the default tables for characters with codes less than\n" . + "128 (ASCII characters). These tables are used when no external tables are\n" . + "passed to PCRE. */\n\n" . + "const unsigned char kjs_pcre_default_tables[%d] = {\n\n" . + "/* This table is a lower casing table. */\n\n", $pcre_internal{tables_length}); + +if ($pcre_internal{lcc_offset} != 0) { + die "lcc_offset != 0"; +} + +printf(OUT " "); +for (my $i = 0; $i < 128; $i++) { + if (($i & 7) == 0 && $i != 0) { + printf(OUT "\n "); + } + printf(OUT "0x%02X", ord(lc(chr($i)))); + if ($i != 127) { + printf(OUT ", "); + } +} +printf(OUT ",\n\n"); + +printf(OUT "/* This table is a case flipping table. */\n\n"); + +if ($pcre_internal{fcc_offset} != 128) { + die "fcc_offset != 128"; +} + +printf(OUT " "); +for (my $i = 0; $i < 128; $i++) { + if (($i & 7) == 0 && $i != 0) { + printf(OUT "\n "); + } + my $c = chr($i); + printf(OUT "0x%02X", $c =~ /[[:lower:]]/ ? ord(uc($c)) : ord(lc($c))); + if ($i != 127) { + printf(OUT ", "); + } +} +printf(OUT ",\n\n"); + +printf(OUT + "/* This table contains bit maps for various character classes.\n" . + "Each map is 32 bytes long and the bits run from the least\n" . + "significant end of each byte. The classes are: space, digit, word. */\n\n"); + +if ($pcre_internal{cbits_offset} != $pcre_internal{fcc_offset} + 128) { + die "cbits_offset != fcc_offset + 128"; +} + +my @cbit_table = (0) x $pcre_internal{cbit_length}; +for (my $i = ord('0'); $i <= ord('9'); $i++) { + $cbit_table[$pcre_internal{cbit_digit} + $i / 8] |= 1 << ($i & 7); +} +$cbit_table[$pcre_internal{cbit_word} + ord('_') / 8] |= 1 << (ord('_') & 7); +for (my $i = 0; $i < 128; $i++) { + my $c = chr($i); + if ($c =~ /[[:alnum:]]/) { + $cbit_table[$pcre_internal{cbit_word} + $i / 8] |= 1 << ($i & 7); + } + if ($c =~ /[[:space:]]/) { + $cbit_table[$pcre_internal{cbit_space} + $i / 8] |= 1 << ($i & 7); + } +} + +printf(OUT " "); +for (my $i = 0; $i < $pcre_internal{cbit_length}; $i++) { + if (($i & 7) == 0 && $i != 0) { + if (($i & 31) == 0) { + printf(OUT "\n"); + } + printf(OUT "\n "); + } + printf(OUT "0x%02X", $cbit_table[$i]); + if ($i != $pcre_internal{cbit_length} - 1) { + printf(OUT ", "); + } +} +printf(OUT ",\n\n"); + +printf(OUT + "/* This table identifies various classes of character by individual bits:\n" . + " 0x%02x white space character\n" . + " 0x%02x hexadecimal digit\n" . + " 0x%02x alphanumeric or '_'\n*/\n\n", + $pcre_internal{ctype_space}, $pcre_internal{ctype_xdigit}, $pcre_internal{ctype_word}); + +if ($pcre_internal{ctypes_offset} != $pcre_internal{cbits_offset} + $pcre_internal{cbit_length}) { + die "ctypes_offset != cbits_offset + cbit_length"; +} + +printf(OUT " "); +for (my $i = 0; $i < 128; $i++) { + my $x = 0; + my $c = chr($i); + if ($c =~ /[[:space:]]/) { + $x += $pcre_internal{ctype_space}; + } + if ($c =~ /[[:xdigit:]]/) { + $x += $pcre_internal{ctype_xdigit}; + } + if ($c =~ /[[:alnum:]_]/) { + $x += $pcre_internal{ctype_word}; + } + printf(OUT "0x%02X", $x); + if ($i != 127) { + printf(OUT ", "); + } else { + printf(OUT "};"); + } + if (($i & 7) == 7) { + printf(OUT " /* "); + my $d = chr($i - 7); + if ($d =~ /[[:print:]]/) { + printf(OUT " %c -", $i - 7); + } else { + printf(OUT "%3d-", $i - 7); + } + if ($c =~ m/[[:print:]]/) { + printf(OUT " %c ", $i); + } else { + printf(OUT "%3d", $i); + } + printf(OUT " */\n"); + if ($i != 127) { + printf(OUT " "); + } + } +} + +if ($pcre_internal{tables_length} != $pcre_internal{ctypes_offset} + 128) { + die "tables_length != ctypes_offset + 128"; +} + +printf(OUT "\n\n/* End of chartables.c */\n"); + +close(OUT); + +exit 0; + +sub readHeaderValues() +{ + my @variables = qw( + cbit_digit + cbit_length + cbit_space + cbit_word + cbits_offset + ctype_space + ctype_word + ctype_xdigit + ctypes_offset + fcc_offset + lcc_offset + tables_length + ); + + local $/ = undef; + + my $headerPath = File::Spec->catfile(dirname($0), "pcre_internal.h"); + + my $fh = new File::Temp( + DIR => ($ENV{'TMPDIR'} || "/tmp"), + SUFFIX => ".in", + TEMPLATE => basename($0) . "-XXXXXXXX", + UNLINK => 0, + ); + my $tempFile = $fh->filename(); + + print $fh "#define DFTABLES\n\n"; + + open(HEADER, "<", $headerPath) or die "$!"; + print $fh
; + close(HEADER); + + print $fh "\n\n"; + + for my $v (@variables) { + print $fh "\$pcre_internal{\"$v\"} = $v;\n"; + } + + close($fh); + + open(CPP, "cpp '$tempFile' |") or die "$!"; + my $content = ; + close(CPP); + + eval $content; + die "$@" if $@; +} diff --git a/pcre/pcre.h b/pcre/pcre.h new file mode 100644 index 0000000..1be4523 --- /dev/null +++ b/pcre/pcre.h @@ -0,0 +1,68 @@ +/* This is the public header file for JavaScriptCore's variant of the PCRE +library. While this library started out as a copy of PCRE, many of the +features of PCRE have been removed. This library now supports only the +regular expression features required by the JavaScript language +specification, and has only the functions needed by JavaScriptCore and the +rest of WebKit. + + Copyright (c) 1997-2005 University of Cambridge + Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +// FIXME: This file needs to be renamed to JSRegExp.h; it's no longer PCRE. + +#ifndef JSRegExp_h +#define JSRegExp_h + +#include + +struct JSRegExp; + +enum JSRegExpIgnoreCaseOption { JSRegExpDoNotIgnoreCase, JSRegExpIgnoreCase }; +enum JSRegExpMultilineOption { JSRegExpSingleLine, JSRegExpMultiline }; + +/* jsRegExpExecute error codes */ +const int JSRegExpErrorNoMatch = -1; +const int JSRegExpErrorHitLimit = -2; +const int JSRegExpErrorNoMemory = -3; +const int JSRegExpErrorInternal = -4; + +JSRegExp* jsRegExpCompile(const ::UChar* pattern, int patternLength, + JSRegExpIgnoreCaseOption, JSRegExpMultilineOption, + unsigned* numSubpatterns, const char** errorMessage); + +int jsRegExpExecute(const JSRegExp*, + const ::UChar* subject, int subjectLength, int startOffset, + int* offsetsVector, int offsetsVectorLength); + +void jsRegExpFree(JSRegExp*); + +#endif diff --git a/pcre/pcre.pri b/pcre/pcre.pri new file mode 100644 index 0000000..c2e9312 --- /dev/null +++ b/pcre/pcre.pri @@ -0,0 +1,34 @@ +# Perl Compatible Regular Expressions - Qt4 build info +VPATH += $$PWD +INCLUDEPATH += $$PWD $$OUTPUT_DIR/JavaScriptCore/kjs/tmp +DEPENDPATH += $$PWD + +isEmpty(GENERATED_SOURCES_DIR):GENERATED_SOURCES_DIR = tmp + +SOURCES += \ + pcre_compile.cpp \ + pcre_exec.cpp \ + pcre_tables.cpp \ + pcre_ucp_searchfuncs.cpp \ + pcre_xclass.cpp + +!CONFIG(QTDIR_build) { + defineTest(addExtraCompiler) { + QMAKE_EXTRA_COMPILERS += $$1 + generated_files.depends += compiler_$${1}_make_all + export(QMAKE_EXTRA_COMPILERS) + export(generated_files.depends) + return(true) + } +} + +# GENERATOR: "chartables.c": compile and execute the chartables generator (and add it to sources) +DFTABLES = $$PWD/dftables +ctgen.input = DFTABLES +ctgen.output = $$GENERATED_SOURCES_DIR/chartables.c +ctgen.commands = perl $$DFTABLES ${QMAKE_FILE_OUT} +ctgen.CONFIG += target_predeps no_link +ctgen.variable_out = GENERATED_SOURCES +ctgen.dependency_type = TYPE_C +ctgen.clean = ${QMAKE_FILE_OUT} ${QMAKE_VAR_GENERATED_SOURCES_DIR}${QMAKE_FILE_BASE} +addExtraCompiler(ctgen) diff --git a/pcre/pcre_compile.cpp b/pcre/pcre_compile.cpp new file mode 100644 index 0000000..49b9a58 --- /dev/null +++ b/pcre/pcre_compile.cpp @@ -0,0 +1,2671 @@ +/* This is JavaScriptCore's variant of the PCRE library. While this library +started out as a copy of PCRE, many of the features of PCRE have been +removed. This library now supports only the regular expression features +required by the JavaScript language specification, and has only the functions +needed by JavaScriptCore and the rest of WebKit. + + Originally written by Philip Hazel + Copyright (c) 1997-2006 University of Cambridge + Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. + Copyright (C) 2007 Eric Seidel + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +/* This module contains the external function jsRegExpExecute(), along with +supporting internal functions that are not used by other modules. */ + +#include "config.h" + +#include "pcre_internal.h" + +#include +#include +#include + +using namespace WTF; + +/* Negative values for the firstchar and reqchar variables */ + +#define REQ_UNSET (-2) +#define REQ_NONE (-1) + +/************************************************* +* Code parameters and static tables * +*************************************************/ + +/* Maximum number of items on the nested bracket stacks at compile time. This +applies to the nesting of all kinds of parentheses. It does not limit +un-nested, non-capturing parentheses. This number can be made bigger if +necessary - it is used to dimension one int and one unsigned char vector at +compile time. */ + +#define BRASTACK_SIZE 200 + +/* Table for handling escaped characters in the range '0'-'z'. Positive returns +are simple data values; negative values are for special things like \d and so +on. Zero means further processing is needed (for things like \x), or the escape +is invalid. */ + +static const short escapes[] = { + 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */ + 0, 0, ':', ';', '<', '=', '>', '?', /* 8 - ? */ + '@', 0, -ESC_B, 0, -ESC_D, 0, 0, 0, /* @ - G */ + 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */ + 0, 0, 0, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */ + 0, 0, 0, '[', '\\', ']', '^', '_', /* X - _ */ + '`', 7, -ESC_b, 0, -ESC_d, 0, '\f', 0, /* ` - g */ + 0, 0, 0, 0, 0, 0, '\n', 0, /* h - o */ + 0, 0, '\r', -ESC_s, '\t', 0, '\v', -ESC_w, /* p - w */ + 0, 0, 0 /* x - z */ +}; + +/* Error code numbers. They are given names so that they can more easily be +tracked. */ + +enum ErrorCode { + ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, + ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17 +}; + +/* The texts of compile-time error messages. These are "char *" because they +are passed to the outside world. */ + +static const char* errorText(ErrorCode code) +{ + static const char errorTexts[] = + /* 1 */ + "\\ at end of pattern\0" + "\\c at end of pattern\0" + "character value in \\x{...} sequence is too large\0" + "numbers out of order in {} quantifier\0" + /* 5 */ + "number too big in {} quantifier\0" + "missing terminating ] for character class\0" + "internal error: code overflow\0" + "range out of order in character class\0" + "nothing to repeat\0" + /* 10 */ + "unmatched parentheses\0" + "internal error: unexpected repeat\0" + "unrecognized character after (?\0" + "failed to get memory\0" + "missing )\0" + /* 15 */ + "reference to non-existent subpattern\0" + "regular expression too large\0" + "parentheses nested too deeply" + ; + + int i = code; + const char* text = errorTexts; + while (i > 1) + i -= !*text++; + return text; +} + +/* Structure for passing "static" information around between the functions +doing the compiling. */ + +struct CompileData { + CompileData() { + top_backref = 0; + backrefMap = 0; + req_varyopt = 0; + needOuterBracket = false; + numCapturingBrackets = 0; + } + int top_backref; /* Maximum back reference */ + unsigned backrefMap; /* Bitmap of low back refs */ + int req_varyopt; /* "After variable item" flag for reqbyte */ + bool needOuterBracket; + int numCapturingBrackets; +}; + +/* Definitions to allow mutual recursion */ + +static bool compileBracket(int, int*, unsigned char**, const UChar**, const UChar*, ErrorCode*, int, int*, int*, CompileData&); +static bool bracketIsAnchored(const unsigned char* code); +static bool bracketNeedsLineStart(const unsigned char* code, unsigned captureMap, unsigned backrefMap); +static int bracketFindFirstAssertedCharacter(const unsigned char* code, bool inassert); + +/************************************************* +* Handle escapes * +*************************************************/ + +/* This function is called when a \ has been encountered. It either returns a +positive value for a simple escape such as \n, or a negative value which +encodes one of the more complicated things such as \d. When UTF-8 is enabled, +a positive value greater than 255 may be returned. On entry, ptr is pointing at +the \. On exit, it is on the final character of the escape sequence. + +Arguments: + ptrptr points to the pattern position pointer + errorcodeptr points to the errorcode variable + bracount number of previous extracting brackets + options the options bits + isclass true if inside a character class + +Returns: zero or positive => a data character + negative => a special escape sequence + on error, errorptr is set +*/ + +static int checkEscape(const UChar** ptrptr, const UChar* patternEnd, ErrorCode* errorcodeptr, int bracount, bool isclass) +{ + const UChar* ptr = *ptrptr + 1; + + /* If backslash is at the end of the pattern, it's an error. */ + if (ptr == patternEnd) { + *errorcodeptr = ERR1; + *ptrptr = ptr; + return 0; + } + + int c = *ptr; + + /* Non-alphamerics are literals. For digits or letters, do an initial lookup in + a table. A non-zero result is something that can be returned immediately. + Otherwise further processing may be required. */ + + if (c < '0' || c > 'z') { /* Not alphameric */ + } else if (int escapeValue = escapes[c - '0']) { + c = escapeValue; + if (isclass) { + if (-c == ESC_b) + c = '\b'; /* \b is backslash in a class */ + else if (-c == ESC_B) + c = 'B'; /* and \B is a capital B in a class (in browsers event though ECMAScript 15.10.2.19 says it raises an error) */ + } + /* Escapes that need further processing, or are illegal. */ + + } else { + switch (c) { + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + /* Escape sequences starting with a non-zero digit are backreferences, + unless there are insufficient brackets, in which case they are octal + escape sequences. Those sequences end on the first non-octal character + or when we overflow 0-255, whichever comes first. */ + + if (!isclass) { + const UChar* oldptr = ptr; + c -= '0'; + while ((ptr + 1 < patternEnd) && isASCIIDigit(ptr[1]) && c <= bracount) + c = c * 10 + *(++ptr) - '0'; + if (c <= bracount) { + c = -(ESC_REF + c); + break; + } + ptr = oldptr; /* Put the pointer back and fall through */ + } + + /* Handle an octal number following \. If the first digit is 8 or 9, + this is not octal. */ + + if ((c = *ptr) >= '8') + break; + + /* \0 always starts an octal number, but we may drop through to here with a + larger first octal digit. */ + + case '0': { + c -= '0'; + int i; + for (i = 1; i <= 2; ++i) { + if (ptr + i >= patternEnd || ptr[i] < '0' || ptr[i] > '7') + break; + int cc = c * 8 + ptr[i] - '0'; + if (cc > 255) + break; + c = cc; + } + ptr += i - 1; + break; + } + + case 'x': { + c = 0; + int i; + for (i = 1; i <= 2; ++i) { + if (ptr + i >= patternEnd || !isASCIIHexDigit(ptr[i])) { + c = 'x'; + i = 1; + break; + } + int cc = ptr[i]; + if (cc >= 'a') + cc -= 32; /* Convert to upper case */ + c = c * 16 + cc - ((cc < 'A') ? '0' : ('A' - 10)); + } + ptr += i - 1; + break; + } + + case 'u': { + c = 0; + int i; + for (i = 1; i <= 4; ++i) { + if (ptr + i >= patternEnd || !isASCIIHexDigit(ptr[i])) { + c = 'u'; + i = 1; + break; + } + int cc = ptr[i]; + if (cc >= 'a') + cc -= 32; /* Convert to upper case */ + c = c * 16 + cc - ((cc < 'A') ? '0' : ('A' - 10)); + } + ptr += i - 1; + break; + } + + case 'c': + if (++ptr == patternEnd) { + *errorcodeptr = ERR2; + return 0; + } + c = *ptr; + + /* A letter is upper-cased; then the 0x40 bit is flipped. This coding + is ASCII-specific, but then the whole concept of \cx is ASCII-specific. */ + c = toASCIIUpper(c) ^ 0x40; + break; + } + } + + *ptrptr = ptr; + return c; +} + +/************************************************* +* Check for counted repeat * +*************************************************/ + +/* This function is called when a '{' is encountered in a place where it might +start a quantifier. It looks ahead to see if it really is a quantifier or not. +It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd} +where the ddds are digits. + +Arguments: + p pointer to the first char after '{' + +Returns: true or false +*/ + +static bool isCountedRepeat(const UChar* p, const UChar* patternEnd) +{ + if (p >= patternEnd || !isASCIIDigit(*p)) + return false; + p++; + while (p < patternEnd && isASCIIDigit(*p)) + p++; + if (p < patternEnd && *p == '}') + return true; + + if (p >= patternEnd || *p++ != ',') + return false; + if (p < patternEnd && *p == '}') + return true; + + if (p >= patternEnd || !isASCIIDigit(*p)) + return false; + p++; + while (p < patternEnd && isASCIIDigit(*p)) + p++; + + return (p < patternEnd && *p == '}'); +} + +/************************************************* +* Read repeat counts * +*************************************************/ + +/* Read an item of the form {n,m} and return the values. This is called only +after isCountedRepeat() has confirmed that a repeat-count quantifier exists, +so the syntax is guaranteed to be correct, but we need to check the values. + +Arguments: + p pointer to first char after '{' + minp pointer to int for min + maxp pointer to int for max + returned as -1 if no max + errorcodeptr points to error code variable + +Returns: pointer to '}' on success; + current ptr on error, with errorcodeptr set non-zero +*/ + +static const UChar* readRepeatCounts(const UChar* p, int* minp, int* maxp, ErrorCode* errorcodeptr) +{ + int min = 0; + int max = -1; + + /* Read the minimum value and do a paranoid check: a negative value indicates + an integer overflow. */ + + while (isASCIIDigit(*p)) + min = min * 10 + *p++ - '0'; + if (min < 0 || min > 65535) { + *errorcodeptr = ERR5; + return p; + } + + /* Read the maximum value if there is one, and again do a paranoid on its size. + Also, max must not be less than min. */ + + if (*p == '}') + max = min; + else { + if (*(++p) != '}') { + max = 0; + while (isASCIIDigit(*p)) + max = max * 10 + *p++ - '0'; + if (max < 0 || max > 65535) { + *errorcodeptr = ERR5; + return p; + } + if (max < min) { + *errorcodeptr = ERR4; + return p; + } + } + } + + /* Fill in the required variables, and pass back the pointer to the terminating + '}'. */ + + *minp = min; + *maxp = max; + return p; +} + +/************************************************* +* Find first significant op code * +*************************************************/ + +/* This is called by several functions that scan a compiled expression looking +for a fixed first character, or an anchoring op code etc. It skips over things +that do not influence this. + +Arguments: + code pointer to the start of the group +Returns: pointer to the first significant opcode +*/ + +static const unsigned char* firstSignificantOpcode(const unsigned char* code) +{ + while (*code == OP_BRANUMBER) + code += 3; + return code; +} + +static const unsigned char* firstSignificantOpcodeSkippingAssertions(const unsigned char* code) +{ + while (true) { + switch (*code) { + case OP_ASSERT_NOT: + advanceToEndOfBracket(code); + code += 1 + LINK_SIZE; + break; + case OP_WORD_BOUNDARY: + case OP_NOT_WORD_BOUNDARY: + ++code; + break; + case OP_BRANUMBER: + code += 3; + break; + default: + return code; + } + } +} + +/************************************************* +* Get othercase range * +*************************************************/ + +/* This function is passed the start and end of a class range, in UTF-8 mode +with UCP support. It searches up the characters, looking for internal ranges of +characters in the "other" case. Each call returns the next one, updating the +start address. + +Arguments: + cptr points to starting character value; updated + d end value + ocptr where to put start of othercase range + odptr where to put end of othercase range + +Yield: true when range returned; false when no more +*/ + +static bool getOthercaseRange(int* cptr, int d, int* ocptr, int* odptr) +{ + int c, othercase = 0; + + for (c = *cptr; c <= d; c++) { + if ((othercase = kjs_pcre_ucp_othercase(c)) >= 0) + break; + } + + if (c > d) + return false; + + *ocptr = othercase; + int next = othercase + 1; + + for (++c; c <= d; c++) { + if (kjs_pcre_ucp_othercase(c) != next) + break; + next++; + } + + *odptr = next - 1; + *cptr = c; + + return true; +} + +/************************************************* + * Convert character value to UTF-8 * + *************************************************/ + +/* This function takes an integer value in the range 0 - 0x7fffffff + and encodes it as a UTF-8 character in 0 to 6 bytes. + + Arguments: + cvalue the character value + buffer pointer to buffer for result - at least 6 bytes long + + Returns: number of characters placed in the buffer + */ + +static int encodeUTF8(int cvalue, unsigned char *buffer) +{ + int i; + for (i = 0; i < kjs_pcre_utf8_table1_size; i++) + if (cvalue <= kjs_pcre_utf8_table1[i]) + break; + buffer += i; + for (int j = i; j > 0; j--) { + *buffer-- = 0x80 | (cvalue & 0x3f); + cvalue >>= 6; + } + *buffer = kjs_pcre_utf8_table2[i] | cvalue; + return i + 1; +} + +/************************************************* +* Compile one branch * +*************************************************/ + +/* Scan the pattern, compiling it into the code vector. + +Arguments: + options the option bits + brackets points to number of extracting brackets used + codeptr points to the pointer to the current code point + ptrptr points to the current pattern pointer + errorcodeptr points to error code variable + firstbyteptr set to initial literal character, or < 0 (REQ_UNSET, REQ_NONE) + reqbyteptr set to the last literal character required, else < 0 + cd contains pointers to tables etc. + +Returns: true on success + false, with *errorcodeptr set non-zero on error +*/ + +static inline bool safelyCheckNextChar(const UChar* ptr, const UChar* patternEnd, UChar expected) +{ + return ((ptr + 1 < patternEnd) && ptr[1] == expected); +} + +static bool +compileBranch(int options, int* brackets, unsigned char** codeptr, + const UChar** ptrptr, const UChar* patternEnd, ErrorCode* errorcodeptr, int *firstbyteptr, + int* reqbyteptr, CompileData& cd) +{ + int repeat_type, op_type; + int repeat_min = 0, repeat_max = 0; /* To please picky compilers */ + int bravalue = 0; + int reqvary, tempreqvary; + int c; + unsigned char* code = *codeptr; + unsigned char* tempcode; + bool groupsetfirstbyte = false; + const UChar* ptr = *ptrptr; + const UChar* tempptr; + unsigned char* previous = NULL; + unsigned char classbits[32]; + + bool class_utf8; + unsigned char* class_utf8data; + unsigned char utf8_char[6]; + + /* Initialize no first byte, no required byte. REQ_UNSET means "no char + matching encountered yet". It gets changed to REQ_NONE if we hit something that + matches a non-fixed char first char; reqbyte just remains unset if we never + find one. + + When we hit a repeat whose minimum is zero, we may have to adjust these values + to take the zero repeat into account. This is implemented by setting them to + zerofirstbyte and zeroreqbyte when such a repeat is encountered. The individual + item types that can be repeated set these backoff variables appropriately. */ + + int firstbyte = REQ_UNSET; + int reqbyte = REQ_UNSET; + int zeroreqbyte = REQ_UNSET; + int zerofirstbyte = REQ_UNSET; + + /* The variable req_caseopt contains either the REQ_IGNORE_CASE value or zero, + according to the current setting of the ignores-case flag. REQ_IGNORE_CASE is a bit + value > 255. It is added into the firstbyte or reqbyte variables to record the + case status of the value. This is used only for ASCII characters. */ + + int req_caseopt = (options & IgnoreCaseOption) ? REQ_IGNORE_CASE : 0; + + /* Switch on next character until the end of the branch */ + + for (;; ptr++) { + bool negate_class; + bool should_flip_negation; /* If a negative special such as \S is used, we should negate the whole class to properly support Unicode. */ + int class_charcount; + int class_lastchar; + int skipbytes; + int subreqbyte; + int subfirstbyte; + int mclength; + unsigned char mcbuffer[8]; + + /* Next byte in the pattern */ + + c = ptr < patternEnd ? *ptr : 0; + + /* Fill in length of a previous callout, except when the next thing is + a quantifier. */ + + bool is_quantifier = c == '*' || c == '+' || c == '?' || (c == '{' && isCountedRepeat(ptr + 1, patternEnd)); + + switch (c) { + /* The branch terminates at end of string, |, or ). */ + + case 0: + if (ptr < patternEnd) + goto NORMAL_CHAR; + // End of string; fall through + case '|': + case ')': + *firstbyteptr = firstbyte; + *reqbyteptr = reqbyte; + *codeptr = code; + *ptrptr = ptr; + return true; + + /* Handle single-character metacharacters. In multiline mode, ^ disables + the setting of any following char as a first character. */ + + case '^': + if (options & MatchAcrossMultipleLinesOption) { + if (firstbyte == REQ_UNSET) + firstbyte = REQ_NONE; + } + previous = NULL; + *code++ = OP_CIRC; + break; + + case '$': + previous = NULL; + *code++ = OP_DOLL; + break; + + /* There can never be a first char if '.' is first, whatever happens about + repeats. The value of reqbyte doesn't change either. */ + + case '.': + if (firstbyte == REQ_UNSET) + firstbyte = REQ_NONE; + zerofirstbyte = firstbyte; + zeroreqbyte = reqbyte; + previous = code; + *code++ = OP_NOT_NEWLINE; + break; + + /* Character classes. If the included characters are all < 256, we build a + 32-byte bitmap of the permitted characters, except in the special case + where there is only one such character. For negated classes, we build the + map as usual, then invert it at the end. However, we use a different opcode + so that data characters > 255 can be handled correctly. + + If the class contains characters outside the 0-255 range, a different + opcode is compiled. It may optionally have a bit map for characters < 256, + but those above are are explicitly listed afterwards. A flag byte tells + whether the bitmap is present, and whether this is a negated class or not. + */ + + case '[': { + previous = code; + should_flip_negation = false; + + /* PCRE supports POSIX class stuff inside a class. Perl gives an error if + they are encountered at the top level, so we'll do that too. */ + + /* If the first character is '^', set the negation flag and skip it. */ + + if (ptr + 1 >= patternEnd) { + *errorcodeptr = ERR6; + return false; + } + + if (ptr[1] == '^') { + negate_class = true; + ++ptr; + } else + negate_class = false; + + /* Keep a count of chars with values < 256 so that we can optimize the case + of just a single character (as long as it's < 256). For higher valued UTF-8 + characters, we don't yet do any optimization. */ + + class_charcount = 0; + class_lastchar = -1; + + class_utf8 = false; /* No chars >= 256 */ + class_utf8data = code + LINK_SIZE + 34; /* For UTF-8 items */ + + /* Initialize the 32-char bit map to all zeros. We have to build the + map in a temporary bit of store, in case the class contains only 1 + character (< 256), because in that case the compiled code doesn't use the + bit map. */ + + memset(classbits, 0, 32 * sizeof(unsigned char)); + + /* Process characters until ] is reached. The first pass + through the regex checked the overall syntax, so we don't need to be very + strict here. At the start of the loop, c contains the first byte of the + character. */ + + while ((++ptr < patternEnd) && (c = *ptr) != ']') { + /* Backslash may introduce a single character, or it may introduce one + of the specials, which just set a flag. Escaped items are checked for + validity in the pre-compiling pass. The sequence \b is a special case. + Inside a class (and only there) it is treated as backspace. Elsewhere + it marks a word boundary. Other escapes have preset maps ready to + or into the one we are building. We assume they have more than one + character in them, so set class_charcount bigger than one. */ + + if (c == '\\') { + c = checkEscape(&ptr, patternEnd, errorcodeptr, cd.numCapturingBrackets, true); + if (c < 0) { + class_charcount += 2; /* Greater than 1 is what matters */ + switch (-c) { + case ESC_d: + for (c = 0; c < 32; c++) + classbits[c] |= classBitmapForChar(c + cbit_digit); + continue; + + case ESC_D: + should_flip_negation = true; + for (c = 0; c < 32; c++) + classbits[c] |= ~classBitmapForChar(c + cbit_digit); + continue; + + case ESC_w: + for (c = 0; c < 32; c++) + classbits[c] |= classBitmapForChar(c + cbit_word); + continue; + + case ESC_W: + should_flip_negation = true; + for (c = 0; c < 32; c++) + classbits[c] |= ~classBitmapForChar(c + cbit_word); + continue; + + case ESC_s: + for (c = 0; c < 32; c++) + classbits[c] |= classBitmapForChar(c + cbit_space); + continue; + + case ESC_S: + should_flip_negation = true; + for (c = 0; c < 32; c++) + classbits[c] |= ~classBitmapForChar(c + cbit_space); + continue; + + /* Unrecognized escapes are faulted if PCRE is running in its + strict mode. By default, for compatibility with Perl, they are + treated as literals. */ + + default: + c = *ptr; /* The final character */ + class_charcount -= 2; /* Undo the default count from above */ + } + } + + /* Fall through if we have a single character (c >= 0). This may be + > 256 in UTF-8 mode. */ + + } /* End of backslash handling */ + + /* A single character may be followed by '-' to form a range. However, + Perl does not permit ']' to be the end of the range. A '-' character + here is treated as a literal. */ + + if ((ptr + 2 < patternEnd) && ptr[1] == '-' && ptr[2] != ']') { + ptr += 2; + + int d = *ptr; + + /* The second part of a range can be a single-character escape, but + not any of the other escapes. Perl 5.6 treats a hyphen as a literal + in such circumstances. */ + + if (d == '\\') { + const UChar* oldptr = ptr; + d = checkEscape(&ptr, patternEnd, errorcodeptr, cd.numCapturingBrackets, true); + + /* \X is literal X; any other special means the '-' was literal */ + if (d < 0) { + ptr = oldptr - 2; + goto LONE_SINGLE_CHARACTER; /* A few lines below */ + } + } + + /* The check that the two values are in the correct order happens in + the pre-pass. Optimize one-character ranges */ + + if (d == c) + goto LONE_SINGLE_CHARACTER; /* A few lines below */ + + /* In UTF-8 mode, if the upper limit is > 255, or > 127 for caseless + matching, we have to use an XCLASS with extra data items. Caseless + matching for characters > 127 is available only if UCP support is + available. */ + + if ((d > 255 || ((options & IgnoreCaseOption) && d > 127))) { + class_utf8 = true; + + /* With UCP support, we can find the other case equivalents of + the relevant characters. There may be several ranges. Optimize how + they fit with the basic range. */ + + if (options & IgnoreCaseOption) { + int occ, ocd; + int cc = c; + int origd = d; + while (getOthercaseRange(&cc, origd, &occ, &ocd)) { + if (occ >= c && ocd <= d) + continue; /* Skip embedded ranges */ + + if (occ < c && ocd >= c - 1) /* Extend the basic range */ + { /* if there is overlap, */ + c = occ; /* noting that if occ < c */ + continue; /* we can't have ocd > d */ + } /* because a subrange is */ + if (ocd > d && occ <= d + 1) /* always shorter than */ + { /* the basic range. */ + d = ocd; + continue; + } + + if (occ == ocd) + *class_utf8data++ = XCL_SINGLE; + else { + *class_utf8data++ = XCL_RANGE; + class_utf8data += encodeUTF8(occ, class_utf8data); + } + class_utf8data += encodeUTF8(ocd, class_utf8data); + } + } + + /* Now record the original range, possibly modified for UCP caseless + overlapping ranges. */ + + *class_utf8data++ = XCL_RANGE; + class_utf8data += encodeUTF8(c, class_utf8data); + class_utf8data += encodeUTF8(d, class_utf8data); + + /* With UCP support, we are done. Without UCP support, there is no + caseless matching for UTF-8 characters > 127; we can use the bit map + for the smaller ones. */ + + continue; /* With next character in the class */ + } + + /* We use the bit map for all cases when not in UTF-8 mode; else + ranges that lie entirely within 0-127 when there is UCP support; else + for partial ranges without UCP support. */ + + for (; c <= d; c++) { + classbits[c/8] |= (1 << (c&7)); + if (options & IgnoreCaseOption) { + int uc = flipCase(c); + classbits[uc/8] |= (1 << (uc&7)); + } + class_charcount++; /* in case a one-char range */ + class_lastchar = c; + } + + continue; /* Go get the next char in the class */ + } + + /* Handle a lone single character - we can get here for a normal + non-escape char, or after \ that introduces a single character or for an + apparent range that isn't. */ + + LONE_SINGLE_CHARACTER: + + /* Handle a character that cannot go in the bit map */ + + if ((c > 255 || ((options & IgnoreCaseOption) && c > 127))) { + class_utf8 = true; + *class_utf8data++ = XCL_SINGLE; + class_utf8data += encodeUTF8(c, class_utf8data); + + if (options & IgnoreCaseOption) { + int othercase; + if ((othercase = kjs_pcre_ucp_othercase(c)) >= 0) { + *class_utf8data++ = XCL_SINGLE; + class_utf8data += encodeUTF8(othercase, class_utf8data); + } + } + } else { + /* Handle a single-byte character */ + classbits[c/8] |= (1 << (c&7)); + if (options & IgnoreCaseOption) { + c = flipCase(c); + classbits[c/8] |= (1 << (c&7)); + } + class_charcount++; + class_lastchar = c; + } + } + + /* If class_charcount is 1, we saw precisely one character whose value is + less than 256. In non-UTF-8 mode we can always optimize. In UTF-8 mode, we + can optimize the negative case only if there were no characters >= 128 + because OP_NOT and the related opcodes like OP_NOTSTAR operate on + single-bytes only. This is an historical hangover. Maybe one day we can + tidy these opcodes to handle multi-byte characters. + + The optimization throws away the bit map. We turn the item into a + 1-character OP_CHAR[NC] if it's positive, or OP_NOT if it's negative. Note + that OP_NOT does not support multibyte characters. In the positive case, it + can cause firstbyte to be set. Otherwise, there can be no first char if + this item is first, whatever repeat count may follow. In the case of + reqbyte, save the previous value for reinstating. */ + + if (class_charcount == 1 && (!class_utf8 && (!negate_class || class_lastchar < 128))) { + zeroreqbyte = reqbyte; + + /* The OP_NOT opcode works on one-byte characters only. */ + + if (negate_class) { + if (firstbyte == REQ_UNSET) + firstbyte = REQ_NONE; + zerofirstbyte = firstbyte; + *code++ = OP_NOT; + *code++ = class_lastchar; + break; + } + + /* For a single, positive character, get the value into c, and + then we can handle this with the normal one-character code. */ + + c = class_lastchar; + goto NORMAL_CHAR; + } /* End of 1-char optimization */ + + /* The general case - not the one-char optimization. If this is the first + thing in the branch, there can be no first char setting, whatever the + repeat count. Any reqbyte setting must remain unchanged after any kind of + repeat. */ + + if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE; + zerofirstbyte = firstbyte; + zeroreqbyte = reqbyte; + + /* If there are characters with values > 255, we have to compile an + extended class, with its own opcode. If there are no characters < 256, + we can omit the bitmap. */ + + if (class_utf8 && !should_flip_negation) { + *class_utf8data++ = XCL_END; /* Marks the end of extra data */ + *code++ = OP_XCLASS; + code += LINK_SIZE; + *code = negate_class? XCL_NOT : 0; + + /* If the map is required, install it, and move on to the end of + the extra data */ + + if (class_charcount > 0) { + *code++ |= XCL_MAP; + memcpy(code, classbits, 32); + code = class_utf8data; + } + + /* If the map is not required, slide down the extra data. */ + + else { + int len = class_utf8data - (code + 33); + memmove(code + 1, code + 33, len); + code += len + 1; + } + + /* Now fill in the complete length of the item */ + + putLinkValue(previous + 1, code - previous); + break; /* End of class handling */ + } + + /* If there are no characters > 255, negate the 32-byte map if necessary, + and copy it into the code vector. If this is the first thing in the branch, + there can be no first char setting, whatever the repeat count. Any reqbyte + setting must remain unchanged after any kind of repeat. */ + + *code++ = (negate_class == should_flip_negation) ? OP_CLASS : OP_NCLASS; + if (negate_class) + for (c = 0; c < 32; c++) + code[c] = ~classbits[c]; + else + memcpy(code, classbits, 32); + code += 32; + break; + } + + /* Various kinds of repeat; '{' is not necessarily a quantifier, but this + has been tested above. */ + + case '{': + if (!is_quantifier) + goto NORMAL_CHAR; + ptr = readRepeatCounts(ptr + 1, &repeat_min, &repeat_max, errorcodeptr); + if (*errorcodeptr) + goto FAILED; + goto REPEAT; + + case '*': + repeat_min = 0; + repeat_max = -1; + goto REPEAT; + + case '+': + repeat_min = 1; + repeat_max = -1; + goto REPEAT; + + case '?': + repeat_min = 0; + repeat_max = 1; + + REPEAT: + if (!previous) { + *errorcodeptr = ERR9; + goto FAILED; + } + + if (repeat_min == 0) { + firstbyte = zerofirstbyte; /* Adjust for zero repeat */ + reqbyte = zeroreqbyte; /* Ditto */ + } + + /* Remember whether this is a variable length repeat */ + + reqvary = (repeat_min == repeat_max) ? 0 : REQ_VARY; + + op_type = 0; /* Default single-char op codes */ + + /* Save start of previous item, in case we have to move it up to make space + for an inserted OP_ONCE for the additional '+' extension. */ + /* FIXME: Probably don't need this because we don't use OP_ONCE. */ + + tempcode = previous; + + /* If the next character is '+', we have a possessive quantifier. This + implies greediness, whatever the setting of the PCRE_UNGREEDY option. + If the next character is '?' this is a minimizing repeat, by default, + but if PCRE_UNGREEDY is set, it works the other way round. We change the + repeat type to the non-default. */ + + if (safelyCheckNextChar(ptr, patternEnd, '?')) { + repeat_type = 1; + ptr++; + } else + repeat_type = 0; + + /* If previous was a character match, abolish the item and generate a + repeat item instead. If a char item has a minumum of more than one, ensure + that it is set in reqbyte - it might not be if a sequence such as x{3} is + the first thing in a branch because the x will have gone into firstbyte + instead. */ + + if (*previous == OP_CHAR || *previous == OP_CHAR_IGNORING_CASE) { + /* Deal with UTF-8 characters that take up more than one byte. It's + easier to write this out separately than try to macrify it. Use c to + hold the length of the character in bytes, plus 0x80 to flag that it's a + length rather than a small character. */ + + if (code[-1] & 0x80) { + unsigned char *lastchar = code - 1; + while((*lastchar & 0xc0) == 0x80) + lastchar--; + c = code - lastchar; /* Length of UTF-8 character */ + memcpy(utf8_char, lastchar, c); /* Save the char */ + c |= 0x80; /* Flag c as a length */ + } + else { + c = code[-1]; + if (repeat_min > 1) + reqbyte = c | req_caseopt | cd.req_varyopt; + } + + goto OUTPUT_SINGLE_REPEAT; /* Code shared with single character types */ + } + + else if (*previous == OP_ASCII_CHAR || *previous == OP_ASCII_LETTER_IGNORING_CASE) { + c = previous[1]; + if (repeat_min > 1) + reqbyte = c | req_caseopt | cd.req_varyopt; + goto OUTPUT_SINGLE_REPEAT; + } + + /* If previous was a single negated character ([^a] or similar), we use + one of the special opcodes, replacing it. The code is shared with single- + character repeats by setting opt_type to add a suitable offset into + repeat_type. OP_NOT is currently used only for single-byte chars. */ + + else if (*previous == OP_NOT) { + op_type = OP_NOTSTAR - OP_STAR; /* Use "not" opcodes */ + c = previous[1]; + goto OUTPUT_SINGLE_REPEAT; + } + + /* If previous was a character type match (\d or similar), abolish it and + create a suitable repeat item. The code is shared with single-character + repeats by setting op_type to add a suitable offset into repeat_type. */ + + else if (*previous <= OP_NOT_NEWLINE) { + op_type = OP_TYPESTAR - OP_STAR; /* Use type opcodes */ + c = *previous; + + OUTPUT_SINGLE_REPEAT: + int prop_type = -1; + int prop_value = -1; + + unsigned char* oldcode = code; + code = previous; /* Usually overwrite previous item */ + + /* If the maximum is zero then the minimum must also be zero; Perl allows + this case, so we do too - by simply omitting the item altogether. */ + + if (repeat_max == 0) + goto END_REPEAT; + + /* Combine the op_type with the repeat_type */ + + repeat_type += op_type; + + /* A minimum of zero is handled either as the special case * or ?, or as + an UPTO, with the maximum given. */ + + if (repeat_min == 0) { + if (repeat_max == -1) + *code++ = OP_STAR + repeat_type; + else if (repeat_max == 1) + *code++ = OP_QUERY + repeat_type; + else { + *code++ = OP_UPTO + repeat_type; + put2ByteValueAndAdvance(code, repeat_max); + } + } + + /* A repeat minimum of 1 is optimized into some special cases. If the + maximum is unlimited, we use OP_PLUS. Otherwise, the original item it + left in place and, if the maximum is greater than 1, we use OP_UPTO with + one less than the maximum. */ + + else if (repeat_min == 1) { + if (repeat_max == -1) + *code++ = OP_PLUS + repeat_type; + else { + code = oldcode; /* leave previous item in place */ + if (repeat_max == 1) + goto END_REPEAT; + *code++ = OP_UPTO + repeat_type; + put2ByteValueAndAdvance(code, repeat_max - 1); + } + } + + /* The case {n,n} is just an EXACT, while the general case {n,m} is + handled as an EXACT followed by an UPTO. */ + + else { + *code++ = OP_EXACT + op_type; /* NB EXACT doesn't have repeat_type */ + put2ByteValueAndAdvance(code, repeat_min); + + /* If the maximum is unlimited, insert an OP_STAR. Before doing so, + we have to insert the character for the previous code. For a repeated + Unicode property match, there are two extra bytes that define the + required property. In UTF-8 mode, long characters have their length in + c, with the 0x80 bit as a flag. */ + + if (repeat_max < 0) { + if (c >= 128) { + memcpy(code, utf8_char, c & 7); + code += c & 7; + } else { + *code++ = c; + if (prop_type >= 0) { + *code++ = prop_type; + *code++ = prop_value; + } + } + *code++ = OP_STAR + repeat_type; + } + + /* Else insert an UPTO if the max is greater than the min, again + preceded by the character, for the previously inserted code. */ + + else if (repeat_max != repeat_min) { + if (c >= 128) { + memcpy(code, utf8_char, c & 7); + code += c & 7; + } else + *code++ = c; + if (prop_type >= 0) { + *code++ = prop_type; + *code++ = prop_value; + } + repeat_max -= repeat_min; + *code++ = OP_UPTO + repeat_type; + put2ByteValueAndAdvance(code, repeat_max); + } + } + + /* The character or character type itself comes last in all cases. */ + + if (c >= 128) { + memcpy(code, utf8_char, c & 7); + code += c & 7; + } else + *code++ = c; + + /* For a repeated Unicode property match, there are two extra bytes that + define the required property. */ + + if (prop_type >= 0) { + *code++ = prop_type; + *code++ = prop_value; + } + } + + /* If previous was a character class or a back reference, we put the repeat + stuff after it, but just skip the item if the repeat was {0,0}. */ + + else if (*previous == OP_CLASS || + *previous == OP_NCLASS || + *previous == OP_XCLASS || + *previous == OP_REF) + { + if (repeat_max == 0) { + code = previous; + goto END_REPEAT; + } + + if (repeat_min == 0 && repeat_max == -1) + *code++ = OP_CRSTAR + repeat_type; + else if (repeat_min == 1 && repeat_max == -1) + *code++ = OP_CRPLUS + repeat_type; + else if (repeat_min == 0 && repeat_max == 1) + *code++ = OP_CRQUERY + repeat_type; + else { + *code++ = OP_CRRANGE + repeat_type; + put2ByteValueAndAdvance(code, repeat_min); + if (repeat_max == -1) + repeat_max = 0; /* 2-byte encoding for max */ + put2ByteValueAndAdvance(code, repeat_max); + } + } + + /* If previous was a bracket group, we may have to replicate it in certain + cases. */ + + else if (*previous >= OP_BRA) { + int ketoffset = 0; + int len = code - previous; + unsigned char* bralink = NULL; + + /* If the maximum repeat count is unlimited, find the end of the bracket + by scanning through from the start, and compute the offset back to it + from the current code pointer. There may be an OP_OPT setting following + the final KET, so we can't find the end just by going back from the code + pointer. */ + + if (repeat_max == -1) { + const unsigned char* ket = previous; + advanceToEndOfBracket(ket); + ketoffset = code - ket; + } + + /* The case of a zero minimum is special because of the need to stick + OP_BRAZERO in front of it, and because the group appears once in the + data, whereas in other cases it appears the minimum number of times. For + this reason, it is simplest to treat this case separately, as otherwise + the code gets far too messy. There are several special subcases when the + minimum is zero. */ + + if (repeat_min == 0) { + /* If the maximum is also zero, we just omit the group from the output + altogether. */ + + if (repeat_max == 0) { + code = previous; + goto END_REPEAT; + } + + /* If the maximum is 1 or unlimited, we just have to stick in the + BRAZERO and do no more at this point. However, we do need to adjust + any OP_RECURSE calls inside the group that refer to the group itself or + any internal group, because the offset is from the start of the whole + regex. Temporarily terminate the pattern while doing this. */ + + if (repeat_max <= 1) { + *code = OP_END; + memmove(previous+1, previous, len); + code++; + *previous++ = OP_BRAZERO + repeat_type; + } + + /* If the maximum is greater than 1 and limited, we have to replicate + in a nested fashion, sticking OP_BRAZERO before each set of brackets. + The first one has to be handled carefully because it's the original + copy, which has to be moved up. The remainder can be handled by code + that is common with the non-zero minimum case below. We have to + adjust the value of repeat_max, since one less copy is required. */ + + else { + *code = OP_END; + memmove(previous + 2 + LINK_SIZE, previous, len); + code += 2 + LINK_SIZE; + *previous++ = OP_BRAZERO + repeat_type; + *previous++ = OP_BRA; + + /* We chain together the bracket offset fields that have to be + filled in later when the ends of the brackets are reached. */ + + int offset = (!bralink) ? 0 : previous - bralink; + bralink = previous; + putLinkValueAllowZeroAndAdvance(previous, offset); + } + + repeat_max--; + } + + /* If the minimum is greater than zero, replicate the group as many + times as necessary, and adjust the maximum to the number of subsequent + copies that we need. If we set a first char from the group, and didn't + set a required char, copy the latter from the former. */ + + else { + if (repeat_min > 1) { + if (groupsetfirstbyte && reqbyte < 0) + reqbyte = firstbyte; + for (int i = 1; i < repeat_min; i++) { + memcpy(code, previous, len); + code += len; + } + } + if (repeat_max > 0) + repeat_max -= repeat_min; + } + + /* This code is common to both the zero and non-zero minimum cases. If + the maximum is limited, it replicates the group in a nested fashion, + remembering the bracket starts on a stack. In the case of a zero minimum, + the first one was set up above. In all cases the repeat_max now specifies + the number of additional copies needed. */ + + if (repeat_max >= 0) { + for (int i = repeat_max - 1; i >= 0; i--) { + *code++ = OP_BRAZERO + repeat_type; + + /* All but the final copy start a new nesting, maintaining the + chain of brackets outstanding. */ + + if (i != 0) { + *code++ = OP_BRA; + int offset = (!bralink) ? 0 : code - bralink; + bralink = code; + putLinkValueAllowZeroAndAdvance(code, offset); + } + + memcpy(code, previous, len); + code += len; + } + + /* Now chain through the pending brackets, and fill in their length + fields (which are holding the chain links pro tem). */ + + while (bralink) { + int offset = code - bralink + 1; + unsigned char* bra = code - offset; + int oldlinkoffset = getLinkValueAllowZero(bra + 1); + bralink = (!oldlinkoffset) ? 0 : bralink - oldlinkoffset; + *code++ = OP_KET; + putLinkValueAndAdvance(code, offset); + putLinkValue(bra + 1, offset); + } + } + + /* If the maximum is unlimited, set a repeater in the final copy. We + can't just offset backwards from the current code point, because we + don't know if there's been an options resetting after the ket. The + correct offset was computed above. */ + + else + code[-ketoffset] = OP_KETRMAX + repeat_type; + } + + /* Else there's some kind of shambles */ + + else { + *errorcodeptr = ERR11; + goto FAILED; + } + + /* In all case we no longer have a previous item. We also set the + "follows varying string" flag for subsequently encountered reqbytes if + it isn't already set and we have just passed a varying length item. */ + + END_REPEAT: + previous = NULL; + cd.req_varyopt |= reqvary; + break; + + /* Start of nested bracket sub-expression, or comment or lookahead or + lookbehind or option setting or condition. First deal with special things + that can come after a bracket; all are introduced by ?, and the appearance + of any of them means that this is not a referencing group. They were + checked for validity in the first pass over the string, so we don't have to + check for syntax errors here. */ + + case '(': + skipbytes = 0; + + if (*(++ptr) == '?') { + switch (*(++ptr)) { + case ':': /* Non-extracting bracket */ + bravalue = OP_BRA; + ptr++; + break; + + case '=': /* Positive lookahead */ + bravalue = OP_ASSERT; + ptr++; + break; + + case '!': /* Negative lookahead */ + bravalue = OP_ASSERT_NOT; + ptr++; + break; + + /* Character after (? not specially recognized */ + + default: + *errorcodeptr = ERR12; + goto FAILED; + } + } + + /* Else we have a referencing group; adjust the opcode. If the bracket + number is greater than EXTRACT_BASIC_MAX, we set the opcode one higher, and + arrange for the true number to follow later, in an OP_BRANUMBER item. */ + + else { + if (++(*brackets) > EXTRACT_BASIC_MAX) { + bravalue = OP_BRA + EXTRACT_BASIC_MAX + 1; + code[1 + LINK_SIZE] = OP_BRANUMBER; + put2ByteValue(code + 2 + LINK_SIZE, *brackets); + skipbytes = 3; + } + else + bravalue = OP_BRA + *brackets; + } + + /* Process nested bracketed re. Assertions may not be repeated, but other + kinds can be. We copy code into a non-variable in order to be able + to pass its address because some compilers complain otherwise. Pass in a + new setting for the ims options if they have changed. */ + + previous = (bravalue >= OP_BRAZERO) ? code : 0; + *code = bravalue; + tempcode = code; + tempreqvary = cd.req_varyopt; /* Save value before bracket */ + + if (!compileBracket( + options, + brackets, /* Extracting bracket count */ + &tempcode, /* Where to put code (updated) */ + &ptr, /* Input pointer (updated) */ + patternEnd, + errorcodeptr, /* Where to put an error message */ + skipbytes, /* Skip over OP_BRANUMBER */ + &subfirstbyte, /* For possible first char */ + &subreqbyte, /* For possible last char */ + cd)) /* Tables block */ + goto FAILED; + + /* At the end of compiling, code is still pointing to the start of the + group, while tempcode has been updated to point past the end of the group + and any option resetting that may follow it. The pattern pointer (ptr) + is on the bracket. */ + + /* Handle updating of the required and first characters. Update for normal + brackets of all kinds, and conditions with two branches (see code above). + If the bracket is followed by a quantifier with zero repeat, we have to + back off. Hence the definition of zeroreqbyte and zerofirstbyte outside the + main loop so that they can be accessed for the back off. */ + + zeroreqbyte = reqbyte; + zerofirstbyte = firstbyte; + groupsetfirstbyte = false; + + if (bravalue >= OP_BRA) { + /* If we have not yet set a firstbyte in this branch, take it from the + subpattern, remembering that it was set here so that a repeat of more + than one can replicate it as reqbyte if necessary. If the subpattern has + no firstbyte, set "none" for the whole branch. In both cases, a zero + repeat forces firstbyte to "none". */ + + if (firstbyte == REQ_UNSET) { + if (subfirstbyte >= 0) { + firstbyte = subfirstbyte; + groupsetfirstbyte = true; + } + else + firstbyte = REQ_NONE; + zerofirstbyte = REQ_NONE; + } + + /* If firstbyte was previously set, convert the subpattern's firstbyte + into reqbyte if there wasn't one, using the vary flag that was in + existence beforehand. */ + + else if (subfirstbyte >= 0 && subreqbyte < 0) + subreqbyte = subfirstbyte | tempreqvary; + + /* If the subpattern set a required byte (or set a first byte that isn't + really the first byte - see above), set it. */ + + if (subreqbyte >= 0) + reqbyte = subreqbyte; + } + + /* For a forward assertion, we take the reqbyte, if set. This can be + helpful if the pattern that follows the assertion doesn't set a different + char. For example, it's useful for /(?=abcde).+/. We can't set firstbyte + for an assertion, however because it leads to incorrect effect for patterns + such as /(?=a)a.+/ when the "real" "a" would then become a reqbyte instead + of a firstbyte. This is overcome by a scan at the end if there's no + firstbyte, looking for an asserted first char. */ + + else if (bravalue == OP_ASSERT && subreqbyte >= 0) + reqbyte = subreqbyte; + + /* Now update the main code pointer to the end of the group. */ + + code = tempcode; + + /* Error if hit end of pattern */ + + if (ptr >= patternEnd || *ptr != ')') { + *errorcodeptr = ERR14; + goto FAILED; + } + break; + + /* Check \ for being a real metacharacter; if not, fall through and handle + it as a data character at the start of a string. Escape items are checked + for validity in the pre-compiling pass. */ + + case '\\': + tempptr = ptr; + c = checkEscape(&ptr, patternEnd, errorcodeptr, cd.numCapturingBrackets, false); + + /* Handle metacharacters introduced by \. For ones like \d, the ESC_ values + are arranged to be the negation of the corresponding OP_values. For the + back references, the values are ESC_REF plus the reference number. Only + back references and those types that consume a character may be repeated. + We can test for values between ESC_b and ESC_w for the latter; this may + have to change if any new ones are ever created. */ + + if (c < 0) { + /* For metasequences that actually match a character, we disable the + setting of a first character if it hasn't already been set. */ + + if (firstbyte == REQ_UNSET && -c > ESC_b && -c <= ESC_w) + firstbyte = REQ_NONE; + + /* Set values to reset to if this is followed by a zero repeat. */ + + zerofirstbyte = firstbyte; + zeroreqbyte = reqbyte; + + /* Back references are handled specially */ + + if (-c >= ESC_REF) { + int number = -c - ESC_REF; + previous = code; + *code++ = OP_REF; + put2ByteValueAndAdvance(code, number); + } + + /* For the rest, we can obtain the OP value by negating the escape + value */ + + else { + previous = (-c > ESC_b && -c <= ESC_w) ? code : NULL; + *code++ = -c; + } + continue; + } + + /* Fall through. */ + + /* Handle a literal character. It is guaranteed not to be whitespace or # + when the extended flag is set. If we are in UTF-8 mode, it may be a + multi-byte literal character. */ + + default: + NORMAL_CHAR: + + previous = code; + + if (c < 128) { + mclength = 1; + mcbuffer[0] = c; + + if ((options & IgnoreCaseOption) && (c | 0x20) >= 'a' && (c | 0x20) <= 'z') { + *code++ = OP_ASCII_LETTER_IGNORING_CASE; + *code++ = c | 0x20; + } else { + *code++ = OP_ASCII_CHAR; + *code++ = c; + } + } else { + mclength = encodeUTF8(c, mcbuffer); + + *code++ = (options & IgnoreCaseOption) ? OP_CHAR_IGNORING_CASE : OP_CHAR; + for (c = 0; c < mclength; c++) + *code++ = mcbuffer[c]; + } + + /* Set the first and required bytes appropriately. If no previous first + byte, set it from this character, but revert to none on a zero repeat. + Otherwise, leave the firstbyte value alone, and don't change it on a zero + repeat. */ + + if (firstbyte == REQ_UNSET) { + zerofirstbyte = REQ_NONE; + zeroreqbyte = reqbyte; + + /* If the character is more than one byte long, we can set firstbyte + only if it is not to be matched caselessly. */ + + if (mclength == 1 || req_caseopt == 0) { + firstbyte = mcbuffer[0] | req_caseopt; + if (mclength != 1) + reqbyte = code[-1] | cd.req_varyopt; + } + else + firstbyte = reqbyte = REQ_NONE; + } + + /* firstbyte was previously set; we can set reqbyte only the length is + 1 or the matching is caseful. */ + + else { + zerofirstbyte = firstbyte; + zeroreqbyte = reqbyte; + if (mclength == 1 || req_caseopt == 0) + reqbyte = code[-1] | req_caseopt | cd.req_varyopt; + } + + break; /* End of literal character handling */ + } + } /* end of big loop */ + + /* Control never reaches here by falling through, only by a goto for all the + error states. Pass back the position in the pattern so that it can be displayed + to the user for diagnosing the error. */ + +FAILED: + *ptrptr = ptr; + return false; +} + +/************************************************* +* Compile sequence of alternatives * +*************************************************/ + +/* On entry, ptr is pointing past the bracket character, but on return +it points to the closing bracket, or vertical bar, or end of string. +The code variable is pointing at the byte into which the BRA operator has been +stored. If the ims options are changed at the start (for a (?ims: group) or +during any branch, we need to insert an OP_OPT item at the start of every +following branch to ensure they get set correctly at run time, and also pass +the new options into every subsequent branch compile. + +Argument: + options option bits, including any changes for this subpattern + brackets -> int containing the number of extracting brackets used + codeptr -> the address of the current code pointer + ptrptr -> the address of the current pattern pointer + errorcodeptr -> pointer to error code variable + skipbytes skip this many bytes at start (for OP_BRANUMBER) + firstbyteptr place to put the first required character, or a negative number + reqbyteptr place to put the last required character, or a negative number + cd points to the data block with tables pointers etc. + +Returns: true on success +*/ + +static bool +compileBracket(int options, int* brackets, unsigned char** codeptr, + const UChar** ptrptr, const UChar* patternEnd, ErrorCode* errorcodeptr, int skipbytes, + int* firstbyteptr, int* reqbyteptr, CompileData& cd) +{ + const UChar* ptr = *ptrptr; + unsigned char* code = *codeptr; + unsigned char* last_branch = code; + unsigned char* start_bracket = code; + int firstbyte = REQ_UNSET; + int reqbyte = REQ_UNSET; + + /* Offset is set zero to mark that this bracket is still open */ + + putLinkValueAllowZero(code + 1, 0); + code += 1 + LINK_SIZE + skipbytes; + + /* Loop for each alternative branch */ + + while (true) { + /* Now compile the branch */ + + int branchfirstbyte; + int branchreqbyte; + if (!compileBranch(options, brackets, &code, &ptr, patternEnd, errorcodeptr, + &branchfirstbyte, &branchreqbyte, cd)) { + *ptrptr = ptr; + return false; + } + + /* If this is the first branch, the firstbyte and reqbyte values for the + branch become the values for the regex. */ + + if (*last_branch != OP_ALT) { + firstbyte = branchfirstbyte; + reqbyte = branchreqbyte; + } + + /* If this is not the first branch, the first char and reqbyte have to + match the values from all the previous branches, except that if the previous + value for reqbyte didn't have REQ_VARY set, it can still match, and we set + REQ_VARY for the regex. */ + + else { + /* If we previously had a firstbyte, but it doesn't match the new branch, + we have to abandon the firstbyte for the regex, but if there was previously + no reqbyte, it takes on the value of the old firstbyte. */ + + if (firstbyte >= 0 && firstbyte != branchfirstbyte) { + if (reqbyte < 0) + reqbyte = firstbyte; + firstbyte = REQ_NONE; + } + + /* If we (now or from before) have no firstbyte, a firstbyte from the + branch becomes a reqbyte if there isn't a branch reqbyte. */ + + if (firstbyte < 0 && branchfirstbyte >= 0 && branchreqbyte < 0) + branchreqbyte = branchfirstbyte; + + /* Now ensure that the reqbytes match */ + + if ((reqbyte & ~REQ_VARY) != (branchreqbyte & ~REQ_VARY)) + reqbyte = REQ_NONE; + else + reqbyte |= branchreqbyte; /* To "or" REQ_VARY */ + } + + /* Reached end of expression, either ')' or end of pattern. Go back through + the alternative branches and reverse the chain of offsets, with the field in + the BRA item now becoming an offset to the first alternative. If there are + no alternatives, it points to the end of the group. The length in the + terminating ket is always the length of the whole bracketed item. If any of + the ims options were changed inside the group, compile a resetting op-code + following, except at the very end of the pattern. Return leaving the pointer + at the terminating char. */ + + if (ptr >= patternEnd || *ptr != '|') { + int length = code - last_branch; + do { + int prev_length = getLinkValueAllowZero(last_branch + 1); + putLinkValue(last_branch + 1, length); + length = prev_length; + last_branch -= length; + } while (length > 0); + + /* Fill in the ket */ + + *code = OP_KET; + putLinkValue(code + 1, code - start_bracket); + code += 1 + LINK_SIZE; + + /* Set values to pass back */ + + *codeptr = code; + *ptrptr = ptr; + *firstbyteptr = firstbyte; + *reqbyteptr = reqbyte; + return true; + } + + /* Another branch follows; insert an "or" node. Its length field points back + to the previous branch while the bracket remains open. At the end the chain + is reversed. It's done like this so that the start of the bracket has a + zero offset until it is closed, making it possible to detect recursion. */ + + *code = OP_ALT; + putLinkValue(code + 1, code - last_branch); + last_branch = code; + code += 1 + LINK_SIZE; + ptr++; + } + ASSERT_NOT_REACHED(); +} + +/************************************************* +* Check for anchored expression * +*************************************************/ + +/* Try to find out if this is an anchored regular expression. Consider each +alternative branch. If they all start OP_CIRC, or with a bracket +all of whose alternatives start OP_CIRC (recurse ad lib), then +it's anchored. + +Arguments: + code points to start of expression (the bracket) + captureMap a bitmap of which brackets we are inside while testing; this + handles up to substring 31; all brackets after that share + the zero bit + backrefMap the back reference bitmap +*/ + +static bool branchIsAnchored(const unsigned char* code) +{ + const unsigned char* scode = firstSignificantOpcode(code); + int op = *scode; + + /* Brackets */ + if (op >= OP_BRA || op == OP_ASSERT) + return bracketIsAnchored(scode); + + /* Check for explicit anchoring */ + return op == OP_CIRC; +} + +static bool bracketIsAnchored(const unsigned char* code) +{ + do { + if (!branchIsAnchored(code + 1 + LINK_SIZE)) + return false; + code += getLinkValue(code + 1); + } while (*code == OP_ALT); /* Loop for each alternative */ + return true; +} + +/************************************************* +* Check for starting with ^ or .* * +*************************************************/ + +/* This is called to find out if every branch starts with ^ or .* so that +"first char" processing can be done to speed things up in multiline +matching and for non-DOTALL patterns that start with .* (which must start at +the beginning or after \n) + +Except when the .* appears inside capturing parentheses, and there is a +subsequent back reference to those parentheses. By keeping a bitmap of the +first 31 back references, we can catch some of the more common cases more +precisely; all the greater back references share a single bit. + +Arguments: + code points to start of expression (the bracket) + captureMap a bitmap of which brackets we are inside while testing; this + handles up to substring 31; all brackets after that share + the zero bit + backrefMap the back reference bitmap +*/ + +static bool branchNeedsLineStart(const unsigned char* code, unsigned captureMap, unsigned backrefMap) +{ + const unsigned char* scode = firstSignificantOpcode(code); + int op = *scode; + + /* Capturing brackets */ + if (op > OP_BRA) { + int captureNum = op - OP_BRA; + if (captureNum > EXTRACT_BASIC_MAX) + captureNum = get2ByteValue(scode + 2 + LINK_SIZE); + int bracketMask = (captureNum < 32) ? (1 << captureNum) : 1; + return bracketNeedsLineStart(scode, captureMap | bracketMask, backrefMap); + } + + /* Other brackets */ + if (op == OP_BRA || op == OP_ASSERT) + return bracketNeedsLineStart(scode, captureMap, backrefMap); + + /* .* means "start at start or after \n" if it isn't in brackets that + may be referenced. */ + + if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR) + return scode[1] == OP_NOT_NEWLINE && !(captureMap & backrefMap); + + /* Explicit ^ */ + return op == OP_CIRC; +} + +static bool bracketNeedsLineStart(const unsigned char* code, unsigned captureMap, unsigned backrefMap) +{ + do { + if (!branchNeedsLineStart(code + 1 + LINK_SIZE, captureMap, backrefMap)) + return false; + code += getLinkValue(code + 1); + } while (*code == OP_ALT); /* Loop for each alternative */ + return true; +} + +/************************************************* +* Check for asserted fixed first char * +*************************************************/ + +/* During compilation, the "first char" settings from forward assertions are +discarded, because they can cause conflicts with actual literals that follow. +However, if we end up without a first char setting for an unanchored pattern, +it is worth scanning the regex to see if there is an initial asserted first +char. If all branches start with the same asserted char, or with a bracket all +of whose alternatives start with the same asserted char (recurse ad lib), then +we return that char, otherwise -1. + +Arguments: + code points to start of expression (the bracket) + options pointer to the options (used to check casing changes) + inassert true if in an assertion + +Returns: -1 or the fixed first char +*/ + +static int branchFindFirstAssertedCharacter(const unsigned char* code, bool inassert) +{ + const unsigned char* scode = firstSignificantOpcodeSkippingAssertions(code); + int op = *scode; + + if (op >= OP_BRA) + op = OP_BRA; + + switch (op) { + default: + return -1; + + case OP_BRA: + case OP_ASSERT: + return bracketFindFirstAssertedCharacter(scode, op == OP_ASSERT); + + case OP_EXACT: + scode += 2; + /* Fall through */ + + case OP_CHAR: + case OP_CHAR_IGNORING_CASE: + case OP_ASCII_CHAR: + case OP_ASCII_LETTER_IGNORING_CASE: + case OP_PLUS: + case OP_MINPLUS: + if (!inassert) + return -1; + return scode[1]; + } +} + +static int bracketFindFirstAssertedCharacter(const unsigned char* code, bool inassert) +{ + int c = -1; + do { + int d = branchFindFirstAssertedCharacter(code + 1 + LINK_SIZE, inassert); + if (d < 0) + return -1; + if (c < 0) + c = d; + else if (c != d) + return -1; + code += getLinkValue(code + 1); + } while (*code == OP_ALT); + return c; +} + +static inline int multiplyWithOverflowCheck(int a, int b) +{ + if (!a || !b) + return 0; + if (a > MAX_PATTERN_SIZE / b) + return -1; + return a * b; +} + +static int calculateCompiledPatternLength(const UChar* pattern, int patternLength, JSRegExpIgnoreCaseOption ignoreCase, + CompileData& cd, ErrorCode& errorcode) +{ + /* Make a pass over the pattern to compute the + amount of store required to hold the compiled code. This does not have to be + perfect as long as errors are overestimates. */ + + if (patternLength > MAX_PATTERN_SIZE) { + errorcode = ERR16; + return -1; + } + + int length = 1 + LINK_SIZE; /* For initial BRA plus length */ + int branch_extra = 0; + int lastitemlength = 0; + unsigned brastackptr = 0; + int brastack[BRASTACK_SIZE]; + unsigned char bralenstack[BRASTACK_SIZE]; + int bracount = 0; + + const UChar* ptr = (const UChar*)(pattern - 1); + const UChar* patternEnd = (const UChar*)(pattern + patternLength); + + while (++ptr < patternEnd) { + int minRepeats = 0, maxRepeats = 0; + int c = *ptr; + + switch (c) { + /* A backslashed item may be an escaped data character or it may be a + character type. */ + + case '\\': + c = checkEscape(&ptr, patternEnd, &errorcode, cd.numCapturingBrackets, false); + if (errorcode != 0) + return -1; + + lastitemlength = 1; /* Default length of last item for repeats */ + + if (c >= 0) { /* Data character */ + length += 2; /* For a one-byte character */ + + if (c > 127) { + int i; + for (i = 0; i < kjs_pcre_utf8_table1_size; i++) + if (c <= kjs_pcre_utf8_table1[i]) break; + length += i; + lastitemlength += i; + } + + continue; + } + + /* Other escapes need one byte */ + + length++; + + /* A back reference needs an additional 2 bytes, plus either one or 5 + bytes for a repeat. We also need to keep the value of the highest + back reference. */ + + if (c <= -ESC_REF) { + int refnum = -c - ESC_REF; + cd.backrefMap |= (refnum < 32) ? (1 << refnum) : 1; + if (refnum > cd.top_backref) + cd.top_backref = refnum; + length += 2; /* For single back reference */ + if (safelyCheckNextChar(ptr, patternEnd, '{') && isCountedRepeat(ptr + 2, patternEnd)) { + ptr = readRepeatCounts(ptr + 2, &minRepeats, &maxRepeats, &errorcode); + if (errorcode) + return -1; + if ((minRepeats == 0 && (maxRepeats == 1 || maxRepeats == -1)) || + (minRepeats == 1 && maxRepeats == -1)) + length++; + else + length += 5; + if (safelyCheckNextChar(ptr, patternEnd, '?')) + ptr++; + } + } + continue; + + case '^': /* Single-byte metacharacters */ + case '.': + case '$': + length++; + lastitemlength = 1; + continue; + + case '*': /* These repeats won't be after brackets; */ + case '+': /* those are handled separately */ + case '?': + length++; + goto POSSESSIVE; + + /* This covers the cases of braced repeats after a single char, metachar, + class, or back reference. */ + + case '{': + if (!isCountedRepeat(ptr + 1, patternEnd)) + goto NORMAL_CHAR; + ptr = readRepeatCounts(ptr + 1, &minRepeats, &maxRepeats, &errorcode); + if (errorcode != 0) + return -1; + + /* These special cases just insert one extra opcode */ + + if ((minRepeats == 0 && (maxRepeats == 1 || maxRepeats == -1)) || + (minRepeats == 1 && maxRepeats == -1)) + length++; + + /* These cases might insert additional copies of a preceding character. */ + + else { + if (minRepeats != 1) { + length -= lastitemlength; /* Uncount the original char or metachar */ + if (minRepeats > 0) + length += 3 + lastitemlength; + } + length += lastitemlength + ((maxRepeats > 0) ? 3 : 1); + } + + if (safelyCheckNextChar(ptr, patternEnd, '?')) + ptr++; /* Needs no extra length */ + + POSSESSIVE: /* Test for possessive quantifier */ + if (safelyCheckNextChar(ptr, patternEnd, '+')) { + ptr++; + length += 2 + 2 * LINK_SIZE; /* Allow for atomic brackets */ + } + continue; + + /* An alternation contains an offset to the next branch or ket. If any ims + options changed in the previous branch(es), and/or if we are in a + lookbehind assertion, extra space will be needed at the start of the + branch. This is handled by branch_extra. */ + + case '|': + if (brastackptr == 0) + cd.needOuterBracket = true; + length += 1 + LINK_SIZE + branch_extra; + continue; + + /* A character class uses 33 characters provided that all the character + values are less than 256. Otherwise, it uses a bit map for low valued + characters, and individual items for others. Don't worry about character + types that aren't allowed in classes - they'll get picked up during the + compile. A character class that contains only one single-byte character + uses 2 or 3 bytes, depending on whether it is negated or not. Notice this + where we can. (In UTF-8 mode we can do this only for chars < 128.) */ + + case '[': { + int class_optcount; + if (*(++ptr) == '^') { + class_optcount = 10; /* Greater than one */ + ptr++; + } + else + class_optcount = 0; + + bool class_utf8 = false; + + for (; ptr < patternEnd && *ptr != ']'; ++ptr) { + /* Check for escapes */ + + if (*ptr == '\\') { + c = checkEscape(&ptr, patternEnd, &errorcode, cd.numCapturingBrackets, true); + if (errorcode != 0) + return -1; + + /* Handle escapes that turn into characters */ + + if (c >= 0) + goto NON_SPECIAL_CHARACTER; + + /* Escapes that are meta-things. The normal ones just affect the + bit map, but Unicode properties require an XCLASS extended item. */ + + else + class_optcount = 10; /* \d, \s etc; make sure > 1 */ + } + + /* Anything else increments the possible optimization count. We have to + detect ranges here so that we can compute the number of extra ranges for + caseless wide characters when UCP support is available. If there are wide + characters, we are going to have to use an XCLASS, even for single + characters. */ + + else { + c = *ptr; + + /* Come here from handling \ above when it escapes to a char value */ + + NON_SPECIAL_CHARACTER: + class_optcount++; + + int d = -1; + if (safelyCheckNextChar(ptr, patternEnd, '-')) { + UChar const *hyptr = ptr++; + if (safelyCheckNextChar(ptr, patternEnd, '\\')) { + ptr++; + d = checkEscape(&ptr, patternEnd, &errorcode, cd.numCapturingBrackets, true); + if (errorcode != 0) + return -1; + } + else if ((ptr + 1 < patternEnd) && ptr[1] != ']') + d = *++ptr; + if (d < 0) + ptr = hyptr; /* go back to hyphen as data */ + } + + /* If d >= 0 we have a range. In UTF-8 mode, if the end is > 255, or > + 127 for caseless matching, we will need to use an XCLASS. */ + + if (d >= 0) { + class_optcount = 10; /* Ensure > 1 */ + if (d < c) { + errorcode = ERR8; + return -1; + } + + if ((d > 255 || (ignoreCase && d > 127))) { + unsigned char buffer[6]; + if (!class_utf8) /* Allow for XCLASS overhead */ + { + class_utf8 = true; + length += LINK_SIZE + 2; + } + + /* If we have UCP support, find out how many extra ranges are + needed to map the other case of characters within this range. We + have to mimic the range optimization here, because extending the + range upwards might push d over a boundary that makes it use + another byte in the UTF-8 representation. */ + + if (ignoreCase) { + int occ, ocd; + int cc = c; + int origd = d; + while (getOthercaseRange(&cc, origd, &occ, &ocd)) { + if (occ >= c && ocd <= d) + continue; /* Skip embedded */ + + if (occ < c && ocd >= c - 1) /* Extend the basic range */ + { /* if there is overlap, */ + c = occ; /* noting that if occ < c */ + continue; /* we can't have ocd > d */ + } /* because a subrange is */ + if (ocd > d && occ <= d + 1) /* always shorter than */ + { /* the basic range. */ + d = ocd; + continue; + } + + /* An extra item is needed */ + + length += 1 + encodeUTF8(occ, buffer) + + ((occ == ocd) ? 0 : encodeUTF8(ocd, buffer)); + } + } + + /* The length of the (possibly extended) range */ + + length += 1 + encodeUTF8(c, buffer) + encodeUTF8(d, buffer); + } + + } + + /* We have a single character. There is nothing to be done unless we + are in UTF-8 mode. If the char is > 255, or 127 when caseless, we must + allow for an XCL_SINGLE item, doubled for caselessness if there is UCP + support. */ + + else { + if ((c > 255 || (ignoreCase && c > 127))) { + unsigned char buffer[6]; + class_optcount = 10; /* Ensure > 1 */ + if (!class_utf8) /* Allow for XCLASS overhead */ + { + class_utf8 = true; + length += LINK_SIZE + 2; + } + length += (ignoreCase ? 2 : 1) * (1 + encodeUTF8(c, buffer)); + } + } + } + } + + if (ptr >= patternEnd) { /* Missing terminating ']' */ + errorcode = ERR6; + return -1; + } + + /* We can optimize when there was only one optimizable character. + Note that this does not detect the case of a negated single character. + In that case we do an incorrect length computation, but it's not a serious + problem because the computed length is too large rather than too small. */ + + if (class_optcount == 1) + goto NORMAL_CHAR; + + /* Here, we handle repeats for the class opcodes. */ + { + length += 33; + + /* A repeat needs either 1 or 5 bytes. If it is a possessive quantifier, + we also need extra for wrapping the whole thing in a sub-pattern. */ + + if (safelyCheckNextChar(ptr, patternEnd, '{') && isCountedRepeat(ptr + 2, patternEnd)) { + ptr = readRepeatCounts(ptr + 2, &minRepeats, &maxRepeats, &errorcode); + if (errorcode != 0) + return -1; + if ((minRepeats == 0 && (maxRepeats == 1 || maxRepeats == -1)) || + (minRepeats == 1 && maxRepeats == -1)) + length++; + else + length += 5; + if (safelyCheckNextChar(ptr, patternEnd, '+')) { + ptr++; + length += 2 + 2 * LINK_SIZE; + } else if (safelyCheckNextChar(ptr, patternEnd, '?')) + ptr++; + } + } + continue; + } + + /* Brackets may be genuine groups or special things */ + + case '(': { + int branch_newextra = 0; + int bracket_length = 1 + LINK_SIZE; + bool capturing = false; + + /* Handle special forms of bracket, which all start (? */ + + if (safelyCheckNextChar(ptr, patternEnd, '?')) { + switch (c = (ptr + 2 < patternEnd ? ptr[2] : 0)) { + /* Non-referencing groups and lookaheads just move the pointer on, and + then behave like a non-special bracket, except that they don't increment + the count of extracting brackets. Ditto for the "once only" bracket, + which is in Perl from version 5.005. */ + + case ':': + case '=': + case '!': + ptr += 2; + break; + + /* Else loop checking valid options until ) is met. Anything else is an + error. If we are without any brackets, i.e. at top level, the settings + act as if specified in the options, so massage the options immediately. + This is for backward compatibility with Perl 5.004. */ + + default: + errorcode = ERR12; + return -1; + } + } else + capturing = 1; + + /* Capturing brackets must be counted so we can process escapes in a + Perlish way. If the number exceeds EXTRACT_BASIC_MAX we are going to need + an additional 3 bytes of memory per capturing bracket. */ + + if (capturing) { + bracount++; + if (bracount > EXTRACT_BASIC_MAX) + bracket_length += 3; + } + + /* Save length for computing whole length at end if there's a repeat that + requires duplication of the group. Also save the current value of + branch_extra, and start the new group with the new value. If non-zero, this + will either be 2 for a (?imsx: group, or 3 for a lookbehind assertion. */ + + if (brastackptr >= sizeof(brastack)/sizeof(int)) { + errorcode = ERR17; + return -1; + } + + bralenstack[brastackptr] = branch_extra; + branch_extra = branch_newextra; + + brastack[brastackptr++] = length; + length += bracket_length; + continue; + } + + /* Handle ket. Look for subsequent maxRepeats/minRepeats; for certain sets of values we + have to replicate this bracket up to that many times. If brastackptr is + 0 this is an unmatched bracket which will generate an error, but take care + not to try to access brastack[-1] when computing the length and restoring + the branch_extra value. */ + + case ')': { + int duplength; + length += 1 + LINK_SIZE; + if (brastackptr > 0) { + duplength = length - brastack[--brastackptr]; + branch_extra = bralenstack[brastackptr]; + } + else + duplength = 0; + + /* Leave ptr at the final char; for readRepeatCounts this happens + automatically; for the others we need an increment. */ + + if ((ptr + 1 < patternEnd) && (c = ptr[1]) == '{' && isCountedRepeat(ptr + 2, patternEnd)) { + ptr = readRepeatCounts(ptr + 2, &minRepeats, &maxRepeats, &errorcode); + if (errorcode) + return -1; + } else if (c == '*') { + minRepeats = 0; + maxRepeats = -1; + ptr++; + } else if (c == '+') { + minRepeats = 1; + maxRepeats = -1; + ptr++; + } else if (c == '?') { + minRepeats = 0; + maxRepeats = 1; + ptr++; + } else { + minRepeats = 1; + maxRepeats = 1; + } + + /* If the minimum is zero, we have to allow for an OP_BRAZERO before the + group, and if the maximum is greater than zero, we have to replicate + maxval-1 times; each replication acquires an OP_BRAZERO plus a nesting + bracket set. */ + + int repeatsLength; + if (minRepeats == 0) { + length++; + if (maxRepeats > 0) { + repeatsLength = multiplyWithOverflowCheck(maxRepeats - 1, duplength + 3 + 2 * LINK_SIZE); + if (repeatsLength < 0) { + errorcode = ERR16; + return -1; + } + length += repeatsLength; + if (length > MAX_PATTERN_SIZE) { + errorcode = ERR16; + return -1; + } + } + } + + /* When the minimum is greater than zero, we have to replicate up to + minval-1 times, with no additions required in the copies. Then, if there + is a limited maximum we have to replicate up to maxval-1 times allowing + for a BRAZERO item before each optional copy and nesting brackets for all + but one of the optional copies. */ + + else { + repeatsLength = multiplyWithOverflowCheck(minRepeats - 1, duplength); + if (repeatsLength < 0) { + errorcode = ERR16; + return -1; + } + length += repeatsLength; + if (maxRepeats > minRepeats) { /* Need this test as maxRepeats=-1 means no limit */ + repeatsLength = multiplyWithOverflowCheck(maxRepeats - minRepeats, duplength + 3 + 2 * LINK_SIZE); + if (repeatsLength < 0) { + errorcode = ERR16; + return -1; + } + length += repeatsLength - (2 + 2 * LINK_SIZE); + } + if (length > MAX_PATTERN_SIZE) { + errorcode = ERR16; + return -1; + } + } + + /* Allow space for once brackets for "possessive quantifier" */ + + if (safelyCheckNextChar(ptr, patternEnd, '+')) { + ptr++; + length += 2 + 2 * LINK_SIZE; + } + continue; + } + + /* Non-special character. It won't be space or # in extended mode, so it is + always a genuine character. If we are in a \Q...\E sequence, check for the + end; if not, we have a literal. */ + + default: + NORMAL_CHAR: + length += 2; /* For a one-byte character */ + lastitemlength = 1; /* Default length of last item for repeats */ + + if (c > 127) { + int i; + for (i = 0; i < kjs_pcre_utf8_table1_size; i++) + if (c <= kjs_pcre_utf8_table1[i]) + break; + length += i; + lastitemlength += i; + } + + continue; + } + } + + length += 2 + LINK_SIZE; /* For final KET and END */ + + cd.numCapturingBrackets = bracount; + return length; +} + +/************************************************* +* Compile a Regular Expression * +*************************************************/ + +/* This function takes a string and returns a pointer to a block of store +holding a compiled version of the expression. The original API for this +function had no error code return variable; it is retained for backwards +compatibility. The new function is given a new name. + +Arguments: + pattern the regular expression + options various option bits + errorcodeptr pointer to error code variable (pcre_compile2() only) + can be NULL if you don't want a code value + errorptr pointer to pointer to error text + erroroffset ptr offset in pattern where error was detected + tables pointer to character tables or NULL + +Returns: pointer to compiled data block, or NULL on error, + with errorptr and erroroffset set +*/ + +static inline JSRegExp* returnError(ErrorCode errorcode, const char** errorptr) +{ + *errorptr = errorText(errorcode); + return 0; +} + +JSRegExp* jsRegExpCompile(const UChar* pattern, int patternLength, + JSRegExpIgnoreCaseOption ignoreCase, JSRegExpMultilineOption multiline, + unsigned* numSubpatterns, const char** errorptr) +{ + /* We can't pass back an error message if errorptr is NULL; I guess the best we + can do is just return NULL, but we can set a code value if there is a code pointer. */ + if (!errorptr) + return 0; + *errorptr = NULL; + + CompileData cd; + + ErrorCode errorcode = ERR0; + /* Call this once just to count the brackets. */ + calculateCompiledPatternLength(pattern, patternLength, ignoreCase, cd, errorcode); + /* Call it again to compute the length. */ + int length = calculateCompiledPatternLength(pattern, patternLength, ignoreCase, cd, errorcode); + if (errorcode) + return returnError(errorcode, errorptr); + + if (length > MAX_PATTERN_SIZE) + return returnError(ERR16, errorptr); + + size_t size = length + sizeof(JSRegExp); + JSRegExp* re = reinterpret_cast(new char[size]); + + if (!re) + return returnError(ERR13, errorptr); + + re->options = (ignoreCase ? IgnoreCaseOption : 0) | (multiline ? MatchAcrossMultipleLinesOption : 0); + + /* The starting points of the name/number translation table and of the code are + passed around in the compile data block. */ + + const unsigned char* codeStart = (const unsigned char*)(re + 1); + + /* Set up a starting, non-extracting bracket, then compile the expression. On + error, errorcode will be set non-zero, so we don't need to look at the result + of the function here. */ + + const UChar* ptr = (const UChar*)pattern; + const UChar* patternEnd = pattern + patternLength; + unsigned char* code = (unsigned char*)codeStart; + int firstbyte, reqbyte; + int bracketCount = 0; + if (!cd.needOuterBracket) + compileBranch(re->options, &bracketCount, &code, &ptr, patternEnd, &errorcode, &firstbyte, &reqbyte, cd); + else { + *code = OP_BRA; + compileBracket(re->options, &bracketCount, &code, &ptr, patternEnd, &errorcode, 0, &firstbyte, &reqbyte, cd); + } + re->top_bracket = bracketCount; + re->top_backref = cd.top_backref; + + /* If not reached end of pattern on success, there's an excess bracket. */ + + if (errorcode == 0 && ptr < patternEnd) + errorcode = ERR10; + + /* Fill in the terminating state and check for disastrous overflow, but + if debugging, leave the test till after things are printed out. */ + + *code++ = OP_END; + + ASSERT(code - codeStart <= length); + if (code - codeStart > length) + errorcode = ERR7; + + /* Give an error if there's back reference to a non-existent capturing + subpattern. */ + + if (re->top_backref > re->top_bracket) + errorcode = ERR15; + + /* Failed to compile, or error while post-processing */ + + if (errorcode != ERR0) { + delete [] reinterpret_cast(re); + return returnError(errorcode, errorptr); + } + + /* If the anchored option was not passed, set the flag if we can determine that + the pattern is anchored by virtue of ^ characters or \A or anything else (such + as starting with .* when DOTALL is set). + + Otherwise, if we know what the first character has to be, save it, because that + speeds up unanchored matches no end. If not, see if we can set the + UseMultiLineFirstByteOptimizationOption flag. This is helpful for multiline matches when all branches + start with ^. and also when all branches start with .* for non-DOTALL matches. + */ + + if (cd.needOuterBracket ? bracketIsAnchored(codeStart) : branchIsAnchored(codeStart)) + re->options |= IsAnchoredOption; + else { + if (firstbyte < 0) { + firstbyte = (cd.needOuterBracket + ? bracketFindFirstAssertedCharacter(codeStart, false) + : branchFindFirstAssertedCharacter(codeStart, false)) + | ((re->options & IgnoreCaseOption) ? REQ_IGNORE_CASE : 0); + } + if (firstbyte >= 0) { + int ch = firstbyte & 255; + if (ch < 127) { + re->first_byte = ((firstbyte & REQ_IGNORE_CASE) && flipCase(ch) == ch) ? ch : firstbyte; + re->options |= UseFirstByteOptimizationOption; + } + } else { + if (cd.needOuterBracket ? bracketNeedsLineStart(codeStart, 0, cd.backrefMap) : branchNeedsLineStart(codeStart, 0, cd.backrefMap)) + re->options |= UseMultiLineFirstByteOptimizationOption; + } + } + + /* For an anchored pattern, we use the "required byte" only if it follows a + variable length item in the regex. Remove the caseless flag for non-caseable + bytes. */ + + if (reqbyte >= 0 && (!(re->options & IsAnchoredOption) || (reqbyte & REQ_VARY))) { + int ch = reqbyte & 255; + if (ch < 127) { + re->req_byte = ((reqbyte & REQ_IGNORE_CASE) && flipCase(ch) == ch) ? (reqbyte & ~REQ_IGNORE_CASE) : reqbyte; + re->options |= UseRequiredByteOptimizationOption; + } + } + + if (numSubpatterns) + *numSubpatterns = re->top_bracket; + return re; +} + +void jsRegExpFree(JSRegExp* re) +{ + delete [] reinterpret_cast(re); +} diff --git a/pcre/pcre_exec.cpp b/pcre/pcre_exec.cpp new file mode 100644 index 0000000..674b76c --- /dev/null +++ b/pcre/pcre_exec.cpp @@ -0,0 +1,2066 @@ +/* This is JavaScriptCore's variant of the PCRE library. While this library +started out as a copy of PCRE, many of the features of PCRE have been +removed. This library now supports only the regular expression features +required by the JavaScript language specification, and has only the functions +needed by JavaScriptCore and the rest of WebKit. + + Originally written by Philip Hazel + Copyright (c) 1997-2006 University of Cambridge + Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. + Copyright (C) 2007 Eric Seidel + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +/* This module contains jsRegExpExecute(), the externally visible function +that does pattern matching using an NFA algorithm, following the rules from +the JavaScript specification. There are also some supporting functions. */ + +#include "config.h" + +#include "pcre_internal.h" + +#include +#include + +#include + +using namespace WTF; + +#ifdef __GNUC__ +#define USE_COMPUTED_GOTO_FOR_MATCH_RECURSION +//#define USE_COMPUTED_GOTO_FOR_MATCH_OPCODE_LOOP +#endif + +/* Avoid warnings on Windows. */ +#undef min +#undef max + +#ifndef USE_COMPUTED_GOTO_FOR_MATCH_RECURSION +typedef int ReturnLocation; +#else +typedef void* ReturnLocation; +#endif + +/* Structure for building a chain of data for holding the values of +the subject pointer at the start of each bracket, used to detect when +an empty string has been matched by a bracket to break infinite loops. */ +struct BracketChainNode { + BracketChainNode* previousBracket; + const UChar* bracketStart; +}; + +struct MatchFrame { + ReturnLocation returnLocation; + struct MatchFrame* previousFrame; + + /* Function arguments that may change */ + struct { + const UChar* subjectPtr; + const unsigned char* instructionPtr; + int offsetTop; + BracketChainNode* bracketChain; + } args; + + + /* PCRE uses "fake" recursion built off of gotos, thus + stack-based local variables are not safe to use. Instead we have to + store local variables on the current MatchFrame. */ + struct { + const unsigned char* data; + const unsigned char* startOfRepeatingBracket; + const UChar* subjectPtrAtStartOfInstruction; // Several instrutions stash away a subjectPtr here for later compare + const unsigned char* instructionPtrAtStartOfOnce; + + int repeatOthercase; + + int ctype; + int fc; + int fi; + int length; + int max; + int number; + int offset; + int saveOffset1; + int saveOffset2; + int saveOffset3; + + BracketChainNode bracketChainNode; + } locals; +}; + +/* Structure for passing "static" information around between the functions +doing traditional NFA matching, so that they are thread-safe. */ + +struct MatchData { + int* offsetVector; /* Offset vector */ + int offsetEnd; /* One past the end */ + int offsetMax; /* The maximum usable for return data */ + bool offsetOverflow; /* Set if too many extractions */ + const UChar* startSubject; /* Start of the subject string */ + const UChar* endSubject; /* End of the subject string */ + const UChar* endMatchPtr; /* Subject position at end match */ + int endOffsetTop; /* Highwater mark at end of match */ + bool multiline; + bool ignoreCase; +}; + +/* The maximum remaining length of subject we are prepared to search for a +req_byte match. */ + +#define REQ_BYTE_MAX 1000 + +/* The below limit restricts the number of "recursive" match calls in order to +avoid spending exponential time on complex regular expressions. */ + +static const unsigned matchLimit = 100000; + +#ifdef DEBUG +/************************************************* +* Debugging function to print chars * +*************************************************/ + +/* Print a sequence of chars in printable format, stopping at the end of the +subject if the requested. + +Arguments: + p points to characters + length number to print + isSubject true if printing from within md.startSubject + md pointer to matching data block, if isSubject is true +*/ + +static void pchars(const UChar* p, int length, bool isSubject, const MatchData& md) +{ + if (isSubject && length > md.endSubject - p) + length = md.endSubject - p; + while (length-- > 0) { + int c; + if (isprint(c = *(p++))) + printf("%c", c); + else if (c < 256) + printf("\\x%02x", c); + else + printf("\\x{%x}", c); + } +} +#endif + +/************************************************* +* Match a back-reference * +*************************************************/ + +/* If a back reference hasn't been set, the length that is passed is greater +than the number of characters left in the string, so the match fails. + +Arguments: + offset index into the offset vector + subjectPtr points into the subject + length length to be matched + md points to match data block + +Returns: true if matched +*/ + +static bool matchRef(int offset, const UChar* subjectPtr, int length, const MatchData& md) +{ + const UChar* p = md.startSubject + md.offsetVector[offset]; + +#ifdef DEBUG + if (subjectPtr >= md.endSubject) + printf("matching subject "); + else { + printf("matching subject "); + pchars(subjectPtr, length, true, md); + } + printf(" against backref "); + pchars(p, length, false, md); + printf("\n"); +#endif + + /* Always fail if not enough characters left */ + + if (length > md.endSubject - subjectPtr) + return false; + + /* Separate the caselesss case for speed */ + + if (md.ignoreCase) { + while (length-- > 0) { + UChar c = *p++; + int othercase = kjs_pcre_ucp_othercase(c); + UChar d = *subjectPtr++; + if (c != d && othercase != d) + return false; + } + } + else { + while (length-- > 0) + if (*p++ != *subjectPtr++) + return false; + } + + return true; +} + +#ifndef USE_COMPUTED_GOTO_FOR_MATCH_RECURSION + +/* Use numbered labels and switch statement at the bottom of the match function. */ + +#define RMATCH_WHERE(num) num +#define RRETURN_LABEL RRETURN_SWITCH + +#else + +/* Use GCC's computed goto extension. */ + +/* For one test case this is more than 40% faster than the switch statement. +We could avoid the use of the num argument entirely by using local labels, +but using it for the GCC case as well as the non-GCC case allows us to share +a bit more code and notice if we use conflicting numbers.*/ + +#define RMATCH_WHERE(num) &&RRETURN_##num +#define RRETURN_LABEL *stack.currentFrame->returnLocation + +#endif + +#define RECURSIVE_MATCH_COMMON(num) \ + goto RECURSE;\ + RRETURN_##num: \ + stack.popCurrentFrame(); + +#define RECURSIVE_MATCH(num, ra, rb) \ + do { \ + stack.pushNewFrame((ra), (rb), RMATCH_WHERE(num)); \ + RECURSIVE_MATCH_COMMON(num) \ + } while (0) + +#define RECURSIVE_MATCH_STARTNG_NEW_GROUP(num, ra, rb) \ + do { \ + stack.pushNewFrame((ra), (rb), RMATCH_WHERE(num)); \ + startNewGroup(stack.currentFrame); \ + RECURSIVE_MATCH_COMMON(num) \ + } while (0) + +#define RRETURN goto RRETURN_LABEL + +#define RRETURN_NO_MATCH do { isMatch = false; RRETURN; } while (0) + +/************************************************* +* Match from current position * +*************************************************/ + +/* On entry instructionPtr points to the first opcode, and subjectPtr to the first character +in the subject string, while substringStart holds the value of subjectPtr at the start of the +last bracketed group - used for breaking infinite loops matching zero-length +strings. This function is called recursively in many circumstances. Whenever it +returns a negative (error) response, the outer match() call must also return the +same response. + +Arguments: + subjectPtr pointer in subject + instructionPtr position in code + offsetTop current top pointer + md pointer to "static" info for the match + +Returns: 1 if matched ) these values are >= 0 + 0 if failed to match ) + a negative error value if aborted by an error condition + (e.g. stopped by repeated call or recursion limit) +*/ + +static const unsigned FRAMES_ON_STACK = 16; + +struct MatchStack { + MatchStack() + : framesEnd(frames + FRAMES_ON_STACK) + , currentFrame(frames) + , size(1) // match() creates accesses the first frame w/o calling pushNewFrame + { + ASSERT((sizeof(frames) / sizeof(frames[0])) == FRAMES_ON_STACK); + } + + MatchFrame frames[FRAMES_ON_STACK]; + MatchFrame* framesEnd; + MatchFrame* currentFrame; + unsigned size; + + inline bool canUseStackBufferForNextFrame() + { + return size < FRAMES_ON_STACK; + } + + inline MatchFrame* allocateNextFrame() + { + if (canUseStackBufferForNextFrame()) + return currentFrame + 1; + return new MatchFrame; + } + + inline void pushNewFrame(const unsigned char* instructionPtr, BracketChainNode* bracketChain, ReturnLocation returnLocation) + { + MatchFrame* newframe = allocateNextFrame(); + newframe->previousFrame = currentFrame; + + newframe->args.subjectPtr = currentFrame->args.subjectPtr; + newframe->args.offsetTop = currentFrame->args.offsetTop; + newframe->args.instructionPtr = instructionPtr; + newframe->args.bracketChain = bracketChain; + newframe->returnLocation = returnLocation; + size++; + + currentFrame = newframe; + } + + inline void popCurrentFrame() + { + MatchFrame* oldFrame = currentFrame; + currentFrame = currentFrame->previousFrame; + if (size > FRAMES_ON_STACK) + delete oldFrame; + size--; + } + + void popAllFrames() + { + while (size) + popCurrentFrame(); + } +}; + +static int matchError(int errorCode, MatchStack& stack) +{ + stack.popAllFrames(); + return errorCode; +} + +/* Get the next UTF-8 character, not advancing the pointer, incrementing length + if there are extra bytes. This is called when we know we are in UTF-8 mode. */ + +static inline void getUTF8CharAndIncrementLength(int& c, const unsigned char* subjectPtr, int& len) +{ + c = *subjectPtr; + if ((c & 0xc0) == 0xc0) { + int gcaa = kjs_pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ + int gcss = 6 * gcaa; + c = (c & kjs_pcre_utf8_table3[gcaa]) << gcss; + for (int gcii = 1; gcii <= gcaa; gcii++) { + gcss -= 6; + c |= (subjectPtr[gcii] & 0x3f) << gcss; + } + len += gcaa; + } +} + +static inline void startNewGroup(MatchFrame* currentFrame) +{ + /* At the start of a bracketed group, add the current subject pointer to the + stack of such pointers, to be re-instated at the end of the group when we hit + the closing ket. When match() is called in other circumstances, we don't add to + this stack. */ + + currentFrame->locals.bracketChainNode.previousBracket = currentFrame->args.bracketChain; + currentFrame->locals.bracketChainNode.bracketStart = currentFrame->args.subjectPtr; + currentFrame->args.bracketChain = ¤tFrame->locals.bracketChainNode; +} + +// FIXME: "minimize" means "not greedy", we should invert the callers to ask for "greedy" to be less confusing +static inline void repeatInformationFromInstructionOffset(short instructionOffset, bool& minimize, int& minimumRepeats, int& maximumRepeats) +{ + // Instruction offsets are based off of OP_CRSTAR, OP_STAR, OP_TYPESTAR, OP_NOTSTAR + static const char minimumRepeatsFromInstructionOffset[] = { 0, 0, 1, 1, 0, 0 }; + static const int maximumRepeatsFromInstructionOffset[] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX, 1, 1 }; + + ASSERT(instructionOffset >= 0); + ASSERT(instructionOffset <= (OP_CRMINQUERY - OP_CRSTAR)); + + minimize = (instructionOffset & 1); // this assumes ordering: Instruction, MinimizeInstruction, Instruction2, MinimizeInstruction2 + minimumRepeats = minimumRepeatsFromInstructionOffset[instructionOffset]; + maximumRepeats = maximumRepeatsFromInstructionOffset[instructionOffset]; +} + +static int match(const UChar* subjectPtr, const unsigned char* instructionPtr, int offsetTop, MatchData& md) +{ + bool isMatch = false; + int min; + bool minimize = false; /* Initialization not really needed, but some compilers think so. */ + unsigned matchCount = 0; + + MatchStack stack; + + /* The opcode jump table. */ +#ifdef USE_COMPUTED_GOTO_FOR_MATCH_OPCODE_LOOP +#define EMIT_JUMP_TABLE_ENTRY(opcode) &&LABEL_OP_##opcode, + static void* opcodeJumpTable[256] = { FOR_EACH_OPCODE(EMIT_JUMP_TABLE_ENTRY) }; +#undef EMIT_JUMP_TABLE_ENTRY +#endif + + /* One-time setup of the opcode jump table. */ +#ifdef USE_COMPUTED_GOTO_FOR_MATCH_OPCODE_LOOP + for (int i = 255; !opcodeJumpTable[i]; i--) + opcodeJumpTable[i] = &&CAPTURING_BRACKET; +#endif + +#ifdef USE_COMPUTED_GOTO_FOR_MATCH_RECURSION + // Shark shows this as a hot line + // Using a static const here makes this line disappear, but makes later access hotter (not sure why) + stack.currentFrame->returnLocation = &&RETURN; +#else + stack.currentFrame->returnLocation = 0; +#endif + stack.currentFrame->args.subjectPtr = subjectPtr; + stack.currentFrame->args.instructionPtr = instructionPtr; + stack.currentFrame->args.offsetTop = offsetTop; + stack.currentFrame->args.bracketChain = 0; + startNewGroup(stack.currentFrame); + + /* This is where control jumps back to to effect "recursion" */ + +RECURSE: + if (++matchCount > matchLimit) + return matchError(JSRegExpErrorHitLimit, stack); + + /* Now start processing the operations. */ + +#ifndef USE_COMPUTED_GOTO_FOR_MATCH_OPCODE_LOOP + while (true) +#endif + { + +#ifdef USE_COMPUTED_GOTO_FOR_MATCH_OPCODE_LOOP +#define BEGIN_OPCODE(opcode) LABEL_OP_##opcode +#define NEXT_OPCODE goto *opcodeJumpTable[*stack.currentFrame->args.instructionPtr] +#else +#define BEGIN_OPCODE(opcode) case OP_##opcode +#define NEXT_OPCODE continue +#endif + +#ifdef USE_COMPUTED_GOTO_FOR_MATCH_OPCODE_LOOP + NEXT_OPCODE; +#else + switch (*stack.currentFrame->args.instructionPtr) +#endif + { + /* Non-capturing bracket: optimized */ + + BEGIN_OPCODE(BRA): + NON_CAPTURING_BRACKET: + DPRINTF(("start bracket 0\n")); + do { + RECURSIVE_MATCH_STARTNG_NEW_GROUP(2, stack.currentFrame->args.instructionPtr + 1 + LINK_SIZE, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + stack.currentFrame->args.instructionPtr += getLinkValue(stack.currentFrame->args.instructionPtr + 1); + } while (*stack.currentFrame->args.instructionPtr == OP_ALT); + DPRINTF(("bracket 0 failed\n")); + RRETURN; + + /* Skip over large extraction number data if encountered. */ + + BEGIN_OPCODE(BRANUMBER): + stack.currentFrame->args.instructionPtr += 3; + NEXT_OPCODE; + + /* End of the pattern. */ + + BEGIN_OPCODE(END): + md.endMatchPtr = stack.currentFrame->args.subjectPtr; /* Record where we ended */ + md.endOffsetTop = stack.currentFrame->args.offsetTop; /* and how many extracts were taken */ + isMatch = true; + RRETURN; + + /* Assertion brackets. Check the alternative branches in turn - the + matching won't pass the KET for an assertion. If any one branch matches, + the assertion is true. Lookbehind assertions have an OP_REVERSE item at the + start of each branch to move the current point backwards, so the code at + this level is identical to the lookahead case. */ + + BEGIN_OPCODE(ASSERT): + do { + RECURSIVE_MATCH_STARTNG_NEW_GROUP(6, stack.currentFrame->args.instructionPtr + 1 + LINK_SIZE, NULL); + if (isMatch) + break; + stack.currentFrame->args.instructionPtr += getLinkValue(stack.currentFrame->args.instructionPtr + 1); + } while (*stack.currentFrame->args.instructionPtr == OP_ALT); + if (*stack.currentFrame->args.instructionPtr == OP_KET) + RRETURN_NO_MATCH; + + /* Continue from after the assertion, updating the offsets high water + mark, since extracts may have been taken during the assertion. */ + + advanceToEndOfBracket(stack.currentFrame->args.instructionPtr); + stack.currentFrame->args.instructionPtr += 1 + LINK_SIZE; + stack.currentFrame->args.offsetTop = md.endOffsetTop; + NEXT_OPCODE; + + /* Negative assertion: all branches must fail to match */ + + BEGIN_OPCODE(ASSERT_NOT): + do { + RECURSIVE_MATCH_STARTNG_NEW_GROUP(7, stack.currentFrame->args.instructionPtr + 1 + LINK_SIZE, NULL); + if (isMatch) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr += getLinkValue(stack.currentFrame->args.instructionPtr + 1); + } while (*stack.currentFrame->args.instructionPtr == OP_ALT); + + stack.currentFrame->args.instructionPtr += 1 + LINK_SIZE; + NEXT_OPCODE; + + /* An alternation is the end of a branch; scan along to find the end of the + bracketed group and go to there. */ + + BEGIN_OPCODE(ALT): + advanceToEndOfBracket(stack.currentFrame->args.instructionPtr); + NEXT_OPCODE; + + /* BRAZERO and BRAMINZERO occur just before a bracket group, indicating + that it may occur zero times. It may repeat infinitely, or not at all - + i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper + repeat limits are compiled as a number of copies, with the optional ones + preceded by BRAZERO or BRAMINZERO. */ + + BEGIN_OPCODE(BRAZERO): { + stack.currentFrame->locals.startOfRepeatingBracket = stack.currentFrame->args.instructionPtr + 1; + RECURSIVE_MATCH_STARTNG_NEW_GROUP(14, stack.currentFrame->locals.startOfRepeatingBracket, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + advanceToEndOfBracket(stack.currentFrame->locals.startOfRepeatingBracket); + stack.currentFrame->args.instructionPtr = stack.currentFrame->locals.startOfRepeatingBracket + 1 + LINK_SIZE; + NEXT_OPCODE; + } + + BEGIN_OPCODE(BRAMINZERO): { + stack.currentFrame->locals.startOfRepeatingBracket = stack.currentFrame->args.instructionPtr + 1; + advanceToEndOfBracket(stack.currentFrame->locals.startOfRepeatingBracket); + RECURSIVE_MATCH_STARTNG_NEW_GROUP(15, stack.currentFrame->locals.startOfRepeatingBracket + 1 + LINK_SIZE, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + } + + /* End of a group, repeated or non-repeating. If we are at the end of + an assertion "group", stop matching and return 1, but record the + current high water mark for use by positive assertions. Do this also + for the "once" (not-backup up) groups. */ + + BEGIN_OPCODE(KET): + BEGIN_OPCODE(KETRMIN): + BEGIN_OPCODE(KETRMAX): + stack.currentFrame->locals.instructionPtrAtStartOfOnce = stack.currentFrame->args.instructionPtr - getLinkValue(stack.currentFrame->args.instructionPtr + 1); + stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.bracketChain->bracketStart; + + /* Back up the stack of bracket start pointers. */ + + stack.currentFrame->args.bracketChain = stack.currentFrame->args.bracketChain->previousBracket; + + if (*stack.currentFrame->locals.instructionPtrAtStartOfOnce == OP_ASSERT || *stack.currentFrame->locals.instructionPtrAtStartOfOnce == OP_ASSERT_NOT) { + md.endOffsetTop = stack.currentFrame->args.offsetTop; + isMatch = true; + RRETURN; + } + + /* In all other cases except a conditional group we have to check the + group number back at the start and if necessary complete handling an + extraction by setting the offsets and bumping the high water mark. */ + + stack.currentFrame->locals.number = *stack.currentFrame->locals.instructionPtrAtStartOfOnce - OP_BRA; + + /* For extended extraction brackets (large number), we have to fish out + the number from a dummy opcode at the start. */ + + if (stack.currentFrame->locals.number > EXTRACT_BASIC_MAX) + stack.currentFrame->locals.number = get2ByteValue(stack.currentFrame->locals.instructionPtrAtStartOfOnce + 2 + LINK_SIZE); + stack.currentFrame->locals.offset = stack.currentFrame->locals.number << 1; + +#ifdef DEBUG + printf("end bracket %d", stack.currentFrame->locals.number); + printf("\n"); +#endif + + /* Test for a numbered group. This includes groups called as a result + of recursion. Note that whole-pattern recursion is coded as a recurse + into group 0, so it won't be picked up here. Instead, we catch it when + the OP_END is reached. */ + + if (stack.currentFrame->locals.number > 0) { + if (stack.currentFrame->locals.offset >= md.offsetMax) + md.offsetOverflow = true; + else { + md.offsetVector[stack.currentFrame->locals.offset] = + md.offsetVector[md.offsetEnd - stack.currentFrame->locals.number]; + md.offsetVector[stack.currentFrame->locals.offset+1] = stack.currentFrame->args.subjectPtr - md.startSubject; + if (stack.currentFrame->args.offsetTop <= stack.currentFrame->locals.offset) + stack.currentFrame->args.offsetTop = stack.currentFrame->locals.offset + 2; + } + } + + /* For a non-repeating ket, just continue at this level. This also + happens for a repeating ket if no characters were matched in the group. + This is the forcible breaking of infinite loops as implemented in Perl + 5.005. If there is an options reset, it will get obeyed in the normal + course of events. */ + + if (*stack.currentFrame->args.instructionPtr == OP_KET || stack.currentFrame->args.subjectPtr == stack.currentFrame->locals.subjectPtrAtStartOfInstruction) { + stack.currentFrame->args.instructionPtr += 1 + LINK_SIZE; + NEXT_OPCODE; + } + + /* The repeating kets try the rest of the pattern or restart from the + preceding bracket, in the appropriate order. */ + + if (*stack.currentFrame->args.instructionPtr == OP_KETRMIN) { + RECURSIVE_MATCH(16, stack.currentFrame->args.instructionPtr + 1 + LINK_SIZE, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + RECURSIVE_MATCH_STARTNG_NEW_GROUP(17, stack.currentFrame->locals.instructionPtrAtStartOfOnce, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + } else { /* OP_KETRMAX */ + RECURSIVE_MATCH_STARTNG_NEW_GROUP(18, stack.currentFrame->locals.instructionPtrAtStartOfOnce, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + RECURSIVE_MATCH(19, stack.currentFrame->args.instructionPtr + 1 + LINK_SIZE, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + } + RRETURN; + + /* Start of subject, or after internal newline if multiline. */ + + BEGIN_OPCODE(CIRC): + if (stack.currentFrame->args.subjectPtr != md.startSubject && (!md.multiline || !isNewline(stack.currentFrame->args.subjectPtr[-1]))) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + + /* End of subject, or before internal newline if multiline. */ + + BEGIN_OPCODE(DOLL): + if (stack.currentFrame->args.subjectPtr < md.endSubject && (!md.multiline || !isNewline(*stack.currentFrame->args.subjectPtr))) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + + /* Word boundary assertions */ + + BEGIN_OPCODE(NOT_WORD_BOUNDARY): + BEGIN_OPCODE(WORD_BOUNDARY): { + bool currentCharIsWordChar = false; + bool previousCharIsWordChar = false; + + if (stack.currentFrame->args.subjectPtr > md.startSubject) + previousCharIsWordChar = isWordChar(stack.currentFrame->args.subjectPtr[-1]); + if (stack.currentFrame->args.subjectPtr < md.endSubject) + currentCharIsWordChar = isWordChar(*stack.currentFrame->args.subjectPtr); + + /* Now see if the situation is what we want */ + bool wordBoundaryDesired = (*stack.currentFrame->args.instructionPtr++ == OP_WORD_BOUNDARY); + if (wordBoundaryDesired ? currentCharIsWordChar == previousCharIsWordChar : currentCharIsWordChar != previousCharIsWordChar) + RRETURN_NO_MATCH; + NEXT_OPCODE; + } + + /* Match a single character type; inline for speed */ + + BEGIN_OPCODE(NOT_NEWLINE): + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + if (isNewline(*stack.currentFrame->args.subjectPtr++)) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + + BEGIN_OPCODE(NOT_DIGIT): + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + if (isASCIIDigit(*stack.currentFrame->args.subjectPtr++)) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + + BEGIN_OPCODE(DIGIT): + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + if (!isASCIIDigit(*stack.currentFrame->args.subjectPtr++)) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + + BEGIN_OPCODE(NOT_WHITESPACE): + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + if (isSpaceChar(*stack.currentFrame->args.subjectPtr++)) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + + BEGIN_OPCODE(WHITESPACE): + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + if (!isSpaceChar(*stack.currentFrame->args.subjectPtr++)) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + + BEGIN_OPCODE(NOT_WORDCHAR): + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + if (isWordChar(*stack.currentFrame->args.subjectPtr++)) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + + BEGIN_OPCODE(WORDCHAR): + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + if (!isWordChar(*stack.currentFrame->args.subjectPtr++)) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + NEXT_OPCODE; + + /* Match a back reference, possibly repeatedly. Look past the end of the + item to see if there is repeat information following. The code is similar + to that for character classes, but repeated for efficiency. Then obey + similar code to character type repeats - written out again for speed. + However, if the referenced string is the empty string, always treat + it as matched, any number of times (otherwise there could be infinite + loops). */ + + BEGIN_OPCODE(REF): + stack.currentFrame->locals.offset = get2ByteValue(stack.currentFrame->args.instructionPtr + 1) << 1; /* Doubled ref number */ + stack.currentFrame->args.instructionPtr += 3; /* Advance past item */ + + /* If the reference is unset, set the length to be longer than the amount + of subject left; this ensures that every attempt at a match fails. We + can't just fail here, because of the possibility of quantifiers with zero + minima. */ + + if (stack.currentFrame->locals.offset >= stack.currentFrame->args.offsetTop || md.offsetVector[stack.currentFrame->locals.offset] < 0) + stack.currentFrame->locals.length = 0; + else + stack.currentFrame->locals.length = md.offsetVector[stack.currentFrame->locals.offset+1] - md.offsetVector[stack.currentFrame->locals.offset]; + + /* Set up for repetition, or handle the non-repeated case */ + + switch (*stack.currentFrame->args.instructionPtr) { + case OP_CRSTAR: + case OP_CRMINSTAR: + case OP_CRPLUS: + case OP_CRMINPLUS: + case OP_CRQUERY: + case OP_CRMINQUERY: + repeatInformationFromInstructionOffset(*stack.currentFrame->args.instructionPtr++ - OP_CRSTAR, minimize, min, stack.currentFrame->locals.max); + break; + + case OP_CRRANGE: + case OP_CRMINRANGE: + minimize = (*stack.currentFrame->args.instructionPtr == OP_CRMINRANGE); + min = get2ByteValue(stack.currentFrame->args.instructionPtr + 1); + stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 3); + if (stack.currentFrame->locals.max == 0) + stack.currentFrame->locals.max = INT_MAX; + stack.currentFrame->args.instructionPtr += 5; + break; + + default: /* No repeat follows */ + if (!matchRef(stack.currentFrame->locals.offset, stack.currentFrame->args.subjectPtr, stack.currentFrame->locals.length, md)) + RRETURN_NO_MATCH; + stack.currentFrame->args.subjectPtr += stack.currentFrame->locals.length; + NEXT_OPCODE; + } + + /* If the length of the reference is zero, just continue with the + main loop. */ + + if (stack.currentFrame->locals.length == 0) + NEXT_OPCODE; + + /* First, ensure the minimum number of matches are present. */ + + for (int i = 1; i <= min; i++) { + if (!matchRef(stack.currentFrame->locals.offset, stack.currentFrame->args.subjectPtr, stack.currentFrame->locals.length, md)) + RRETURN_NO_MATCH; + stack.currentFrame->args.subjectPtr += stack.currentFrame->locals.length; + } + + /* If min = max, continue at the same level without recursion. + They are not both allowed to be zero. */ + + if (min == stack.currentFrame->locals.max) + NEXT_OPCODE; + + /* If minimizing, keep trying and advancing the pointer */ + + if (minimize) { + for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) { + RECURSIVE_MATCH(20, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || !matchRef(stack.currentFrame->locals.offset, stack.currentFrame->args.subjectPtr, stack.currentFrame->locals.length, md)) + RRETURN; + stack.currentFrame->args.subjectPtr += stack.currentFrame->locals.length; + } + /* Control never reaches here */ + } + + /* If maximizing, find the longest string and work backwards */ + + else { + stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr; + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (!matchRef(stack.currentFrame->locals.offset, stack.currentFrame->args.subjectPtr, stack.currentFrame->locals.length, md)) + break; + stack.currentFrame->args.subjectPtr += stack.currentFrame->locals.length; + } + while (stack.currentFrame->args.subjectPtr >= stack.currentFrame->locals.subjectPtrAtStartOfInstruction) { + RECURSIVE_MATCH(21, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + stack.currentFrame->args.subjectPtr -= stack.currentFrame->locals.length; + } + RRETURN_NO_MATCH; + } + /* Control never reaches here */ + + /* Match a bit-mapped character class, possibly repeatedly. This op code is + used when all the characters in the class have values in the range 0-255, + and either the matching is caseful, or the characters are in the range + 0-127 when UTF-8 processing is enabled. The only difference between + OP_CLASS and OP_NCLASS occurs when a data character outside the range is + encountered. + + First, look past the end of the item to see if there is repeat information + following. Then obey similar code to character type repeats - written out + again for speed. */ + + BEGIN_OPCODE(NCLASS): + BEGIN_OPCODE(CLASS): + stack.currentFrame->locals.data = stack.currentFrame->args.instructionPtr + 1; /* Save for matching */ + stack.currentFrame->args.instructionPtr += 33; /* Advance past the item */ + + switch (*stack.currentFrame->args.instructionPtr) { + case OP_CRSTAR: + case OP_CRMINSTAR: + case OP_CRPLUS: + case OP_CRMINPLUS: + case OP_CRQUERY: + case OP_CRMINQUERY: + repeatInformationFromInstructionOffset(*stack.currentFrame->args.instructionPtr++ - OP_CRSTAR, minimize, min, stack.currentFrame->locals.max); + break; + + case OP_CRRANGE: + case OP_CRMINRANGE: + minimize = (*stack.currentFrame->args.instructionPtr == OP_CRMINRANGE); + min = get2ByteValue(stack.currentFrame->args.instructionPtr + 1); + stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 3); + if (stack.currentFrame->locals.max == 0) + stack.currentFrame->locals.max = INT_MAX; + stack.currentFrame->args.instructionPtr += 5; + break; + + default: /* No repeat follows */ + min = stack.currentFrame->locals.max = 1; + break; + } + + /* First, ensure the minimum number of matches are present. */ + + for (int i = 1; i <= min; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + int c = *stack.currentFrame->args.subjectPtr++; + if (c > 255) { + if (stack.currentFrame->locals.data[-1] == OP_CLASS) + RRETURN_NO_MATCH; + } else { + if (!(stack.currentFrame->locals.data[c / 8] & (1 << (c & 7)))) + RRETURN_NO_MATCH; + } + } + + /* If max == min we can continue with the main loop without the + need to recurse. */ + + if (min == stack.currentFrame->locals.max) + NEXT_OPCODE; + + /* If minimizing, keep testing the rest of the expression and advancing + the pointer while it matches the class. */ + if (minimize) { + for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) { + RECURSIVE_MATCH(22, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN; + int c = *stack.currentFrame->args.subjectPtr++; + if (c > 255) { + if (stack.currentFrame->locals.data[-1] == OP_CLASS) + RRETURN; + } else { + if ((stack.currentFrame->locals.data[c/8] & (1 << (c&7))) == 0) + RRETURN; + } + } + /* Control never reaches here */ + } + /* If maximizing, find the longest possible run, then work backwards. */ + else { + stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr; + + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int c = *stack.currentFrame->args.subjectPtr; + if (c > 255) { + if (stack.currentFrame->locals.data[-1] == OP_CLASS) + break; + } else { + if (!(stack.currentFrame->locals.data[c / 8] & (1 << (c & 7)))) + break; + } + ++stack.currentFrame->args.subjectPtr; + } + for (;;) { + RECURSIVE_MATCH(24, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->args.subjectPtr-- == stack.currentFrame->locals.subjectPtrAtStartOfInstruction) + break; /* Stop if tried at original pos */ + } + + RRETURN; + } + /* Control never reaches here */ + + /* Match an extended character class. */ + + BEGIN_OPCODE(XCLASS): + stack.currentFrame->locals.data = stack.currentFrame->args.instructionPtr + 1 + LINK_SIZE; /* Save for matching */ + stack.currentFrame->args.instructionPtr += getLinkValue(stack.currentFrame->args.instructionPtr + 1); /* Advance past the item */ + + switch (*stack.currentFrame->args.instructionPtr) { + case OP_CRSTAR: + case OP_CRMINSTAR: + case OP_CRPLUS: + case OP_CRMINPLUS: + case OP_CRQUERY: + case OP_CRMINQUERY: + repeatInformationFromInstructionOffset(*stack.currentFrame->args.instructionPtr++ - OP_CRSTAR, minimize, min, stack.currentFrame->locals.max); + break; + + case OP_CRRANGE: + case OP_CRMINRANGE: + minimize = (*stack.currentFrame->args.instructionPtr == OP_CRMINRANGE); + min = get2ByteValue(stack.currentFrame->args.instructionPtr + 1); + stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 3); + if (stack.currentFrame->locals.max == 0) + stack.currentFrame->locals.max = INT_MAX; + stack.currentFrame->args.instructionPtr += 5; + break; + + default: /* No repeat follows */ + min = stack.currentFrame->locals.max = 1; + } + + /* First, ensure the minimum number of matches are present. */ + + for (int i = 1; i <= min; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + int c = *stack.currentFrame->args.subjectPtr++; + if (!kjs_pcre_xclass(c, stack.currentFrame->locals.data)) + RRETURN_NO_MATCH; + } + + /* If max == min we can continue with the main loop without the + need to recurse. */ + + if (min == stack.currentFrame->locals.max) + NEXT_OPCODE; + + /* If minimizing, keep testing the rest of the expression and advancing + the pointer while it matches the class. */ + + if (minimize) { + for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) { + RECURSIVE_MATCH(26, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN; + int c = *stack.currentFrame->args.subjectPtr++; + if (!kjs_pcre_xclass(c, stack.currentFrame->locals.data)) + RRETURN; + } + /* Control never reaches here */ + } + + /* If maximizing, find the longest possible run, then work backwards. */ + + else { + stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr; + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int c = *stack.currentFrame->args.subjectPtr; + if (!kjs_pcre_xclass(c, stack.currentFrame->locals.data)) + break; + ++stack.currentFrame->args.subjectPtr; + } + for(;;) { + RECURSIVE_MATCH(27, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->args.subjectPtr-- == stack.currentFrame->locals.subjectPtrAtStartOfInstruction) + break; /* Stop if tried at original pos */ + } + RRETURN; + } + + /* Control never reaches here */ + + /* Match a single character, casefully */ + + BEGIN_OPCODE(CHAR): + stack.currentFrame->locals.length = 1; + stack.currentFrame->args.instructionPtr++; + getUTF8CharAndIncrementLength(stack.currentFrame->locals.fc, stack.currentFrame->args.instructionPtr, stack.currentFrame->locals.length); + stack.currentFrame->args.instructionPtr += stack.currentFrame->locals.length; + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + if (stack.currentFrame->locals.fc != *stack.currentFrame->args.subjectPtr++) + RRETURN_NO_MATCH; + NEXT_OPCODE; + + /* Match a single character, caselessly */ + + BEGIN_OPCODE(CHAR_IGNORING_CASE): { + stack.currentFrame->locals.length = 1; + stack.currentFrame->args.instructionPtr++; + getUTF8CharAndIncrementLength(stack.currentFrame->locals.fc, stack.currentFrame->args.instructionPtr, stack.currentFrame->locals.length); + stack.currentFrame->args.instructionPtr += stack.currentFrame->locals.length; + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + int dc = *stack.currentFrame->args.subjectPtr++; + if (stack.currentFrame->locals.fc != dc && kjs_pcre_ucp_othercase(stack.currentFrame->locals.fc) != dc) + RRETURN_NO_MATCH; + NEXT_OPCODE; + } + + /* Match a single ASCII character. */ + + BEGIN_OPCODE(ASCII_CHAR): + if (md.endSubject == stack.currentFrame->args.subjectPtr) + RRETURN_NO_MATCH; + if (*stack.currentFrame->args.subjectPtr != stack.currentFrame->args.instructionPtr[1]) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + stack.currentFrame->args.instructionPtr += 2; + NEXT_OPCODE; + + /* Match one of two cases of an ASCII letter. */ + + BEGIN_OPCODE(ASCII_LETTER_IGNORING_CASE): + if (md.endSubject == stack.currentFrame->args.subjectPtr) + RRETURN_NO_MATCH; + if ((*stack.currentFrame->args.subjectPtr | 0x20) != stack.currentFrame->args.instructionPtr[1]) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + stack.currentFrame->args.instructionPtr += 2; + NEXT_OPCODE; + + /* Match a single character repeatedly; different opcodes share code. */ + + BEGIN_OPCODE(EXACT): + min = stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 1); + minimize = false; + stack.currentFrame->args.instructionPtr += 3; + goto REPEATCHAR; + + BEGIN_OPCODE(UPTO): + BEGIN_OPCODE(MINUPTO): + min = 0; + stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 1); + minimize = *stack.currentFrame->args.instructionPtr == OP_MINUPTO; + stack.currentFrame->args.instructionPtr += 3; + goto REPEATCHAR; + + BEGIN_OPCODE(STAR): + BEGIN_OPCODE(MINSTAR): + BEGIN_OPCODE(PLUS): + BEGIN_OPCODE(MINPLUS): + BEGIN_OPCODE(QUERY): + BEGIN_OPCODE(MINQUERY): + repeatInformationFromInstructionOffset(*stack.currentFrame->args.instructionPtr++ - OP_STAR, minimize, min, stack.currentFrame->locals.max); + + /* Common code for all repeated single-character matches. We can give + up quickly if there are fewer than the minimum number of characters left in + the subject. */ + + REPEATCHAR: + + stack.currentFrame->locals.length = 1; + getUTF8CharAndIncrementLength(stack.currentFrame->locals.fc, stack.currentFrame->args.instructionPtr, stack.currentFrame->locals.length); + if (min * (stack.currentFrame->locals.fc > 0xFFFF ? 2 : 1) > md.endSubject - stack.currentFrame->args.subjectPtr) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr += stack.currentFrame->locals.length; + + if (stack.currentFrame->locals.fc <= 0xFFFF) { + int othercase = md.ignoreCase ? kjs_pcre_ucp_othercase(stack.currentFrame->locals.fc) : -1; + + for (int i = 1; i <= min; i++) { + if (*stack.currentFrame->args.subjectPtr != stack.currentFrame->locals.fc && *stack.currentFrame->args.subjectPtr != othercase) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + } + + if (min == stack.currentFrame->locals.max) + NEXT_OPCODE; + + if (minimize) { + stack.currentFrame->locals.repeatOthercase = othercase; + for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) { + RECURSIVE_MATCH(28, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN; + if (*stack.currentFrame->args.subjectPtr != stack.currentFrame->locals.fc && *stack.currentFrame->args.subjectPtr != stack.currentFrame->locals.repeatOthercase) + RRETURN; + ++stack.currentFrame->args.subjectPtr; + } + /* Control never reaches here */ + } else { + stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr; + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + if (*stack.currentFrame->args.subjectPtr != stack.currentFrame->locals.fc && *stack.currentFrame->args.subjectPtr != othercase) + break; + ++stack.currentFrame->args.subjectPtr; + } + while (stack.currentFrame->args.subjectPtr >= stack.currentFrame->locals.subjectPtrAtStartOfInstruction) { + RECURSIVE_MATCH(29, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + --stack.currentFrame->args.subjectPtr; + } + RRETURN_NO_MATCH; + } + /* Control never reaches here */ + } else { + /* No case on surrogate pairs, so no need to bother with "othercase". */ + + for (int i = 1; i <= min; i++) { + if (*stack.currentFrame->args.subjectPtr != stack.currentFrame->locals.fc) + RRETURN_NO_MATCH; + stack.currentFrame->args.subjectPtr += 2; + } + + if (min == stack.currentFrame->locals.max) + NEXT_OPCODE; + + if (minimize) { + for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) { + RECURSIVE_MATCH(30, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN; + if (*stack.currentFrame->args.subjectPtr != stack.currentFrame->locals.fc) + RRETURN; + stack.currentFrame->args.subjectPtr += 2; + } + /* Control never reaches here */ + } else { + stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr; + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr > md.endSubject - 2) + break; + if (*stack.currentFrame->args.subjectPtr != stack.currentFrame->locals.fc) + break; + stack.currentFrame->args.subjectPtr += 2; + } + while (stack.currentFrame->args.subjectPtr >= stack.currentFrame->locals.subjectPtrAtStartOfInstruction) { + RECURSIVE_MATCH(31, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + stack.currentFrame->args.subjectPtr -= 2; + } + RRETURN_NO_MATCH; + } + /* Control never reaches here */ + } + /* Control never reaches here */ + + /* Match a negated single one-byte character. */ + + BEGIN_OPCODE(NOT): { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN_NO_MATCH; + stack.currentFrame->args.instructionPtr++; + int c = *stack.currentFrame->args.subjectPtr++; + if (md.ignoreCase) { + if (c < 128) + c = toLowerCase(c); + if (toLowerCase(*stack.currentFrame->args.instructionPtr++) == c) + RRETURN_NO_MATCH; + } else { + if (*stack.currentFrame->args.instructionPtr++ == c) + RRETURN_NO_MATCH; + } + NEXT_OPCODE; + } + + /* Match a negated single one-byte character repeatedly. This is almost a + repeat of the code for a repeated single character, but I haven't found a + nice way of commoning these up that doesn't require a test of the + positive/negative option for each character match. Maybe that wouldn't add + very much to the time taken, but character matching *is* what this is all + about... */ + + BEGIN_OPCODE(NOTEXACT): + min = stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 1); + minimize = false; + stack.currentFrame->args.instructionPtr += 3; + goto REPEATNOTCHAR; + + BEGIN_OPCODE(NOTUPTO): + BEGIN_OPCODE(NOTMINUPTO): + min = 0; + stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 1); + minimize = *stack.currentFrame->args.instructionPtr == OP_NOTMINUPTO; + stack.currentFrame->args.instructionPtr += 3; + goto REPEATNOTCHAR; + + BEGIN_OPCODE(NOTSTAR): + BEGIN_OPCODE(NOTMINSTAR): + BEGIN_OPCODE(NOTPLUS): + BEGIN_OPCODE(NOTMINPLUS): + BEGIN_OPCODE(NOTQUERY): + BEGIN_OPCODE(NOTMINQUERY): + repeatInformationFromInstructionOffset(*stack.currentFrame->args.instructionPtr++ - OP_NOTSTAR, minimize, min, stack.currentFrame->locals.max); + + /* Common code for all repeated single-byte matches. We can give up quickly + if there are fewer than the minimum number of bytes left in the + subject. */ + + REPEATNOTCHAR: + if (min > md.endSubject - stack.currentFrame->args.subjectPtr) + RRETURN_NO_MATCH; + stack.currentFrame->locals.fc = *stack.currentFrame->args.instructionPtr++; + + /* The code is duplicated for the caseless and caseful cases, for speed, + since matching characters is likely to be quite common. First, ensure the + minimum number of matches are present. If min = max, continue at the same + level without recursing. Otherwise, if minimizing, keep trying the rest of + the expression and advancing one matching character if failing, up to the + maximum. Alternatively, if maximizing, find the maximum number of + characters and work backwards. */ + + DPRINTF(("negative matching %c{%d,%d}\n", stack.currentFrame->locals.fc, min, stack.currentFrame->locals.max)); + + if (md.ignoreCase) { + if (stack.currentFrame->locals.fc < 128) + stack.currentFrame->locals.fc = toLowerCase(stack.currentFrame->locals.fc); + + for (int i = 1; i <= min; i++) { + int d = *stack.currentFrame->args.subjectPtr++; + if (d < 128) + d = toLowerCase(d); + if (stack.currentFrame->locals.fc == d) + RRETURN_NO_MATCH; + } + + if (min == stack.currentFrame->locals.max) + NEXT_OPCODE; + + if (minimize) { + for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) { + RECURSIVE_MATCH(38, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + int d = *stack.currentFrame->args.subjectPtr++; + if (d < 128) + d = toLowerCase(d); + if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject || stack.currentFrame->locals.fc == d) + RRETURN; + } + /* Control never reaches here */ + } + + /* Maximize case */ + + else { + stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr; + + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int d = *stack.currentFrame->args.subjectPtr; + if (d < 128) + d = toLowerCase(d); + if (stack.currentFrame->locals.fc == d) + break; + ++stack.currentFrame->args.subjectPtr; + } + for (;;) { + RECURSIVE_MATCH(40, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->args.subjectPtr-- == stack.currentFrame->locals.subjectPtrAtStartOfInstruction) + break; /* Stop if tried at original pos */ + } + + RRETURN; + } + /* Control never reaches here */ + } + + /* Caseful comparisons */ + + else { + for (int i = 1; i <= min; i++) { + int d = *stack.currentFrame->args.subjectPtr++; + if (stack.currentFrame->locals.fc == d) + RRETURN_NO_MATCH; + } + + if (min == stack.currentFrame->locals.max) + NEXT_OPCODE; + + if (minimize) { + for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) { + RECURSIVE_MATCH(42, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + int d = *stack.currentFrame->args.subjectPtr++; + if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject || stack.currentFrame->locals.fc == d) + RRETURN; + } + /* Control never reaches here */ + } + + /* Maximize case */ + + else { + stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr; + + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int d = *stack.currentFrame->args.subjectPtr; + if (stack.currentFrame->locals.fc == d) + break; + ++stack.currentFrame->args.subjectPtr; + } + for (;;) { + RECURSIVE_MATCH(44, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->args.subjectPtr-- == stack.currentFrame->locals.subjectPtrAtStartOfInstruction) + break; /* Stop if tried at original pos */ + } + + RRETURN; + } + } + /* Control never reaches here */ + + /* Match a single character type repeatedly; several different opcodes + share code. This is very similar to the code for single characters, but we + repeat it in the interests of efficiency. */ + + BEGIN_OPCODE(TYPEEXACT): + min = stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 1); + minimize = true; + stack.currentFrame->args.instructionPtr += 3; + goto REPEATTYPE; + + BEGIN_OPCODE(TYPEUPTO): + BEGIN_OPCODE(TYPEMINUPTO): + min = 0; + stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 1); + minimize = *stack.currentFrame->args.instructionPtr == OP_TYPEMINUPTO; + stack.currentFrame->args.instructionPtr += 3; + goto REPEATTYPE; + + BEGIN_OPCODE(TYPESTAR): + BEGIN_OPCODE(TYPEMINSTAR): + BEGIN_OPCODE(TYPEPLUS): + BEGIN_OPCODE(TYPEMINPLUS): + BEGIN_OPCODE(TYPEQUERY): + BEGIN_OPCODE(TYPEMINQUERY): + repeatInformationFromInstructionOffset(*stack.currentFrame->args.instructionPtr++ - OP_TYPESTAR, minimize, min, stack.currentFrame->locals.max); + + /* Common code for all repeated single character type matches. Note that + in UTF-8 mode, '.' matches a character of any length, but for the other + character types, the valid characters are all one-byte long. */ + + REPEATTYPE: + stack.currentFrame->locals.ctype = *stack.currentFrame->args.instructionPtr++; /* Code for the character type */ + + /* First, ensure the minimum number of matches are present. Use inline + code for maximizing the speed, and do the type test once at the start + (i.e. keep it out of the loop). Also we can test that there are at least + the minimum number of characters before we start. */ + + if (min > md.endSubject - stack.currentFrame->args.subjectPtr) + RRETURN_NO_MATCH; + if (min > 0) { + switch (stack.currentFrame->locals.ctype) { + case OP_NOT_NEWLINE: + for (int i = 1; i <= min; i++) { + if (isNewline(*stack.currentFrame->args.subjectPtr)) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_NOT_DIGIT: + for (int i = 1; i <= min; i++) { + if (isASCIIDigit(*stack.currentFrame->args.subjectPtr)) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_DIGIT: + for (int i = 1; i <= min; i++) { + if (!isASCIIDigit(*stack.currentFrame->args.subjectPtr)) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_NOT_WHITESPACE: + for (int i = 1; i <= min; i++) { + if (isSpaceChar(*stack.currentFrame->args.subjectPtr)) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_WHITESPACE: + for (int i = 1; i <= min; i++) { + if (!isSpaceChar(*stack.currentFrame->args.subjectPtr)) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_NOT_WORDCHAR: + for (int i = 1; i <= min; i++) { + if (isWordChar(*stack.currentFrame->args.subjectPtr)) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_WORDCHAR: + for (int i = 1; i <= min; i++) { + if (!isWordChar(*stack.currentFrame->args.subjectPtr)) + RRETURN_NO_MATCH; + ++stack.currentFrame->args.subjectPtr; + } + break; + + default: + ASSERT_NOT_REACHED(); + return matchError(JSRegExpErrorInternal, stack); + } /* End switch(stack.currentFrame->locals.ctype) */ + } + + /* If min = max, continue at the same level without recursing */ + + if (min == stack.currentFrame->locals.max) + NEXT_OPCODE; + + /* If minimizing, we have to test the rest of the pattern before each + subsequent match. */ + + if (minimize) { + for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) { + RECURSIVE_MATCH(48, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject) + RRETURN; + + int c = *stack.currentFrame->args.subjectPtr++; + switch (stack.currentFrame->locals.ctype) { + case OP_NOT_NEWLINE: + if (isNewline(c)) + RRETURN; + break; + + case OP_NOT_DIGIT: + if (isASCIIDigit(c)) + RRETURN; + break; + + case OP_DIGIT: + if (!isASCIIDigit(c)) + RRETURN; + break; + + case OP_NOT_WHITESPACE: + if (isSpaceChar(c)) + RRETURN; + break; + + case OP_WHITESPACE: + if (!isSpaceChar(c)) + RRETURN; + break; + + case OP_NOT_WORDCHAR: + if (isWordChar(c)) + RRETURN; + break; + + case OP_WORDCHAR: + if (!isWordChar(c)) + RRETURN; + break; + + default: + ASSERT_NOT_REACHED(); + return matchError(JSRegExpErrorInternal, stack); + } + } + /* Control never reaches here */ + } + + /* If maximizing it is worth using inline code for speed, doing the type + test once at the start (i.e. keep it out of the loop). */ + + else { + stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr; /* Remember where we started */ + + switch (stack.currentFrame->locals.ctype) { + case OP_NOT_NEWLINE: + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject || isNewline(*stack.currentFrame->args.subjectPtr)) + break; + stack.currentFrame->args.subjectPtr++; + } + break; + + case OP_NOT_DIGIT: + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int c = *stack.currentFrame->args.subjectPtr; + if (isASCIIDigit(c)) + break; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_DIGIT: + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int c = *stack.currentFrame->args.subjectPtr; + if (!isASCIIDigit(c)) + break; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_NOT_WHITESPACE: + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int c = *stack.currentFrame->args.subjectPtr; + if (isSpaceChar(c)) + break; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_WHITESPACE: + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int c = *stack.currentFrame->args.subjectPtr; + if (!isSpaceChar(c)) + break; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_NOT_WORDCHAR: + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int c = *stack.currentFrame->args.subjectPtr; + if (isWordChar(c)) + break; + ++stack.currentFrame->args.subjectPtr; + } + break; + + case OP_WORDCHAR: + for (int i = min; i < stack.currentFrame->locals.max; i++) { + if (stack.currentFrame->args.subjectPtr >= md.endSubject) + break; + int c = *stack.currentFrame->args.subjectPtr; + if (!isWordChar(c)) + break; + ++stack.currentFrame->args.subjectPtr; + } + break; + + default: + ASSERT_NOT_REACHED(); + return matchError(JSRegExpErrorInternal, stack); + } + + /* stack.currentFrame->args.subjectPtr is now past the end of the maximum run */ + + for (;;) { + RECURSIVE_MATCH(52, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + if (stack.currentFrame->args.subjectPtr-- == stack.currentFrame->locals.subjectPtrAtStartOfInstruction) + break; /* Stop if tried at original pos */ + } + + /* Get here if we can't make it match with any permitted repetitions */ + + RRETURN; + } + /* Control never reaches here */ + + BEGIN_OPCODE(CRMINPLUS): + BEGIN_OPCODE(CRMINQUERY): + BEGIN_OPCODE(CRMINRANGE): + BEGIN_OPCODE(CRMINSTAR): + BEGIN_OPCODE(CRPLUS): + BEGIN_OPCODE(CRQUERY): + BEGIN_OPCODE(CRRANGE): + BEGIN_OPCODE(CRSTAR): + ASSERT_NOT_REACHED(); + return matchError(JSRegExpErrorInternal, stack); + +#ifdef USE_COMPUTED_GOTO_FOR_MATCH_OPCODE_LOOP + CAPTURING_BRACKET: +#else + default: +#endif + /* Opening capturing bracket. If there is space in the offset vector, save + the current subject position in the working slot at the top of the vector. We + mustn't change the current values of the data slot, because they may be set + from a previous iteration of this group, and be referred to by a reference + inside the group. + + If the bracket fails to match, we need to restore this value and also the + values of the final offsets, in case they were set by a previous iteration of + the same bracket. + + If there isn't enough space in the offset vector, treat this as if it were a + non-capturing bracket. Don't worry about setting the flag for the error case + here; that is handled in the code for KET. */ + + ASSERT(*stack.currentFrame->args.instructionPtr > OP_BRA); + + stack.currentFrame->locals.number = *stack.currentFrame->args.instructionPtr - OP_BRA; + + /* For extended extraction brackets (large number), we have to fish out the + number from a dummy opcode at the start. */ + + if (stack.currentFrame->locals.number > EXTRACT_BASIC_MAX) + stack.currentFrame->locals.number = get2ByteValue(stack.currentFrame->args.instructionPtr + 2 + LINK_SIZE); + stack.currentFrame->locals.offset = stack.currentFrame->locals.number << 1; + +#ifdef DEBUG + printf("start bracket %d subject=", stack.currentFrame->locals.number); + pchars(stack.currentFrame->args.subjectPtr, 16, true, md); + printf("\n"); +#endif + + if (stack.currentFrame->locals.offset < md.offsetMax) { + stack.currentFrame->locals.saveOffset1 = md.offsetVector[stack.currentFrame->locals.offset]; + stack.currentFrame->locals.saveOffset2 = md.offsetVector[stack.currentFrame->locals.offset + 1]; + stack.currentFrame->locals.saveOffset3 = md.offsetVector[md.offsetEnd - stack.currentFrame->locals.number]; + + DPRINTF(("saving %d %d %d\n", stack.currentFrame->locals.saveOffset1, stack.currentFrame->locals.saveOffset2, stack.currentFrame->locals.saveOffset3)); + md.offsetVector[md.offsetEnd - stack.currentFrame->locals.number] = stack.currentFrame->args.subjectPtr - md.startSubject; + + do { + RECURSIVE_MATCH_STARTNG_NEW_GROUP(1, stack.currentFrame->args.instructionPtr + 1 + LINK_SIZE, stack.currentFrame->args.bracketChain); + if (isMatch) + RRETURN; + stack.currentFrame->args.instructionPtr += getLinkValue(stack.currentFrame->args.instructionPtr + 1); + } while (*stack.currentFrame->args.instructionPtr == OP_ALT); + + DPRINTF(("bracket %d failed\n", stack.currentFrame->locals.number)); + + md.offsetVector[stack.currentFrame->locals.offset] = stack.currentFrame->locals.saveOffset1; + md.offsetVector[stack.currentFrame->locals.offset + 1] = stack.currentFrame->locals.saveOffset2; + md.offsetVector[md.offsetEnd - stack.currentFrame->locals.number] = stack.currentFrame->locals.saveOffset3; + + RRETURN; + } + + /* Insufficient room for saving captured contents */ + + goto NON_CAPTURING_BRACKET; + } + + /* Do not stick any code in here without much thought; it is assumed + that "continue" in the code above comes out to here to repeat the main + loop. */ + + } /* End of main loop */ + + ASSERT_NOT_REACHED(); + +#ifndef USE_COMPUTED_GOTO_FOR_MATCH_RECURSION + +RRETURN_SWITCH: + switch (stack.currentFrame->returnLocation) { + case 0: goto RETURN; + case 1: goto RRETURN_1; + case 2: goto RRETURN_2; + case 6: goto RRETURN_6; + case 7: goto RRETURN_7; + case 14: goto RRETURN_14; + case 15: goto RRETURN_15; + case 16: goto RRETURN_16; + case 17: goto RRETURN_17; + case 18: goto RRETURN_18; + case 19: goto RRETURN_19; + case 20: goto RRETURN_20; + case 21: goto RRETURN_21; + case 22: goto RRETURN_22; + case 24: goto RRETURN_24; + case 26: goto RRETURN_26; + case 27: goto RRETURN_27; + case 28: goto RRETURN_28; + case 29: goto RRETURN_29; + case 30: goto RRETURN_30; + case 31: goto RRETURN_31; + case 38: goto RRETURN_38; + case 40: goto RRETURN_40; + case 42: goto RRETURN_42; + case 44: goto RRETURN_44; + case 48: goto RRETURN_48; + case 52: goto RRETURN_52; + } + + ASSERT_NOT_REACHED(); + return matchError(JSRegExpErrorInternal, stack); + +#endif + +RETURN: + return isMatch; +} + + +/************************************************* +* Execute a Regular Expression * +*************************************************/ + +/* This function applies a compiled re to a subject string and picks out +portions of the string if it matches. Two elements in the vector are set for +each substring: the offsets to the start and end of the substring. + +Arguments: + re points to the compiled expression + extra_data points to extra data or is NULL + subject points to the subject string + length length of subject string (may contain binary zeros) + start_offset where to start in the subject string + options option bits + offsets points to a vector of ints to be filled in with offsets + offsetcount the number of elements in the vector + +Returns: > 0 => success; value is the number of elements filled in + = 0 => success, but offsets is not big enough + -1 => failed to match + < -1 => some kind of unexpected problem +*/ + +static void tryFirstByteOptimization(const UChar*& subjectPtr, const UChar* endSubject, int first_byte, bool first_byte_caseless, bool useMultiLineFirstCharOptimization, const UChar* originalSubjectStart) +{ + // If first_byte is set, try scanning to the first instance of that byte + // no need to try and match against any earlier part of the subject string. + if (first_byte >= 0) { + UChar first_char = first_byte; + if (first_byte_caseless) + while (subjectPtr < endSubject) { + int c = *subjectPtr; + if (c > 127) + break; + if (toLowerCase(c) == first_char) + break; + subjectPtr++; + } + else { + while (subjectPtr < endSubject && *subjectPtr != first_char) + subjectPtr++; + } + } else if (useMultiLineFirstCharOptimization) { + /* Or to just after \n for a multiline match if possible */ + // I'm not sure why this != originalSubjectStart check is necessary -- ecs 11/18/07 + if (subjectPtr > originalSubjectStart) { + while (subjectPtr < endSubject && !isNewline(subjectPtr[-1])) + subjectPtr++; + } + } +} + +static bool tryRequiredByteOptimization(const UChar*& subjectPtr, const UChar* endSubject, int req_byte, int req_byte2, bool req_byte_caseless, bool hasFirstByte, const UChar*& reqBytePtr) +{ + /* If req_byte is set, we know that that character must appear in the subject + for the match to succeed. If the first character is set, req_byte must be + later in the subject; otherwise the test starts at the match point. This + optimization can save a huge amount of backtracking in patterns with nested + unlimited repeats that aren't going to match. Writing separate code for + cased/caseless versions makes it go faster, as does using an autoincrement + and backing off on a match. + + HOWEVER: when the subject string is very, very long, searching to its end can + take a long time, and give bad performance on quite ordinary patterns. This + showed up when somebody was matching /^C/ on a 32-megabyte string... so we + don't do this when the string is sufficiently long. + */ + + if (req_byte >= 0 && endSubject - subjectPtr < REQ_BYTE_MAX) { + const UChar* p = subjectPtr + (hasFirstByte ? 1 : 0); + + /* We don't need to repeat the search if we haven't yet reached the + place we found it at last time. */ + + if (p > reqBytePtr) { + if (req_byte_caseless) { + while (p < endSubject) { + int pp = *p++; + if (pp == req_byte || pp == req_byte2) { + p--; + break; + } + } + } else { + while (p < endSubject) { + if (*p++ == req_byte) { + p--; + break; + } + } + } + + /* If we can't find the required character, break the matching loop */ + + if (p >= endSubject) + return true; + + /* If we have found the required character, save the point where we + found it, so that we don't search again next time round the loop if + the start hasn't passed this character yet. */ + + reqBytePtr = p; + } + } + return false; +} + +int jsRegExpExecute(const JSRegExp* re, + const UChar* subject, int length, int start_offset, int* offsets, + int offsetcount) +{ + ASSERT(re); + ASSERT(subject); + ASSERT(offsetcount >= 0); + ASSERT(offsets || offsetcount == 0); + + MatchData matchBlock; + matchBlock.startSubject = subject; + matchBlock.endSubject = matchBlock.startSubject + length; + const UChar* endSubject = matchBlock.endSubject; + + matchBlock.multiline = (re->options & MatchAcrossMultipleLinesOption); + matchBlock.ignoreCase = (re->options & IgnoreCaseOption); + + /* If the expression has got more back references than the offsets supplied can + hold, we get a temporary chunk of working store to use during the matching. + Otherwise, we can use the vector supplied, rounding down its size to a multiple + of 3. */ + + int ocount = offsetcount - (offsetcount % 3); + + // FIXME: This is lame that we have to second-guess our caller here. + // The API should change to either fail-hard when we don't have enough offset space + // or that we shouldn't ask our callers to pre-allocate in the first place. + bool using_temporary_offsets = false; + if (re->top_backref > 0 && re->top_backref >= ocount/3) { + ocount = re->top_backref * 3 + 3; + matchBlock.offsetVector = new int[ocount]; + if (!matchBlock.offsetVector) + return JSRegExpErrorNoMemory; + using_temporary_offsets = true; + } else + matchBlock.offsetVector = offsets; + + matchBlock.offsetEnd = ocount; + matchBlock.offsetMax = (2*ocount)/3; + matchBlock.offsetOverflow = false; + + /* Compute the minimum number of offsets that we need to reset each time. Doing + this makes a huge difference to execution time when there aren't many brackets + in the pattern. */ + + int resetcount = 2 + re->top_bracket * 2; + if (resetcount > offsetcount) + resetcount = ocount; + + /* Reset the working variable associated with each extraction. These should + never be used unless previously set, but they get saved and restored, and so we + initialize them to avoid reading uninitialized locations. */ + + if (matchBlock.offsetVector) { + int* iptr = matchBlock.offsetVector + ocount; + int* iend = iptr - resetcount/2 + 1; + while (--iptr >= iend) + *iptr = -1; + } + + /* Set up the first character to match, if available. The first_byte value is + never set for an anchored regular expression, but the anchoring may be forced + at run time, so we have to test for anchoring. The first char may be unset for + an unanchored pattern, of course. If there's no first char and the pattern was + studied, there may be a bitmap of possible first characters. */ + + bool first_byte_caseless = false; + int first_byte = -1; + if (re->options & UseFirstByteOptimizationOption) { + first_byte = re->first_byte & 255; + if ((first_byte_caseless = (re->first_byte & REQ_IGNORE_CASE))) + first_byte = toLowerCase(first_byte); + } + + /* For anchored or unanchored matches, there may be a "last known required + character" set. */ + + bool req_byte_caseless = false; + int req_byte = -1; + int req_byte2 = -1; + if (re->options & UseRequiredByteOptimizationOption) { + req_byte = re->req_byte & 255; // FIXME: This optimization could be made to work for UTF16 chars as well... + req_byte_caseless = (re->req_byte & REQ_IGNORE_CASE); + req_byte2 = flipCase(req_byte); + } + + /* Loop for handling unanchored repeated matching attempts; for anchored regexs + the loop runs just once. */ + + const UChar* startMatch = subject + start_offset; + const UChar* reqBytePtr = startMatch - 1; + bool useMultiLineFirstCharOptimization = re->options & UseMultiLineFirstByteOptimizationOption; + + do { + /* Reset the maximum number of extractions we might see. */ + if (matchBlock.offsetVector) { + int* iptr = matchBlock.offsetVector; + int* iend = iptr + resetcount; + while (iptr < iend) + *iptr++ = -1; + } + + tryFirstByteOptimization(startMatch, endSubject, first_byte, first_byte_caseless, useMultiLineFirstCharOptimization, matchBlock.startSubject + start_offset); + if (tryRequiredByteOptimization(startMatch, endSubject, req_byte, req_byte2, req_byte_caseless, first_byte >= 0, reqBytePtr)) + break; + + /* When a match occurs, substrings will be set for all internal extractions; + we just need to set up the whole thing as substring 0 before returning. If + there were too many extractions, set the return code to zero. In the case + where we had to get some local store to hold offsets for backreferences, copy + those back references that we can. In this case there need not be overflow + if certain parts of the pattern were not used. */ + + /* The code starts after the JSRegExp block and the capture name table. */ + const unsigned char* start_code = (const unsigned char*)(re + 1); + + int returnCode = match(startMatch, start_code, 2, matchBlock); + + /* When the result is no match, advance the pointer to the next character + and continue. */ + if (returnCode == 0) { + startMatch++; + continue; + } + + if (returnCode != 1) { + ASSERT(returnCode == JSRegExpErrorHitLimit || returnCode == JSRegExpErrorNoMemory); + DPRINTF((">>>> error: returning %d\n", rc)); + return returnCode; + } + + /* We have a match! Copy the offset information from temporary store if + necessary */ + + if (using_temporary_offsets) { + if (offsetcount >= 4) { + memcpy(offsets + 2, matchBlock.offsetVector + 2, (offsetcount - 2) * sizeof(int)); + DPRINTF(("Copied offsets from temporary memory\n")); + } + if (matchBlock.endOffsetTop > offsetcount) + matchBlock.offsetOverflow = true; + + DPRINTF(("Freeing temporary memory\n")); + delete [] matchBlock.offsetVector; + } + + returnCode = matchBlock.offsetOverflow ? 0 : matchBlock.endOffsetTop / 2; + + if (offsetcount < 2) + returnCode = 0; + else { + offsets[0] = startMatch - matchBlock.startSubject; + offsets[1] = matchBlock.endMatchPtr - matchBlock.startSubject; + } + + DPRINTF((">>>> returning %d\n", rc)); + return returnCode; + } while (startMatch <= endSubject); + + if (using_temporary_offsets) { + DPRINTF(("Freeing temporary memory\n")); + delete [] matchBlock.offsetVector; + } + + DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n")); + return JSRegExpErrorNoMatch; +} diff --git a/pcre/pcre_internal.h b/pcre/pcre_internal.h new file mode 100644 index 0000000..3e7b5cd --- /dev/null +++ b/pcre/pcre_internal.h @@ -0,0 +1,419 @@ +/* This is JavaScriptCore's variant of the PCRE library. While this library +started out as a copy of PCRE, many of the features of PCRE have been +removed. This library now supports only the regular expression features +required by the JavaScript language specification, and has only the functions +needed by JavaScriptCore and the rest of WebKit. + + Originally written by Philip Hazel + Copyright (c) 1997-2006 University of Cambridge + Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +/* This header contains definitions that are shared between the different +modules, but which are not relevant to the exported API. This includes some +functions whose names all begin with "_pcre_". */ + +#ifndef PCRE_INTERNAL_H +#define PCRE_INTERNAL_H + +/* Bit definitions for entries in the pcre_ctypes table. */ + +#define ctype_space 0x01 +#define ctype_xdigit 0x08 +#define ctype_word 0x10 /* alphameric or '_' */ + +/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set +of bits for a class map. Some classes are built by combining these tables. */ + +#define cbit_space 0 /* \s */ +#define cbit_digit 32 /* \d */ +#define cbit_word 64 /* \w */ +#define cbit_length 96 /* Length of the cbits table */ + +/* Offsets of the various tables from the base tables pointer, and +total length. */ + +#define lcc_offset 0 +#define fcc_offset 128 +#define cbits_offset 256 +#define ctypes_offset (cbits_offset + cbit_length) +#define tables_length (ctypes_offset + 128) + +#ifndef DFTABLES + +#include "Assertions.h" + +#if COMPILER(MSVC) +#pragma warning(disable: 4232) +#pragma warning(disable: 4244) +#endif + +#include "pcre.h" + +/* The value of LINK_SIZE determines the number of bytes used to store links as +offsets within the compiled regex. The default is 2, which allows for compiled +patterns up to 64K long. */ + +#define LINK_SIZE 2 + +/* Define DEBUG to get debugging output on stdout. */ + +#if 0 +#define DEBUG +#endif + +/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef +inline, and there are *still* stupid compilers about that don't like indented +pre-processor statements, or at least there were when I first wrote this. After +all, it had only been about 10 years then... */ + +#ifdef DEBUG +#define DPRINTF(p) printf p +#else +#define DPRINTF(p) /*nothing*/ +#endif + +/* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored +in big-endian order) by default. These are used, for example, to link from the +start of a subpattern to its alternatives and its end. The use of 2 bytes per +offset limits the size of the compiled regex to around 64K, which is big enough +for almost everybody. However, I received a request for an even bigger limit. +For this reason, and also to make the code easier to maintain, the storing and +loading of offsets from the byte string is now handled by the functions that are +defined here. */ + +/* PCRE uses some other 2-byte quantities that do not change when the size of +offsets changes. There are used for repeat counts and for other things such as +capturing parenthesis numbers in back references. */ + +static inline void put2ByteValue(unsigned char* opcodePtr, int value) +{ + ASSERT(value >= 0 && value <= 0xFFFF); + opcodePtr[0] = value >> 8; + opcodePtr[1] = value; +} + +static inline int get2ByteValue(const unsigned char* opcodePtr) +{ + return (opcodePtr[0] << 8) | opcodePtr[1]; +} + +static inline void put2ByteValueAndAdvance(unsigned char*& opcodePtr, int value) +{ + put2ByteValue(opcodePtr, value); + opcodePtr += 2; +} + +static inline void putLinkValueAllowZero(unsigned char* opcodePtr, int value) +{ + put2ByteValue(opcodePtr, value); +} + +static inline int getLinkValueAllowZero(const unsigned char* opcodePtr) +{ + return get2ByteValue(opcodePtr); +} + +#define MAX_PATTERN_SIZE (1 << 16) + +static inline void putLinkValue(unsigned char* opcodePtr, int value) +{ + ASSERT(value); + putLinkValueAllowZero(opcodePtr, value); +} + +static inline int getLinkValue(const unsigned char* opcodePtr) +{ + int value = getLinkValueAllowZero(opcodePtr); + ASSERT(value); + return value; +} + +static inline void putLinkValueAndAdvance(unsigned char*& opcodePtr, int value) +{ + putLinkValue(opcodePtr, value); + opcodePtr += LINK_SIZE; +} + +static inline void putLinkValueAllowZeroAndAdvance(unsigned char*& opcodePtr, int value) +{ + putLinkValueAllowZero(opcodePtr, value); + opcodePtr += LINK_SIZE; +} + +// FIXME: These are really more of a "compiled regexp state" than "regexp options" +enum RegExpOptions { + UseFirstByteOptimizationOption = 0x40000000, /* first_byte is set */ + UseRequiredByteOptimizationOption = 0x20000000, /* req_byte is set */ + UseMultiLineFirstByteOptimizationOption = 0x10000000, /* start after \n for multiline */ + IsAnchoredOption = 0x02000000, /* can't use partial with this regex */ + IgnoreCaseOption = 0x00000001, + MatchAcrossMultipleLinesOption = 0x00000002 +}; + +/* Flags added to firstbyte or reqbyte; a "non-literal" item is either a +variable-length repeat, or a anything other than literal characters. */ + +#define REQ_IGNORE_CASE 0x0100 /* indicates should ignore case */ +#define REQ_VARY 0x0200 /* reqbyte followed non-literal item */ + +/* Miscellaneous definitions */ + +/* Flag bits and data types for the extended class (OP_XCLASS) for classes that +contain UTF-8 characters with values greater than 255. */ + +#define XCL_NOT 0x01 /* Flag: this is a negative class */ +#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */ + +#define XCL_END 0 /* Marks end of individual items */ +#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */ +#define XCL_RANGE 2 /* A range (two multibyte chars) follows */ + +/* These are escaped items that aren't just an encoding of a particular data +value such as \n. They must have non-zero values, as check_escape() returns +their negation. Also, they must appear in the same order as in the opcode +definitions below, up to ESC_w. The final one must be +ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two +tests in the code for an escape > ESC_b and <= ESC_w to +detect the types that may be repeated. These are the types that consume +characters. If any new escapes are put in between that don't consume a +character, that code will have to change. */ + +enum { ESC_B = 1, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w, ESC_REF }; + +/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets +that extract substrings. Starting from 1 (i.e. after OP_END), the values up to +OP_EOD must correspond in order to the list of escapes immediately above. +Note that whenever this list is updated, the two macro definitions that follow +must also be updated to match. */ + +#define FOR_EACH_OPCODE(macro) \ + macro(END) \ + \ + macro(NOT_WORD_BOUNDARY) \ + macro(WORD_BOUNDARY) \ + macro(NOT_DIGIT) \ + macro(DIGIT) \ + macro(NOT_WHITESPACE) \ + macro(WHITESPACE) \ + macro(NOT_WORDCHAR) \ + macro(WORDCHAR) \ + \ + macro(NOT_NEWLINE) \ + \ + macro(CIRC) \ + macro(DOLL) \ + macro(CHAR) \ + macro(CHAR_IGNORING_CASE) \ + macro(ASCII_CHAR) \ + macro(ASCII_LETTER_IGNORING_CASE) \ + macro(NOT) \ + \ + macro(STAR) \ + macro(MINSTAR) \ + macro(PLUS) \ + macro(MINPLUS) \ + macro(QUERY) \ + macro(MINQUERY) \ + macro(UPTO) \ + macro(MINUPTO) \ + macro(EXACT) \ + \ + macro(NOTSTAR) \ + macro(NOTMINSTAR) \ + macro(NOTPLUS) \ + macro(NOTMINPLUS) \ + macro(NOTQUERY) \ + macro(NOTMINQUERY) \ + macro(NOTUPTO) \ + macro(NOTMINUPTO) \ + macro(NOTEXACT) \ + \ + macro(TYPESTAR) \ + macro(TYPEMINSTAR) \ + macro(TYPEPLUS) \ + macro(TYPEMINPLUS) \ + macro(TYPEQUERY) \ + macro(TYPEMINQUERY) \ + macro(TYPEUPTO) \ + macro(TYPEMINUPTO) \ + macro(TYPEEXACT) \ + \ + macro(CRSTAR) \ + macro(CRMINSTAR) \ + macro(CRPLUS) \ + macro(CRMINPLUS) \ + macro(CRQUERY) \ + macro(CRMINQUERY) \ + macro(CRRANGE) \ + macro(CRMINRANGE) \ + \ + macro(CLASS) \ + macro(NCLASS) \ + macro(XCLASS) \ + \ + macro(REF) \ + \ + macro(ALT) \ + macro(KET) \ + macro(KETRMAX) \ + macro(KETRMIN) \ + \ + macro(ASSERT) \ + macro(ASSERT_NOT) \ + \ + macro(BRAZERO) \ + macro(BRAMINZERO) \ + macro(BRANUMBER) \ + macro(BRA) + +#define OPCODE_ENUM_VALUE(opcode) OP_##opcode, +enum { FOR_EACH_OPCODE(OPCODE_ENUM_VALUE) }; + +/* WARNING WARNING WARNING: There is an implicit assumption in pcre.c and +study.c that all opcodes are less than 128 in value. This makes handling UTF-8 +character sequences easier. */ + +/* The highest extraction number before we have to start using additional +bytes. (Originally PCRE didn't have support for extraction counts higher than +this number.) The value is limited by the number of opcodes left after OP_BRA, +i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional +opcodes. */ + +/* FIXME: Note that OP_BRA + 100 is > 128, so the two comments above +are in conflict! */ + +#define EXTRACT_BASIC_MAX 100 + +/* The index of names and the +code vector run on as long as necessary after the end. We store an explicit +offset to the name table so that if a regex is compiled on one host, saved, and +then run on another where the size of pointers is different, all might still +be well. For the case of compiled-on-4 and run-on-8, we include an extra +pointer that is always NULL. +*/ + +struct JSRegExp { + unsigned options; + + unsigned short top_bracket; + unsigned short top_backref; + + unsigned short first_byte; + unsigned short req_byte; +}; + +/* Internal shared data tables. These are tables that are used by more than one + of the exported public functions. They have to be "external" in the C sense, + but are not part of the PCRE public API. The data for these tables is in the + pcre_tables.c module. */ + +#define kjs_pcre_utf8_table1_size 6 + +extern const int kjs_pcre_utf8_table1[6]; +extern const int kjs_pcre_utf8_table2[6]; +extern const int kjs_pcre_utf8_table3[6]; +extern const unsigned char kjs_pcre_utf8_table4[0x40]; + +extern const unsigned char kjs_pcre_default_tables[tables_length]; + +static inline unsigned char toLowerCase(unsigned char c) +{ + static const unsigned char* lowerCaseChars = kjs_pcre_default_tables + lcc_offset; + return lowerCaseChars[c]; +} + +static inline unsigned char flipCase(unsigned char c) +{ + static const unsigned char* flippedCaseChars = kjs_pcre_default_tables + fcc_offset; + return flippedCaseChars[c]; +} + +static inline unsigned char classBitmapForChar(unsigned char c) +{ + static const unsigned char* charClassBitmaps = kjs_pcre_default_tables + cbits_offset; + return charClassBitmaps[c]; +} + +static inline unsigned char charTypeForChar(unsigned char c) +{ + const unsigned char* charTypeMap = kjs_pcre_default_tables + ctypes_offset; + return charTypeMap[c]; +} + +static inline bool isWordChar(UChar c) +{ + return c < 128 && (charTypeForChar(c) & ctype_word); +} + +static inline bool isSpaceChar(UChar c) +{ + return c < 128 && (charTypeForChar(c) & ctype_space); +} + +static inline bool isNewline(UChar nl) +{ + return (nl == 0xA || nl == 0xD || nl == 0x2028 || nl == 0x2029); +} + +static inline bool isBracketStartOpcode(unsigned char opcode) +{ + if (opcode >= OP_BRA) + return true; + switch (opcode) { + case OP_ASSERT: + case OP_ASSERT_NOT: + return true; + default: + return false; + } +} + +static inline void advanceToEndOfBracket(const unsigned char*& opcodePtr) +{ + ASSERT(isBracketStartOpcode(*opcodePtr) || *opcodePtr == OP_ALT); + do + opcodePtr += getLinkValue(opcodePtr + 1); + while (*opcodePtr == OP_ALT); +} + +/* Internal shared functions. These are functions that are used in more +that one of the source files. They have to have external linkage, but +but are not part of the public API and so not exported from the library. */ + +extern int kjs_pcre_ucp_othercase(unsigned); +extern bool kjs_pcre_xclass(int, const unsigned char*); + +#endif + +#endif + +/* End of pcre_internal.h */ diff --git a/pcre/pcre_tables.cpp b/pcre/pcre_tables.cpp new file mode 100644 index 0000000..164a3ab --- /dev/null +++ b/pcre/pcre_tables.cpp @@ -0,0 +1,71 @@ +/* This is JavaScriptCore's variant of the PCRE library. While this library +started out as a copy of PCRE, many of the features of PCRE have been +removed. This library now supports only the regular expression features +required by the JavaScript language specification, and has only the functions +needed by JavaScriptCore and the rest of WebKit. + + Originally written by Philip Hazel + Copyright (c) 1997-2006 University of Cambridge + Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +/* This module contains some fixed tables that are used by more than one of the +PCRE code modules. */ + +#include "pcre_internal.h" + +/************************************************* +* Tables for UTF-8 support * +*************************************************/ + +/* These are the breakpoints for different numbers of bytes in a UTF-8 +character. */ + +const int kjs_pcre_utf8_table1[6] = + { 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff}; + +/* These are the indicator bits and the mask for the data bits to set in the +first byte of a character, indexed by the number of additional bytes. */ + +const int kjs_pcre_utf8_table2[6] = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}; +const int kjs_pcre_utf8_table3[6] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01}; + +/* Table of the number of extra characters, indexed by the first character +masked with 0x3f. The highest number for a valid UTF-8 character is in fact +0x3d. */ + +const unsigned char kjs_pcre_utf8_table4[0x40] = { + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 }; + +#include "chartables.c" diff --git a/pcre/pcre_ucp_searchfuncs.cpp b/pcre/pcre_ucp_searchfuncs.cpp new file mode 100644 index 0000000..f63bdbc --- /dev/null +++ b/pcre/pcre_ucp_searchfuncs.cpp @@ -0,0 +1,98 @@ +/* This is JavaScriptCore's variant of the PCRE library. While this library +started out as a copy of PCRE, many of the features of PCRE have been +removed. This library now supports only the regular expression features +required by the JavaScript language specification, and has only the functions +needed by JavaScriptCore and the rest of WebKit. + + Originally written by Philip Hazel + Copyright (c) 1997-2006 University of Cambridge + Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + + +/* This module contains code for searching the table of Unicode character +properties. */ + +#include "pcre_internal.h" + +#include "ucpinternal.h" /* Internal table details */ +#include "ucptable.cpp" /* The table itself */ + +/************************************************* +* Search table and return other case * +*************************************************/ + +/* If the given character is a letter, and there is another case for the +letter, return the other case. Otherwise, return -1. + +Arguments: + c the character value + +Returns: the other case or -1 if none +*/ + +int kjs_pcre_ucp_othercase(unsigned c) +{ + int bot = 0; + int top = sizeof(ucp_table) / sizeof(cnode); + int mid; + + /* The table is searched using a binary chop. You might think that using + intermediate variables to hold some of the common expressions would speed + things up, but tests with gcc 3.4.4 on Linux showed that, on the contrary, it + makes things a lot slower. */ + + for (;;) { + if (top <= bot) + return -1; + mid = (bot + top) >> 1; + if (c == (ucp_table[mid].f0 & f0_charmask)) + break; + if (c < (ucp_table[mid].f0 & f0_charmask)) + top = mid; + else { + if ((ucp_table[mid].f0 & f0_rangeflag) && (c <= (ucp_table[mid].f0 & f0_charmask) + (ucp_table[mid].f1 & f1_rangemask))) + break; + bot = mid + 1; + } + } + + /* Found an entry in the table. Return -1 for a range entry. Otherwise return + the other case if there is one, else -1. */ + + if (ucp_table[mid].f0 & f0_rangeflag) + return -1; + + int offset = ucp_table[mid].f1 & f1_casemask; + if (offset & f1_caseneg) + offset |= f1_caseneg; + return !offset ? -1 : c + offset; +} diff --git a/pcre/pcre_xclass.cpp b/pcre/pcre_xclass.cpp new file mode 100644 index 0000000..4bf2a25 --- /dev/null +++ b/pcre/pcre_xclass.cpp @@ -0,0 +1,114 @@ +/* This is JavaScriptCore's variant of the PCRE library. While this library +started out as a copy of PCRE, many of the features of PCRE have been +removed. This library now supports only the regular expression features +required by the JavaScript language specification, and has only the functions +needed by JavaScriptCore and the rest of WebKit. + + Originally written by Philip Hazel + Copyright (c) 1997-2006 University of Cambridge + Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +/* This module contains an internal function that is used to match an extended +class (one that contains characters whose values are > 255). */ + +#include "pcre_internal.h" + +/************************************************* +* Match character against an XCLASS * +*************************************************/ + +/* This function is called to match a character against an extended class that +might contain values > 255. + +Arguments: + c the character + data points to the flag byte of the XCLASS data + +Returns: true if character matches, else false +*/ + +/* Get the next UTF-8 character, advancing the pointer. This is called when we + know we are in UTF-8 mode. */ + +static inline void getUTF8CharAndAdvancePointer(int& c, const unsigned char*& subjectPtr) +{ + c = *subjectPtr++; + if ((c & 0xc0) == 0xc0) { + int gcaa = kjs_pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ + int gcss = 6 * gcaa; + c = (c & kjs_pcre_utf8_table3[gcaa]) << gcss; + while (gcaa-- > 0) { + gcss -= 6; + c |= (*subjectPtr++ & 0x3f) << gcss; + } + } +} + +bool kjs_pcre_xclass(int c, const unsigned char* data) +{ + bool negated = (*data & XCL_NOT); + + /* Character values < 256 are matched against a bitmap, if one is present. If + not, we still carry on, because there may be ranges that start below 256 in the + additional data. */ + + if (c < 256) { + if ((*data & XCL_MAP) != 0 && (data[1 + c/8] & (1 << (c&7))) != 0) + return !negated; /* char found */ + } + + /* First skip the bit map if present. Then match against the list of Unicode + properties or large chars or ranges that end with a large char. We won't ever + encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */ + + if ((*data++ & XCL_MAP) != 0) + data += 32; + + int t; + while ((t = *data++) != XCL_END) { + if (t == XCL_SINGLE) { + int x; + getUTF8CharAndAdvancePointer(x, data); + if (c == x) + return !negated; + } + else if (t == XCL_RANGE) { + int x, y; + getUTF8CharAndAdvancePointer(x, data); + getUTF8CharAndAdvancePointer(y, data); + if (c >= x && c <= y) + return !negated; + } + } + + return negated; /* char did not match */ +} diff --git a/pcre/ucpinternal.h b/pcre/ucpinternal.h new file mode 100644 index 0000000..c8bc4aa --- /dev/null +++ b/pcre/ucpinternal.h @@ -0,0 +1,126 @@ +/* This is JavaScriptCore's variant of the PCRE library. While this library +started out as a copy of PCRE, many of the features of PCRE have been +removed. This library now supports only the regular expression features +required by the JavaScript language specification, and has only the functions +needed by JavaScriptCore and the rest of WebKit. + + Originally written by Philip Hazel + Copyright (c) 1997-2006 University of Cambridge + Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +/************************************************* +* Unicode Property Table handler * +*************************************************/ + +/* Internal header file defining the layout of the bits in each pair of 32-bit +words that form a data item in the table. */ + +typedef struct cnode { + unsigned f0; + unsigned f1; +} cnode; + +/* Things for the f0 field */ + +#define f0_scriptmask 0xff000000 /* Mask for script field */ +#define f0_scriptshift 24 /* Shift for script value */ +#define f0_rangeflag 0x00f00000 /* Flag for a range item */ +#define f0_charmask 0x001fffff /* Mask for code point value */ + +/* Things for the f1 field */ + +#define f1_typemask 0xfc000000 /* Mask for char type field */ +#define f1_typeshift 26 /* Shift for the type field */ +#define f1_rangemask 0x0000ffff /* Mask for a range offset */ +#define f1_casemask 0x0000ffff /* Mask for a case offset */ +#define f1_caseneg 0xffff8000 /* Bits for negation */ + +/* The data consists of a vector of structures of type cnode. The two unsigned +32-bit integers are used as follows: + +(f0) (1) The most significant byte holds the script number. The numbers are + defined by the enum in ucp.h. + + (2) The 0x00800000 bit is set if this entry defines a range of characters. + It is not set if this entry defines a single character + + (3) The 0x00600000 bits are spare. + + (4) The 0x001fffff bits contain the code point. No Unicode code point will + ever be greater than 0x0010ffff, so this should be OK for ever. + +(f1) (1) The 0xfc000000 bits contain the character type number. The numbers are + defined by an enum in ucp.h. + + (2) The 0x03ff0000 bits are spare. + + (3) The 0x0000ffff bits contain EITHER the unsigned offset to the top of + range if this entry defines a range, OR the *signed* offset to the + character's "other case" partner if this entry defines a single + character. There is no partner if the value is zero. + +------------------------------------------------------------------------------- +| script (8) |.|.|.| codepoint (21) || type (6) |.|.| spare (8) | offset (16) | +------------------------------------------------------------------------------- + | | | | | + | | |-> spare | |-> spare + | | | + | |-> spare |-> spare + | + |-> range flag + +The upper/lower casing information is set only for characters that come in +pairs. The non-one-to-one mappings in the Unicode data are ignored. + +When searching the data, proceed as follows: + +(1) Set up for a binary chop search. + +(2) If the top is not greater than the bottom, the character is not in the + table. Its type must therefore be "Cn" ("Undefined"). + +(3) Find the middle vector element. + +(4) Extract the code point and compare. If equal, we are done. + +(5) If the test character is smaller, set the top to the current point, and + goto (2). + +(6) If the current entry defines a range, compute the last character by adding + the offset, and see if the test character is within the range. If it is, + we are done. + +(7) Otherwise, set the bottom to one element past the current point and goto + (2). +*/ + +/* End of ucpinternal.h */ diff --git a/pcre/ucptable.cpp b/pcre/ucptable.cpp new file mode 100644 index 0000000..011f7f5 --- /dev/null +++ b/pcre/ucptable.cpp @@ -0,0 +1,2968 @@ +/* This source module is automatically generated from the Unicode +property table. See ucpinternal.h for a description of the layout. */ + +static const cnode ucp_table[] = { + { 0x09800000, 0x0000001f }, + { 0x09000020, 0x74000000 }, + { 0x09800021, 0x54000002 }, + { 0x09000024, 0x5c000000 }, + { 0x09800025, 0x54000002 }, + { 0x09000028, 0x58000000 }, + { 0x09000029, 0x48000000 }, + { 0x0900002a, 0x54000000 }, + { 0x0900002b, 0x64000000 }, + { 0x0900002c, 0x54000000 }, + { 0x0900002d, 0x44000000 }, + { 0x0980002e, 0x54000001 }, + { 0x09800030, 0x34000009 }, + { 0x0980003a, 0x54000001 }, + { 0x0980003c, 0x64000002 }, + { 0x0980003f, 0x54000001 }, + { 0x21000041, 0x24000020 }, + { 0x21000042, 0x24000020 }, + { 0x21000043, 0x24000020 }, + { 0x21000044, 0x24000020 }, + { 0x21000045, 0x24000020 }, + { 0x21000046, 0x24000020 }, + { 0x21000047, 0x24000020 }, + { 0x21000048, 0x24000020 }, + { 0x21000049, 0x24000020 }, + { 0x2100004a, 0x24000020 }, + { 0x2100004b, 0x24000020 }, + { 0x2100004c, 0x24000020 }, + { 0x2100004d, 0x24000020 }, + { 0x2100004e, 0x24000020 }, + { 0x2100004f, 0x24000020 }, + { 0x21000050, 0x24000020 }, + { 0x21000051, 0x24000020 }, + { 0x21000052, 0x24000020 }, + { 0x21000053, 0x24000020 }, + { 0x21000054, 0x24000020 }, + { 0x21000055, 0x24000020 }, + { 0x21000056, 0x24000020 }, + { 0x21000057, 0x24000020 }, + { 0x21000058, 0x24000020 }, + { 0x21000059, 0x24000020 }, + { 0x2100005a, 0x24000020 }, + { 0x0900005b, 0x58000000 }, + { 0x0900005c, 0x54000000 }, + { 0x0900005d, 0x48000000 }, + { 0x0900005e, 0x60000000 }, + { 0x0900005f, 0x40000000 }, + { 0x09000060, 0x60000000 }, + { 0x21000061, 0x1400ffe0 }, + { 0x21000062, 0x1400ffe0 }, + { 0x21000063, 0x1400ffe0 }, + { 0x21000064, 0x1400ffe0 }, + { 0x21000065, 0x1400ffe0 }, + { 0x21000066, 0x1400ffe0 }, + { 0x21000067, 0x1400ffe0 }, + { 0x21000068, 0x1400ffe0 }, + { 0x21000069, 0x1400ffe0 }, + { 0x2100006a, 0x1400ffe0 }, + { 0x2100006b, 0x1400ffe0 }, + { 0x2100006c, 0x1400ffe0 }, + { 0x2100006d, 0x1400ffe0 }, + { 0x2100006e, 0x1400ffe0 }, + { 0x2100006f, 0x1400ffe0 }, + { 0x21000070, 0x1400ffe0 }, + { 0x21000071, 0x1400ffe0 }, + { 0x21000072, 0x1400ffe0 }, + { 0x21000073, 0x1400ffe0 }, + { 0x21000074, 0x1400ffe0 }, + { 0x21000075, 0x1400ffe0 }, + { 0x21000076, 0x1400ffe0 }, + { 0x21000077, 0x1400ffe0 }, + { 0x21000078, 0x1400ffe0 }, + { 0x21000079, 0x1400ffe0 }, + { 0x2100007a, 0x1400ffe0 }, + { 0x0900007b, 0x58000000 }, + { 0x0900007c, 0x64000000 }, + { 0x0900007d, 0x48000000 }, + { 0x0900007e, 0x64000000 }, + { 0x0980007f, 0x00000020 }, + { 0x090000a0, 0x74000000 }, + { 0x090000a1, 0x54000000 }, + { 0x098000a2, 0x5c000003 }, + { 0x098000a6, 0x68000001 }, + { 0x090000a8, 0x60000000 }, + { 0x090000a9, 0x68000000 }, + { 0x210000aa, 0x14000000 }, + { 0x090000ab, 0x50000000 }, + { 0x090000ac, 0x64000000 }, + { 0x090000ad, 0x04000000 }, + { 0x090000ae, 0x68000000 }, + { 0x090000af, 0x60000000 }, + { 0x090000b0, 0x68000000 }, + { 0x090000b1, 0x64000000 }, + { 0x098000b2, 0x3c000001 }, + { 0x090000b4, 0x60000000 }, + { 0x090000b5, 0x140002e7 }, + { 0x090000b6, 0x68000000 }, + { 0x090000b7, 0x54000000 }, + { 0x090000b8, 0x60000000 }, + { 0x090000b9, 0x3c000000 }, + { 0x210000ba, 0x14000000 }, + { 0x090000bb, 0x4c000000 }, + { 0x098000bc, 0x3c000002 }, + { 0x090000bf, 0x54000000 }, + { 0x210000c0, 0x24000020 }, + { 0x210000c1, 0x24000020 }, + { 0x210000c2, 0x24000020 }, + { 0x210000c3, 0x24000020 }, + { 0x210000c4, 0x24000020 }, + { 0x210000c5, 0x24000020 }, + { 0x210000c6, 0x24000020 }, + { 0x210000c7, 0x24000020 }, + { 0x210000c8, 0x24000020 }, + { 0x210000c9, 0x24000020 }, + { 0x210000ca, 0x24000020 }, + { 0x210000cb, 0x24000020 }, + { 0x210000cc, 0x24000020 }, + { 0x210000cd, 0x24000020 }, + { 0x210000ce, 0x24000020 }, + { 0x210000cf, 0x24000020 }, + { 0x210000d0, 0x24000020 }, + { 0x210000d1, 0x24000020 }, + { 0x210000d2, 0x24000020 }, + { 0x210000d3, 0x24000020 }, + { 0x210000d4, 0x24000020 }, + { 0x210000d5, 0x24000020 }, + { 0x210000d6, 0x24000020 }, + { 0x090000d7, 0x64000000 }, + { 0x210000d8, 0x24000020 }, + { 0x210000d9, 0x24000020 }, + { 0x210000da, 0x24000020 }, + { 0x210000db, 0x24000020 }, + { 0x210000dc, 0x24000020 }, + { 0x210000dd, 0x24000020 }, + { 0x210000de, 0x24000020 }, + { 0x210000df, 0x14000000 }, + { 0x210000e0, 0x1400ffe0 }, + { 0x210000e1, 0x1400ffe0 }, + { 0x210000e2, 0x1400ffe0 }, + { 0x210000e3, 0x1400ffe0 }, + { 0x210000e4, 0x1400ffe0 }, + { 0x210000e5, 0x1400ffe0 }, + { 0x210000e6, 0x1400ffe0 }, + { 0x210000e7, 0x1400ffe0 }, + { 0x210000e8, 0x1400ffe0 }, + { 0x210000e9, 0x1400ffe0 }, + { 0x210000ea, 0x1400ffe0 }, + { 0x210000eb, 0x1400ffe0 }, + { 0x210000ec, 0x1400ffe0 }, + { 0x210000ed, 0x1400ffe0 }, + { 0x210000ee, 0x1400ffe0 }, + { 0x210000ef, 0x1400ffe0 }, + { 0x210000f0, 0x1400ffe0 }, + { 0x210000f1, 0x1400ffe0 }, + { 0x210000f2, 0x1400ffe0 }, + { 0x210000f3, 0x1400ffe0 }, + { 0x210000f4, 0x1400ffe0 }, + { 0x210000f5, 0x1400ffe0 }, + { 0x210000f6, 0x1400ffe0 }, + { 0x090000f7, 0x64000000 }, + { 0x210000f8, 0x1400ffe0 }, + { 0x210000f9, 0x1400ffe0 }, + { 0x210000fa, 0x1400ffe0 }, + { 0x210000fb, 0x1400ffe0 }, + { 0x210000fc, 0x1400ffe0 }, + { 0x210000fd, 0x1400ffe0 }, + { 0x210000fe, 0x1400ffe0 }, + { 0x210000ff, 0x14000079 }, + { 0x21000100, 0x24000001 }, + { 0x21000101, 0x1400ffff }, + { 0x21000102, 0x24000001 }, + { 0x21000103, 0x1400ffff }, + { 0x21000104, 0x24000001 }, + { 0x21000105, 0x1400ffff }, + { 0x21000106, 0x24000001 }, + { 0x21000107, 0x1400ffff }, + { 0x21000108, 0x24000001 }, + { 0x21000109, 0x1400ffff }, + { 0x2100010a, 0x24000001 }, + { 0x2100010b, 0x1400ffff }, + { 0x2100010c, 0x24000001 }, + { 0x2100010d, 0x1400ffff }, + { 0x2100010e, 0x24000001 }, + { 0x2100010f, 0x1400ffff }, + { 0x21000110, 0x24000001 }, + { 0x21000111, 0x1400ffff }, + { 0x21000112, 0x24000001 }, + { 0x21000113, 0x1400ffff }, + { 0x21000114, 0x24000001 }, + { 0x21000115, 0x1400ffff }, + { 0x21000116, 0x24000001 }, + { 0x21000117, 0x1400ffff }, + { 0x21000118, 0x24000001 }, + { 0x21000119, 0x1400ffff }, + { 0x2100011a, 0x24000001 }, + { 0x2100011b, 0x1400ffff }, + { 0x2100011c, 0x24000001 }, + { 0x2100011d, 0x1400ffff }, + { 0x2100011e, 0x24000001 }, + { 0x2100011f, 0x1400ffff }, + { 0x21000120, 0x24000001 }, + { 0x21000121, 0x1400ffff }, + { 0x21000122, 0x24000001 }, + { 0x21000123, 0x1400ffff }, + { 0x21000124, 0x24000001 }, + { 0x21000125, 0x1400ffff }, + { 0x21000126, 0x24000001 }, + { 0x21000127, 0x1400ffff }, + { 0x21000128, 0x24000001 }, + { 0x21000129, 0x1400ffff }, + { 0x2100012a, 0x24000001 }, + { 0x2100012b, 0x1400ffff }, + { 0x2100012c, 0x24000001 }, + { 0x2100012d, 0x1400ffff }, + { 0x2100012e, 0x24000001 }, + { 0x2100012f, 0x1400ffff }, + { 0x21000130, 0x2400ff39 }, + { 0x21000131, 0x1400ff18 }, + { 0x21000132, 0x24000001 }, + { 0x21000133, 0x1400ffff }, + { 0x21000134, 0x24000001 }, + { 0x21000135, 0x1400ffff }, + { 0x21000136, 0x24000001 }, + { 0x21000137, 0x1400ffff }, + { 0x21000138, 0x14000000 }, + { 0x21000139, 0x24000001 }, + { 0x2100013a, 0x1400ffff }, + { 0x2100013b, 0x24000001 }, + { 0x2100013c, 0x1400ffff }, + { 0x2100013d, 0x24000001 }, + { 0x2100013e, 0x1400ffff }, + { 0x2100013f, 0x24000001 }, + { 0x21000140, 0x1400ffff }, + { 0x21000141, 0x24000001 }, + { 0x21000142, 0x1400ffff }, + { 0x21000143, 0x24000001 }, + { 0x21000144, 0x1400ffff }, + { 0x21000145, 0x24000001 }, + { 0x21000146, 0x1400ffff }, + { 0x21000147, 0x24000001 }, + { 0x21000148, 0x1400ffff }, + { 0x21000149, 0x14000000 }, + { 0x2100014a, 0x24000001 }, + { 0x2100014b, 0x1400ffff }, + { 0x2100014c, 0x24000001 }, + { 0x2100014d, 0x1400ffff }, + { 0x2100014e, 0x24000001 }, + { 0x2100014f, 0x1400ffff }, + { 0x21000150, 0x24000001 }, + { 0x21000151, 0x1400ffff }, + { 0x21000152, 0x24000001 }, + { 0x21000153, 0x1400ffff }, + { 0x21000154, 0x24000001 }, + { 0x21000155, 0x1400ffff }, + { 0x21000156, 0x24000001 }, + { 0x21000157, 0x1400ffff }, + { 0x21000158, 0x24000001 }, + { 0x21000159, 0x1400ffff }, + { 0x2100015a, 0x24000001 }, + { 0x2100015b, 0x1400ffff }, + { 0x2100015c, 0x24000001 }, + { 0x2100015d, 0x1400ffff }, + { 0x2100015e, 0x24000001 }, + { 0x2100015f, 0x1400ffff }, + { 0x21000160, 0x24000001 }, + { 0x21000161, 0x1400ffff }, + { 0x21000162, 0x24000001 }, + { 0x21000163, 0x1400ffff }, + { 0x21000164, 0x24000001 }, + { 0x21000165, 0x1400ffff }, + { 0x21000166, 0x24000001 }, + { 0x21000167, 0x1400ffff }, + { 0x21000168, 0x24000001 }, + { 0x21000169, 0x1400ffff }, + { 0x2100016a, 0x24000001 }, + { 0x2100016b, 0x1400ffff }, + { 0x2100016c, 0x24000001 }, + { 0x2100016d, 0x1400ffff }, + { 0x2100016e, 0x24000001 }, + { 0x2100016f, 0x1400ffff }, + { 0x21000170, 0x24000001 }, + { 0x21000171, 0x1400ffff }, + { 0x21000172, 0x24000001 }, + { 0x21000173, 0x1400ffff }, + { 0x21000174, 0x24000001 }, + { 0x21000175, 0x1400ffff }, + { 0x21000176, 0x24000001 }, + { 0x21000177, 0x1400ffff }, + { 0x21000178, 0x2400ff87 }, + { 0x21000179, 0x24000001 }, + { 0x2100017a, 0x1400ffff }, + { 0x2100017b, 0x24000001 }, + { 0x2100017c, 0x1400ffff }, + { 0x2100017d, 0x24000001 }, + { 0x2100017e, 0x1400ffff }, + { 0x2100017f, 0x1400fed4 }, + { 0x21000180, 0x14000000 }, + { 0x21000181, 0x240000d2 }, + { 0x21000182, 0x24000001 }, + { 0x21000183, 0x1400ffff }, + { 0x21000184, 0x24000001 }, + { 0x21000185, 0x1400ffff }, + { 0x21000186, 0x240000ce }, + { 0x21000187, 0x24000001 }, + { 0x21000188, 0x1400ffff }, + { 0x21000189, 0x240000cd }, + { 0x2100018a, 0x240000cd }, + { 0x2100018b, 0x24000001 }, + { 0x2100018c, 0x1400ffff }, + { 0x2100018d, 0x14000000 }, + { 0x2100018e, 0x2400004f }, + { 0x2100018f, 0x240000ca }, + { 0x21000190, 0x240000cb }, + { 0x21000191, 0x24000001 }, + { 0x21000192, 0x1400ffff }, + { 0x21000193, 0x240000cd }, + { 0x21000194, 0x240000cf }, + { 0x21000195, 0x14000061 }, + { 0x21000196, 0x240000d3 }, + { 0x21000197, 0x240000d1 }, + { 0x21000198, 0x24000001 }, + { 0x21000199, 0x1400ffff }, + { 0x2100019a, 0x140000a3 }, + { 0x2100019b, 0x14000000 }, + { 0x2100019c, 0x240000d3 }, + { 0x2100019d, 0x240000d5 }, + { 0x2100019e, 0x14000082 }, + { 0x2100019f, 0x240000d6 }, + { 0x210001a0, 0x24000001 }, + { 0x210001a1, 0x1400ffff }, + { 0x210001a2, 0x24000001 }, + { 0x210001a3, 0x1400ffff }, + { 0x210001a4, 0x24000001 }, + { 0x210001a5, 0x1400ffff }, + { 0x210001a6, 0x240000da }, + { 0x210001a7, 0x24000001 }, + { 0x210001a8, 0x1400ffff }, + { 0x210001a9, 0x240000da }, + { 0x218001aa, 0x14000001 }, + { 0x210001ac, 0x24000001 }, + { 0x210001ad, 0x1400ffff }, + { 0x210001ae, 0x240000da }, + { 0x210001af, 0x24000001 }, + { 0x210001b0, 0x1400ffff }, + { 0x210001b1, 0x240000d9 }, + { 0x210001b2, 0x240000d9 }, + { 0x210001b3, 0x24000001 }, + { 0x210001b4, 0x1400ffff }, + { 0x210001b5, 0x24000001 }, + { 0x210001b6, 0x1400ffff }, + { 0x210001b7, 0x240000db }, + { 0x210001b8, 0x24000001 }, + { 0x210001b9, 0x1400ffff }, + { 0x210001ba, 0x14000000 }, + { 0x210001bb, 0x1c000000 }, + { 0x210001bc, 0x24000001 }, + { 0x210001bd, 0x1400ffff }, + { 0x210001be, 0x14000000 }, + { 0x210001bf, 0x14000038 }, + { 0x218001c0, 0x1c000003 }, + { 0x210001c4, 0x24000002 }, + { 0x210001c5, 0x2000ffff }, + { 0x210001c6, 0x1400fffe }, + { 0x210001c7, 0x24000002 }, + { 0x210001c8, 0x2000ffff }, + { 0x210001c9, 0x1400fffe }, + { 0x210001ca, 0x24000002 }, + { 0x210001cb, 0x2000ffff }, + { 0x210001cc, 0x1400fffe }, + { 0x210001cd, 0x24000001 }, + { 0x210001ce, 0x1400ffff }, + { 0x210001cf, 0x24000001 }, + { 0x210001d0, 0x1400ffff }, + { 0x210001d1, 0x24000001 }, + { 0x210001d2, 0x1400ffff }, + { 0x210001d3, 0x24000001 }, + { 0x210001d4, 0x1400ffff }, + { 0x210001d5, 0x24000001 }, + { 0x210001d6, 0x1400ffff }, + { 0x210001d7, 0x24000001 }, + { 0x210001d8, 0x1400ffff }, + { 0x210001d9, 0x24000001 }, + { 0x210001da, 0x1400ffff }, + { 0x210001db, 0x24000001 }, + { 0x210001dc, 0x1400ffff }, + { 0x210001dd, 0x1400ffb1 }, + { 0x210001de, 0x24000001 }, + { 0x210001df, 0x1400ffff }, + { 0x210001e0, 0x24000001 }, + { 0x210001e1, 0x1400ffff }, + { 0x210001e2, 0x24000001 }, + { 0x210001e3, 0x1400ffff }, + { 0x210001e4, 0x24000001 }, + { 0x210001e5, 0x1400ffff }, + { 0x210001e6, 0x24000001 }, + { 0x210001e7, 0x1400ffff }, + { 0x210001e8, 0x24000001 }, + { 0x210001e9, 0x1400ffff }, + { 0x210001ea, 0x24000001 }, + { 0x210001eb, 0x1400ffff }, + { 0x210001ec, 0x24000001 }, + { 0x210001ed, 0x1400ffff }, + { 0x210001ee, 0x24000001 }, + { 0x210001ef, 0x1400ffff }, + { 0x210001f0, 0x14000000 }, + { 0x210001f1, 0x24000002 }, + { 0x210001f2, 0x2000ffff }, + { 0x210001f3, 0x1400fffe }, + { 0x210001f4, 0x24000001 }, + { 0x210001f5, 0x1400ffff }, + { 0x210001f6, 0x2400ff9f }, + { 0x210001f7, 0x2400ffc8 }, + { 0x210001f8, 0x24000001 }, + { 0x210001f9, 0x1400ffff }, + { 0x210001fa, 0x24000001 }, + { 0x210001fb, 0x1400ffff }, + { 0x210001fc, 0x24000001 }, + { 0x210001fd, 0x1400ffff }, + { 0x210001fe, 0x24000001 }, + { 0x210001ff, 0x1400ffff }, + { 0x21000200, 0x24000001 }, + { 0x21000201, 0x1400ffff }, + { 0x21000202, 0x24000001 }, + { 0x21000203, 0x1400ffff }, + { 0x21000204, 0x24000001 }, + { 0x21000205, 0x1400ffff }, + { 0x21000206, 0x24000001 }, + { 0x21000207, 0x1400ffff }, + { 0x21000208, 0x24000001 }, + { 0x21000209, 0x1400ffff }, + { 0x2100020a, 0x24000001 }, + { 0x2100020b, 0x1400ffff }, + { 0x2100020c, 0x24000001 }, + { 0x2100020d, 0x1400ffff }, + { 0x2100020e, 0x24000001 }, + { 0x2100020f, 0x1400ffff }, + { 0x21000210, 0x24000001 }, + { 0x21000211, 0x1400ffff }, + { 0x21000212, 0x24000001 }, + { 0x21000213, 0x1400ffff }, + { 0x21000214, 0x24000001 }, + { 0x21000215, 0x1400ffff }, + { 0x21000216, 0x24000001 }, + { 0x21000217, 0x1400ffff }, + { 0x21000218, 0x24000001 }, + { 0x21000219, 0x1400ffff }, + { 0x2100021a, 0x24000001 }, + { 0x2100021b, 0x1400ffff }, + { 0x2100021c, 0x24000001 }, + { 0x2100021d, 0x1400ffff }, + { 0x2100021e, 0x24000001 }, + { 0x2100021f, 0x1400ffff }, + { 0x21000220, 0x2400ff7e }, + { 0x21000221, 0x14000000 }, + { 0x21000222, 0x24000001 }, + { 0x21000223, 0x1400ffff }, + { 0x21000224, 0x24000001 }, + { 0x21000225, 0x1400ffff }, + { 0x21000226, 0x24000001 }, + { 0x21000227, 0x1400ffff }, + { 0x21000228, 0x24000001 }, + { 0x21000229, 0x1400ffff }, + { 0x2100022a, 0x24000001 }, + { 0x2100022b, 0x1400ffff }, + { 0x2100022c, 0x24000001 }, + { 0x2100022d, 0x1400ffff }, + { 0x2100022e, 0x24000001 }, + { 0x2100022f, 0x1400ffff }, + { 0x21000230, 0x24000001 }, + { 0x21000231, 0x1400ffff }, + { 0x21000232, 0x24000001 }, + { 0x21000233, 0x1400ffff }, + { 0x21800234, 0x14000005 }, + { 0x2100023a, 0x24000000 }, + { 0x2100023b, 0x24000001 }, + { 0x2100023c, 0x1400ffff }, + { 0x2100023d, 0x2400ff5d }, + { 0x2100023e, 0x24000000 }, + { 0x2180023f, 0x14000001 }, + { 0x21000241, 0x24000053 }, + { 0x21800250, 0x14000002 }, + { 0x21000253, 0x1400ff2e }, + { 0x21000254, 0x1400ff32 }, + { 0x21000255, 0x14000000 }, + { 0x21000256, 0x1400ff33 }, + { 0x21000257, 0x1400ff33 }, + { 0x21000258, 0x14000000 }, + { 0x21000259, 0x1400ff36 }, + { 0x2100025a, 0x14000000 }, + { 0x2100025b, 0x1400ff35 }, + { 0x2180025c, 0x14000003 }, + { 0x21000260, 0x1400ff33 }, + { 0x21800261, 0x14000001 }, + { 0x21000263, 0x1400ff31 }, + { 0x21800264, 0x14000003 }, + { 0x21000268, 0x1400ff2f }, + { 0x21000269, 0x1400ff2d }, + { 0x2180026a, 0x14000004 }, + { 0x2100026f, 0x1400ff2d }, + { 0x21800270, 0x14000001 }, + { 0x21000272, 0x1400ff2b }, + { 0x21800273, 0x14000001 }, + { 0x21000275, 0x1400ff2a }, + { 0x21800276, 0x14000009 }, + { 0x21000280, 0x1400ff26 }, + { 0x21800281, 0x14000001 }, + { 0x21000283, 0x1400ff26 }, + { 0x21800284, 0x14000003 }, + { 0x21000288, 0x1400ff26 }, + { 0x21000289, 0x14000000 }, + { 0x2100028a, 0x1400ff27 }, + { 0x2100028b, 0x1400ff27 }, + { 0x2180028c, 0x14000005 }, + { 0x21000292, 0x1400ff25 }, + { 0x21000293, 0x14000000 }, + { 0x21000294, 0x1400ffad }, + { 0x21800295, 0x1400001a }, + { 0x218002b0, 0x18000011 }, + { 0x098002c2, 0x60000003 }, + { 0x098002c6, 0x1800000b }, + { 0x098002d2, 0x6000000d }, + { 0x218002e0, 0x18000004 }, + { 0x098002e5, 0x60000008 }, + { 0x090002ee, 0x18000000 }, + { 0x098002ef, 0x60000010 }, + { 0x1b800300, 0x30000044 }, + { 0x1b000345, 0x30000054 }, + { 0x1b800346, 0x30000029 }, + { 0x13800374, 0x60000001 }, + { 0x1300037a, 0x18000000 }, + { 0x0900037e, 0x54000000 }, + { 0x13800384, 0x60000001 }, + { 0x13000386, 0x24000026 }, + { 0x09000387, 0x54000000 }, + { 0x13000388, 0x24000025 }, + { 0x13000389, 0x24000025 }, + { 0x1300038a, 0x24000025 }, + { 0x1300038c, 0x24000040 }, + { 0x1300038e, 0x2400003f }, + { 0x1300038f, 0x2400003f }, + { 0x13000390, 0x14000000 }, + { 0x13000391, 0x24000020 }, + { 0x13000392, 0x24000020 }, + { 0x13000393, 0x24000020 }, + { 0x13000394, 0x24000020 }, + { 0x13000395, 0x24000020 }, + { 0x13000396, 0x24000020 }, + { 0x13000397, 0x24000020 }, + { 0x13000398, 0x24000020 }, + { 0x13000399, 0x24000020 }, + { 0x1300039a, 0x24000020 }, + { 0x1300039b, 0x24000020 }, + { 0x1300039c, 0x24000020 }, + { 0x1300039d, 0x24000020 }, + { 0x1300039e, 0x24000020 }, + { 0x1300039f, 0x24000020 }, + { 0x130003a0, 0x24000020 }, + { 0x130003a1, 0x24000020 }, + { 0x130003a3, 0x24000020 }, + { 0x130003a4, 0x24000020 }, + { 0x130003a5, 0x24000020 }, + { 0x130003a6, 0x24000020 }, + { 0x130003a7, 0x24000020 }, + { 0x130003a8, 0x24000020 }, + { 0x130003a9, 0x24000020 }, + { 0x130003aa, 0x24000020 }, + { 0x130003ab, 0x24000020 }, + { 0x130003ac, 0x1400ffda }, + { 0x130003ad, 0x1400ffdb }, + { 0x130003ae, 0x1400ffdb }, + { 0x130003af, 0x1400ffdb }, + { 0x130003b0, 0x14000000 }, + { 0x130003b1, 0x1400ffe0 }, + { 0x130003b2, 0x1400ffe0 }, + { 0x130003b3, 0x1400ffe0 }, + { 0x130003b4, 0x1400ffe0 }, + { 0x130003b5, 0x1400ffe0 }, + { 0x130003b6, 0x1400ffe0 }, + { 0x130003b7, 0x1400ffe0 }, + { 0x130003b8, 0x1400ffe0 }, + { 0x130003b9, 0x1400ffe0 }, + { 0x130003ba, 0x1400ffe0 }, + { 0x130003bb, 0x1400ffe0 }, + { 0x130003bc, 0x1400ffe0 }, + { 0x130003bd, 0x1400ffe0 }, + { 0x130003be, 0x1400ffe0 }, + { 0x130003bf, 0x1400ffe0 }, + { 0x130003c0, 0x1400ffe0 }, + { 0x130003c1, 0x1400ffe0 }, + { 0x130003c2, 0x1400ffe1 }, + { 0x130003c3, 0x1400ffe0 }, + { 0x130003c4, 0x1400ffe0 }, + { 0x130003c5, 0x1400ffe0 }, + { 0x130003c6, 0x1400ffe0 }, + { 0x130003c7, 0x1400ffe0 }, + { 0x130003c8, 0x1400ffe0 }, + { 0x130003c9, 0x1400ffe0 }, + { 0x130003ca, 0x1400ffe0 }, + { 0x130003cb, 0x1400ffe0 }, + { 0x130003cc, 0x1400ffc0 }, + { 0x130003cd, 0x1400ffc1 }, + { 0x130003ce, 0x1400ffc1 }, + { 0x130003d0, 0x1400ffc2 }, + { 0x130003d1, 0x1400ffc7 }, + { 0x138003d2, 0x24000002 }, + { 0x130003d5, 0x1400ffd1 }, + { 0x130003d6, 0x1400ffca }, + { 0x130003d7, 0x14000000 }, + { 0x130003d8, 0x24000001 }, + { 0x130003d9, 0x1400ffff }, + { 0x130003da, 0x24000001 }, + { 0x130003db, 0x1400ffff }, + { 0x130003dc, 0x24000001 }, + { 0x130003dd, 0x1400ffff }, + { 0x130003de, 0x24000001 }, + { 0x130003df, 0x1400ffff }, + { 0x130003e0, 0x24000001 }, + { 0x130003e1, 0x1400ffff }, + { 0x0a0003e2, 0x24000001 }, + { 0x0a0003e3, 0x1400ffff }, + { 0x0a0003e4, 0x24000001 }, + { 0x0a0003e5, 0x1400ffff }, + { 0x0a0003e6, 0x24000001 }, + { 0x0a0003e7, 0x1400ffff }, + { 0x0a0003e8, 0x24000001 }, + { 0x0a0003e9, 0x1400ffff }, + { 0x0a0003ea, 0x24000001 }, + { 0x0a0003eb, 0x1400ffff }, + { 0x0a0003ec, 0x24000001 }, + { 0x0a0003ed, 0x1400ffff }, + { 0x0a0003ee, 0x24000001 }, + { 0x0a0003ef, 0x1400ffff }, + { 0x130003f0, 0x1400ffaa }, + { 0x130003f1, 0x1400ffb0 }, + { 0x130003f2, 0x14000007 }, + { 0x130003f3, 0x14000000 }, + { 0x130003f4, 0x2400ffc4 }, + { 0x130003f5, 0x1400ffa0 }, + { 0x130003f6, 0x64000000 }, + { 0x130003f7, 0x24000001 }, + { 0x130003f8, 0x1400ffff }, + { 0x130003f9, 0x2400fff9 }, + { 0x130003fa, 0x24000001 }, + { 0x130003fb, 0x1400ffff }, + { 0x130003fc, 0x14000000 }, + { 0x138003fd, 0x24000002 }, + { 0x0c000400, 0x24000050 }, + { 0x0c000401, 0x24000050 }, + { 0x0c000402, 0x24000050 }, + { 0x0c000403, 0x24000050 }, + { 0x0c000404, 0x24000050 }, + { 0x0c000405, 0x24000050 }, + { 0x0c000406, 0x24000050 }, + { 0x0c000407, 0x24000050 }, + { 0x0c000408, 0x24000050 }, + { 0x0c000409, 0x24000050 }, + { 0x0c00040a, 0x24000050 }, + { 0x0c00040b, 0x24000050 }, + { 0x0c00040c, 0x24000050 }, + { 0x0c00040d, 0x24000050 }, + { 0x0c00040e, 0x24000050 }, + { 0x0c00040f, 0x24000050 }, + { 0x0c000410, 0x24000020 }, + { 0x0c000411, 0x24000020 }, + { 0x0c000412, 0x24000020 }, + { 0x0c000413, 0x24000020 }, + { 0x0c000414, 0x24000020 }, + { 0x0c000415, 0x24000020 }, + { 0x0c000416, 0x24000020 }, + { 0x0c000417, 0x24000020 }, + { 0x0c000418, 0x24000020 }, + { 0x0c000419, 0x24000020 }, + { 0x0c00041a, 0x24000020 }, + { 0x0c00041b, 0x24000020 }, + { 0x0c00041c, 0x24000020 }, + { 0x0c00041d, 0x24000020 }, + { 0x0c00041e, 0x24000020 }, + { 0x0c00041f, 0x24000020 }, + { 0x0c000420, 0x24000020 }, + { 0x0c000421, 0x24000020 }, + { 0x0c000422, 0x24000020 }, + { 0x0c000423, 0x24000020 }, + { 0x0c000424, 0x24000020 }, + { 0x0c000425, 0x24000020 }, + { 0x0c000426, 0x24000020 }, + { 0x0c000427, 0x24000020 }, + { 0x0c000428, 0x24000020 }, + { 0x0c000429, 0x24000020 }, + { 0x0c00042a, 0x24000020 }, + { 0x0c00042b, 0x24000020 }, + { 0x0c00042c, 0x24000020 }, + { 0x0c00042d, 0x24000020 }, + { 0x0c00042e, 0x24000020 }, + { 0x0c00042f, 0x24000020 }, + { 0x0c000430, 0x1400ffe0 }, + { 0x0c000431, 0x1400ffe0 }, + { 0x0c000432, 0x1400ffe0 }, + { 0x0c000433, 0x1400ffe0 }, + { 0x0c000434, 0x1400ffe0 }, + { 0x0c000435, 0x1400ffe0 }, + { 0x0c000436, 0x1400ffe0 }, + { 0x0c000437, 0x1400ffe0 }, + { 0x0c000438, 0x1400ffe0 }, + { 0x0c000439, 0x1400ffe0 }, + { 0x0c00043a, 0x1400ffe0 }, + { 0x0c00043b, 0x1400ffe0 }, + { 0x0c00043c, 0x1400ffe0 }, + { 0x0c00043d, 0x1400ffe0 }, + { 0x0c00043e, 0x1400ffe0 }, + { 0x0c00043f, 0x1400ffe0 }, + { 0x0c000440, 0x1400ffe0 }, + { 0x0c000441, 0x1400ffe0 }, + { 0x0c000442, 0x1400ffe0 }, + { 0x0c000443, 0x1400ffe0 }, + { 0x0c000444, 0x1400ffe0 }, + { 0x0c000445, 0x1400ffe0 }, + { 0x0c000446, 0x1400ffe0 }, + { 0x0c000447, 0x1400ffe0 }, + { 0x0c000448, 0x1400ffe0 }, + { 0x0c000449, 0x1400ffe0 }, + { 0x0c00044a, 0x1400ffe0 }, + { 0x0c00044b, 0x1400ffe0 }, + { 0x0c00044c, 0x1400ffe0 }, + { 0x0c00044d, 0x1400ffe0 }, + { 0x0c00044e, 0x1400ffe0 }, + { 0x0c00044f, 0x1400ffe0 }, + { 0x0c000450, 0x1400ffb0 }, + { 0x0c000451, 0x1400ffb0 }, + { 0x0c000452, 0x1400ffb0 }, + { 0x0c000453, 0x1400ffb0 }, + { 0x0c000454, 0x1400ffb0 }, + { 0x0c000455, 0x1400ffb0 }, + { 0x0c000456, 0x1400ffb0 }, + { 0x0c000457, 0x1400ffb0 }, + { 0x0c000458, 0x1400ffb0 }, + { 0x0c000459, 0x1400ffb0 }, + { 0x0c00045a, 0x1400ffb0 }, + { 0x0c00045b, 0x1400ffb0 }, + { 0x0c00045c, 0x1400ffb0 }, + { 0x0c00045d, 0x1400ffb0 }, + { 0x0c00045e, 0x1400ffb0 }, + { 0x0c00045f, 0x1400ffb0 }, + { 0x0c000460, 0x24000001 }, + { 0x0c000461, 0x1400ffff }, + { 0x0c000462, 0x24000001 }, + { 0x0c000463, 0x1400ffff }, + { 0x0c000464, 0x24000001 }, + { 0x0c000465, 0x1400ffff }, + { 0x0c000466, 0x24000001 }, + { 0x0c000467, 0x1400ffff }, + { 0x0c000468, 0x24000001 }, + { 0x0c000469, 0x1400ffff }, + { 0x0c00046a, 0x24000001 }, + { 0x0c00046b, 0x1400ffff }, + { 0x0c00046c, 0x24000001 }, + { 0x0c00046d, 0x1400ffff }, + { 0x0c00046e, 0x24000001 }, + { 0x0c00046f, 0x1400ffff }, + { 0x0c000470, 0x24000001 }, + { 0x0c000471, 0x1400ffff }, + { 0x0c000472, 0x24000001 }, + { 0x0c000473, 0x1400ffff }, + { 0x0c000474, 0x24000001 }, + { 0x0c000475, 0x1400ffff }, + { 0x0c000476, 0x24000001 }, + { 0x0c000477, 0x1400ffff }, + { 0x0c000478, 0x24000001 }, + { 0x0c000479, 0x1400ffff }, + { 0x0c00047a, 0x24000001 }, + { 0x0c00047b, 0x1400ffff }, + { 0x0c00047c, 0x24000001 }, + { 0x0c00047d, 0x1400ffff }, + { 0x0c00047e, 0x24000001 }, + { 0x0c00047f, 0x1400ffff }, + { 0x0c000480, 0x24000001 }, + { 0x0c000481, 0x1400ffff }, + { 0x0c000482, 0x68000000 }, + { 0x0c800483, 0x30000003 }, + { 0x0c800488, 0x2c000001 }, + { 0x0c00048a, 0x24000001 }, + { 0x0c00048b, 0x1400ffff }, + { 0x0c00048c, 0x24000001 }, + { 0x0c00048d, 0x1400ffff }, + { 0x0c00048e, 0x24000001 }, + { 0x0c00048f, 0x1400ffff }, + { 0x0c000490, 0x24000001 }, + { 0x0c000491, 0x1400ffff }, + { 0x0c000492, 0x24000001 }, + { 0x0c000493, 0x1400ffff }, + { 0x0c000494, 0x24000001 }, + { 0x0c000495, 0x1400ffff }, + { 0x0c000496, 0x24000001 }, + { 0x0c000497, 0x1400ffff }, + { 0x0c000498, 0x24000001 }, + { 0x0c000499, 0x1400ffff }, + { 0x0c00049a, 0x24000001 }, + { 0x0c00049b, 0x1400ffff }, + { 0x0c00049c, 0x24000001 }, + { 0x0c00049d, 0x1400ffff }, + { 0x0c00049e, 0x24000001 }, + { 0x0c00049f, 0x1400ffff }, + { 0x0c0004a0, 0x24000001 }, + { 0x0c0004a1, 0x1400ffff }, + { 0x0c0004a2, 0x24000001 }, + { 0x0c0004a3, 0x1400ffff }, + { 0x0c0004a4, 0x24000001 }, + { 0x0c0004a5, 0x1400ffff }, + { 0x0c0004a6, 0x24000001 }, + { 0x0c0004a7, 0x1400ffff }, + { 0x0c0004a8, 0x24000001 }, + { 0x0c0004a9, 0x1400ffff }, + { 0x0c0004aa, 0x24000001 }, + { 0x0c0004ab, 0x1400ffff }, + { 0x0c0004ac, 0x24000001 }, + { 0x0c0004ad, 0x1400ffff }, + { 0x0c0004ae, 0x24000001 }, + { 0x0c0004af, 0x1400ffff }, + { 0x0c0004b0, 0x24000001 }, + { 0x0c0004b1, 0x1400ffff }, + { 0x0c0004b2, 0x24000001 }, + { 0x0c0004b3, 0x1400ffff }, + { 0x0c0004b4, 0x24000001 }, + { 0x0c0004b5, 0x1400ffff }, + { 0x0c0004b6, 0x24000001 }, + { 0x0c0004b7, 0x1400ffff }, + { 0x0c0004b8, 0x24000001 }, + { 0x0c0004b9, 0x1400ffff }, + { 0x0c0004ba, 0x24000001 }, + { 0x0c0004bb, 0x1400ffff }, + { 0x0c0004bc, 0x24000001 }, + { 0x0c0004bd, 0x1400ffff }, + { 0x0c0004be, 0x24000001 }, + { 0x0c0004bf, 0x1400ffff }, + { 0x0c0004c0, 0x24000000 }, + { 0x0c0004c1, 0x24000001 }, + { 0x0c0004c2, 0x1400ffff }, + { 0x0c0004c3, 0x24000001 }, + { 0x0c0004c4, 0x1400ffff }, + { 0x0c0004c5, 0x24000001 }, + { 0x0c0004c6, 0x1400ffff }, + { 0x0c0004c7, 0x24000001 }, + { 0x0c0004c8, 0x1400ffff }, + { 0x0c0004c9, 0x24000001 }, + { 0x0c0004ca, 0x1400ffff }, + { 0x0c0004cb, 0x24000001 }, + { 0x0c0004cc, 0x1400ffff }, + { 0x0c0004cd, 0x24000001 }, + { 0x0c0004ce, 0x1400ffff }, + { 0x0c0004d0, 0x24000001 }, + { 0x0c0004d1, 0x1400ffff }, + { 0x0c0004d2, 0x24000001 }, + { 0x0c0004d3, 0x1400ffff }, + { 0x0c0004d4, 0x24000001 }, + { 0x0c0004d5, 0x1400ffff }, + { 0x0c0004d6, 0x24000001 }, + { 0x0c0004d7, 0x1400ffff }, + { 0x0c0004d8, 0x24000001 }, + { 0x0c0004d9, 0x1400ffff }, + { 0x0c0004da, 0x24000001 }, + { 0x0c0004db, 0x1400ffff }, + { 0x0c0004dc, 0x24000001 }, + { 0x0c0004dd, 0x1400ffff }, + { 0x0c0004de, 0x24000001 }, + { 0x0c0004df, 0x1400ffff }, + { 0x0c0004e0, 0x24000001 }, + { 0x0c0004e1, 0x1400ffff }, + { 0x0c0004e2, 0x24000001 }, + { 0x0c0004e3, 0x1400ffff }, + { 0x0c0004e4, 0x24000001 }, + { 0x0c0004e5, 0x1400ffff }, + { 0x0c0004e6, 0x24000001 }, + { 0x0c0004e7, 0x1400ffff }, + { 0x0c0004e8, 0x24000001 }, + { 0x0c0004e9, 0x1400ffff }, + { 0x0c0004ea, 0x24000001 }, + { 0x0c0004eb, 0x1400ffff }, + { 0x0c0004ec, 0x24000001 }, + { 0x0c0004ed, 0x1400ffff }, + { 0x0c0004ee, 0x24000001 }, + { 0x0c0004ef, 0x1400ffff }, + { 0x0c0004f0, 0x24000001 }, + { 0x0c0004f1, 0x1400ffff }, + { 0x0c0004f2, 0x24000001 }, + { 0x0c0004f3, 0x1400ffff }, + { 0x0c0004f4, 0x24000001 }, + { 0x0c0004f5, 0x1400ffff }, + { 0x0c0004f6, 0x24000001 }, + { 0x0c0004f7, 0x1400ffff }, + { 0x0c0004f8, 0x24000001 }, + { 0x0c0004f9, 0x1400ffff }, + { 0x0c000500, 0x24000001 }, + { 0x0c000501, 0x1400ffff }, + { 0x0c000502, 0x24000001 }, + { 0x0c000503, 0x1400ffff }, + { 0x0c000504, 0x24000001 }, + { 0x0c000505, 0x1400ffff }, + { 0x0c000506, 0x24000001 }, + { 0x0c000507, 0x1400ffff }, + { 0x0c000508, 0x24000001 }, + { 0x0c000509, 0x1400ffff }, + { 0x0c00050a, 0x24000001 }, + { 0x0c00050b, 0x1400ffff }, + { 0x0c00050c, 0x24000001 }, + { 0x0c00050d, 0x1400ffff }, + { 0x0c00050e, 0x24000001 }, + { 0x0c00050f, 0x1400ffff }, + { 0x01000531, 0x24000030 }, + { 0x01000532, 0x24000030 }, + { 0x01000533, 0x24000030 }, + { 0x01000534, 0x24000030 }, + { 0x01000535, 0x24000030 }, + { 0x01000536, 0x24000030 }, + { 0x01000537, 0x24000030 }, + { 0x01000538, 0x24000030 }, + { 0x01000539, 0x24000030 }, + { 0x0100053a, 0x24000030 }, + { 0x0100053b, 0x24000030 }, + { 0x0100053c, 0x24000030 }, + { 0x0100053d, 0x24000030 }, + { 0x0100053e, 0x24000030 }, + { 0x0100053f, 0x24000030 }, + { 0x01000540, 0x24000030 }, + { 0x01000541, 0x24000030 }, + { 0x01000542, 0x24000030 }, + { 0x01000543, 0x24000030 }, + { 0x01000544, 0x24000030 }, + { 0x01000545, 0x24000030 }, + { 0x01000546, 0x24000030 }, + { 0x01000547, 0x24000030 }, + { 0x01000548, 0x24000030 }, + { 0x01000549, 0x24000030 }, + { 0x0100054a, 0x24000030 }, + { 0x0100054b, 0x24000030 }, + { 0x0100054c, 0x24000030 }, + { 0x0100054d, 0x24000030 }, + { 0x0100054e, 0x24000030 }, + { 0x0100054f, 0x24000030 }, + { 0x01000550, 0x24000030 }, + { 0x01000551, 0x24000030 }, + { 0x01000552, 0x24000030 }, + { 0x01000553, 0x24000030 }, + { 0x01000554, 0x24000030 }, + { 0x01000555, 0x24000030 }, + { 0x01000556, 0x24000030 }, + { 0x01000559, 0x18000000 }, + { 0x0180055a, 0x54000005 }, + { 0x01000561, 0x1400ffd0 }, + { 0x01000562, 0x1400ffd0 }, + { 0x01000563, 0x1400ffd0 }, + { 0x01000564, 0x1400ffd0 }, + { 0x01000565, 0x1400ffd0 }, + { 0x01000566, 0x1400ffd0 }, + { 0x01000567, 0x1400ffd0 }, + { 0x01000568, 0x1400ffd0 }, + { 0x01000569, 0x1400ffd0 }, + { 0x0100056a, 0x1400ffd0 }, + { 0x0100056b, 0x1400ffd0 }, + { 0x0100056c, 0x1400ffd0 }, + { 0x0100056d, 0x1400ffd0 }, + { 0x0100056e, 0x1400ffd0 }, + { 0x0100056f, 0x1400ffd0 }, + { 0x01000570, 0x1400ffd0 }, + { 0x01000571, 0x1400ffd0 }, + { 0x01000572, 0x1400ffd0 }, + { 0x01000573, 0x1400ffd0 }, + { 0x01000574, 0x1400ffd0 }, + { 0x01000575, 0x1400ffd0 }, + { 0x01000576, 0x1400ffd0 }, + { 0x01000577, 0x1400ffd0 }, + { 0x01000578, 0x1400ffd0 }, + { 0x01000579, 0x1400ffd0 }, + { 0x0100057a, 0x1400ffd0 }, + { 0x0100057b, 0x1400ffd0 }, + { 0x0100057c, 0x1400ffd0 }, + { 0x0100057d, 0x1400ffd0 }, + { 0x0100057e, 0x1400ffd0 }, + { 0x0100057f, 0x1400ffd0 }, + { 0x01000580, 0x1400ffd0 }, + { 0x01000581, 0x1400ffd0 }, + { 0x01000582, 0x1400ffd0 }, + { 0x01000583, 0x1400ffd0 }, + { 0x01000584, 0x1400ffd0 }, + { 0x01000585, 0x1400ffd0 }, + { 0x01000586, 0x1400ffd0 }, + { 0x01000587, 0x14000000 }, + { 0x09000589, 0x54000000 }, + { 0x0100058a, 0x44000000 }, + { 0x19800591, 0x30000028 }, + { 0x198005bb, 0x30000002 }, + { 0x190005be, 0x54000000 }, + { 0x190005bf, 0x30000000 }, + { 0x190005c0, 0x54000000 }, + { 0x198005c1, 0x30000001 }, + { 0x190005c3, 0x54000000 }, + { 0x198005c4, 0x30000001 }, + { 0x190005c6, 0x54000000 }, + { 0x190005c7, 0x30000000 }, + { 0x198005d0, 0x1c00001a }, + { 0x198005f0, 0x1c000002 }, + { 0x198005f3, 0x54000001 }, + { 0x09800600, 0x04000003 }, + { 0x0000060b, 0x5c000000 }, + { 0x0980060c, 0x54000001 }, + { 0x0080060e, 0x68000001 }, + { 0x00800610, 0x30000005 }, + { 0x0900061b, 0x54000000 }, + { 0x0080061e, 0x54000001 }, + { 0x00800621, 0x1c000019 }, + { 0x09000640, 0x18000000 }, + { 0x00800641, 0x1c000009 }, + { 0x1b80064b, 0x30000013 }, + { 0x09800660, 0x34000009 }, + { 0x0080066a, 0x54000003 }, + { 0x0080066e, 0x1c000001 }, + { 0x1b000670, 0x30000000 }, + { 0x00800671, 0x1c000062 }, + { 0x000006d4, 0x54000000 }, + { 0x000006d5, 0x1c000000 }, + { 0x008006d6, 0x30000006 }, + { 0x090006dd, 0x04000000 }, + { 0x000006de, 0x2c000000 }, + { 0x008006df, 0x30000005 }, + { 0x008006e5, 0x18000001 }, + { 0x008006e7, 0x30000001 }, + { 0x000006e9, 0x68000000 }, + { 0x008006ea, 0x30000003 }, + { 0x008006ee, 0x1c000001 }, + { 0x008006f0, 0x34000009 }, + { 0x008006fa, 0x1c000002 }, + { 0x008006fd, 0x68000001 }, + { 0x000006ff, 0x1c000000 }, + { 0x31800700, 0x5400000d }, + { 0x3100070f, 0x04000000 }, + { 0x31000710, 0x1c000000 }, + { 0x31000711, 0x30000000 }, + { 0x31800712, 0x1c00001d }, + { 0x31800730, 0x3000001a }, + { 0x3180074d, 0x1c000020 }, + { 0x37800780, 0x1c000025 }, + { 0x378007a6, 0x3000000a }, + { 0x370007b1, 0x1c000000 }, + { 0x0e800901, 0x30000001 }, + { 0x0e000903, 0x28000000 }, + { 0x0e800904, 0x1c000035 }, + { 0x0e00093c, 0x30000000 }, + { 0x0e00093d, 0x1c000000 }, + { 0x0e80093e, 0x28000002 }, + { 0x0e800941, 0x30000007 }, + { 0x0e800949, 0x28000003 }, + { 0x0e00094d, 0x30000000 }, + { 0x0e000950, 0x1c000000 }, + { 0x0e800951, 0x30000003 }, + { 0x0e800958, 0x1c000009 }, + { 0x0e800962, 0x30000001 }, + { 0x09800964, 0x54000001 }, + { 0x0e800966, 0x34000009 }, + { 0x09000970, 0x54000000 }, + { 0x0e00097d, 0x1c000000 }, + { 0x02000981, 0x30000000 }, + { 0x02800982, 0x28000001 }, + { 0x02800985, 0x1c000007 }, + { 0x0280098f, 0x1c000001 }, + { 0x02800993, 0x1c000015 }, + { 0x028009aa, 0x1c000006 }, + { 0x020009b2, 0x1c000000 }, + { 0x028009b6, 0x1c000003 }, + { 0x020009bc, 0x30000000 }, + { 0x020009bd, 0x1c000000 }, + { 0x028009be, 0x28000002 }, + { 0x028009c1, 0x30000003 }, + { 0x028009c7, 0x28000001 }, + { 0x028009cb, 0x28000001 }, + { 0x020009cd, 0x30000000 }, + { 0x020009ce, 0x1c000000 }, + { 0x020009d7, 0x28000000 }, + { 0x028009dc, 0x1c000001 }, + { 0x028009df, 0x1c000002 }, + { 0x028009e2, 0x30000001 }, + { 0x028009e6, 0x34000009 }, + { 0x028009f0, 0x1c000001 }, + { 0x028009f2, 0x5c000001 }, + { 0x028009f4, 0x3c000005 }, + { 0x020009fa, 0x68000000 }, + { 0x15800a01, 0x30000001 }, + { 0x15000a03, 0x28000000 }, + { 0x15800a05, 0x1c000005 }, + { 0x15800a0f, 0x1c000001 }, + { 0x15800a13, 0x1c000015 }, + { 0x15800a2a, 0x1c000006 }, + { 0x15800a32, 0x1c000001 }, + { 0x15800a35, 0x1c000001 }, + { 0x15800a38, 0x1c000001 }, + { 0x15000a3c, 0x30000000 }, + { 0x15800a3e, 0x28000002 }, + { 0x15800a41, 0x30000001 }, + { 0x15800a47, 0x30000001 }, + { 0x15800a4b, 0x30000002 }, + { 0x15800a59, 0x1c000003 }, + { 0x15000a5e, 0x1c000000 }, + { 0x15800a66, 0x34000009 }, + { 0x15800a70, 0x30000001 }, + { 0x15800a72, 0x1c000002 }, + { 0x14800a81, 0x30000001 }, + { 0x14000a83, 0x28000000 }, + { 0x14800a85, 0x1c000008 }, + { 0x14800a8f, 0x1c000002 }, + { 0x14800a93, 0x1c000015 }, + { 0x14800aaa, 0x1c000006 }, + { 0x14800ab2, 0x1c000001 }, + { 0x14800ab5, 0x1c000004 }, + { 0x14000abc, 0x30000000 }, + { 0x14000abd, 0x1c000000 }, + { 0x14800abe, 0x28000002 }, + { 0x14800ac1, 0x30000004 }, + { 0x14800ac7, 0x30000001 }, + { 0x14000ac9, 0x28000000 }, + { 0x14800acb, 0x28000001 }, + { 0x14000acd, 0x30000000 }, + { 0x14000ad0, 0x1c000000 }, + { 0x14800ae0, 0x1c000001 }, + { 0x14800ae2, 0x30000001 }, + { 0x14800ae6, 0x34000009 }, + { 0x14000af1, 0x5c000000 }, + { 0x2b000b01, 0x30000000 }, + { 0x2b800b02, 0x28000001 }, + { 0x2b800b05, 0x1c000007 }, + { 0x2b800b0f, 0x1c000001 }, + { 0x2b800b13, 0x1c000015 }, + { 0x2b800b2a, 0x1c000006 }, + { 0x2b800b32, 0x1c000001 }, + { 0x2b800b35, 0x1c000004 }, + { 0x2b000b3c, 0x30000000 }, + { 0x2b000b3d, 0x1c000000 }, + { 0x2b000b3e, 0x28000000 }, + { 0x2b000b3f, 0x30000000 }, + { 0x2b000b40, 0x28000000 }, + { 0x2b800b41, 0x30000002 }, + { 0x2b800b47, 0x28000001 }, + { 0x2b800b4b, 0x28000001 }, + { 0x2b000b4d, 0x30000000 }, + { 0x2b000b56, 0x30000000 }, + { 0x2b000b57, 0x28000000 }, + { 0x2b800b5c, 0x1c000001 }, + { 0x2b800b5f, 0x1c000002 }, + { 0x2b800b66, 0x34000009 }, + { 0x2b000b70, 0x68000000 }, + { 0x2b000b71, 0x1c000000 }, + { 0x35000b82, 0x30000000 }, + { 0x35000b83, 0x1c000000 }, + { 0x35800b85, 0x1c000005 }, + { 0x35800b8e, 0x1c000002 }, + { 0x35800b92, 0x1c000003 }, + { 0x35800b99, 0x1c000001 }, + { 0x35000b9c, 0x1c000000 }, + { 0x35800b9e, 0x1c000001 }, + { 0x35800ba3, 0x1c000001 }, + { 0x35800ba8, 0x1c000002 }, + { 0x35800bae, 0x1c00000b }, + { 0x35800bbe, 0x28000001 }, + { 0x35000bc0, 0x30000000 }, + { 0x35800bc1, 0x28000001 }, + { 0x35800bc6, 0x28000002 }, + { 0x35800bca, 0x28000002 }, + { 0x35000bcd, 0x30000000 }, + { 0x35000bd7, 0x28000000 }, + { 0x35800be6, 0x34000009 }, + { 0x35800bf0, 0x3c000002 }, + { 0x35800bf3, 0x68000005 }, + { 0x35000bf9, 0x5c000000 }, + { 0x35000bfa, 0x68000000 }, + { 0x36800c01, 0x28000002 }, + { 0x36800c05, 0x1c000007 }, + { 0x36800c0e, 0x1c000002 }, + { 0x36800c12, 0x1c000016 }, + { 0x36800c2a, 0x1c000009 }, + { 0x36800c35, 0x1c000004 }, + { 0x36800c3e, 0x30000002 }, + { 0x36800c41, 0x28000003 }, + { 0x36800c46, 0x30000002 }, + { 0x36800c4a, 0x30000003 }, + { 0x36800c55, 0x30000001 }, + { 0x36800c60, 0x1c000001 }, + { 0x36800c66, 0x34000009 }, + { 0x1c800c82, 0x28000001 }, + { 0x1c800c85, 0x1c000007 }, + { 0x1c800c8e, 0x1c000002 }, + { 0x1c800c92, 0x1c000016 }, + { 0x1c800caa, 0x1c000009 }, + { 0x1c800cb5, 0x1c000004 }, + { 0x1c000cbc, 0x30000000 }, + { 0x1c000cbd, 0x1c000000 }, + { 0x1c000cbe, 0x28000000 }, + { 0x1c000cbf, 0x30000000 }, + { 0x1c800cc0, 0x28000004 }, + { 0x1c000cc6, 0x30000000 }, + { 0x1c800cc7, 0x28000001 }, + { 0x1c800cca, 0x28000001 }, + { 0x1c800ccc, 0x30000001 }, + { 0x1c800cd5, 0x28000001 }, + { 0x1c000cde, 0x1c000000 }, + { 0x1c800ce0, 0x1c000001 }, + { 0x1c800ce6, 0x34000009 }, + { 0x24800d02, 0x28000001 }, + { 0x24800d05, 0x1c000007 }, + { 0x24800d0e, 0x1c000002 }, + { 0x24800d12, 0x1c000016 }, + { 0x24800d2a, 0x1c00000f }, + { 0x24800d3e, 0x28000002 }, + { 0x24800d41, 0x30000002 }, + { 0x24800d46, 0x28000002 }, + { 0x24800d4a, 0x28000002 }, + { 0x24000d4d, 0x30000000 }, + { 0x24000d57, 0x28000000 }, + { 0x24800d60, 0x1c000001 }, + { 0x24800d66, 0x34000009 }, + { 0x2f800d82, 0x28000001 }, + { 0x2f800d85, 0x1c000011 }, + { 0x2f800d9a, 0x1c000017 }, + { 0x2f800db3, 0x1c000008 }, + { 0x2f000dbd, 0x1c000000 }, + { 0x2f800dc0, 0x1c000006 }, + { 0x2f000dca, 0x30000000 }, + { 0x2f800dcf, 0x28000002 }, + { 0x2f800dd2, 0x30000002 }, + { 0x2f000dd6, 0x30000000 }, + { 0x2f800dd8, 0x28000007 }, + { 0x2f800df2, 0x28000001 }, + { 0x2f000df4, 0x54000000 }, + { 0x38800e01, 0x1c00002f }, + { 0x38000e31, 0x30000000 }, + { 0x38800e32, 0x1c000001 }, + { 0x38800e34, 0x30000006 }, + { 0x09000e3f, 0x5c000000 }, + { 0x38800e40, 0x1c000005 }, + { 0x38000e46, 0x18000000 }, + { 0x38800e47, 0x30000007 }, + { 0x38000e4f, 0x54000000 }, + { 0x38800e50, 0x34000009 }, + { 0x38800e5a, 0x54000001 }, + { 0x20800e81, 0x1c000001 }, + { 0x20000e84, 0x1c000000 }, + { 0x20800e87, 0x1c000001 }, + { 0x20000e8a, 0x1c000000 }, + { 0x20000e8d, 0x1c000000 }, + { 0x20800e94, 0x1c000003 }, + { 0x20800e99, 0x1c000006 }, + { 0x20800ea1, 0x1c000002 }, + { 0x20000ea5, 0x1c000000 }, + { 0x20000ea7, 0x1c000000 }, + { 0x20800eaa, 0x1c000001 }, + { 0x20800ead, 0x1c000003 }, + { 0x20000eb1, 0x30000000 }, + { 0x20800eb2, 0x1c000001 }, + { 0x20800eb4, 0x30000005 }, + { 0x20800ebb, 0x30000001 }, + { 0x20000ebd, 0x1c000000 }, + { 0x20800ec0, 0x1c000004 }, + { 0x20000ec6, 0x18000000 }, + { 0x20800ec8, 0x30000005 }, + { 0x20800ed0, 0x34000009 }, + { 0x20800edc, 0x1c000001 }, + { 0x39000f00, 0x1c000000 }, + { 0x39800f01, 0x68000002 }, + { 0x39800f04, 0x5400000e }, + { 0x39800f13, 0x68000004 }, + { 0x39800f18, 0x30000001 }, + { 0x39800f1a, 0x68000005 }, + { 0x39800f20, 0x34000009 }, + { 0x39800f2a, 0x3c000009 }, + { 0x39000f34, 0x68000000 }, + { 0x39000f35, 0x30000000 }, + { 0x39000f36, 0x68000000 }, + { 0x39000f37, 0x30000000 }, + { 0x39000f38, 0x68000000 }, + { 0x39000f39, 0x30000000 }, + { 0x39000f3a, 0x58000000 }, + { 0x39000f3b, 0x48000000 }, + { 0x39000f3c, 0x58000000 }, + { 0x39000f3d, 0x48000000 }, + { 0x39800f3e, 0x28000001 }, + { 0x39800f40, 0x1c000007 }, + { 0x39800f49, 0x1c000021 }, + { 0x39800f71, 0x3000000d }, + { 0x39000f7f, 0x28000000 }, + { 0x39800f80, 0x30000004 }, + { 0x39000f85, 0x54000000 }, + { 0x39800f86, 0x30000001 }, + { 0x39800f88, 0x1c000003 }, + { 0x39800f90, 0x30000007 }, + { 0x39800f99, 0x30000023 }, + { 0x39800fbe, 0x68000007 }, + { 0x39000fc6, 0x30000000 }, + { 0x39800fc7, 0x68000005 }, + { 0x39000fcf, 0x68000000 }, + { 0x39800fd0, 0x54000001 }, + { 0x26801000, 0x1c000021 }, + { 0x26801023, 0x1c000004 }, + { 0x26801029, 0x1c000001 }, + { 0x2600102c, 0x28000000 }, + { 0x2680102d, 0x30000003 }, + { 0x26001031, 0x28000000 }, + { 0x26001032, 0x30000000 }, + { 0x26801036, 0x30000001 }, + { 0x26001038, 0x28000000 }, + { 0x26001039, 0x30000000 }, + { 0x26801040, 0x34000009 }, + { 0x2680104a, 0x54000005 }, + { 0x26801050, 0x1c000005 }, + { 0x26801056, 0x28000001 }, + { 0x26801058, 0x30000001 }, + { 0x100010a0, 0x24001c60 }, + { 0x100010a1, 0x24001c60 }, + { 0x100010a2, 0x24001c60 }, + { 0x100010a3, 0x24001c60 }, + { 0x100010a4, 0x24001c60 }, + { 0x100010a5, 0x24001c60 }, + { 0x100010a6, 0x24001c60 }, + { 0x100010a7, 0x24001c60 }, + { 0x100010a8, 0x24001c60 }, + { 0x100010a9, 0x24001c60 }, + { 0x100010aa, 0x24001c60 }, + { 0x100010ab, 0x24001c60 }, + { 0x100010ac, 0x24001c60 }, + { 0x100010ad, 0x24001c60 }, + { 0x100010ae, 0x24001c60 }, + { 0x100010af, 0x24001c60 }, + { 0x100010b0, 0x24001c60 }, + { 0x100010b1, 0x24001c60 }, + { 0x100010b2, 0x24001c60 }, + { 0x100010b3, 0x24001c60 }, + { 0x100010b4, 0x24001c60 }, + { 0x100010b5, 0x24001c60 }, + { 0x100010b6, 0x24001c60 }, + { 0x100010b7, 0x24001c60 }, + { 0x100010b8, 0x24001c60 }, + { 0x100010b9, 0x24001c60 }, + { 0x100010ba, 0x24001c60 }, + { 0x100010bb, 0x24001c60 }, + { 0x100010bc, 0x24001c60 }, + { 0x100010bd, 0x24001c60 }, + { 0x100010be, 0x24001c60 }, + { 0x100010bf, 0x24001c60 }, + { 0x100010c0, 0x24001c60 }, + { 0x100010c1, 0x24001c60 }, + { 0x100010c2, 0x24001c60 }, + { 0x100010c3, 0x24001c60 }, + { 0x100010c4, 0x24001c60 }, + { 0x100010c5, 0x24001c60 }, + { 0x108010d0, 0x1c00002a }, + { 0x090010fb, 0x54000000 }, + { 0x100010fc, 0x18000000 }, + { 0x17801100, 0x1c000059 }, + { 0x1780115f, 0x1c000043 }, + { 0x178011a8, 0x1c000051 }, + { 0x0f801200, 0x1c000048 }, + { 0x0f80124a, 0x1c000003 }, + { 0x0f801250, 0x1c000006 }, + { 0x0f001258, 0x1c000000 }, + { 0x0f80125a, 0x1c000003 }, + { 0x0f801260, 0x1c000028 }, + { 0x0f80128a, 0x1c000003 }, + { 0x0f801290, 0x1c000020 }, + { 0x0f8012b2, 0x1c000003 }, + { 0x0f8012b8, 0x1c000006 }, + { 0x0f0012c0, 0x1c000000 }, + { 0x0f8012c2, 0x1c000003 }, + { 0x0f8012c8, 0x1c00000e }, + { 0x0f8012d8, 0x1c000038 }, + { 0x0f801312, 0x1c000003 }, + { 0x0f801318, 0x1c000042 }, + { 0x0f00135f, 0x30000000 }, + { 0x0f001360, 0x68000000 }, + { 0x0f801361, 0x54000007 }, + { 0x0f801369, 0x3c000013 }, + { 0x0f801380, 0x1c00000f }, + { 0x0f801390, 0x68000009 }, + { 0x088013a0, 0x1c000054 }, + { 0x07801401, 0x1c00026b }, + { 0x0780166d, 0x54000001 }, + { 0x0780166f, 0x1c000007 }, + { 0x28001680, 0x74000000 }, + { 0x28801681, 0x1c000019 }, + { 0x2800169b, 0x58000000 }, + { 0x2800169c, 0x48000000 }, + { 0x2d8016a0, 0x1c00004a }, + { 0x098016eb, 0x54000002 }, + { 0x2d8016ee, 0x38000002 }, + { 0x32801700, 0x1c00000c }, + { 0x3280170e, 0x1c000003 }, + { 0x32801712, 0x30000002 }, + { 0x18801720, 0x1c000011 }, + { 0x18801732, 0x30000002 }, + { 0x09801735, 0x54000001 }, + { 0x06801740, 0x1c000011 }, + { 0x06801752, 0x30000001 }, + { 0x33801760, 0x1c00000c }, + { 0x3380176e, 0x1c000002 }, + { 0x33801772, 0x30000001 }, + { 0x1f801780, 0x1c000033 }, + { 0x1f8017b4, 0x04000001 }, + { 0x1f0017b6, 0x28000000 }, + { 0x1f8017b7, 0x30000006 }, + { 0x1f8017be, 0x28000007 }, + { 0x1f0017c6, 0x30000000 }, + { 0x1f8017c7, 0x28000001 }, + { 0x1f8017c9, 0x3000000a }, + { 0x1f8017d4, 0x54000002 }, + { 0x1f0017d7, 0x18000000 }, + { 0x1f8017d8, 0x54000002 }, + { 0x1f0017db, 0x5c000000 }, + { 0x1f0017dc, 0x1c000000 }, + { 0x1f0017dd, 0x30000000 }, + { 0x1f8017e0, 0x34000009 }, + { 0x1f8017f0, 0x3c000009 }, + { 0x25801800, 0x54000005 }, + { 0x25001806, 0x44000000 }, + { 0x25801807, 0x54000003 }, + { 0x2580180b, 0x30000002 }, + { 0x2500180e, 0x74000000 }, + { 0x25801810, 0x34000009 }, + { 0x25801820, 0x1c000022 }, + { 0x25001843, 0x18000000 }, + { 0x25801844, 0x1c000033 }, + { 0x25801880, 0x1c000028 }, + { 0x250018a9, 0x30000000 }, + { 0x22801900, 0x1c00001c }, + { 0x22801920, 0x30000002 }, + { 0x22801923, 0x28000003 }, + { 0x22801927, 0x30000001 }, + { 0x22801929, 0x28000002 }, + { 0x22801930, 0x28000001 }, + { 0x22001932, 0x30000000 }, + { 0x22801933, 0x28000005 }, + { 0x22801939, 0x30000002 }, + { 0x22001940, 0x68000000 }, + { 0x22801944, 0x54000001 }, + { 0x22801946, 0x34000009 }, + { 0x34801950, 0x1c00001d }, + { 0x34801970, 0x1c000004 }, + { 0x27801980, 0x1c000029 }, + { 0x278019b0, 0x28000010 }, + { 0x278019c1, 0x1c000006 }, + { 0x278019c8, 0x28000001 }, + { 0x278019d0, 0x34000009 }, + { 0x278019de, 0x54000001 }, + { 0x1f8019e0, 0x6800001f }, + { 0x05801a00, 0x1c000016 }, + { 0x05801a17, 0x30000001 }, + { 0x05801a19, 0x28000002 }, + { 0x05801a1e, 0x54000001 }, + { 0x21801d00, 0x1400002b }, + { 0x21801d2c, 0x18000035 }, + { 0x21801d62, 0x14000015 }, + { 0x0c001d78, 0x18000000 }, + { 0x21801d79, 0x14000021 }, + { 0x21801d9b, 0x18000024 }, + { 0x1b801dc0, 0x30000003 }, + { 0x21001e00, 0x24000001 }, + { 0x21001e01, 0x1400ffff }, + { 0x21001e02, 0x24000001 }, + { 0x21001e03, 0x1400ffff }, + { 0x21001e04, 0x24000001 }, + { 0x21001e05, 0x1400ffff }, + { 0x21001e06, 0x24000001 }, + { 0x21001e07, 0x1400ffff }, + { 0x21001e08, 0x24000001 }, + { 0x21001e09, 0x1400ffff }, + { 0x21001e0a, 0x24000001 }, + { 0x21001e0b, 0x1400ffff }, + { 0x21001e0c, 0x24000001 }, + { 0x21001e0d, 0x1400ffff }, + { 0x21001e0e, 0x24000001 }, + { 0x21001e0f, 0x1400ffff }, + { 0x21001e10, 0x24000001 }, + { 0x21001e11, 0x1400ffff }, + { 0x21001e12, 0x24000001 }, + { 0x21001e13, 0x1400ffff }, + { 0x21001e14, 0x24000001 }, + { 0x21001e15, 0x1400ffff }, + { 0x21001e16, 0x24000001 }, + { 0x21001e17, 0x1400ffff }, + { 0x21001e18, 0x24000001 }, + { 0x21001e19, 0x1400ffff }, + { 0x21001e1a, 0x24000001 }, + { 0x21001e1b, 0x1400ffff }, + { 0x21001e1c, 0x24000001 }, + { 0x21001e1d, 0x1400ffff }, + { 0x21001e1e, 0x24000001 }, + { 0x21001e1f, 0x1400ffff }, + { 0x21001e20, 0x24000001 }, + { 0x21001e21, 0x1400ffff }, + { 0x21001e22, 0x24000001 }, + { 0x21001e23, 0x1400ffff }, + { 0x21001e24, 0x24000001 }, + { 0x21001e25, 0x1400ffff }, + { 0x21001e26, 0x24000001 }, + { 0x21001e27, 0x1400ffff }, + { 0x21001e28, 0x24000001 }, + { 0x21001e29, 0x1400ffff }, + { 0x21001e2a, 0x24000001 }, + { 0x21001e2b, 0x1400ffff }, + { 0x21001e2c, 0x24000001 }, + { 0x21001e2d, 0x1400ffff }, + { 0x21001e2e, 0x24000001 }, + { 0x21001e2f, 0x1400ffff }, + { 0x21001e30, 0x24000001 }, + { 0x21001e31, 0x1400ffff }, + { 0x21001e32, 0x24000001 }, + { 0x21001e33, 0x1400ffff }, + { 0x21001e34, 0x24000001 }, + { 0x21001e35, 0x1400ffff }, + { 0x21001e36, 0x24000001 }, + { 0x21001e37, 0x1400ffff }, + { 0x21001e38, 0x24000001 }, + { 0x21001e39, 0x1400ffff }, + { 0x21001e3a, 0x24000001 }, + { 0x21001e3b, 0x1400ffff }, + { 0x21001e3c, 0x24000001 }, + { 0x21001e3d, 0x1400ffff }, + { 0x21001e3e, 0x24000001 }, + { 0x21001e3f, 0x1400ffff }, + { 0x21001e40, 0x24000001 }, + { 0x21001e41, 0x1400ffff }, + { 0x21001e42, 0x24000001 }, + { 0x21001e43, 0x1400ffff }, + { 0x21001e44, 0x24000001 }, + { 0x21001e45, 0x1400ffff }, + { 0x21001e46, 0x24000001 }, + { 0x21001e47, 0x1400ffff }, + { 0x21001e48, 0x24000001 }, + { 0x21001e49, 0x1400ffff }, + { 0x21001e4a, 0x24000001 }, + { 0x21001e4b, 0x1400ffff }, + { 0x21001e4c, 0x24000001 }, + { 0x21001e4d, 0x1400ffff }, + { 0x21001e4e, 0x24000001 }, + { 0x21001e4f, 0x1400ffff }, + { 0x21001e50, 0x24000001 }, + { 0x21001e51, 0x1400ffff }, + { 0x21001e52, 0x24000001 }, + { 0x21001e53, 0x1400ffff }, + { 0x21001e54, 0x24000001 }, + { 0x21001e55, 0x1400ffff }, + { 0x21001e56, 0x24000001 }, + { 0x21001e57, 0x1400ffff }, + { 0x21001e58, 0x24000001 }, + { 0x21001e59, 0x1400ffff }, + { 0x21001e5a, 0x24000001 }, + { 0x21001e5b, 0x1400ffff }, + { 0x21001e5c, 0x24000001 }, + { 0x21001e5d, 0x1400ffff }, + { 0x21001e5e, 0x24000001 }, + { 0x21001e5f, 0x1400ffff }, + { 0x21001e60, 0x24000001 }, + { 0x21001e61, 0x1400ffff }, + { 0x21001e62, 0x24000001 }, + { 0x21001e63, 0x1400ffff }, + { 0x21001e64, 0x24000001 }, + { 0x21001e65, 0x1400ffff }, + { 0x21001e66, 0x24000001 }, + { 0x21001e67, 0x1400ffff }, + { 0x21001e68, 0x24000001 }, + { 0x21001e69, 0x1400ffff }, + { 0x21001e6a, 0x24000001 }, + { 0x21001e6b, 0x1400ffff }, + { 0x21001e6c, 0x24000001 }, + { 0x21001e6d, 0x1400ffff }, + { 0x21001e6e, 0x24000001 }, + { 0x21001e6f, 0x1400ffff }, + { 0x21001e70, 0x24000001 }, + { 0x21001e71, 0x1400ffff }, + { 0x21001e72, 0x24000001 }, + { 0x21001e73, 0x1400ffff }, + { 0x21001e74, 0x24000001 }, + { 0x21001e75, 0x1400ffff }, + { 0x21001e76, 0x24000001 }, + { 0x21001e77, 0x1400ffff }, + { 0x21001e78, 0x24000001 }, + { 0x21001e79, 0x1400ffff }, + { 0x21001e7a, 0x24000001 }, + { 0x21001e7b, 0x1400ffff }, + { 0x21001e7c, 0x24000001 }, + { 0x21001e7d, 0x1400ffff }, + { 0x21001e7e, 0x24000001 }, + { 0x21001e7f, 0x1400ffff }, + { 0x21001e80, 0x24000001 }, + { 0x21001e81, 0x1400ffff }, + { 0x21001e82, 0x24000001 }, + { 0x21001e83, 0x1400ffff }, + { 0x21001e84, 0x24000001 }, + { 0x21001e85, 0x1400ffff }, + { 0x21001e86, 0x24000001 }, + { 0x21001e87, 0x1400ffff }, + { 0x21001e88, 0x24000001 }, + { 0x21001e89, 0x1400ffff }, + { 0x21001e8a, 0x24000001 }, + { 0x21001e8b, 0x1400ffff }, + { 0x21001e8c, 0x24000001 }, + { 0x21001e8d, 0x1400ffff }, + { 0x21001e8e, 0x24000001 }, + { 0x21001e8f, 0x1400ffff }, + { 0x21001e90, 0x24000001 }, + { 0x21001e91, 0x1400ffff }, + { 0x21001e92, 0x24000001 }, + { 0x21001e93, 0x1400ffff }, + { 0x21001e94, 0x24000001 }, + { 0x21001e95, 0x1400ffff }, + { 0x21801e96, 0x14000004 }, + { 0x21001e9b, 0x1400ffc5 }, + { 0x21001ea0, 0x24000001 }, + { 0x21001ea1, 0x1400ffff }, + { 0x21001ea2, 0x24000001 }, + { 0x21001ea3, 0x1400ffff }, + { 0x21001ea4, 0x24000001 }, + { 0x21001ea5, 0x1400ffff }, + { 0x21001ea6, 0x24000001 }, + { 0x21001ea7, 0x1400ffff }, + { 0x21001ea8, 0x24000001 }, + { 0x21001ea9, 0x1400ffff }, + { 0x21001eaa, 0x24000001 }, + { 0x21001eab, 0x1400ffff }, + { 0x21001eac, 0x24000001 }, + { 0x21001ead, 0x1400ffff }, + { 0x21001eae, 0x24000001 }, + { 0x21001eaf, 0x1400ffff }, + { 0x21001eb0, 0x24000001 }, + { 0x21001eb1, 0x1400ffff }, + { 0x21001eb2, 0x24000001 }, + { 0x21001eb3, 0x1400ffff }, + { 0x21001eb4, 0x24000001 }, + { 0x21001eb5, 0x1400ffff }, + { 0x21001eb6, 0x24000001 }, + { 0x21001eb7, 0x1400ffff }, + { 0x21001eb8, 0x24000001 }, + { 0x21001eb9, 0x1400ffff }, + { 0x21001eba, 0x24000001 }, + { 0x21001ebb, 0x1400ffff }, + { 0x21001ebc, 0x24000001 }, + { 0x21001ebd, 0x1400ffff }, + { 0x21001ebe, 0x24000001 }, + { 0x21001ebf, 0x1400ffff }, + { 0x21001ec0, 0x24000001 }, + { 0x21001ec1, 0x1400ffff }, + { 0x21001ec2, 0x24000001 }, + { 0x21001ec3, 0x1400ffff }, + { 0x21001ec4, 0x24000001 }, + { 0x21001ec5, 0x1400ffff }, + { 0x21001ec6, 0x24000001 }, + { 0x21001ec7, 0x1400ffff }, + { 0x21001ec8, 0x24000001 }, + { 0x21001ec9, 0x1400ffff }, + { 0x21001eca, 0x24000001 }, + { 0x21001ecb, 0x1400ffff }, + { 0x21001ecc, 0x24000001 }, + { 0x21001ecd, 0x1400ffff }, + { 0x21001ece, 0x24000001 }, + { 0x21001ecf, 0x1400ffff }, + { 0x21001ed0, 0x24000001 }, + { 0x21001ed1, 0x1400ffff }, + { 0x21001ed2, 0x24000001 }, + { 0x21001ed3, 0x1400ffff }, + { 0x21001ed4, 0x24000001 }, + { 0x21001ed5, 0x1400ffff }, + { 0x21001ed6, 0x24000001 }, + { 0x21001ed7, 0x1400ffff }, + { 0x21001ed8, 0x24000001 }, + { 0x21001ed9, 0x1400ffff }, + { 0x21001eda, 0x24000001 }, + { 0x21001edb, 0x1400ffff }, + { 0x21001edc, 0x24000001 }, + { 0x21001edd, 0x1400ffff }, + { 0x21001ede, 0x24000001 }, + { 0x21001edf, 0x1400ffff }, + { 0x21001ee0, 0x24000001 }, + { 0x21001ee1, 0x1400ffff }, + { 0x21001ee2, 0x24000001 }, + { 0x21001ee3, 0x1400ffff }, + { 0x21001ee4, 0x24000001 }, + { 0x21001ee5, 0x1400ffff }, + { 0x21001ee6, 0x24000001 }, + { 0x21001ee7, 0x1400ffff }, + { 0x21001ee8, 0x24000001 }, + { 0x21001ee9, 0x1400ffff }, + { 0x21001eea, 0x24000001 }, + { 0x21001eeb, 0x1400ffff }, + { 0x21001eec, 0x24000001 }, + { 0x21001eed, 0x1400ffff }, + { 0x21001eee, 0x24000001 }, + { 0x21001eef, 0x1400ffff }, + { 0x21001ef0, 0x24000001 }, + { 0x21001ef1, 0x1400ffff }, + { 0x21001ef2, 0x24000001 }, + { 0x21001ef3, 0x1400ffff }, + { 0x21001ef4, 0x24000001 }, + { 0x21001ef5, 0x1400ffff }, + { 0x21001ef6, 0x24000001 }, + { 0x21001ef7, 0x1400ffff }, + { 0x21001ef8, 0x24000001 }, + { 0x21001ef9, 0x1400ffff }, + { 0x13001f00, 0x14000008 }, + { 0x13001f01, 0x14000008 }, + { 0x13001f02, 0x14000008 }, + { 0x13001f03, 0x14000008 }, + { 0x13001f04, 0x14000008 }, + { 0x13001f05, 0x14000008 }, + { 0x13001f06, 0x14000008 }, + { 0x13001f07, 0x14000008 }, + { 0x13001f08, 0x2400fff8 }, + { 0x13001f09, 0x2400fff8 }, + { 0x13001f0a, 0x2400fff8 }, + { 0x13001f0b, 0x2400fff8 }, + { 0x13001f0c, 0x2400fff8 }, + { 0x13001f0d, 0x2400fff8 }, + { 0x13001f0e, 0x2400fff8 }, + { 0x13001f0f, 0x2400fff8 }, + { 0x13001f10, 0x14000008 }, + { 0x13001f11, 0x14000008 }, + { 0x13001f12, 0x14000008 }, + { 0x13001f13, 0x14000008 }, + { 0x13001f14, 0x14000008 }, + { 0x13001f15, 0x14000008 }, + { 0x13001f18, 0x2400fff8 }, + { 0x13001f19, 0x2400fff8 }, + { 0x13001f1a, 0x2400fff8 }, + { 0x13001f1b, 0x2400fff8 }, + { 0x13001f1c, 0x2400fff8 }, + { 0x13001f1d, 0x2400fff8 }, + { 0x13001f20, 0x14000008 }, + { 0x13001f21, 0x14000008 }, + { 0x13001f22, 0x14000008 }, + { 0x13001f23, 0x14000008 }, + { 0x13001f24, 0x14000008 }, + { 0x13001f25, 0x14000008 }, + { 0x13001f26, 0x14000008 }, + { 0x13001f27, 0x14000008 }, + { 0x13001f28, 0x2400fff8 }, + { 0x13001f29, 0x2400fff8 }, + { 0x13001f2a, 0x2400fff8 }, + { 0x13001f2b, 0x2400fff8 }, + { 0x13001f2c, 0x2400fff8 }, + { 0x13001f2d, 0x2400fff8 }, + { 0x13001f2e, 0x2400fff8 }, + { 0x13001f2f, 0x2400fff8 }, + { 0x13001f30, 0x14000008 }, + { 0x13001f31, 0x14000008 }, + { 0x13001f32, 0x14000008 }, + { 0x13001f33, 0x14000008 }, + { 0x13001f34, 0x14000008 }, + { 0x13001f35, 0x14000008 }, + { 0x13001f36, 0x14000008 }, + { 0x13001f37, 0x14000008 }, + { 0x13001f38, 0x2400fff8 }, + { 0x13001f39, 0x2400fff8 }, + { 0x13001f3a, 0x2400fff8 }, + { 0x13001f3b, 0x2400fff8 }, + { 0x13001f3c, 0x2400fff8 }, + { 0x13001f3d, 0x2400fff8 }, + { 0x13001f3e, 0x2400fff8 }, + { 0x13001f3f, 0x2400fff8 }, + { 0x13001f40, 0x14000008 }, + { 0x13001f41, 0x14000008 }, + { 0x13001f42, 0x14000008 }, + { 0x13001f43, 0x14000008 }, + { 0x13001f44, 0x14000008 }, + { 0x13001f45, 0x14000008 }, + { 0x13001f48, 0x2400fff8 }, + { 0x13001f49, 0x2400fff8 }, + { 0x13001f4a, 0x2400fff8 }, + { 0x13001f4b, 0x2400fff8 }, + { 0x13001f4c, 0x2400fff8 }, + { 0x13001f4d, 0x2400fff8 }, + { 0x13001f50, 0x14000000 }, + { 0x13001f51, 0x14000008 }, + { 0x13001f52, 0x14000000 }, + { 0x13001f53, 0x14000008 }, + { 0x13001f54, 0x14000000 }, + { 0x13001f55, 0x14000008 }, + { 0x13001f56, 0x14000000 }, + { 0x13001f57, 0x14000008 }, + { 0x13001f59, 0x2400fff8 }, + { 0x13001f5b, 0x2400fff8 }, + { 0x13001f5d, 0x2400fff8 }, + { 0x13001f5f, 0x2400fff8 }, + { 0x13001f60, 0x14000008 }, + { 0x13001f61, 0x14000008 }, + { 0x13001f62, 0x14000008 }, + { 0x13001f63, 0x14000008 }, + { 0x13001f64, 0x14000008 }, + { 0x13001f65, 0x14000008 }, + { 0x13001f66, 0x14000008 }, + { 0x13001f67, 0x14000008 }, + { 0x13001f68, 0x2400fff8 }, + { 0x13001f69, 0x2400fff8 }, + { 0x13001f6a, 0x2400fff8 }, + { 0x13001f6b, 0x2400fff8 }, + { 0x13001f6c, 0x2400fff8 }, + { 0x13001f6d, 0x2400fff8 }, + { 0x13001f6e, 0x2400fff8 }, + { 0x13001f6f, 0x2400fff8 }, + { 0x13001f70, 0x1400004a }, + { 0x13001f71, 0x1400004a }, + { 0x13001f72, 0x14000056 }, + { 0x13001f73, 0x14000056 }, + { 0x13001f74, 0x14000056 }, + { 0x13001f75, 0x14000056 }, + { 0x13001f76, 0x14000064 }, + { 0x13001f77, 0x14000064 }, + { 0x13001f78, 0x14000080 }, + { 0x13001f79, 0x14000080 }, + { 0x13001f7a, 0x14000070 }, + { 0x13001f7b, 0x14000070 }, + { 0x13001f7c, 0x1400007e }, + { 0x13001f7d, 0x1400007e }, + { 0x13001f80, 0x14000008 }, + { 0x13001f81, 0x14000008 }, + { 0x13001f82, 0x14000008 }, + { 0x13001f83, 0x14000008 }, + { 0x13001f84, 0x14000008 }, + { 0x13001f85, 0x14000008 }, + { 0x13001f86, 0x14000008 }, + { 0x13001f87, 0x14000008 }, + { 0x13001f88, 0x2000fff8 }, + { 0x13001f89, 0x2000fff8 }, + { 0x13001f8a, 0x2000fff8 }, + { 0x13001f8b, 0x2000fff8 }, + { 0x13001f8c, 0x2000fff8 }, + { 0x13001f8d, 0x2000fff8 }, + { 0x13001f8e, 0x2000fff8 }, + { 0x13001f8f, 0x2000fff8 }, + { 0x13001f90, 0x14000008 }, + { 0x13001f91, 0x14000008 }, + { 0x13001f92, 0x14000008 }, + { 0x13001f93, 0x14000008 }, + { 0x13001f94, 0x14000008 }, + { 0x13001f95, 0x14000008 }, + { 0x13001f96, 0x14000008 }, + { 0x13001f97, 0x14000008 }, + { 0x13001f98, 0x2000fff8 }, + { 0x13001f99, 0x2000fff8 }, + { 0x13001f9a, 0x2000fff8 }, + { 0x13001f9b, 0x2000fff8 }, + { 0x13001f9c, 0x2000fff8 }, + { 0x13001f9d, 0x2000fff8 }, + { 0x13001f9e, 0x2000fff8 }, + { 0x13001f9f, 0x2000fff8 }, + { 0x13001fa0, 0x14000008 }, + { 0x13001fa1, 0x14000008 }, + { 0x13001fa2, 0x14000008 }, + { 0x13001fa3, 0x14000008 }, + { 0x13001fa4, 0x14000008 }, + { 0x13001fa5, 0x14000008 }, + { 0x13001fa6, 0x14000008 }, + { 0x13001fa7, 0x14000008 }, + { 0x13001fa8, 0x2000fff8 }, + { 0x13001fa9, 0x2000fff8 }, + { 0x13001faa, 0x2000fff8 }, + { 0x13001fab, 0x2000fff8 }, + { 0x13001fac, 0x2000fff8 }, + { 0x13001fad, 0x2000fff8 }, + { 0x13001fae, 0x2000fff8 }, + { 0x13001faf, 0x2000fff8 }, + { 0x13001fb0, 0x14000008 }, + { 0x13001fb1, 0x14000008 }, + { 0x13001fb2, 0x14000000 }, + { 0x13001fb3, 0x14000009 }, + { 0x13001fb4, 0x14000000 }, + { 0x13801fb6, 0x14000001 }, + { 0x13001fb8, 0x2400fff8 }, + { 0x13001fb9, 0x2400fff8 }, + { 0x13001fba, 0x2400ffb6 }, + { 0x13001fbb, 0x2400ffb6 }, + { 0x13001fbc, 0x2000fff7 }, + { 0x13001fbd, 0x60000000 }, + { 0x13001fbe, 0x1400e3db }, + { 0x13801fbf, 0x60000002 }, + { 0x13001fc2, 0x14000000 }, + { 0x13001fc3, 0x14000009 }, + { 0x13001fc4, 0x14000000 }, + { 0x13801fc6, 0x14000001 }, + { 0x13001fc8, 0x2400ffaa }, + { 0x13001fc9, 0x2400ffaa }, + { 0x13001fca, 0x2400ffaa }, + { 0x13001fcb, 0x2400ffaa }, + { 0x13001fcc, 0x2000fff7 }, + { 0x13801fcd, 0x60000002 }, + { 0x13001fd0, 0x14000008 }, + { 0x13001fd1, 0x14000008 }, + { 0x13801fd2, 0x14000001 }, + { 0x13801fd6, 0x14000001 }, + { 0x13001fd8, 0x2400fff8 }, + { 0x13001fd9, 0x2400fff8 }, + { 0x13001fda, 0x2400ff9c }, + { 0x13001fdb, 0x2400ff9c }, + { 0x13801fdd, 0x60000002 }, + { 0x13001fe0, 0x14000008 }, + { 0x13001fe1, 0x14000008 }, + { 0x13801fe2, 0x14000002 }, + { 0x13001fe5, 0x14000007 }, + { 0x13801fe6, 0x14000001 }, + { 0x13001fe8, 0x2400fff8 }, + { 0x13001fe9, 0x2400fff8 }, + { 0x13001fea, 0x2400ff90 }, + { 0x13001feb, 0x2400ff90 }, + { 0x13001fec, 0x2400fff9 }, + { 0x13801fed, 0x60000002 }, + { 0x13001ff2, 0x14000000 }, + { 0x13001ff3, 0x14000009 }, + { 0x13001ff4, 0x14000000 }, + { 0x13801ff6, 0x14000001 }, + { 0x13001ff8, 0x2400ff80 }, + { 0x13001ff9, 0x2400ff80 }, + { 0x13001ffa, 0x2400ff82 }, + { 0x13001ffb, 0x2400ff82 }, + { 0x13001ffc, 0x2000fff7 }, + { 0x13801ffd, 0x60000001 }, + { 0x09802000, 0x7400000a }, + { 0x0980200b, 0x04000004 }, + { 0x09802010, 0x44000005 }, + { 0x09802016, 0x54000001 }, + { 0x09002018, 0x50000000 }, + { 0x09002019, 0x4c000000 }, + { 0x0900201a, 0x58000000 }, + { 0x0980201b, 0x50000001 }, + { 0x0900201d, 0x4c000000 }, + { 0x0900201e, 0x58000000 }, + { 0x0900201f, 0x50000000 }, + { 0x09802020, 0x54000007 }, + { 0x09002028, 0x6c000000 }, + { 0x09002029, 0x70000000 }, + { 0x0980202a, 0x04000004 }, + { 0x0900202f, 0x74000000 }, + { 0x09802030, 0x54000008 }, + { 0x09002039, 0x50000000 }, + { 0x0900203a, 0x4c000000 }, + { 0x0980203b, 0x54000003 }, + { 0x0980203f, 0x40000001 }, + { 0x09802041, 0x54000002 }, + { 0x09002044, 0x64000000 }, + { 0x09002045, 0x58000000 }, + { 0x09002046, 0x48000000 }, + { 0x09802047, 0x5400000a }, + { 0x09002052, 0x64000000 }, + { 0x09002053, 0x54000000 }, + { 0x09002054, 0x40000000 }, + { 0x09802055, 0x54000009 }, + { 0x0900205f, 0x74000000 }, + { 0x09802060, 0x04000003 }, + { 0x0980206a, 0x04000005 }, + { 0x09002070, 0x3c000000 }, + { 0x21002071, 0x14000000 }, + { 0x09802074, 0x3c000005 }, + { 0x0980207a, 0x64000002 }, + { 0x0900207d, 0x58000000 }, + { 0x0900207e, 0x48000000 }, + { 0x2100207f, 0x14000000 }, + { 0x09802080, 0x3c000009 }, + { 0x0980208a, 0x64000002 }, + { 0x0900208d, 0x58000000 }, + { 0x0900208e, 0x48000000 }, + { 0x21802090, 0x18000004 }, + { 0x098020a0, 0x5c000015 }, + { 0x1b8020d0, 0x3000000c }, + { 0x1b8020dd, 0x2c000003 }, + { 0x1b0020e1, 0x30000000 }, + { 0x1b8020e2, 0x2c000002 }, + { 0x1b8020e5, 0x30000006 }, + { 0x09802100, 0x68000001 }, + { 0x09002102, 0x24000000 }, + { 0x09802103, 0x68000003 }, + { 0x09002107, 0x24000000 }, + { 0x09802108, 0x68000001 }, + { 0x0900210a, 0x14000000 }, + { 0x0980210b, 0x24000002 }, + { 0x0980210e, 0x14000001 }, + { 0x09802110, 0x24000002 }, + { 0x09002113, 0x14000000 }, + { 0x09002114, 0x68000000 }, + { 0x09002115, 0x24000000 }, + { 0x09802116, 0x68000002 }, + { 0x09802119, 0x24000004 }, + { 0x0980211e, 0x68000005 }, + { 0x09002124, 0x24000000 }, + { 0x09002125, 0x68000000 }, + { 0x13002126, 0x2400e2a3 }, + { 0x09002127, 0x68000000 }, + { 0x09002128, 0x24000000 }, + { 0x09002129, 0x68000000 }, + { 0x2100212a, 0x2400df41 }, + { 0x2100212b, 0x2400dfba }, + { 0x0980212c, 0x24000001 }, + { 0x0900212e, 0x68000000 }, + { 0x0900212f, 0x14000000 }, + { 0x09802130, 0x24000001 }, + { 0x09002132, 0x68000000 }, + { 0x09002133, 0x24000000 }, + { 0x09002134, 0x14000000 }, + { 0x09802135, 0x1c000003 }, + { 0x09002139, 0x14000000 }, + { 0x0980213a, 0x68000001 }, + { 0x0980213c, 0x14000001 }, + { 0x0980213e, 0x24000001 }, + { 0x09802140, 0x64000004 }, + { 0x09002145, 0x24000000 }, + { 0x09802146, 0x14000003 }, + { 0x0900214a, 0x68000000 }, + { 0x0900214b, 0x64000000 }, + { 0x0900214c, 0x68000000 }, + { 0x09802153, 0x3c00000c }, + { 0x09002160, 0x38000010 }, + { 0x09002161, 0x38000010 }, + { 0x09002162, 0x38000010 }, + { 0x09002163, 0x38000010 }, + { 0x09002164, 0x38000010 }, + { 0x09002165, 0x38000010 }, + { 0x09002166, 0x38000010 }, + { 0x09002167, 0x38000010 }, + { 0x09002168, 0x38000010 }, + { 0x09002169, 0x38000010 }, + { 0x0900216a, 0x38000010 }, + { 0x0900216b, 0x38000010 }, + { 0x0900216c, 0x38000010 }, + { 0x0900216d, 0x38000010 }, + { 0x0900216e, 0x38000010 }, + { 0x0900216f, 0x38000010 }, + { 0x09002170, 0x3800fff0 }, + { 0x09002171, 0x3800fff0 }, + { 0x09002172, 0x3800fff0 }, + { 0x09002173, 0x3800fff0 }, + { 0x09002174, 0x3800fff0 }, + { 0x09002175, 0x3800fff0 }, + { 0x09002176, 0x3800fff0 }, + { 0x09002177, 0x3800fff0 }, + { 0x09002178, 0x3800fff0 }, + { 0x09002179, 0x3800fff0 }, + { 0x0900217a, 0x3800fff0 }, + { 0x0900217b, 0x3800fff0 }, + { 0x0900217c, 0x3800fff0 }, + { 0x0900217d, 0x3800fff0 }, + { 0x0900217e, 0x3800fff0 }, + { 0x0900217f, 0x3800fff0 }, + { 0x09802180, 0x38000003 }, + { 0x09802190, 0x64000004 }, + { 0x09802195, 0x68000004 }, + { 0x0980219a, 0x64000001 }, + { 0x0980219c, 0x68000003 }, + { 0x090021a0, 0x64000000 }, + { 0x098021a1, 0x68000001 }, + { 0x090021a3, 0x64000000 }, + { 0x098021a4, 0x68000001 }, + { 0x090021a6, 0x64000000 }, + { 0x098021a7, 0x68000006 }, + { 0x090021ae, 0x64000000 }, + { 0x098021af, 0x6800001e }, + { 0x098021ce, 0x64000001 }, + { 0x098021d0, 0x68000001 }, + { 0x090021d2, 0x64000000 }, + { 0x090021d3, 0x68000000 }, + { 0x090021d4, 0x64000000 }, + { 0x098021d5, 0x6800001e }, + { 0x098021f4, 0x6400010b }, + { 0x09802300, 0x68000007 }, + { 0x09802308, 0x64000003 }, + { 0x0980230c, 0x68000013 }, + { 0x09802320, 0x64000001 }, + { 0x09802322, 0x68000006 }, + { 0x09002329, 0x58000000 }, + { 0x0900232a, 0x48000000 }, + { 0x0980232b, 0x68000050 }, + { 0x0900237c, 0x64000000 }, + { 0x0980237d, 0x6800001d }, + { 0x0980239b, 0x64000018 }, + { 0x090023b4, 0x58000000 }, + { 0x090023b5, 0x48000000 }, + { 0x090023b6, 0x54000000 }, + { 0x098023b7, 0x68000024 }, + { 0x09802400, 0x68000026 }, + { 0x09802440, 0x6800000a }, + { 0x09802460, 0x3c00003b }, + { 0x0980249c, 0x68000019 }, + { 0x090024b6, 0x6800001a }, + { 0x090024b7, 0x6800001a }, + { 0x090024b8, 0x6800001a }, + { 0x090024b9, 0x6800001a }, + { 0x090024ba, 0x6800001a }, + { 0x090024bb, 0x6800001a }, + { 0x090024bc, 0x6800001a }, + { 0x090024bd, 0x6800001a }, + { 0x090024be, 0x6800001a }, + { 0x090024bf, 0x6800001a }, + { 0x090024c0, 0x6800001a }, + { 0x090024c1, 0x6800001a }, + { 0x090024c2, 0x6800001a }, + { 0x090024c3, 0x6800001a }, + { 0x090024c4, 0x6800001a }, + { 0x090024c5, 0x6800001a }, + { 0x090024c6, 0x6800001a }, + { 0x090024c7, 0x6800001a }, + { 0x090024c8, 0x6800001a }, + { 0x090024c9, 0x6800001a }, + { 0x090024ca, 0x6800001a }, + { 0x090024cb, 0x6800001a }, + { 0x090024cc, 0x6800001a }, + { 0x090024cd, 0x6800001a }, + { 0x090024ce, 0x6800001a }, + { 0x090024cf, 0x6800001a }, + { 0x090024d0, 0x6800ffe6 }, + { 0x090024d1, 0x6800ffe6 }, + { 0x090024d2, 0x6800ffe6 }, + { 0x090024d3, 0x6800ffe6 }, + { 0x090024d4, 0x6800ffe6 }, + { 0x090024d5, 0x6800ffe6 }, + { 0x090024d6, 0x6800ffe6 }, + { 0x090024d7, 0x6800ffe6 }, + { 0x090024d8, 0x6800ffe6 }, + { 0x090024d9, 0x6800ffe6 }, + { 0x090024da, 0x6800ffe6 }, + { 0x090024db, 0x6800ffe6 }, + { 0x090024dc, 0x6800ffe6 }, + { 0x090024dd, 0x6800ffe6 }, + { 0x090024de, 0x6800ffe6 }, + { 0x090024df, 0x6800ffe6 }, + { 0x090024e0, 0x6800ffe6 }, + { 0x090024e1, 0x6800ffe6 }, + { 0x090024e2, 0x6800ffe6 }, + { 0x090024e3, 0x6800ffe6 }, + { 0x090024e4, 0x6800ffe6 }, + { 0x090024e5, 0x6800ffe6 }, + { 0x090024e6, 0x6800ffe6 }, + { 0x090024e7, 0x6800ffe6 }, + { 0x090024e8, 0x6800ffe6 }, + { 0x090024e9, 0x6800ffe6 }, + { 0x098024ea, 0x3c000015 }, + { 0x09802500, 0x680000b6 }, + { 0x090025b7, 0x64000000 }, + { 0x098025b8, 0x68000008 }, + { 0x090025c1, 0x64000000 }, + { 0x098025c2, 0x68000035 }, + { 0x098025f8, 0x64000007 }, + { 0x09802600, 0x6800006e }, + { 0x0900266f, 0x64000000 }, + { 0x09802670, 0x6800002c }, + { 0x098026a0, 0x68000011 }, + { 0x09802701, 0x68000003 }, + { 0x09802706, 0x68000003 }, + { 0x0980270c, 0x6800001b }, + { 0x09802729, 0x68000022 }, + { 0x0900274d, 0x68000000 }, + { 0x0980274f, 0x68000003 }, + { 0x09002756, 0x68000000 }, + { 0x09802758, 0x68000006 }, + { 0x09802761, 0x68000006 }, + { 0x09002768, 0x58000000 }, + { 0x09002769, 0x48000000 }, + { 0x0900276a, 0x58000000 }, + { 0x0900276b, 0x48000000 }, + { 0x0900276c, 0x58000000 }, + { 0x0900276d, 0x48000000 }, + { 0x0900276e, 0x58000000 }, + { 0x0900276f, 0x48000000 }, + { 0x09002770, 0x58000000 }, + { 0x09002771, 0x48000000 }, + { 0x09002772, 0x58000000 }, + { 0x09002773, 0x48000000 }, + { 0x09002774, 0x58000000 }, + { 0x09002775, 0x48000000 }, + { 0x09802776, 0x3c00001d }, + { 0x09002794, 0x68000000 }, + { 0x09802798, 0x68000017 }, + { 0x098027b1, 0x6800000d }, + { 0x098027c0, 0x64000004 }, + { 0x090027c5, 0x58000000 }, + { 0x090027c6, 0x48000000 }, + { 0x098027d0, 0x64000015 }, + { 0x090027e6, 0x58000000 }, + { 0x090027e7, 0x48000000 }, + { 0x090027e8, 0x58000000 }, + { 0x090027e9, 0x48000000 }, + { 0x090027ea, 0x58000000 }, + { 0x090027eb, 0x48000000 }, + { 0x098027f0, 0x6400000f }, + { 0x04802800, 0x680000ff }, + { 0x09802900, 0x64000082 }, + { 0x09002983, 0x58000000 }, + { 0x09002984, 0x48000000 }, + { 0x09002985, 0x58000000 }, + { 0x09002986, 0x48000000 }, + { 0x09002987, 0x58000000 }, + { 0x09002988, 0x48000000 }, + { 0x09002989, 0x58000000 }, + { 0x0900298a, 0x48000000 }, + { 0x0900298b, 0x58000000 }, + { 0x0900298c, 0x48000000 }, + { 0x0900298d, 0x58000000 }, + { 0x0900298e, 0x48000000 }, + { 0x0900298f, 0x58000000 }, + { 0x09002990, 0x48000000 }, + { 0x09002991, 0x58000000 }, + { 0x09002992, 0x48000000 }, + { 0x09002993, 0x58000000 }, + { 0x09002994, 0x48000000 }, + { 0x09002995, 0x58000000 }, + { 0x09002996, 0x48000000 }, + { 0x09002997, 0x58000000 }, + { 0x09002998, 0x48000000 }, + { 0x09802999, 0x6400003e }, + { 0x090029d8, 0x58000000 }, + { 0x090029d9, 0x48000000 }, + { 0x090029da, 0x58000000 }, + { 0x090029db, 0x48000000 }, + { 0x098029dc, 0x6400001f }, + { 0x090029fc, 0x58000000 }, + { 0x090029fd, 0x48000000 }, + { 0x098029fe, 0x64000101 }, + { 0x09802b00, 0x68000013 }, + { 0x11002c00, 0x24000030 }, + { 0x11002c01, 0x24000030 }, + { 0x11002c02, 0x24000030 }, + { 0x11002c03, 0x24000030 }, + { 0x11002c04, 0x24000030 }, + { 0x11002c05, 0x24000030 }, + { 0x11002c06, 0x24000030 }, + { 0x11002c07, 0x24000030 }, + { 0x11002c08, 0x24000030 }, + { 0x11002c09, 0x24000030 }, + { 0x11002c0a, 0x24000030 }, + { 0x11002c0b, 0x24000030 }, + { 0x11002c0c, 0x24000030 }, + { 0x11002c0d, 0x24000030 }, + { 0x11002c0e, 0x24000030 }, + { 0x11002c0f, 0x24000030 }, + { 0x11002c10, 0x24000030 }, + { 0x11002c11, 0x24000030 }, + { 0x11002c12, 0x24000030 }, + { 0x11002c13, 0x24000030 }, + { 0x11002c14, 0x24000030 }, + { 0x11002c15, 0x24000030 }, + { 0x11002c16, 0x24000030 }, + { 0x11002c17, 0x24000030 }, + { 0x11002c18, 0x24000030 }, + { 0x11002c19, 0x24000030 }, + { 0x11002c1a, 0x24000030 }, + { 0x11002c1b, 0x24000030 }, + { 0x11002c1c, 0x24000030 }, + { 0x11002c1d, 0x24000030 }, + { 0x11002c1e, 0x24000030 }, + { 0x11002c1f, 0x24000030 }, + { 0x11002c20, 0x24000030 }, + { 0x11002c21, 0x24000030 }, + { 0x11002c22, 0x24000030 }, + { 0x11002c23, 0x24000030 }, + { 0x11002c24, 0x24000030 }, + { 0x11002c25, 0x24000030 }, + { 0x11002c26, 0x24000030 }, + { 0x11002c27, 0x24000030 }, + { 0x11002c28, 0x24000030 }, + { 0x11002c29, 0x24000030 }, + { 0x11002c2a, 0x24000030 }, + { 0x11002c2b, 0x24000030 }, + { 0x11002c2c, 0x24000030 }, + { 0x11002c2d, 0x24000030 }, + { 0x11002c2e, 0x24000030 }, + { 0x11002c30, 0x1400ffd0 }, + { 0x11002c31, 0x1400ffd0 }, + { 0x11002c32, 0x1400ffd0 }, + { 0x11002c33, 0x1400ffd0 }, + { 0x11002c34, 0x1400ffd0 }, + { 0x11002c35, 0x1400ffd0 }, + { 0x11002c36, 0x1400ffd0 }, + { 0x11002c37, 0x1400ffd0 }, + { 0x11002c38, 0x1400ffd0 }, + { 0x11002c39, 0x1400ffd0 }, + { 0x11002c3a, 0x1400ffd0 }, + { 0x11002c3b, 0x1400ffd0 }, + { 0x11002c3c, 0x1400ffd0 }, + { 0x11002c3d, 0x1400ffd0 }, + { 0x11002c3e, 0x1400ffd0 }, + { 0x11002c3f, 0x1400ffd0 }, + { 0x11002c40, 0x1400ffd0 }, + { 0x11002c41, 0x1400ffd0 }, + { 0x11002c42, 0x1400ffd0 }, + { 0x11002c43, 0x1400ffd0 }, + { 0x11002c44, 0x1400ffd0 }, + { 0x11002c45, 0x1400ffd0 }, + { 0x11002c46, 0x1400ffd0 }, + { 0x11002c47, 0x1400ffd0 }, + { 0x11002c48, 0x1400ffd0 }, + { 0x11002c49, 0x1400ffd0 }, + { 0x11002c4a, 0x1400ffd0 }, + { 0x11002c4b, 0x1400ffd0 }, + { 0x11002c4c, 0x1400ffd0 }, + { 0x11002c4d, 0x1400ffd0 }, + { 0x11002c4e, 0x1400ffd0 }, + { 0x11002c4f, 0x1400ffd0 }, + { 0x11002c50, 0x1400ffd0 }, + { 0x11002c51, 0x1400ffd0 }, + { 0x11002c52, 0x1400ffd0 }, + { 0x11002c53, 0x1400ffd0 }, + { 0x11002c54, 0x1400ffd0 }, + { 0x11002c55, 0x1400ffd0 }, + { 0x11002c56, 0x1400ffd0 }, + { 0x11002c57, 0x1400ffd0 }, + { 0x11002c58, 0x1400ffd0 }, + { 0x11002c59, 0x1400ffd0 }, + { 0x11002c5a, 0x1400ffd0 }, + { 0x11002c5b, 0x1400ffd0 }, + { 0x11002c5c, 0x1400ffd0 }, + { 0x11002c5d, 0x1400ffd0 }, + { 0x11002c5e, 0x1400ffd0 }, + { 0x0a002c80, 0x24000001 }, + { 0x0a002c81, 0x1400ffff }, + { 0x0a002c82, 0x24000001 }, + { 0x0a002c83, 0x1400ffff }, + { 0x0a002c84, 0x24000001 }, + { 0x0a002c85, 0x1400ffff }, + { 0x0a002c86, 0x24000001 }, + { 0x0a002c87, 0x1400ffff }, + { 0x0a002c88, 0x24000001 }, + { 0x0a002c89, 0x1400ffff }, + { 0x0a002c8a, 0x24000001 }, + { 0x0a002c8b, 0x1400ffff }, + { 0x0a002c8c, 0x24000001 }, + { 0x0a002c8d, 0x1400ffff }, + { 0x0a002c8e, 0x24000001 }, + { 0x0a002c8f, 0x1400ffff }, + { 0x0a002c90, 0x24000001 }, + { 0x0a002c91, 0x1400ffff }, + { 0x0a002c92, 0x24000001 }, + { 0x0a002c93, 0x1400ffff }, + { 0x0a002c94, 0x24000001 }, + { 0x0a002c95, 0x1400ffff }, + { 0x0a002c96, 0x24000001 }, + { 0x0a002c97, 0x1400ffff }, + { 0x0a002c98, 0x24000001 }, + { 0x0a002c99, 0x1400ffff }, + { 0x0a002c9a, 0x24000001 }, + { 0x0a002c9b, 0x1400ffff }, + { 0x0a002c9c, 0x24000001 }, + { 0x0a002c9d, 0x1400ffff }, + { 0x0a002c9e, 0x24000001 }, + { 0x0a002c9f, 0x1400ffff }, + { 0x0a002ca0, 0x24000001 }, + { 0x0a002ca1, 0x1400ffff }, + { 0x0a002ca2, 0x24000001 }, + { 0x0a002ca3, 0x1400ffff }, + { 0x0a002ca4, 0x24000001 }, + { 0x0a002ca5, 0x1400ffff }, + { 0x0a002ca6, 0x24000001 }, + { 0x0a002ca7, 0x1400ffff }, + { 0x0a002ca8, 0x24000001 }, + { 0x0a002ca9, 0x1400ffff }, + { 0x0a002caa, 0x24000001 }, + { 0x0a002cab, 0x1400ffff }, + { 0x0a002cac, 0x24000001 }, + { 0x0a002cad, 0x1400ffff }, + { 0x0a002cae, 0x24000001 }, + { 0x0a002caf, 0x1400ffff }, + { 0x0a002cb0, 0x24000001 }, + { 0x0a002cb1, 0x1400ffff }, + { 0x0a002cb2, 0x24000001 }, + { 0x0a002cb3, 0x1400ffff }, + { 0x0a002cb4, 0x24000001 }, + { 0x0a002cb5, 0x1400ffff }, + { 0x0a002cb6, 0x24000001 }, + { 0x0a002cb7, 0x1400ffff }, + { 0x0a002cb8, 0x24000001 }, + { 0x0a002cb9, 0x1400ffff }, + { 0x0a002cba, 0x24000001 }, + { 0x0a002cbb, 0x1400ffff }, + { 0x0a002cbc, 0x24000001 }, + { 0x0a002cbd, 0x1400ffff }, + { 0x0a002cbe, 0x24000001 }, + { 0x0a002cbf, 0x1400ffff }, + { 0x0a002cc0, 0x24000001 }, + { 0x0a002cc1, 0x1400ffff }, + { 0x0a002cc2, 0x24000001 }, + { 0x0a002cc3, 0x1400ffff }, + { 0x0a002cc4, 0x24000001 }, + { 0x0a002cc5, 0x1400ffff }, + { 0x0a002cc6, 0x24000001 }, + { 0x0a002cc7, 0x1400ffff }, + { 0x0a002cc8, 0x24000001 }, + { 0x0a002cc9, 0x1400ffff }, + { 0x0a002cca, 0x24000001 }, + { 0x0a002ccb, 0x1400ffff }, + { 0x0a002ccc, 0x24000001 }, + { 0x0a002ccd, 0x1400ffff }, + { 0x0a002cce, 0x24000001 }, + { 0x0a002ccf, 0x1400ffff }, + { 0x0a002cd0, 0x24000001 }, + { 0x0a002cd1, 0x1400ffff }, + { 0x0a002cd2, 0x24000001 }, + { 0x0a002cd3, 0x1400ffff }, + { 0x0a002cd4, 0x24000001 }, + { 0x0a002cd5, 0x1400ffff }, + { 0x0a002cd6, 0x24000001 }, + { 0x0a002cd7, 0x1400ffff }, + { 0x0a002cd8, 0x24000001 }, + { 0x0a002cd9, 0x1400ffff }, + { 0x0a002cda, 0x24000001 }, + { 0x0a002cdb, 0x1400ffff }, + { 0x0a002cdc, 0x24000001 }, + { 0x0a002cdd, 0x1400ffff }, + { 0x0a002cde, 0x24000001 }, + { 0x0a002cdf, 0x1400ffff }, + { 0x0a002ce0, 0x24000001 }, + { 0x0a002ce1, 0x1400ffff }, + { 0x0a002ce2, 0x24000001 }, + { 0x0a002ce3, 0x1400ffff }, + { 0x0a002ce4, 0x14000000 }, + { 0x0a802ce5, 0x68000005 }, + { 0x0a802cf9, 0x54000003 }, + { 0x0a002cfd, 0x3c000000 }, + { 0x0a802cfe, 0x54000001 }, + { 0x10002d00, 0x1400e3a0 }, + { 0x10002d01, 0x1400e3a0 }, + { 0x10002d02, 0x1400e3a0 }, + { 0x10002d03, 0x1400e3a0 }, + { 0x10002d04, 0x1400e3a0 }, + { 0x10002d05, 0x1400e3a0 }, + { 0x10002d06, 0x1400e3a0 }, + { 0x10002d07, 0x1400e3a0 }, + { 0x10002d08, 0x1400e3a0 }, + { 0x10002d09, 0x1400e3a0 }, + { 0x10002d0a, 0x1400e3a0 }, + { 0x10002d0b, 0x1400e3a0 }, + { 0x10002d0c, 0x1400e3a0 }, + { 0x10002d0d, 0x1400e3a0 }, + { 0x10002d0e, 0x1400e3a0 }, + { 0x10002d0f, 0x1400e3a0 }, + { 0x10002d10, 0x1400e3a0 }, + { 0x10002d11, 0x1400e3a0 }, + { 0x10002d12, 0x1400e3a0 }, + { 0x10002d13, 0x1400e3a0 }, + { 0x10002d14, 0x1400e3a0 }, + { 0x10002d15, 0x1400e3a0 }, + { 0x10002d16, 0x1400e3a0 }, + { 0x10002d17, 0x1400e3a0 }, + { 0x10002d18, 0x1400e3a0 }, + { 0x10002d19, 0x1400e3a0 }, + { 0x10002d1a, 0x1400e3a0 }, + { 0x10002d1b, 0x1400e3a0 }, + { 0x10002d1c, 0x1400e3a0 }, + { 0x10002d1d, 0x1400e3a0 }, + { 0x10002d1e, 0x1400e3a0 }, + { 0x10002d1f, 0x1400e3a0 }, + { 0x10002d20, 0x1400e3a0 }, + { 0x10002d21, 0x1400e3a0 }, + { 0x10002d22, 0x1400e3a0 }, + { 0x10002d23, 0x1400e3a0 }, + { 0x10002d24, 0x1400e3a0 }, + { 0x10002d25, 0x1400e3a0 }, + { 0x3a802d30, 0x1c000035 }, + { 0x3a002d6f, 0x18000000 }, + { 0x0f802d80, 0x1c000016 }, + { 0x0f802da0, 0x1c000006 }, + { 0x0f802da8, 0x1c000006 }, + { 0x0f802db0, 0x1c000006 }, + { 0x0f802db8, 0x1c000006 }, + { 0x0f802dc0, 0x1c000006 }, + { 0x0f802dc8, 0x1c000006 }, + { 0x0f802dd0, 0x1c000006 }, + { 0x0f802dd8, 0x1c000006 }, + { 0x09802e00, 0x54000001 }, + { 0x09002e02, 0x50000000 }, + { 0x09002e03, 0x4c000000 }, + { 0x09002e04, 0x50000000 }, + { 0x09002e05, 0x4c000000 }, + { 0x09802e06, 0x54000002 }, + { 0x09002e09, 0x50000000 }, + { 0x09002e0a, 0x4c000000 }, + { 0x09002e0b, 0x54000000 }, + { 0x09002e0c, 0x50000000 }, + { 0x09002e0d, 0x4c000000 }, + { 0x09802e0e, 0x54000008 }, + { 0x09002e17, 0x44000000 }, + { 0x09002e1c, 0x50000000 }, + { 0x09002e1d, 0x4c000000 }, + { 0x16802e80, 0x68000019 }, + { 0x16802e9b, 0x68000058 }, + { 0x16802f00, 0x680000d5 }, + { 0x09802ff0, 0x6800000b }, + { 0x09003000, 0x74000000 }, + { 0x09803001, 0x54000002 }, + { 0x09003004, 0x68000000 }, + { 0x16003005, 0x18000000 }, + { 0x09003006, 0x1c000000 }, + { 0x16003007, 0x38000000 }, + { 0x09003008, 0x58000000 }, + { 0x09003009, 0x48000000 }, + { 0x0900300a, 0x58000000 }, + { 0x0900300b, 0x48000000 }, + { 0x0900300c, 0x58000000 }, + { 0x0900300d, 0x48000000 }, + { 0x0900300e, 0x58000000 }, + { 0x0900300f, 0x48000000 }, + { 0x09003010, 0x58000000 }, + { 0x09003011, 0x48000000 }, + { 0x09803012, 0x68000001 }, + { 0x09003014, 0x58000000 }, + { 0x09003015, 0x48000000 }, + { 0x09003016, 0x58000000 }, + { 0x09003017, 0x48000000 }, + { 0x09003018, 0x58000000 }, + { 0x09003019, 0x48000000 }, + { 0x0900301a, 0x58000000 }, + { 0x0900301b, 0x48000000 }, + { 0x0900301c, 0x44000000 }, + { 0x0900301d, 0x58000000 }, + { 0x0980301e, 0x48000001 }, + { 0x09003020, 0x68000000 }, + { 0x16803021, 0x38000008 }, + { 0x1b80302a, 0x30000005 }, + { 0x09003030, 0x44000000 }, + { 0x09803031, 0x18000004 }, + { 0x09803036, 0x68000001 }, + { 0x16803038, 0x38000002 }, + { 0x1600303b, 0x18000000 }, + { 0x0900303c, 0x1c000000 }, + { 0x0900303d, 0x54000000 }, + { 0x0980303e, 0x68000001 }, + { 0x1a803041, 0x1c000055 }, + { 0x1b803099, 0x30000001 }, + { 0x0980309b, 0x60000001 }, + { 0x1a80309d, 0x18000001 }, + { 0x1a00309f, 0x1c000000 }, + { 0x090030a0, 0x44000000 }, + { 0x1d8030a1, 0x1c000059 }, + { 0x090030fb, 0x54000000 }, + { 0x098030fc, 0x18000002 }, + { 0x1d0030ff, 0x1c000000 }, + { 0x03803105, 0x1c000027 }, + { 0x17803131, 0x1c00005d }, + { 0x09803190, 0x68000001 }, + { 0x09803192, 0x3c000003 }, + { 0x09803196, 0x68000009 }, + { 0x038031a0, 0x1c000017 }, + { 0x098031c0, 0x6800000f }, + { 0x1d8031f0, 0x1c00000f }, + { 0x17803200, 0x6800001e }, + { 0x09803220, 0x3c000009 }, + { 0x0980322a, 0x68000019 }, + { 0x09003250, 0x68000000 }, + { 0x09803251, 0x3c00000e }, + { 0x17803260, 0x6800001f }, + { 0x09803280, 0x3c000009 }, + { 0x0980328a, 0x68000026 }, + { 0x098032b1, 0x3c00000e }, + { 0x098032c0, 0x6800003e }, + { 0x09803300, 0x680000ff }, + { 0x16803400, 0x1c0019b5 }, + { 0x09804dc0, 0x6800003f }, + { 0x16804e00, 0x1c0051bb }, + { 0x3c80a000, 0x1c000014 }, + { 0x3c00a015, 0x18000000 }, + { 0x3c80a016, 0x1c000476 }, + { 0x3c80a490, 0x68000036 }, + { 0x0980a700, 0x60000016 }, + { 0x3080a800, 0x1c000001 }, + { 0x3000a802, 0x28000000 }, + { 0x3080a803, 0x1c000002 }, + { 0x3000a806, 0x30000000 }, + { 0x3080a807, 0x1c000003 }, + { 0x3000a80b, 0x30000000 }, + { 0x3080a80c, 0x1c000016 }, + { 0x3080a823, 0x28000001 }, + { 0x3080a825, 0x30000001 }, + { 0x3000a827, 0x28000000 }, + { 0x3080a828, 0x68000003 }, + { 0x1780ac00, 0x1c002ba3 }, + { 0x0980d800, 0x1000037f }, + { 0x0980db80, 0x1000007f }, + { 0x0980dc00, 0x100003ff }, + { 0x0980e000, 0x0c0018ff }, + { 0x1680f900, 0x1c00012d }, + { 0x1680fa30, 0x1c00003a }, + { 0x1680fa70, 0x1c000069 }, + { 0x2180fb00, 0x14000006 }, + { 0x0180fb13, 0x14000004 }, + { 0x1900fb1d, 0x1c000000 }, + { 0x1900fb1e, 0x30000000 }, + { 0x1980fb1f, 0x1c000009 }, + { 0x1900fb29, 0x64000000 }, + { 0x1980fb2a, 0x1c00000c }, + { 0x1980fb38, 0x1c000004 }, + { 0x1900fb3e, 0x1c000000 }, + { 0x1980fb40, 0x1c000001 }, + { 0x1980fb43, 0x1c000001 }, + { 0x1980fb46, 0x1c00006b }, + { 0x0080fbd3, 0x1c00016a }, + { 0x0900fd3e, 0x58000000 }, + { 0x0900fd3f, 0x48000000 }, + { 0x0080fd50, 0x1c00003f }, + { 0x0080fd92, 0x1c000035 }, + { 0x0080fdf0, 0x1c00000b }, + { 0x0000fdfc, 0x5c000000 }, + { 0x0900fdfd, 0x68000000 }, + { 0x1b80fe00, 0x3000000f }, + { 0x0980fe10, 0x54000006 }, + { 0x0900fe17, 0x58000000 }, + { 0x0900fe18, 0x48000000 }, + { 0x0900fe19, 0x54000000 }, + { 0x1b80fe20, 0x30000003 }, + { 0x0900fe30, 0x54000000 }, + { 0x0980fe31, 0x44000001 }, + { 0x0980fe33, 0x40000001 }, + { 0x0900fe35, 0x58000000 }, + { 0x0900fe36, 0x48000000 }, + { 0x0900fe37, 0x58000000 }, + { 0x0900fe38, 0x48000000 }, + { 0x0900fe39, 0x58000000 }, + { 0x0900fe3a, 0x48000000 }, + { 0x0900fe3b, 0x58000000 }, + { 0x0900fe3c, 0x48000000 }, + { 0x0900fe3d, 0x58000000 }, + { 0x0900fe3e, 0x48000000 }, + { 0x0900fe3f, 0x58000000 }, + { 0x0900fe40, 0x48000000 }, + { 0x0900fe41, 0x58000000 }, + { 0x0900fe42, 0x48000000 }, + { 0x0900fe43, 0x58000000 }, + { 0x0900fe44, 0x48000000 }, + { 0x0980fe45, 0x54000001 }, + { 0x0900fe47, 0x58000000 }, + { 0x0900fe48, 0x48000000 }, + { 0x0980fe49, 0x54000003 }, + { 0x0980fe4d, 0x40000002 }, + { 0x0980fe50, 0x54000002 }, + { 0x0980fe54, 0x54000003 }, + { 0x0900fe58, 0x44000000 }, + { 0x0900fe59, 0x58000000 }, + { 0x0900fe5a, 0x48000000 }, + { 0x0900fe5b, 0x58000000 }, + { 0x0900fe5c, 0x48000000 }, + { 0x0900fe5d, 0x58000000 }, + { 0x0900fe5e, 0x48000000 }, + { 0x0980fe5f, 0x54000002 }, + { 0x0900fe62, 0x64000000 }, + { 0x0900fe63, 0x44000000 }, + { 0x0980fe64, 0x64000002 }, + { 0x0900fe68, 0x54000000 }, + { 0x0900fe69, 0x5c000000 }, + { 0x0980fe6a, 0x54000001 }, + { 0x0080fe70, 0x1c000004 }, + { 0x0080fe76, 0x1c000086 }, + { 0x0900feff, 0x04000000 }, + { 0x0980ff01, 0x54000002 }, + { 0x0900ff04, 0x5c000000 }, + { 0x0980ff05, 0x54000002 }, + { 0x0900ff08, 0x58000000 }, + { 0x0900ff09, 0x48000000 }, + { 0x0900ff0a, 0x54000000 }, + { 0x0900ff0b, 0x64000000 }, + { 0x0900ff0c, 0x54000000 }, + { 0x0900ff0d, 0x44000000 }, + { 0x0980ff0e, 0x54000001 }, + { 0x0980ff10, 0x34000009 }, + { 0x0980ff1a, 0x54000001 }, + { 0x0980ff1c, 0x64000002 }, + { 0x0980ff1f, 0x54000001 }, + { 0x2100ff21, 0x24000020 }, + { 0x2100ff22, 0x24000020 }, + { 0x2100ff23, 0x24000020 }, + { 0x2100ff24, 0x24000020 }, + { 0x2100ff25, 0x24000020 }, + { 0x2100ff26, 0x24000020 }, + { 0x2100ff27, 0x24000020 }, + { 0x2100ff28, 0x24000020 }, + { 0x2100ff29, 0x24000020 }, + { 0x2100ff2a, 0x24000020 }, + { 0x2100ff2b, 0x24000020 }, + { 0x2100ff2c, 0x24000020 }, + { 0x2100ff2d, 0x24000020 }, + { 0x2100ff2e, 0x24000020 }, + { 0x2100ff2f, 0x24000020 }, + { 0x2100ff30, 0x24000020 }, + { 0x2100ff31, 0x24000020 }, + { 0x2100ff32, 0x24000020 }, + { 0x2100ff33, 0x24000020 }, + { 0x2100ff34, 0x24000020 }, + { 0x2100ff35, 0x24000020 }, + { 0x2100ff36, 0x24000020 }, + { 0x2100ff37, 0x24000020 }, + { 0x2100ff38, 0x24000020 }, + { 0x2100ff39, 0x24000020 }, + { 0x2100ff3a, 0x24000020 }, + { 0x0900ff3b, 0x58000000 }, + { 0x0900ff3c, 0x54000000 }, + { 0x0900ff3d, 0x48000000 }, + { 0x0900ff3e, 0x60000000 }, + { 0x0900ff3f, 0x40000000 }, + { 0x0900ff40, 0x60000000 }, + { 0x2100ff41, 0x1400ffe0 }, + { 0x2100ff42, 0x1400ffe0 }, + { 0x2100ff43, 0x1400ffe0 }, + { 0x2100ff44, 0x1400ffe0 }, + { 0x2100ff45, 0x1400ffe0 }, + { 0x2100ff46, 0x1400ffe0 }, + { 0x2100ff47, 0x1400ffe0 }, + { 0x2100ff48, 0x1400ffe0 }, + { 0x2100ff49, 0x1400ffe0 }, + { 0x2100ff4a, 0x1400ffe0 }, + { 0x2100ff4b, 0x1400ffe0 }, + { 0x2100ff4c, 0x1400ffe0 }, + { 0x2100ff4d, 0x1400ffe0 }, + { 0x2100ff4e, 0x1400ffe0 }, + { 0x2100ff4f, 0x1400ffe0 }, + { 0x2100ff50, 0x1400ffe0 }, + { 0x2100ff51, 0x1400ffe0 }, + { 0x2100ff52, 0x1400ffe0 }, + { 0x2100ff53, 0x1400ffe0 }, + { 0x2100ff54, 0x1400ffe0 }, + { 0x2100ff55, 0x1400ffe0 }, + { 0x2100ff56, 0x1400ffe0 }, + { 0x2100ff57, 0x1400ffe0 }, + { 0x2100ff58, 0x1400ffe0 }, + { 0x2100ff59, 0x1400ffe0 }, + { 0x2100ff5a, 0x1400ffe0 }, + { 0x0900ff5b, 0x58000000 }, + { 0x0900ff5c, 0x64000000 }, + { 0x0900ff5d, 0x48000000 }, + { 0x0900ff5e, 0x64000000 }, + { 0x0900ff5f, 0x58000000 }, + { 0x0900ff60, 0x48000000 }, + { 0x0900ff61, 0x54000000 }, + { 0x0900ff62, 0x58000000 }, + { 0x0900ff63, 0x48000000 }, + { 0x0980ff64, 0x54000001 }, + { 0x1d80ff66, 0x1c000009 }, + { 0x0900ff70, 0x18000000 }, + { 0x1d80ff71, 0x1c00002c }, + { 0x0980ff9e, 0x18000001 }, + { 0x1780ffa0, 0x1c00001e }, + { 0x1780ffc2, 0x1c000005 }, + { 0x1780ffca, 0x1c000005 }, + { 0x1780ffd2, 0x1c000005 }, + { 0x1780ffda, 0x1c000002 }, + { 0x0980ffe0, 0x5c000001 }, + { 0x0900ffe2, 0x64000000 }, + { 0x0900ffe3, 0x60000000 }, + { 0x0900ffe4, 0x68000000 }, + { 0x0980ffe5, 0x5c000001 }, + { 0x0900ffe8, 0x68000000 }, + { 0x0980ffe9, 0x64000003 }, + { 0x0980ffed, 0x68000001 }, + { 0x0980fff9, 0x04000002 }, + { 0x0980fffc, 0x68000001 }, + { 0x23810000, 0x1c00000b }, + { 0x2381000d, 0x1c000019 }, + { 0x23810028, 0x1c000012 }, + { 0x2381003c, 0x1c000001 }, + { 0x2381003f, 0x1c00000e }, + { 0x23810050, 0x1c00000d }, + { 0x23810080, 0x1c00007a }, + { 0x09810100, 0x54000001 }, + { 0x09010102, 0x68000000 }, + { 0x09810107, 0x3c00002c }, + { 0x09810137, 0x68000008 }, + { 0x13810140, 0x38000034 }, + { 0x13810175, 0x3c000003 }, + { 0x13810179, 0x68000010 }, + { 0x1301018a, 0x3c000000 }, + { 0x29810300, 0x1c00001e }, + { 0x29810320, 0x3c000003 }, + { 0x12810330, 0x1c000019 }, + { 0x1201034a, 0x38000000 }, + { 0x3b810380, 0x1c00001d }, + { 0x3b01039f, 0x54000000 }, + { 0x2a8103a0, 0x1c000023 }, + { 0x2a8103c8, 0x1c000007 }, + { 0x2a0103d0, 0x68000000 }, + { 0x2a8103d1, 0x38000004 }, + { 0x0d010400, 0x24000028 }, + { 0x0d010401, 0x24000028 }, + { 0x0d010402, 0x24000028 }, + { 0x0d010403, 0x24000028 }, + { 0x0d010404, 0x24000028 }, + { 0x0d010405, 0x24000028 }, + { 0x0d010406, 0x24000028 }, + { 0x0d010407, 0x24000028 }, + { 0x0d010408, 0x24000028 }, + { 0x0d010409, 0x24000028 }, + { 0x0d01040a, 0x24000028 }, + { 0x0d01040b, 0x24000028 }, + { 0x0d01040c, 0x24000028 }, + { 0x0d01040d, 0x24000028 }, + { 0x0d01040e, 0x24000028 }, + { 0x0d01040f, 0x24000028 }, + { 0x0d010410, 0x24000028 }, + { 0x0d010411, 0x24000028 }, + { 0x0d010412, 0x24000028 }, + { 0x0d010413, 0x24000028 }, + { 0x0d010414, 0x24000028 }, + { 0x0d010415, 0x24000028 }, + { 0x0d010416, 0x24000028 }, + { 0x0d010417, 0x24000028 }, + { 0x0d010418, 0x24000028 }, + { 0x0d010419, 0x24000028 }, + { 0x0d01041a, 0x24000028 }, + { 0x0d01041b, 0x24000028 }, + { 0x0d01041c, 0x24000028 }, + { 0x0d01041d, 0x24000028 }, + { 0x0d01041e, 0x24000028 }, + { 0x0d01041f, 0x24000028 }, + { 0x0d010420, 0x24000028 }, + { 0x0d010421, 0x24000028 }, + { 0x0d010422, 0x24000028 }, + { 0x0d010423, 0x24000028 }, + { 0x0d010424, 0x24000028 }, + { 0x0d010425, 0x24000028 }, + { 0x0d010426, 0x24000028 }, + { 0x0d010427, 0x24000028 }, + { 0x0d010428, 0x1400ffd8 }, + { 0x0d010429, 0x1400ffd8 }, + { 0x0d01042a, 0x1400ffd8 }, + { 0x0d01042b, 0x1400ffd8 }, + { 0x0d01042c, 0x1400ffd8 }, + { 0x0d01042d, 0x1400ffd8 }, + { 0x0d01042e, 0x1400ffd8 }, + { 0x0d01042f, 0x1400ffd8 }, + { 0x0d010430, 0x1400ffd8 }, + { 0x0d010431, 0x1400ffd8 }, + { 0x0d010432, 0x1400ffd8 }, + { 0x0d010433, 0x1400ffd8 }, + { 0x0d010434, 0x1400ffd8 }, + { 0x0d010435, 0x1400ffd8 }, + { 0x0d010436, 0x1400ffd8 }, + { 0x0d010437, 0x1400ffd8 }, + { 0x0d010438, 0x1400ffd8 }, + { 0x0d010439, 0x1400ffd8 }, + { 0x0d01043a, 0x1400ffd8 }, + { 0x0d01043b, 0x1400ffd8 }, + { 0x0d01043c, 0x1400ffd8 }, + { 0x0d01043d, 0x1400ffd8 }, + { 0x0d01043e, 0x1400ffd8 }, + { 0x0d01043f, 0x1400ffd8 }, + { 0x0d010440, 0x1400ffd8 }, + { 0x0d010441, 0x1400ffd8 }, + { 0x0d010442, 0x1400ffd8 }, + { 0x0d010443, 0x1400ffd8 }, + { 0x0d010444, 0x1400ffd8 }, + { 0x0d010445, 0x1400ffd8 }, + { 0x0d010446, 0x1400ffd8 }, + { 0x0d010447, 0x1400ffd8 }, + { 0x0d010448, 0x1400ffd8 }, + { 0x0d010449, 0x1400ffd8 }, + { 0x0d01044a, 0x1400ffd8 }, + { 0x0d01044b, 0x1400ffd8 }, + { 0x0d01044c, 0x1400ffd8 }, + { 0x0d01044d, 0x1400ffd8 }, + { 0x0d01044e, 0x1400ffd8 }, + { 0x0d01044f, 0x1400ffd8 }, + { 0x2e810450, 0x1c00004d }, + { 0x2c8104a0, 0x34000009 }, + { 0x0b810800, 0x1c000005 }, + { 0x0b010808, 0x1c000000 }, + { 0x0b81080a, 0x1c00002b }, + { 0x0b810837, 0x1c000001 }, + { 0x0b01083c, 0x1c000000 }, + { 0x0b01083f, 0x1c000000 }, + { 0x1e010a00, 0x1c000000 }, + { 0x1e810a01, 0x30000002 }, + { 0x1e810a05, 0x30000001 }, + { 0x1e810a0c, 0x30000003 }, + { 0x1e810a10, 0x1c000003 }, + { 0x1e810a15, 0x1c000002 }, + { 0x1e810a19, 0x1c00001a }, + { 0x1e810a38, 0x30000002 }, + { 0x1e010a3f, 0x30000000 }, + { 0x1e810a40, 0x3c000007 }, + { 0x1e810a50, 0x54000008 }, + { 0x0981d000, 0x680000f5 }, + { 0x0981d100, 0x68000026 }, + { 0x0981d12a, 0x6800003a }, + { 0x0981d165, 0x28000001 }, + { 0x1b81d167, 0x30000002 }, + { 0x0981d16a, 0x68000002 }, + { 0x0981d16d, 0x28000005 }, + { 0x0981d173, 0x04000007 }, + { 0x1b81d17b, 0x30000007 }, + { 0x0981d183, 0x68000001 }, + { 0x1b81d185, 0x30000006 }, + { 0x0981d18c, 0x6800001d }, + { 0x1b81d1aa, 0x30000003 }, + { 0x0981d1ae, 0x6800002f }, + { 0x1381d200, 0x68000041 }, + { 0x1381d242, 0x30000002 }, + { 0x1301d245, 0x68000000 }, + { 0x0981d300, 0x68000056 }, + { 0x0981d400, 0x24000019 }, + { 0x0981d41a, 0x14000019 }, + { 0x0981d434, 0x24000019 }, + { 0x0981d44e, 0x14000006 }, + { 0x0981d456, 0x14000011 }, + { 0x0981d468, 0x24000019 }, + { 0x0981d482, 0x14000019 }, + { 0x0901d49c, 0x24000000 }, + { 0x0981d49e, 0x24000001 }, + { 0x0901d4a2, 0x24000000 }, + { 0x0981d4a5, 0x24000001 }, + { 0x0981d4a9, 0x24000003 }, + { 0x0981d4ae, 0x24000007 }, + { 0x0981d4b6, 0x14000003 }, + { 0x0901d4bb, 0x14000000 }, + { 0x0981d4bd, 0x14000006 }, + { 0x0981d4c5, 0x1400000a }, + { 0x0981d4d0, 0x24000019 }, + { 0x0981d4ea, 0x14000019 }, + { 0x0981d504, 0x24000001 }, + { 0x0981d507, 0x24000003 }, + { 0x0981d50d, 0x24000007 }, + { 0x0981d516, 0x24000006 }, + { 0x0981d51e, 0x14000019 }, + { 0x0981d538, 0x24000001 }, + { 0x0981d53b, 0x24000003 }, + { 0x0981d540, 0x24000004 }, + { 0x0901d546, 0x24000000 }, + { 0x0981d54a, 0x24000006 }, + { 0x0981d552, 0x14000019 }, + { 0x0981d56c, 0x24000019 }, + { 0x0981d586, 0x14000019 }, + { 0x0981d5a0, 0x24000019 }, + { 0x0981d5ba, 0x14000019 }, + { 0x0981d5d4, 0x24000019 }, + { 0x0981d5ee, 0x14000019 }, + { 0x0981d608, 0x24000019 }, + { 0x0981d622, 0x14000019 }, + { 0x0981d63c, 0x24000019 }, + { 0x0981d656, 0x14000019 }, + { 0x0981d670, 0x24000019 }, + { 0x0981d68a, 0x1400001b }, + { 0x0981d6a8, 0x24000018 }, + { 0x0901d6c1, 0x64000000 }, + { 0x0981d6c2, 0x14000018 }, + { 0x0901d6db, 0x64000000 }, + { 0x0981d6dc, 0x14000005 }, + { 0x0981d6e2, 0x24000018 }, + { 0x0901d6fb, 0x64000000 }, + { 0x0981d6fc, 0x14000018 }, + { 0x0901d715, 0x64000000 }, + { 0x0981d716, 0x14000005 }, + { 0x0981d71c, 0x24000018 }, + { 0x0901d735, 0x64000000 }, + { 0x0981d736, 0x14000018 }, + { 0x0901d74f, 0x64000000 }, + { 0x0981d750, 0x14000005 }, + { 0x0981d756, 0x24000018 }, + { 0x0901d76f, 0x64000000 }, + { 0x0981d770, 0x14000018 }, + { 0x0901d789, 0x64000000 }, + { 0x0981d78a, 0x14000005 }, + { 0x0981d790, 0x24000018 }, + { 0x0901d7a9, 0x64000000 }, + { 0x0981d7aa, 0x14000018 }, + { 0x0901d7c3, 0x64000000 }, + { 0x0981d7c4, 0x14000005 }, + { 0x0981d7ce, 0x34000031 }, + { 0x16820000, 0x1c00a6d6 }, + { 0x1682f800, 0x1c00021d }, + { 0x090e0001, 0x04000000 }, + { 0x098e0020, 0x0400005f }, + { 0x1b8e0100, 0x300000ef }, + { 0x098f0000, 0x0c00fffd }, + { 0x09900000, 0x0c00fffd }, +}; diff --git a/tests/mozilla/Getopt/Mixed.pm b/tests/mozilla/Getopt/Mixed.pm new file mode 100644 index 0000000..3caee45 --- /dev/null +++ b/tests/mozilla/Getopt/Mixed.pm @@ -0,0 +1,754 @@ +#--------------------------------------------------------------------- +package Getopt::Mixed; +# +# Copyright 1995 Christopher J. Madsen +# +# Author: Christopher J. Madsen +# Created: 1 Jan 1995 +# Version: $Revision: 1.8 $ ($Date: 1996/02/09 00:05:00 $) +# Note that RCS revision 1.23 => $Getopt::Mixed::VERSION = "1.023" +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Perl; see the file COPYING. If not, write to the +# Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Process both single-character and extended options +#--------------------------------------------------------------------- + +require 5.000; +use Carp; + +require Exporter; +@ISA = qw(Exporter); +@EXPORT = (); +@EXPORT_OK = qw(abortMsg getOptions nextOption); + +#===================================================================== +# Package Global Variables: + +BEGIN +{ + # The permissible settings for $order: + $REQUIRE_ORDER = 0; + $PERMUTE = 1; + $RETURN_IN_ORDER = 2; + + # Regular expressions: + $intRegexp = '^[-+]?\d+$'; # Match an integer + $floatRegexp = '^[-+]?(\d*\.?\d+|\d+\.)$'; # Match a real number + $typeChars = 'sif'; # Match type characters + + # Convert RCS revision number (must be main branch) to d.ddd format: + ' $Revision: 1.8 $ ' =~ / (\d+)\.(\d{1,3}) / + or die "Invalid version number"; + $VERSION = sprintf("%d.%03d",$1,$2); +} # end BEGIN + +#===================================================================== +# Subroutines: +#--------------------------------------------------------------------- +# Initialize the option processor: +# +# You should set any customization variables *after* calling init. +# +# For a description of option declarations, see the documentation at +# the end of this file. +# +# Input: +# List of option declarations (separated by whitespace) +# If the first argument is entirely non-alphanumeric characters +# with no whitespace, it is the characters that start options. + +sub init +{ + undef %options; + my($opt,$type); + + $ignoreCase = 1; # Ignore case by default + $optionStart = "-"; # Dash is the default option starter + + # If the first argument is entirely non-alphanumeric characters + # with no whitespace, it is the desired value for $optionStart: + $optionStart = shift @_ if $_[0] =~ /^[^a-z0-9\s]+$/i; + + foreach $group (@_) { + # Ignore case unless there are upper-case options: + $ignoreCase = 0 if $group =~ /[A-Z]/; + foreach $option (split(/\s+/,$group)) { + croak "Invalid option declaration `$option'" + unless $option =~ /^([^=:>]+)([=:][$typeChars]|>[^=:>]+)?$/o; + $opt = $1; + $type = $2 || ""; + if ($type =~ /^>(.*)$/) { + $type = $1; + croak "Invalid synonym `$option'" + if (not defined $options{$type} + or $options{$type} =~ /^[^:=]/); + } # end if synonym + $options{$opt} = $type; + } # end foreach option + } # end foreach group + + # Handle POSIX compliancy: + if (defined $ENV{"POSIXLY_CORRECT"}) { + $order = $REQUIRE_ORDER; + } else { + $order = $PERMUTE; + } + + $optionEnd = 0; + $badOption = \&badOption; + $checkArg = \&checkArg; +} # end init + +#--------------------------------------------------------------------- +# Clean up when we're done: +# +# This just releases the memory used by the %options hash. +# +# If 'help' was defined as an option, a new hash with just 'help' is +# created, in case the program calls abortMsg. + +sub cleanup +{ + my $help = defined($options{'help'}); + undef %options; + $options{'help'} = "" if $help; +} # end cleanup + +#--------------------------------------------------------------------- +# Abort program with message: +# +# Prints program name and arguments to STDERR +# If --help is an option, prints message saying 'Try --help' +# Exits with code 1 + +sub abortMsg +{ + my $name = $0; + $name =~ s|^.+[\\/]||; # Remove any directories from name + print STDERR $name,": ",@_,"\n"; + print STDERR "Try `$name --help' for more information.\n" + if defined $options{"help"}; + exit 1; +} # end abortMsg + +#--------------------------------------------------------------------- +# Standard function for handling bad options: +# +# Prints an error message and exits. +# +# You can override this by setting $Getopt::Mixed::badOption to a +# function reference. +# +# Input: +# Index into @ARGV +# The option that caused the error +# An optional string describing the problem +# Currently, this can be +# undef The option was not recognized +# 'ambiguous' The option could match several long options +# +# Note: +# The option has already been removed from @ARGV. To put it back, +# you can say: +# splice(@ARGV,$_[0],0,$_[1]); +# +# If your function returns, it should return whatever you want +# nextOption to return. + +sub badOption +{ + my ($index, $option, $problem) = @_; + + $problem = 'unrecognized' unless $problem; + + abortMsg("$problem option `$option'"); +} # end badOption + +#--------------------------------------------------------------------- +# Make sure we have the proper argument for this option: +# +# You can override this by setting $Getopt::Mixed::checkArg to a +# function reference. +# +# Input: +# $i: Position of argument in @ARGV +# $value: The text appended to the option (undef if no text) +# $option: The pretty name of the option (as the user typed it) +# $type: The type of the option +# +# Returns: +# The value of the option's argument + +sub checkArg +{ + my ($i,$value,$option,$type) = @_; + + abortMsg("option `$option' does not take an argument") + if (not $type and defined $value); + + if ($type =~ /^=/) { + # An argument is required for this option: + $value = splice(@ARGV,$i,1) unless defined $value; + abortMsg("option `$option' requires an argument") + unless defined $value; + } + + if ($type =~ /i$/) { + abortMsg("option `$option' requires integer argument") + if (defined $value and $value !~ /$intRegexp/o); + } + elsif ($type =~ /f$/) { + abortMsg("option `$option' requires numeric argument") + if (defined $value and $value !~ /$floatRegexp/o); + } + elsif ($type =~ /^[=:]/ and ref($checkType)) { + $value = &$checkType($i,$value,$option,$type); + } + + $value = "" if not defined $value and $type =~ /^:/; + + $value; +} # end checkArg + +#--------------------------------------------------------------------- +# Find a match for an incomplete long option: +# +# Input: +# The option text to match +# +# Returns: +# The option that matched, or +# undef, if no option matched, or +# (undef, 'ambiguous'), if multiple options matched + +sub findMatch +{ + my $opt = shift; + + $opt =~ s/-/[^-]*-/g; + $opt .= ".*"; + + my @matches = grep(/^$opt$/, keys %options); + + return undef if $#matches < 0; + return $matches[0] if $#matches == 0; + + $opt = $matches[0]; + $opt = $options{$opt} if $options{$opt} =~ /^[^=:]/; + + foreach (@matches) { + return (undef, 'ambiguous') + unless $_ eq $opt or $options{$_} eq $opt; + } + + $opt; +} # end findMatch + +#--------------------------------------------------------------------- +# Return the next option: +# +# Returns a list of 3 elements: (OPTION, VALUE, PRETTYNAME), where +# OPTION is the name of the option, +# VALUE is its argument, and +# PRETTYNAME is the option as the user entered it. +# Returns the null list if there are no more options to process +# +# If $order is $RETURN_IN_ORDER, and this is a normal argument (not an +# option), OPTION will be the null string, VALUE will be the argument, +# and PRETTYNAME will be undefined. + +sub nextOption +{ + return () if $#ARGV < 0; # No more arguments + + if ($optionEnd) { + # We aren't processing any more options: + return ("", shift @ARGV) if $order == $RETURN_IN_ORDER; + return (); + } + + # Find the next option: + my $i = 0; + while (length($ARGV[$i]) < 2 or + index($optionStart,substr($ARGV[$i],0,1)) < 0) { + return () if $order == $REQUIRE_ORDER; + return ("", shift @ARGV) if $order == $RETURN_IN_ORDER; + ++$i; + return () if $i > $#ARGV; + } # end while + + # Process the option: + my($option,$opt,$value,$optType,$prettyOpt); + $option = $ARGV[$i]; + if (substr($option,0,1) eq substr($option,1,1)) { + # If the option start character is repeated, it's a long option: + splice @ARGV,$i,1; + if (length($option) == 2) { + # A double dash by itself marks the end of the options: + $optionEnd = 1; # Don't process any more options + return nextOption(); + } # end if bare double dash + $opt = substr($option,2); + if ($opt =~ /^([^=]+)=(.*)$/) { + $opt = $1; + $value = $2; + } # end if option is followed by value + $opt =~ tr/A-Z/a-z/ if $ignoreCase; + $prettyOpt = substr($option,0,2) . $opt; + my $problem; + ($opt, $problem) = findMatch($opt) + unless defined $options{$opt} and length($opt) > 1; + return &$badOption($i,$option,$problem) unless $opt; + $optType = $options{$opt}; + if ($optType =~ /^[^:=]/) { + $opt = $optType; + $optType = $options{$opt}; + } + $value = &$checkArg($i,$value,$prettyOpt,$optType); + } # end if long option + else { + # It's a short option: + $opt = substr($option,1,1); + $opt =~ tr/A-Z/a-z/ if $ignoreCase; + return &$badOption($i,$option) unless defined $options{$opt}; + $optType = $options{$opt}; + if ($optType =~ /^[^:=]/) { + $opt = $optType; + $optType = $options{$opt}; + } + if (length($option) == 2 or $optType) { + # This is the last option in the group, so remove the group: + splice(@ARGV,$i,1); + } else { + # Just remove this option from the group: + substr($ARGV[$i],1,1) = ""; + } + if ($optType) { + $value = (length($option) > 2) ? substr($option,2) : undef; + $value =~ s/^=// if $value; # Allow either -d3 or -d=3 + } # end if option takes an argument + $prettyOpt = substr($option,0,2); + $value = &$checkArg($i,$value,$prettyOpt,$optType); + } # end else short option + ($opt,$value,$prettyOpt); +} # end nextOption + +#--------------------------------------------------------------------- +# Get options: +# +# Input: +# The same as for init() +# If no parameters are supplied, init() is NOT called. This allows +# you to call init() yourself and then change the configuration +# variables. +# +# Output Variables: +# Sets $opt_X for each `-X' option encountered. +# +# Note that if --apple is a synonym for -a, then --apple will cause +# $opt_a to be set, not $opt_apple. + +sub getOptions +{ + &init if $#_ >= 0; # Pass arguments (if any) on to init + + # If you want to use $RETURN_IN_ORDER, you have to call + # nextOption yourself; getOptions doesn't support it: + $order = $PERMUTE if $order == $RETURN_IN_ORDER; + + my ($option,$value,$package); + + $package = (caller)[0]; + + while (($option, $value) = nextOption()) { + $option =~ s/\W/_/g; # Make a legal Perl identifier + $value = 1 unless defined $value; + eval("\$" . $package . '::opt_' . $option . ' = $value;'); + } # end while + + cleanup(); +} # end getOptions + +#===================================================================== +# Package return value: + +$VERSION; + +__END__ + +=head1 NAME + +Getopt::Mixed - getopt processing with both long and short options + +=head1 SYNOPSIS + + use Getopt::Mixed; + Getopt::Mixed::getOptions(...option-descriptions...); + ...examine $opt_* variables... + +or + + use Getopt::Mixed "nextOption"; + Getopt::Mixed::init(...option-descriptions...); + while (($option, $value) = nextOption()) { + ...process option... + } + Getopt::Mixed::cleanup(); + +=head1 DESCRIPTION + +This package is my response to the standard modules Getopt::Std and +Getopt::Long. C doesn't support long options, and C +doesn't support short options. I wanted both, since long options are +easier to remember and short options are faster to type. + +This package is intended to be the "Getopt-to-end-all-Getop's". It +combines (I hope) flexibility and simplicity. It supports both short +options (introduced by C<->) and long options (introduced by C<-->). +Short options which do not take an argument can be grouped together. +Short options which do take an argument must be the last option in +their group, because everything following the option will be +considered to be its argument. + +There are two methods for using Getopt::Mixed: the simple method and +the flexible method. Both methods use the same format for option +descriptions. + +=head2 Option Descriptions + +The option-description arguments required by C and C +are strings composed of individual option descriptions. Several +option descriptions can appear in the same string if they are +separated by whitespace. + +Each description consists of the option name and an optional trailing +argument specifier. Option names may consist of any characters but +whitespace, C<=>, C<:>, and C>. + +Values for argument specifiers are: + + option does not take an argument + =s :s option takes a mandatory (=) or optional (:) string argument + =i :i option takes a mandatory (=) or optional (:) integer argument + =f :f option takes a mandatory (=) or optional (:) real number argument + >new option is a synonym for option `new' + +The C> specifier is not really an argument specifier. It +defines an option as being a synonym for another option. For example, +"a=i apples>a" would define B<-a> as an option that requires an +integer argument and B<--apples> as a synonym for B<-a>. Only one +level of synonyms is supported, and the root option must be listed +first. For example, "apples>a a=i" and "a=i apples>a oranges>apples" +are illegal; use "a=i apples>a oranges>a" if that's what you want. + +For example, in the option description: + "a b=i c:s apple baker>b charlie:s" + -a and --apple do not take arguments + -b takes a mandatory integer argument + --baker is a synonym for -b + -c and --charlie take an optional string argument + +If the first argument to C or C is entirely +non-alphanumeric characters with no whitespace, it represents the +characters which can begin options. + +=head2 User Interface + +From the user's perspective, short options are introduced by a dash +(C<->) and long options are introduced by a double dash (C<-->). +Short options may be combined ("-a -b" can be written "-ab"), but an +option that takes an argument must be the last one in its group, +because anything following it is considered part of the argument. A +double dash by itself marks the end of the options; all arguments +following it are treated as normal arguments, not options. A single +dash by itself is treated as a normal argument, I an option. + +Long options may be abbreviated. An option B<--all-the-time> could be +abbreviated B<--all>, B<--a--tim>, or even B<--a>. Note that B<--time> +would not work; the abbreviation must start at the beginning of the +option name. If an abbreviation is ambiguous, an error message will +be printed. + +In the following examples, B<-i> and B<--int> take integer arguments, +B<-f> and B<--float> take floating point arguments, and B<-s> and +B<--string> take string arguments. All other options do not take an +argument. + + -i24 -f24.5 -sHello + -i=24 --int=-27 -f=24.5 --float=0.27 -s=Hello --string=Hello + +If the argument is required, it can also be separated by whitespace: + + -i 24 --int -27 -f 24.5 --float 0.27 -s Hello --string Hello + +Note that if the option is followed by C<=>, whatever follows the C<=> +I the argument, even if it's the null string. In the example + + -i= 24 -f= 24.5 -s= Hello + +B<-i> and B<-f> will cause an error, because the null string is not a +number, but B<-s> is perfectly legal; its argument is the null string, +not "Hello". + +Remember that optional arguments I be separated from the +option by whitespace. + +=head2 The Simple Method + +The simple method is + + use Getopt::Mixed; + Getopt::Mixed::getOptions(...option-descriptions...); + +You then examine the C<$opt_*> variables to find out what options were +specified and the C<@ARGV> array to see what arguments are left. + +If B<-a> is an option that doesn't take an argument, then C<$opt_a> +will be set to 1 if the option is present, or left undefined if the +option is not present. + +If B<-b> is an option that takes an argument, then C<$opt_b> will be +set to the value of the argument if the option is present, or left +undefined if the option is not present. If the argument is optional +but not supplied, C<$opt_b> will be set to the null string. + +Note that even if you specify that an option I a string +argument, you can still get the null string (if the user specifically +enters it). If the option requires a numeric argument, you will never +get the null string (because it isn't a number). + +When converting the option name to a Perl identifier, any non-word +characters in the name will be converted to underscores (C<_>). + +If the same option occurs more than once, only the last occurrence +will be recorded. If that's not acceptable, you'll have to use the +flexible method instead. + +=head2 The Flexible Method + +The flexible method is + + use Getopt::Mixed "nextOption"; + Getopt::Mixed::init(...option-descriptions...); + while (($option, $value, $pretty) = nextOption()) { + ...process option... + } + Getopt::Mixed::cleanup(); + +This lets you process arguments one at a time. You can then handle +repeated options any way you want to. It also lets you see option +names with non-alphanumeric characters without any translation. This +is also the only method that lets you find out what order the options +and other arguments were in. + +First, you call Getopt::Mixed::init with the option descriptions. +Then, you keep calling nextOption until it returns an empty list. +Finally, you call Getopt::Mixed::cleanup when you're done. The +remaining (non-option) arguments will be found in @ARGV. + +Each call to nextOption returns a list of the next option, its value, +and the option as the user typed it. The value will be undefined if +the option does not take an argument. The option is stripped of its +starter (e.g., you get "a" and "foo", not "-a" or "--foo"). If you +want to print an error message, use the third element, which does +include the option starter. + +=head1 OTHER FUNCTIONS + +Getopt::Mixed provides one other function you can use. C +prints its arguments on STDERR, plus your program's name and a +newline. It then exits with status 1. For example, if F +calls C like this: + + Getopt::Mixed::abortMsg("Error"); + +The output will be: + + foo.pl: Error + +=head1 CUSTOMIZATION + +There are several customization variables you can set. All of these +variables should be set I calling Getopt::Mixed::init and +I calling nextOption. + +If you set any of these variables, you I check the version +number first. The easiest way to do this is like this: + + use Getopt::Mixed 1.006; + +If you are using the simple method, and you want to set these +variables, you'll need to call init before calling getOptions, like +this: + + use Getopt::Mixed 1.006; + Getopt::Mixed::init(...option-descriptions...); + ...set configuration variables... + Getopt::Mixed::getOptions(); # IMPORTANT: no parameters + +=over 4 + +=item $order + +$order can be set to $REQUIRE_ORDER, $PERMUTE, or $RETURN_IN_ORDER. +The default is $REQUIRE_ORDER if the environment variable +POSIXLY_CORRECT has been set, $PERMUTE otherwise. + +$REQUIRE_ORDER means that no options can follow the first argument +which isn't an option. + +$PERMUTE means that all options are treated as if they preceded all +other arguments. + +$RETURN_IN_ORDER means that all arguments maintain their ordering. +When nextOption is called, and the next argument is not an option, it +returns the null string as the option and the argument as the value. +nextOption never returns the null list until all the arguments have +been processed. + +=item $ignoreCase + +Ignore case when matching options. Default is 1 unless the option +descriptions contain an upper-case letter. + +=item $optionStart + +A string of characters that can start options. Default is "-". + +=item $badOption + +A reference to a function that is called when an unrecognized option +is encountered. The function receives three arguments. $_[0] is the +position in @ARGV where the option came from. $_[1] is the option as +the user typed it (including the option start character). $_[2] is +either undef or a string describing the reason the option was not +recognized (Currently, the only possible value is 'ambiguous', for a +long option with several possible matches). The option has already +been removed from @ARGV. To put it back, you can say: + + splice(@ARGV,$_[0],0,$_[1]); + +The function can do anything you want to @ARGV. It should return +whatever you want nextOption to return. + +The default is a function that prints an error message and exits the +program. + +=item $checkArg + +A reference to a function that is called to make sure the argument +type is correct. The function receives four arguments. $_[0] is the +position in @ARGV where the option came from. $_[1] is the text +following the option, or undefined if there was no text following the +option. $_[2] is the name of the option as the user typed it +(including the option start character), suitable for error messages. +$_[3] is the argument type specifier. + +The function can do anything you want to @ARGV. It should return +the value for this option. + +The default is a function that prints an error message and exits the +program if the argument is not the right type for the option. You can +also adjust the behavior of the default function by changing +$intRegexp or $floatRegexp. + +=item $intRegexp + +A regular expression that matches an integer. Default is +'^[-+]?\d+$', which matches a string of digits preceded by an +optional sign. Unlike the other configuration variables, this cannot +be changed after nextOption is called, because the pattern is compiled +only once. + +=item $floatRegexp + +A regular expression that matches a floating point number. Default is +'^[-+]?(\d*\.?\d+|\d+\.)$', which matches the following formats: +"123", "123.", "123.45", and ".123" (plus an optional sign). It does +not match exponential notation. Unlike the other configuration +variables, this cannot be changed after nextOption is called, because +the pattern is compiled only once. + +=item $typeChars + +A string of the characters which are legal argument types. The +default is 'sif', for String, Integer, and Floating point arguments. +The string should consist only of letters. Upper case letters are +discouraged, since this will hamper the case-folding of options. If +you change this, you should set $checkType to a function that will +check arguments of your new type. Unlike the other configuration +variables, this must be set I calling init(), and cannot be +changed afterwards. + +=item $checkType + +If you add new types to $typeChars, you should set this to a function +which will check arguments of the new types. + +=back + +=head1 BUGS + +=over 4 + +=item * + +This document should be expanded. + +=item * + +A long option must be at least two characters long. Sorry. + +=item * + +The C argument specifier of Getopt::Long is not supported, but you +could have options B<--foo> and B<--nofoo> and then do something like: + + $opt_foo = 0 if $opt_nofoo; + +=item * + +The C<@> argument specifier of Getopt::Long is not supported. If you +want your values pushed into an array, you'll have to use nextOption +and do it yourself. + +=back + +=head1 LICENSE + +Getopt::Mixed is distributed under the terms of the GNU General Public +License as published by the Free Software Foundation; either version +2, or (at your option) any later version. + +This means it is distributed in the hope that it will be useful, but +I; without even the implied warranty of +I or I. See the +GNU General Public License for more details. + +Since Perl scripts are only compiled at runtime, and simply calling +Getopt::Mixed does I bring your program under the GPL, the only +real restriction is that you can't use Getopt::Mixed in an +binary-only distribution produced with C (unless you also +provide source code). + +=head1 AUTHOR + +Christopher J. Madsen EFE + +Thanks are also due to Andreas Koenig for helping Getopt::Mixed +conform to the standards for Perl modules and for answering a bunch of +questions. Any remaining deficiencies are my fault. + +=cut diff --git a/tests/mozilla/Makefile b/tests/mozilla/Makefile new file mode 100644 index 0000000..21cfc6f --- /dev/null +++ b/tests/mozilla/Makefile @@ -0,0 +1,3 @@ +testmenu: + exec perl mklistpage.pl > menubody.html + cat menuhead.html menubody.html menufoot.html > menu.html diff --git a/tests/mozilla/README-jsDriver.html b/tests/mozilla/README-jsDriver.html new file mode 100644 index 0000000..57e4c24 --- /dev/null +++ b/tests/mozilla/README-jsDriver.html @@ -0,0 +1,344 @@ + + + + jsDriver.pl + + + +

jsDriver.pl

+ +
+
NAME
+
+ jsDriver.pl - execute JavaScript programs in various shells in + batch or single mode, reporting on failures encountered. +
+
+ +
SYNOPSIS
+
+ + + + + +
+ + jsDriver.pl + + + + [-hkt] [-b BUGURL] [-c CLASSPATH] [-f OUTFILE] + [-j JAVAPATH] [-l TESTLIST ...] [-L NEGLIST ...] [-p TESTPATH] + [-s SHELLPATH] [-u LXRURL] [--help] [--confail] [--trace] + [--classpath=CLASSPATH] [--file=OUTFILE] [--javapath=JAVAPATH] + [--list=TESTLIST] [--neglist=TESTLIST] [--testpath=TESTPATH] + [--shellpath=SHELLPATH] [--lxrurl=LXRURL] {-e ENGINETYPE | + --engine=ENGINETYPE} + +
+
+
+ +
DESCRIPTION
+
+ jsDriver.pl is normally used to run a series of tests against + one of the JavaScript shells. These tests are expected to be laid out + in a directory structure exactly three levels deep. The first level + is considered the root of the tests, subdirectories under the + root represent Test Suites and generally mark broad + categories such as ECMA Level 1 or Live Connect 3. Under the + Test Suites are the Test Categories, which divide the + Test Suite into smaller categories, such as Execution Contexts + or Lexical Rules. Testcases are located under the + Test Categories as normal JavaScript (*.js) files. +

+ If a file named shell.js exists in either the + Test Suite or the Test Category directory, it is + loaded into the shell before the testcase. If shell.js + exists in both directories, the version in the Test Suite + directory is loaded first, giving the version associated with + the Test Category the ability to override functions previously + declared. You can use this to + create functions and variables common to an entire suite or category. +

+ Testcases can report failures back to jsDriver.pl in one of + two ways. The most common is to write a line of text containing + the word FAILED! to STDOUT or STDERR. + When the engine encounters a matching line, the test is marked as + failed, and any line containing FAILED! is displayed in + the failure report. The second way a test case can report failure is + to return an unexpected exit code. By default, jsDriver.pl + expects all test cases to return exit code 0, although a test + can output a line containing EXPECT EXIT n where + n is the exit code the driver should expect to see. Testcases + can return a nonzero exit code by calling the shell function + quit(n) where n is the + code to exit with. The various JavaScript shells report + non-zero exit codes under the following conditions: + +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
ReasonExit Code
+ Engine initialization failure. + + 1 +
+ Invalid argument on command line. + + 2 +
+ Runtime error (uncaught exception) encountered. + + 3 +
+ File argument specified on command line not found. + + 4 +
+ Reserved for future use. + + 5-9 +
+
+
+
+ +
OPTIONS
+
+
+
-b URL, --bugurl=URL
+
+ Bugzilla URL. When a testcase writes a line in the format + BUGNUMBER n to STDOUT or STDERR, + jsDriver.pl interprets n as a bugnumber + in the BugZilla bug + tracking system. In the event that a testcase which has specified + a bugnumber fails, a hyperlink to the BugZilla database + will be included in the output by prefixing the bugnumber with the + URL specified here. By default, URL is assumed to be + "http://bugzilla.mozilla.org/show_bug.cgi?id=". +
+
+ +
-c PATH, --classpath=PATH
+
+ Classpath to pass the the Java Virtual Machine. When running tests + against the Rhino engine, PATH will be passed in as the value + to an argument named "-classpath". If your particular JVM + does not support this option, it is recommended you specify your + class path via an environment setting. Refer to your JVM + documentation for more details about CLASSPATH. +
+
+
-e TYPE ..., --engine=TYPE ...
+
+ Required. Type of engine(s) to run the tests against. TYPE can be + one or more of the following values: +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TYPEEngine
lcoptLiveConnect, optimized
lcdebugLiveConnect, debug
rhinoRhino compiled mode
rhinoiRhino interpreted mode
rhinomsRhino compiled mode for the Microsoft VM (jview)
rhinomsiRhino interpreted mode for the Microsoft VM (jview)
smoptSpider-Monkey, optimized
smdebugSpider-Monkey, debug
xpcshellXPConnect shell
+
+
+
+
-f FILE, --file=FILE
+
+ Generate html output to the HTML file named by FILE. By default, + a filename will be generated using a combination of the engine type + and a date/time stamp, in the format: + results-<engine-type>-<date-stamp>.html +
+
+
-h, --help
+
+ Prints usage information. +
+
+
-j PATH, --javapath=PATH
+
+ Set the location of the Java Virtual Machine to use when running + tests against the Rhino engine. This can be used to test + against multiple JVMs on the same system. +
+
+
-k, --confail
+
+ Log failures to the console. This will show any failures, as they + occur, on STDERR in addition to creating the HTML results + file. This can be useful for times when it may be + counter-productive to load an HTML version of the results each time + a test is re-run. +
+
+
-l FILE ..., --list=FILE ...
+
+ Specify a list of tests to execute. FILE can be a plain text file + containing a list of testcases to execute, a subdirectory + in which to + grovel + for tests, or a single testcase to execute. Any number of FILE + specifiers may follow this option. The driver uses the fact that a + valid testcase should be a file ending in .js to make the distinction + between a file containing a list of tests and an actual testcase. +
+
+
-L FILE ..., --neglist=FILE ...
+
+ Specify a list of tests to skip. FILE has the same meaning as in + the -l option. This option is evaluated after + all -l and --list options, allowing a user + to subtract a single testcase, a directory of testcases, or a + collection of unrelated testcases from the execution list. +
+
+
-p PATH, --testpath=PATH
+
+ Directory holding the "Test Suite" subdirectories. By + default this is ./ +
+
+
-s PATH, --shellpath=PATH
+
+ Directory holding the JavaScript shell. This can be used to override + the automatic shell location jsDriver.pl performs based on + you OS and engine type. For Non Rhino engines, this + includes the name of the executable as well as the path. In + Rhino, this path will be appended to your + CLASSPATH. For the + SpiderMonkey shells, this value defaults to + ../src/<Platform-and-buildtype-specific-directory>/[js|jsshell], + for the + LiveConnect shells, + ../src/liveconnect/src/<Platform-and-buildtype-specific-directory>/lschell + and for the xpcshell the default is the value of your + MOZILLA_FIVE_HOME environment variable. There is no + default (as it is usually not needed) for the Rhino shell. +
+
+
-t, --trace
+
+ Trace execution of jsDriver.pl. This option is primarily + used for debugging of the script itself, but if you are interested in + seeing the actual command being run, or generally like gobs of + useless information, you may find it entertaining. +
+
+
-u URL, --lxrurl=URL
+
+ Failures listed in the HTML results will be hyperlinked to the + lxr source available online by prefixing the test path and + name with this URL. By default, URL is + http://lxr.mozilla.org/mozilla/source/js/tests/ +
+
+ +
+
SEE ALSO
+
+ jsDriver.pl, + mklistpage.pl, + http://www.mozilla.org/js/, + http://www.mozilla.org/js/tests/library.html +
+
+ +
REQUIREMENTS
+
+ jsDriver.pl requires the + Getopt::Mixed + perl package, available from cpan.org. +
+
+
EXAMPLES
+
+ perl jsDriver.pl -e smdebug -L lc*
+ Executes all tests EXCEPT the liveconnect tests against the + SpiderMonkey debug shell, writing the results + to the default result file. (NOTE: Unix shells take care of wildcard + expansion, turning lc* into lc2 lc3. Under + a DOS shell, you must explicitly list the directories.) +

+ perl jsDriver.pl -e rhino -L rhino-n.tests
+ Executes all tests EXCEPT those listed in the + rhino-n.tests file. +

+ perl -I/home/rginda/perl/lib/ jsDriver.pl -e lcopt -l lc2 + lc3 -f lcresults.html -k
+ Executes ONLY the tests under the lc2 and lc3 + directories against the LiveConnect shell. Results will be written to + the file lcresults.html AND the console. The + -I option tells perl to look for modules in the + /home/rginda/perl/lib directory (in addition to the + usual places), useful if you do not have root access to install new + modules on the system. +

+
+ Author: Robert Ginda
+ Currently maintained by Phil Schwartau
+ + + diff --git a/tests/mozilla/ecma/Array/15.4-1.js b/tests/mozilla/ecma/Array/15.4-1.js new file mode 100644 index 0000000..c5c3178 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4-1.js @@ -0,0 +1,126 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4-1.js + ECMA Section: 15.4 Array Objects + + Description: Every Array object has a length property whose value + is always an integer with positive sign and less than + Math.pow(2,32). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Objects"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length", + (Math.pow(2,32)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length", + (Math.pow(2,32)-2), + eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length") + ); + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length", + (Math.pow(2,31)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length") + ); + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length", + (Math.pow(2,31)), + eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length") + ); + + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length", + (Math.pow(2,31)+1), + eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length") + ); + + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]") + ); + array[item++] = new TestCase( SECTION, + "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length", + (Math.pow(2,30)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length") + ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4-2.js b/tests/mozilla/ecma/Array/15.4-2.js new file mode 100644 index 0000000..ca046e6 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4-2.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4-2.js + ECMA Section: 15.4 Array Objects + + Description: Whenever a property is added whose name is an array + index, the length property is changed, if necessary, + to be one more than the numeric value of that array + index; and whenever the length property is changed, + every property whose name is an array index whose value + is not smaller than the new length is automatically + deleted. This constraint applies only to the Array + object itself, and is unaffected by length or array + index properties that may be inherited from its + prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.4-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Objects"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length", Math.pow(2,16)+1, eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") ); + + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length", Math.pow(2,30)-1, eval("var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length") ); + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length", Math.pow(2,30), eval("var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length") ); + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length", Math.pow(2,30)+1, eval("var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length") ); + + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length", Math.pow(2,31)-1, eval("var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length") ); + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length", Math.pow(2,31), eval("var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length") ); + array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length", Math.pow(2,31)+1, eval("var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length") ); + + array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)", "0,1", eval("var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)") ); + array[item++] = new TestCase( SECTION, "var arr = new Array(0,1); arr.length = 3; String(arr)", "0,1,", eval("var arr = new Array(0,1); arr.length = 3; String(arr)") ); +// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length") ); +// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length") ); + + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.1.1.js b/tests/mozilla/ecma/Array/15.4.1.1.js new file mode 100644 index 0000000..315aa2c --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.1.1.js @@ -0,0 +1,88 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.1.1.js + ECMA Section: 15.4.1 Array( item0, item1,... ) + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creation new Array(...) with + the same arguments. + + An array is created and returned as if by the expression + new Array( item0, item1, ... ). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.1.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function ToUint32( n ) { + n = Number( n ); + if( isNaN(n) || n == 0 || n == Number.POSITIVE_INFINITY || + n == Number.NEGATIVE_INFINITY ) { + return 0; + } + var sign = n < 0 ? -1 : 1; + + return ( sign * ( n * Math.floor( Math.abs(n) ) ) ) % Math.pow(2, 32); +} + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof Array(1,2)", "object", typeof Array(1,2) ); + array[item++] = new TestCase( SECTION, "(Array(1,2)).toString", Array.prototype.toString, (Array(1,2)).toString ); + array[item++] = new TestCase( SECTION, + "var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()", + "[object Array]", + eval("var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()") ); + + + array[item++] = new TestCase( SECTION, "(Array(1,2)).length", 2, (Array(1,2)).length ); + array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[0]", 1, eval("var arr = (Array(1,2)); arr[0]") ); + array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[1]", 2, eval("var arr = (Array(1,2)); arr[1]") ); + array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); String(arr)", "1,2", eval("var arr = (Array(1,2)); String(arr)") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.1.2.js b/tests/mozilla/ecma/Array/15.4.1.2.js new file mode 100644 index 0000000..29352e1 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.1.2.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.1.2.js + ECMA Section: 15.4.1.2 Array(len) + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. + + An array is created and returned as if by the + expression new Array(len). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.1.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Constructor Called as a Function: Array(len)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "(Array()).length", 0, (Array()).length ); + array[item++] = new TestCase( SECTION, "(Array(0)).length", 0, (Array(0)).length ); + array[item++] = new TestCase( SECTION, "(Array(1)).length", 1, (Array(1)).length ); + array[item++] = new TestCase( SECTION, "(Array(10)).length", 10, (Array(10)).length ); + array[item++] = new TestCase( SECTION, "(Array('1')).length", 1, (Array('1')).length ); + array[item++] = new TestCase( SECTION, "(Array(1000)).length", 1000, (Array(1000)).length ); + array[item++] = new TestCase( SECTION, "(Array('1000')).length", 1, (Array('1000')).length ); + array[item++] = new TestCase( SECTION, "(Array(4294967295)).length", ToUint32(4294967295), (Array(4294967295)).length ); + array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)-1)).length", ToUint32(Math.pow(2,31)-1), (Array(Math.pow(2,31)-1)).length ); + array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31))).length", ToUint32(Math.pow(2,31)), (Array(Math.pow(2,31))).length ); + array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)+1)).length", ToUint32(Math.pow(2,31)+1), (Array(Math.pow(2,31)+1)).length ); + array[item++] = new TestCase( SECTION, "(Array('8589934592')).length", 1, (Array("8589934592")).length ); + array[item++] = new TestCase( SECTION, "(Array('4294967296')).length", 1, (Array("4294967296")).length ); + array[item++] = new TestCase( SECTION, "(Array(1073741823)).length", ToUint32(1073741823), (Array(1073741823)).length ); + array[item++] = new TestCase( SECTION, "(Array(1073741824)).length", ToUint32(1073741824), (Array(1073741824)).length ); + array[item++] = new TestCase( SECTION, "(Array('a string')).length", 1, (Array("a string")).length ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Array/15.4.1.3.js b/tests/mozilla/ecma/Array/15.4.1.3.js new file mode 100644 index 0000000..4c3393e --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.1.3.js @@ -0,0 +1,86 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.1.3.js + ECMA Section: 15.4.1.3 Array() + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. + + An array is created and returned as if by the + expression new Array(len). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.1.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array Constructor Called as a Function: Array()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); + + array[item++] = new TestCase( SECTION, + "MYARR = new Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()", + "[object Array]", + eval("MYARR = Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()") ); + + array[item++] = new TestCase( SECTION, + "(Array()).length", + 0, ( + Array()).length ); + + array[item++] = new TestCase( SECTION, + "Array().toString()", + "", + Array().toString() ); + + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.1.js b/tests/mozilla/ecma/Array/15.4.1.js new file mode 100644 index 0000000..5640584 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.1.js @@ -0,0 +1,133 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.1.js + ECMA Section: 15.4.1 The Array Constructor Called as a Function + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "Array() +''", + "", + Array() +"" ); + + array[item++] = new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(); arr.toString == Array.prototype.toString") ); + + array[item++] = new TestCase( SECTION, + "Array().length", + 0, + Array().length ); + + + array[item++] = new TestCase( SECTION, + "Array(1,2,3) +''", + "1,2,3", + Array(1,2,3) +"" ); + + array[item++] = new TestCase( SECTION, + "typeof Array(1,2,3)", + "object", + typeof Array(1,2,3) ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(1,2,3); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") ); + + array[item++] = new TestCase( SECTION, + "Array(1,2,3).length", + 3, + Array(1,2,3).length ); + + array[item++] = new TestCase( SECTION, + "typeof Array(12345)", + "object", + typeof Array(12345) ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, + "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") ); + + array[item++] = new TestCase( SECTION, + "Array(12345).length", + 12345, + Array(12345).length ); + + return ( array ); +} +function test() { + for (tc=0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.2.1-1.js b/tests/mozilla/ecma/Array/15.4.2.1-1.js new file mode 100644 index 0000000..4c1c0c6 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.2.1-1.js @@ -0,0 +1,92 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.2.1-1.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + The length property of the newly constructed object is + set to the number of arguments. + + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. + + This file tests the typeof the newly constructed object. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.2.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof new Array(1,2)", "object", typeof new Array(1,2) ); + array[item++] = new TestCase( SECTION, "(new Array(1,2)).toString", Array.prototype.toString, (new Array(1,2)).toString ); + array[item++] = new TestCase( SECTION, + "var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, "(new Array(1,2)).length", 2, (new Array(1,2)).length ); + array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[0]", 1, eval("var arr = (new Array(1,2)); arr[0]") ); + array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[1]", 2, eval("var arr = (new Array(1,2)); arr[1]") ); + array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); String(arr)", "1,2", eval("var arr = (new Array(1,2)); String(arr)") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.2.1-2.js b/tests/mozilla/ecma/Array/15.4.2.1-2.js new file mode 100644 index 0000000..d5a65de --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.2.1-2.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.2.1-2.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + The length property of the newly constructed object is + set to the number of arguments. + + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. + + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + + var TEST_STRING = "new Array("; + var ARGUMENTS = "" + var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); + + for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; + } + + TEST_STRING += ARGUMENTS + ")"; + + TEST_ARRAY = eval( TEST_STRING ); + + for ( item = 0; item < TEST_LENGTH; item++ ) { + array[item] = new TestCase( SECTION, "["+item+"]", item, TEST_ARRAY[item] ); + } + + array[item++ ] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Array/15.4.2.1-3.js b/tests/mozilla/ecma/Array/15.4.2.1-3.js new file mode 100644 index 0000000..b299183 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.2.1-3.js @@ -0,0 +1,112 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.2.1-3.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + The length property of the newly constructed object is + set to the number of arguments. + + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. + + This test stresses the number of arguments presented to + the Array constructor. Should support up to Math.pow + (2,32) arguments, since that is the maximum length of an + ECMAScript array. + + ***Change TEST_LENGTH to Math.pow(2,32) when larger array + lengths are supported. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.2.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + + var TEST_STRING = "new Array("; + var ARGUMENTS = "" + var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); + + for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; + } + + TEST_STRING += ARGUMENTS + ")"; + + TEST_ARRAY = eval( TEST_STRING ); + + for ( item = 0; item < TEST_LENGTH; item++ ) { + array[item] = new TestCase( SECTION, "TEST_ARRAY["+item+"]", item, TEST_ARRAY[item] ); + } + + array[item++] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.toString", Array.prototype.toString, TEST_ARRAY.toString ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.join", Array.prototype.join, TEST_ARRAY.join ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.sort", Array.prototype.sort, TEST_ARRAY.sort ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.reverse", Array.prototype.reverse, TEST_ARRAY.reverse ); + array[item++] = new TestCase( SECTION, "TEST_ARRAY.length", TEST_LENGTH, TEST_ARRAY.length ); + array[item++] = new TestCase( SECTION, + "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()", + "[object Array]", + eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") ); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.2.2-1.js b/tests/mozilla/ecma/Array/15.4.2.2-1.js new file mode 100644 index 0000000..a2e41ef --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.2.2-1.js @@ -0,0 +1,124 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.2.2-1.js + ECMA Section: 15.4.2.2 new Array(len) + + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype(0) + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + If the argument len is a number, then the length + property of the newly constructed object is set to + ToUint32(len). + + If the argument len is not a number, then the length + property of the newly constructed object is set to 1 + and the 0 property of the newly constructed object is + set to len. + + This file tests cases where len is a number. + + The cases in this test need to be updated since the + ToUint32 description has changed. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.2.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( len )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "new Array(0)", "", (new Array(0)).toString() ); + array[item++] = new TestCase( SECTION, "typeof new Array(0)", "object", (typeof new Array(0)) ); + array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length ); + array[item++] = new TestCase( SECTION, "(new Array(0)).toString", Array.prototype.toString, (new Array(0)).toString ); + + array[item++] = new TestCase( SECTION, "new Array(1)", "", (new Array(1)).toString() ); + array[item++] = new TestCase( SECTION, "new Array(1).length", 1, (new Array(1)).length ); + array[item++] = new TestCase( SECTION, "(new Array(1)).toString", Array.prototype.toString, (new Array(1)).toString ); + + array[item++] = new TestCase( SECTION, "(new Array(-0)).length", 0, (new Array(-0)).length ); + array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length ); + + array[item++] = new TestCase( SECTION, "(new Array(10)).length", 10, (new Array(10)).length ); + array[item++] = new TestCase( SECTION, "(new Array('1')).length", 1, (new Array('1')).length ); + array[item++] = new TestCase( SECTION, "(new Array(1000)).length", 1000, (new Array(1000)).length ); + array[item++] = new TestCase( SECTION, "(new Array('1000')).length", 1, (new Array('1000')).length ); + + array[item++] = new TestCase( SECTION, "(new Array(4294967295)).length", ToUint32(4294967295), (new Array(4294967295)).length ); + + array[item++] = new TestCase( SECTION, "(new Array('8589934592')).length", 1, (new Array("8589934592")).length ); + array[item++] = new TestCase( SECTION, "(new Array('4294967296')).length", 1, (new Array("4294967296")).length ); + array[item++] = new TestCase( SECTION, "(new Array(1073741824)).length", ToUint32(1073741824), (new Array(1073741824)).length ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Array/15.4.2.2-2.js b/tests/mozilla/ecma/Array/15.4.2.2-2.js new file mode 100644 index 0000000..c360702 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.2.2-2.js @@ -0,0 +1,89 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.2.2-2.js + ECMA Section: 15.4.2.2 new Array(len) + + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype(0) + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + If the argument len is a number, then the length + property of the newly constructed object is set to + ToUint32(len). + + If the argument len is not a number, then the length + property of the newly constructed object is set to 1 + and the 0 property of the newly constructed object is + set to len. + + This file tests length of the newly constructed array + when len is not a number. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.2.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array( len )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "(new Array(new Number(1073741823))).length", 1, (new Array(new Number(1073741823))).length ); + array[item++] = new TestCase( SECTION, "(new Array(new Number(0))).length", 1, (new Array(new Number(0))).length ); + array[item++] = new TestCase( SECTION, "(new Array(new Number(1000))).length", 1, (new Array(new Number(1000))).length ); + array[item++] = new TestCase( SECTION, "(new Array('mozilla, larryzilla, curlyzilla')).length", 1, (new Array('mozilla, larryzilla, curlyzilla')).length ); + array[item++] = new TestCase( SECTION, "(new Array(true)).length", 1, (new Array(true)).length ); + array[item++] = new TestCase( SECTION, "(new Array(false)).length", 1, (new Array(false)).length); + array[item++] = new TestCase( SECTION, "(new Array(new Boolean(true)).length", 1, (new Array(new Boolean(true))).length ); + array[item++] = new TestCase( SECTION, "(new Array(new Boolean(false)).length", 1, (new Array(new Boolean(false))).length ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.2.3.js b/tests/mozilla/ecma/Array/15.4.2.3.js new file mode 100644 index 0000000..2ddd31b --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.2.3.js @@ -0,0 +1,74 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.2.3.js + ECMA Section: 15.4.2.3 new Array() + Description: The [[Prototype]] property of the newly constructed + object is set to the origianl Array prototype object, + the one that is the initial value of Array.prototype. + The [[Class]] property of the new object is set to + "Array". The length of the object is set to 0. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.2.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Array Constructor: new Array()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "new Array() +''", "", (new Array()) +"" ); + array[item++] = new TestCase( SECTION, "typeof new Array()", "object", (typeof new Array()) ); + array[item++] = new TestCase( SECTION, + "var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); + + array[item++] = new TestCase( SECTION, "(new Array()).length", 0, (new Array()).length ); + array[item++] = new TestCase( SECTION, "(new Array()).toString == Array.prototype.toString", true, (new Array()).toString == Array.prototype.toString ); + array[item++] = new TestCase( SECTION, "(new Array()).join == Array.prototype.join", true, (new Array()).join == Array.prototype.join ); + array[item++] = new TestCase( SECTION, "(new Array()).reverse == Array.prototype.reverse", true, (new Array()).reverse == Array.prototype.reverse ); + array[item++] = new TestCase( SECTION, "(new Array()).sort == Array.prototype.sort", true, (new Array()).sort == Array.prototype.sort ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.3.1-2.js b/tests/mozilla/ecma/Array/15.4.3.1-2.js new file mode 100644 index 0000000..994ce5e --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.3.1-2.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.3.1-1.js + ECMA Section: 15.4.3.1 Array.prototype + Description: The initial value of Array.prototype is the built-in + Array prototype object (15.4.4). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.3.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + var ARRAY_PROTO = Array.prototype; + + array[item++] = new TestCase( SECTION, "var props = ''; for ( p in Array ) { props += p } props", "", eval("var props = ''; for ( p in Array ) { props += p } props") ); + + array[item++] = new TestCase( SECTION, "Array.prototype = null; Array.prototype", ARRAY_PROTO, eval("Array.prototype = null; Array.prototype") ); + + array[item++] = new TestCase( SECTION, "delete Array.prototype", false, delete Array.prototype ); + array[item++] = new TestCase( SECTION, "delete Array.prototype; Array.prototype", ARRAY_PROTO, eval("delete Array.prototype; Array.prototype") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.3.2.js b/tests/mozilla/ecma/Array/15.4.3.2.js new file mode 100644 index 0000000..43c2b4c --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.3.2.js @@ -0,0 +1,57 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.3.2.js + ECMA Section: 15.4.3.2 Array.length + Description: The length property is 1. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.3.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Array.length", 1, Array.length ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.3.js b/tests/mozilla/ecma/Array/15.4.3.js new file mode 100644 index 0000000..b44c6cb --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.3.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.3.js + ECMA Section: 15.4.3 Properties of the Array Constructor + Description: The value of the internal [[Prototype]] property of the + Array constructor is the Function prototype object. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.3"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Properties of the Array Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Array.__proto__", Function.prototype, Array.__proto__ ); + + return ( array ); +} +function test() { + for (tc=0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + + stopTest(); + + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.4.1.js b/tests/mozilla/ecma/Array/15.4.4.1.js new file mode 100644 index 0000000..4b46136 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.4.1.js @@ -0,0 +1,57 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.4.1.js + ECMA Section: 15.4.4.1 Array.prototype.constructor + Description: The initial value of Array.prototype.constructor + is the built-in Array constructor. + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Array.prototype.constructor == Array", true, Array.prototype.constructor == Array); + return ( array ); +} +function test() { + for (tc=0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.4.2.js b/tests/mozilla/ecma/Array/15.4.4.2.js new file mode 100644 index 0000000..9565798 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.4.2.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.4.2.js + ECMA Section: 15.4.4.2 Array.prototype.toString() + Description: The elements of this object are converted to strings + and these strings are then concatenated, separated by + comma characters. The result is the same as if the + built-in join method were invoiked for this object + with no argument. + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.4.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Array.prototype.toString.length", 0, Array.prototype.toString.length ); + + array[item++] = new TestCase( SECTION, "(new Array()).toString()", "", (new Array()).toString() ); + array[item++] = new TestCase( SECTION, "(new Array(2)).toString()", ",", (new Array(2)).toString() ); + array[item++] = new TestCase( SECTION, "(new Array(0,1)).toString()", "0,1", (new Array(0,1)).toString() ); + array[item++] = new TestCase( SECTION, "(new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString()", "NaN,Infinity,-Infinity", (new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString() ); + + array[item++] = new TestCase( SECTION, "(new Array( Boolean(1), Boolean(0))).toString()", "true,false", (new Array(Boolean(1),Boolean(0))).toString() ); + array[item++] = new TestCase( SECTION, "(new Array(void 0,null)).toString()", ",", (new Array(void 0,null)).toString() ); + + var EXPECT_STRING = ""; + var MYARR = new Array(); + + for ( var i = -50; i < 50; i+= 0.25 ) { + MYARR[MYARR.length] = i; + EXPECT_STRING += i +","; + } + + EXPECT_STRING = EXPECT_STRING.substring( 0, EXPECT_STRING.length -1 ); + + array[item++] = new TestCase( SECTION, "MYARR.toString()", EXPECT_STRING, MYARR.toString() ); + + + return ( array ); +} +function test() { + for ( tc=0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.4.3-1.js b/tests/mozilla/ecma/Array/15.4.4.3-1.js new file mode 100644 index 0000000..63ec5b0 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.4.3-1.js @@ -0,0 +1,159 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.join() + Description: The elements of this object are converted to strings and + these strings are then concatenated, separated by comma + characters. The result is the same as if the built-in join + method were invoiked for this object with no argument. + Author: christine@netscape.com, pschwartau@netscape.com + Date: 07 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155285 + ECMA-262 Ed.3 Section 15.4.4.5 Array.prototype.join() + Step 3: If |separator| is |undefined|, let |separator| + be the single-character string "," +* +*/ + + var SECTION = "15.4.4.3-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Array.prototype.join()"); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var ARR_PROTOTYPE = Array.prototype; + + array[item++] = new TestCase( SECTION, "Array.prototype.join.length", 1, Array.prototype.join.length ); + array[item++] = new TestCase( SECTION, "delete Array.prototype.join.length", false, delete Array.prototype.join.length ); + array[item++] = new TestCase( SECTION, "delete Array.prototype.join.length; Array.prototype.join.length", 1, eval("delete Array.prototype.join.length; Array.prototype.join.length") ); + + // case where array length is 0 + + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(); TEST_ARRAY.join()", + "", + eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join()") ); + + // array length is 0, but spearator is specified + + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')", + "", + eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')") ); + + // length is greater than 0, separator is supplied + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')", + "&&true&false&123&[object Object]&true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')") ); + + // length is greater than 0, separator is empty string + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')", + "truefalse123[object Object]true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')") ); + // length is greater than 0, separator is undefined + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)", + ",,true,false,123,[object Object],true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)") ); + + // length is greater than 0, separator is not supplied + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()", + ",,true,false,123,[object Object],true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()") ); + + // separator is a control character + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')", + unescape("%u000B%u000Btrue%u000Bfalse%u000B123%u000B[object Object]%u000Btrue"), + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')") ); + + // length of array is 1 + array[item++] = new TestCase( SECTION, + "var TEST_ARRAY = new Array(true) ); TEST_ARRAY.join('\v')", + "true", + eval("var TEST_ARRAY = new Array(true); TEST_ARRAY.join('\v')") ); + + + SEPARATOR = "\t" + TEST_LENGTH = 100; + TEST_STRING = ""; + ARGUMENTS = ""; + TEST_RESULT = ""; + + for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += ( index == TEST_LENGTH -1 ) ? "" : ","; + + TEST_RESULT += index; + TEST_RESULT += ( index == TEST_LENGTH -1 ) ? "" : SEPARATOR; + } + + TEST_ARRAY = eval( "new Array( "+ARGUMENTS +")" ); + + array[item++] = new TestCase( SECTION, "TEST_ARRAY.join("+SEPARATOR+")", TEST_RESULT, TEST_ARRAY.join( SEPARATOR ) ); + + array[item++] = new TestCase( SECTION, "(new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join()", + "true,false,,,1e+21,1e-7", + (new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join() ); + + // this is not an Array object + array[item++] = new TestCase( SECTION, + "var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')", + "true:false:111:0.5:1230000:NaN::", + eval("var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')") ); + + + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.join; + this.getClass = Object.prototype.toString; +} diff --git a/tests/mozilla/ecma/Array/15.4.4.4-1.js b/tests/mozilla/ecma/Array/15.4.4.4-1.js new file mode 100644 index 0000000..c8e7422 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.4.4-1.js @@ -0,0 +1,272 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.reverse() + Description: + + The elements of the array are rearranged so as to reverse their order. + This object is returned as the result of the call. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 3. Compute floor(Result(2)/2). + 4. Let k be 0. + 5. If k equals Result(3), return this object. + 6. Compute Result(2)k1. + 7. Call ToString(k). + 8. ToString(Result(6)). + 9. Call the [[Get]] method of this object with argument Result(7). + 10. Call the [[Get]] method of this object with argument Result(8). + 11. If this object has a property named by Result(8), go to step 12; but + if this object has no property named by Result(8), then go to either + step 12 or step 14, depending on the implementation. + 12. Call the [[Put]] method of this object with arguments Result(7) and + Result(10). + 13. Go to step 15. + 14. Call the [[Delete]] method on this object, providing Result(7) as the + name of the property to delete. + 15. If this object has a property named by Result(7), go to step 16; but if + this object has no property named by Result(7), then go to either step 16 + or step 18, depending on the implementation. + 16. Call the [[Put]] method of this object with arguments Result(8) and + Result(9). + 17. Go to step 19. + 18. Call the [[Delete]] method on this object, providing Result(8) as the + name of the property to delete. + 19. Increase k by 1. + 20. Go to step 5. + +Note that the reverse function is intentionally generic; it does not require +that its this value be an Array object. Therefore it can be transferred to other +kinds of objects for use as a method. Whether the reverse function can be applied +successfully to a host object is implementation dependent. + + Note: Array.prototype.reverse allows some flexibility in implementation + regarding array indices that have not been populated. This test covers the + cases in which unpopulated indices are not deleted, since the JavaScript + implementation does not delete uninitialzed indices. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.4.4.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var BUGNUMBER="123724"; + + writeHeaderToLog( SECTION + " Array.prototype.reverse()"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var ARR_PROTOTYPE = Array.prototype; + + testcases[testcases.length] = new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length ); + testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length ); + testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); + + // length of array is 0 + testcases[testcases.length] = new TestCase( SECTION, + "var A = new Array(); A.reverse(); A.length", + 0, + eval("var A = new Array(); A.reverse(); A.length") ); + + // length of array is 1 + var A = new Array(true); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + "var A = new Array(true); A.reverse(); A.length", + R.length, + eval("var A = new Array(true); A.reverse(); A.length") ); + CheckItems( R, A ); + + // length of array is 2 + var S = "var A = new Array( true,false )"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( + SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + + CheckItems( R, A ); + + // length of array is 3 + var S = "var A = new Array( true,false,null )"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + // length of array is 4 + var S = "var A = new Array( true,false,null,void 0 )"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + + // some array indexes have not been set + var S = "var A = new Array(); A[8] = 'hi', A[3] = 'yo'"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + + var OBJECT_OBJECT = new Object(); + var FUNCTION_OBJECT = new Function( 'return this' ); + var BOOLEAN_OBJECT = new Boolean; + var DATE_OBJECT = new Date(0); + var STRING_OBJECT = new String('howdy'); + var NUMBER_OBJECT = new Number(Math.PI); + var ARRAY_OBJECT= new Array(1000); + + var args = "null, void 0, Math.pow(2,32), 1.234e-32, OBJECT_OBJECT, BOOLEAN_OBJECT, FUNCTION_OBJECT, DATE_OBJECT, STRING_OBJECT,"+ + "ARRAY_OBJECT, NUMBER_OBJECT, Math, true, false, 123, '90210'"; + + var S = "var A = new Array("+args+")"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + var limit = 1000; + var args = ""; + for (var i = 0; i < limit; i++ ) { + args += i +""; + if ( i + 1 < limit ) { + args += ","; + } + } + + var S = "var A = new Array("+args+")"; + eval(S); + var R = Reverse(A); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + var S = "var MYOBJECT = new Object_1( \"void 0, 1, null, 2, \'\'\" )"; + eval(S); + var R = Reverse( A ); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + CheckItems( R, A ); + + return ( testcases ); +} +function CheckItems( R, A ) { + for ( var i = 0; i < R.length; i++ ) { + testcases[testcases.length] = new TestCase( + SECTION, + "A["+i+ "]", + R[i], + A[i] ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} +function Reverse( array ) { + var r2 = array.length; + var k = 0; + var r3 = Math.floor( r2/2 ); + if ( r3 == k ) { + return array; + } + + for ( k = 0; k < r3; k++ ) { + var r6 = r2 - k - 1; +// var r7 = String( k ); + var r7 = k; + var r8 = String( r6 ); + + var r9 = array[r7]; + var r10 = array[r8]; + + array[r7] = r10; + array[r8] = r9; + } + + return array; +} +function Iterate( array ) { + for ( var i = 0; i < array.length; i++ ) { +// print( i+": "+ array[String(i)] ); + } +} + +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = this.array[i]; + } + this.reverse = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} diff --git a/tests/mozilla/ecma/Array/15.4.4.4-2.js b/tests/mozilla/ecma/Array/15.4.4.4-2.js new file mode 100644 index 0000000..1d0d850 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.4.4-2.js @@ -0,0 +1,163 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.reverse() + Description: + + The elements of the array are rearranged so as to reverse their order. + This object is returned as the result of the call. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 3. Compute floor(Result(2)/2). + 4. Let k be 0. + 5. If k equals Result(3), return this object. + 6. Compute Result(2)k1. + 7. Call ToString(k). + 8. ToString(Result(6)). + 9. Call the [[Get]] method of this object with argument Result(7). + 10. Call the [[Get]] method of this object with argument Result(8). + 11. If this object has a property named by Result(8), go to step 12; but + if this object has no property named by Result(8), then go to either + step 12 or step 14, depending on the implementation. + 12. Call the [[Put]] method of this object with arguments Result(7) and + Result(10). + 13. Go to step 15. + 14. Call the [[Delete]] method on this object, providing Result(7) as the + name of the property to delete. + 15. If this object has a property named by Result(7), go to step 16; but if + this object has no property named by Result(7), then go to either step 16 + or step 18, depending on the implementation. + 16. Call the [[Put]] method of this object with arguments Result(8) and + Result(9). + 17. Go to step 19. + 18. Call the [[Delete]] method on this object, providing Result(8) as the + name of the property to delete. + 19. Increase k by 1. + 20. Go to step 5. + +Note that the reverse function is intentionally generic; it does not require +that its this value be an Array object. Therefore it can be transferred to other +kinds of objects for use as a method. Whether the reverse function can be applied +successfully to a host object is implementation dependent. + + Note: Array.prototype.reverse allows some flexibility in implementation + regarding array indices that have not been populated. This test covers the + cases in which unpopulated indices are not deleted, since the JavaScript + implementation does not delete uninitialzed indices. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.4.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = new Array(); + + writeHeaderToLog( SECTION + " Array.prototype.reverse()"); + + getTestCases(); + test(); + +function getTestCases() { + var ARR_PROTOTYPE = Array.prototype; + + testcases[testcases.length] = new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length ); + testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length ); + testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); + + // length of array is 0 + testcases[testcases.length] = new TestCase( SECTION, + "var A = new Array(); A.reverse(); A.length", + 0, + eval("var A = new Array(); A.reverse(); A.length") ); + return ( testcases ); +} +function CheckItems( R, A ) { + for ( var i = 0; i < R.length; i++ ) { + testcases[testcases.length] = new TestCase( + SECTION, + "A["+i+ "]", + R[i], + A[i] ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} +function Reverse( array ) { + var r2 = array.length; + var k = 0; + var r3 = Math.floor( r2/2 ); + if ( r3 == k ) { + return array; + } + + for ( k = 0; k < r3; k++ ) { + var r6 = r2 - k - 1; +// var r7 = String( k ); + var r7 = k; + var r8 = String( r6 ); + + var r9 = array[r7]; + var r10 = array[r8]; + + array[r7] = r10; + array[r8] = r9; + } + + return array; +} +function Iterate( array ) { + for ( var i = 0; i < array.length; i++ ) { +// print( i+": "+ array[String(i)] ); + } +} + +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = this.array[i]; + } + this.reverse = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} diff --git a/tests/mozilla/ecma/Array/15.4.4.5-1.js b/tests/mozilla/ecma/Array/15.4.4.5-1.js new file mode 100644 index 0000000..0a759c3 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.4.5-1.js @@ -0,0 +1,223 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.4.5.js + ECMA Section: Array.prototype.sort(comparefn) + Description: + + This test file tests cases in which the compare function is not supplied. + + The elements of this array are sorted. The sort is not necessarily stable. + If comparefn is provided, it should be a function that accepts two arguments + x and y and returns a negative value if x < y, zero if x = y, or a positive + value if x > y. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 1. Perform an implementation-dependent sequence of calls to the + [[Get]] , [[Put]], and [[Delete]] methods of this object and + toSortCompare (described below), where the first argument for each call + to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less + than Result(2) and where the arguments for calls to SortCompare are + results of previous calls to the [[Get]] method. After this sequence + is complete, this object must have the following two properties. + (1) There must be some mathematical permutation of the nonnegative + integers less than Result(2), such that for every nonnegative integer + j less than Result(2), if property old[j] existed, then new[(j)] is + exactly the same value as old[j],. but if property old[j] did not exist, + then new[(j)] either does not exist or exists with value undefined. + (2) If comparefn is not supplied or is a consistent comparison + function for the elements of this array, then for all nonnegative + integers j and k, each less than Result(2), if old[j] compares less + than old[k] (see SortCompare below), then (j) < (k). Here we use the + notation old[j] to refer to the hypothetical result of calling the [ + [Get]] method of this object with argument j before this step is + executed, and the notation new[j] to refer to the hypothetical result + of calling the [[Get]] method of this object with argument j after this + step has been completely executed. A function is a consistent + comparison function for a set of values if (a) for any two of those + values (possibly the same value) considered as an ordered pair, it + always returns the same value when given that pair of values as its + two arguments, and the result of applying ToNumber to this value is + not NaN; (b) when considered as a relation, where the pair (x, y) is + considered to be in the relation if and only if applying the function + to x and y and then applying ToNumber to the result produces a + negative value, this relation is a partial order; and (c) when + considered as a different relation, where the pair (x, y) is considered + to be in the relation if and only if applying the function to x and y + and then applying ToNumber to the result produces a zero value (of either + sign), this relation is an equivalence relation. In this context, the + phrase "x compares less than y" means applying Result(2) to x and y and + then applying ToNumber to the result produces a negative value. + 3.Return this object. + + When the SortCompare operator is called with two arguments x and y, the following steps are taken: + 1.If x and y are both undefined, return +0. + 2.If x is undefined, return 1. + 3.If y is undefined, return 1. + 4.If the argument comparefn was not provided in the call to sort, go to step 7. + 5.Call comparefn with arguments x and y. + 6.Return Result(5). + 7.Call ToString(x). + 8.Call ToString(y). + 9.If Result(7) < Result(8), return 1. + 10.If Result(7) > Result(8), return 1. + 11.Return +0. + +Note that, because undefined always compared greater than any other value, undefined and nonexistent +property values always sort to the end of the result. It is implementation-dependent whether or not such +properties will exist or not at the end of the array when the sort is concluded. + +Note that the sort function is intentionally generic; it does not require that its this value be an Array object. +Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be +applied successfully to a host object is implementation dependent . + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "15.4.4.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.sort(comparefn)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var S = new Array(); + var item = 0; + + // array is empty. + S[item++] = "var A = new Array()"; + + // array contains one item + S[item++] = "var A = new Array( true )"; + + // length of array is 2 + S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; + + S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; + + S[item] = "var A = new Array( "; + + var limit = 0x0061; + for ( var i = 0x007A; i >= limit; i-- ) { + S[item] += "\'"+ String.fromCharCode(i) +"\'" ; + if ( i > limit ) { + S[item] += ","; + } + } + + S[item] += ")"; + + item++; + + for ( var i = 0; i < S.length; i++ ) { + CheckItems( S[i] ); + } +} +function CheckItems( S ) { + eval( S ); + var E = Sort( A ); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.sort(); A.length", + E.length, + eval( S + "; A.sort(); A.length") ); + + for ( var i = 0; i < E.length; i++ ) { + testcases[testcases.length] = new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); + + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + testcases[testcases.length] = new TestCase( + SECTION, + "typeof A["+i+ "]", + typeof E[i], + typeof A[i] ); + } + } +} +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.sort = Array.prototype.sort; + this.getClass = Object.prototype.toString; +} +function Sort( a ) { + for ( i = 0; i < a.length; i++ ) { + for ( j = i+1; j < a.length; j++ ) { + var lo = a[i]; + var hi = a[j]; + var c = Compare( lo, hi ); + if ( c == 1 ) { + a[i] = hi; + a[j] = lo; + } + } + } + return a; +} +function Compare( x, y ) { + if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { + return +0; + } + if ( x == void 0 && typeof x == "undefined" ) { + return 1; + } + if ( y == void 0 && typeof y == "undefined" ) { + return -1; + } + x = String(x); + y = String(y); + if ( x < y ) { + return -1; + } + if ( x > y ) { + return 1; + } + return 0; +} diff --git a/tests/mozilla/ecma/Array/15.4.4.5-2.js b/tests/mozilla/ecma/Array/15.4.4.5-2.js new file mode 100644 index 0000000..23e1eac --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.4.5-2.js @@ -0,0 +1,224 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.4.5-2.js + ECMA Section: Array.prototype.sort(comparefn) + Description: + + This test file tests cases in which the compare function is supplied. + In this cases, the sort creates a reverse sort. + + The elements of this array are sorted. The sort is not necessarily stable. + If comparefn is provided, it should be a function that accepts two arguments + x and y and returns a negative value if x < y, zero if x = y, or a positive + value if x > y. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 1. Perform an implementation-dependent sequence of calls to the + [[Get]] , [[Put]], and [[Delete]] methods of this object and + toSortCompare (described below), where the first argument for each call + to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less + than Result(2) and where the arguments for calls to SortCompare are + results of previous calls to the [[Get]] method. After this sequence + is complete, this object must have the following two properties. + (1) There must be some mathematical permutation of the nonnegative + integers less than Result(2), such that for every nonnegative integer + j less than Result(2), if property old[j] existed, then new[(j)] is + exactly the same value as old[j],. but if property old[j] did not exist, + then new[(j)] either does not exist or exists with value undefined. + (2) If comparefn is not supplied or is a consistent comparison + function for the elements of this array, then for all nonnegative + integers j and k, each less than Result(2), if old[j] compares less + than old[k] (see SortCompare below), then (j) < (k). Here we use the + notation old[j] to refer to the hypothetical result of calling the [ + [Get]] method of this object with argument j before this step is + executed, and the notation new[j] to refer to the hypothetical result + of calling the [[Get]] method of this object with argument j after this + step has been completely executed. A function is a consistent + comparison function for a set of values if (a) for any two of those + values (possibly the same value) considered as an ordered pair, it + always returns the same value when given that pair of values as its + two arguments, and the result of applying ToNumber to this value is + not NaN; (b) when considered as a relation, where the pair (x, y) is + considered to be in the relation if and only if applying the function + to x and y and then applying ToNumber to the result produces a + negative value, this relation is a partial order; and (c) when + considered as a different relation, where the pair (x, y) is considered + to be in the relation if and only if applying the function to x and y + and then applying ToNumber to the result produces a zero value (of either + sign), this relation is an equivalence relation. In this context, the + phrase "x compares less than y" means applying Result(2) to x and y and + then applying ToNumber to the result produces a negative value. + 3.Return this object. + + When the SortCompare operator is called with two arguments x and y, the following steps are taken: + 1.If x and y are both undefined, return +0. + 2.If x is undefined, return 1. + 3.If y is undefined, return 1. + 4.If the argument comparefn was not provided in the call to sort, go to step 7. + 5.Call comparefn with arguments x and y. + 6.Return Result(5). + 7.Call ToString(x). + 8.Call ToString(y). + 9.If Result(7) < Result(8), return 1. + 10.If Result(7) > Result(8), return 1. + 11.Return +0. + +Note that, because undefined always compared greater than any other value, undefined and nonexistent +property values always sort to the end of the result. It is implementation-dependent whether or not such +properties will exist or not at the end of the array when the sort is concluded. + +Note that the sort function is intentionally generic; it does not require that its this value be an Array object. +Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be +applied successfully to a host object is implementation dependent . + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "15.4.4.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.sort(comparefn)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var S = new Array(); + var item = 0; + + // array is empty. + S[item++] = "var A = new Array()"; + + // array contains one item + S[item++] = "var A = new Array( true )"; + + // length of array is 2 + S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; + + S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; + + S[item] = "var A = new Array( "; + + var limit = 0x0061; + for ( var i = 0x007A; i >= limit; i-- ) { + S[item] += "\'"+ String.fromCharCode(i) +"\'" ; + if ( i > limit ) { + S[item] += ","; + } + } + + S[item] += ")"; + + for ( var i = 0; i < S.length; i++ ) { + CheckItems( S[i] ); + } + +} +function CheckItems( S ) { + eval( S ); + var E = Sort( A ); + + testcases[testcases.length] = new TestCase( SECTION, + S +"; A.sort(Compare); A.length", + E.length, + eval( S + "; A.sort(Compare); A.length") ); + + for ( var i = 0; i < E.length; i++ ) { + testcases[testcases.length] = new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); + + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + testcases[testcases.length] = new TestCase( + SECTION, + "typeof A["+i+ "]", + typeof E[i], + typeof A[i] ); + } + } +} +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.sort = Array.prototype.sort; + this.getClass = Object.prototype.toString; +} +function Sort( a ) { + var r1 = a.length; + for ( i = 0; i < a.length; i++ ) { + for ( j = i+1; j < a.length; j++ ) { + var lo = a[i]; + var hi = a[j]; + var c = Compare( lo, hi ); + if ( c == 1 ) { + a[i] = hi; + a[j] = lo; + } + } + } + return a; +} +function Compare( x, y ) { + if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { + return +0; + } + if ( x == void 0 && typeof x == "undefined" ) { + return 1; + } + if ( y == void 0 && typeof y == "undefined" ) { + return -1; + } + x = String(x); + y = String(y); + if ( x < y ) { + return 1; + } + if ( x > y ) { + return -1; + } + return 0; +} diff --git a/tests/mozilla/ecma/Array/15.4.4.5-3.js b/tests/mozilla/ecma/Array/15.4.4.5-3.js new file mode 100644 index 0000000..b27e063 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.4.5-3.js @@ -0,0 +1,181 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.4.5-3.js + ECMA Section: Array.prototype.sort(comparefn) + Description: + + This is a regression test for + http://scopus/bugsplat/show_bug.cgi?id=117144 + + Verify that sort is successfull, even if the sort compare function returns + a very large negative or positive value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "15.4.4.5-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.prototype.sort(comparefn)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + var array = new Array(); + + array[array.length] = new Date( TIME_2000 * Math.PI ); + array[array.length] = new Date( TIME_2000 * 10 ); + array[array.length] = new Date( TIME_1900 + TIME_1900 ); + array[array.length] = new Date(0); + array[array.length] = new Date( TIME_2000 ); + array[array.length] = new Date( TIME_1900 + TIME_1900 +TIME_1900 ); + array[array.length] = new Date( TIME_1900 * Math.PI ); + array[array.length] = new Date( TIME_1900 * 10 ); + array[array.length] = new Date( TIME_1900 ); + array[array.length] = new Date( TIME_2000 + TIME_2000 ); + array[array.length] = new Date( 1899, 0, 1 ); + array[array.length] = new Date( 2000, 1, 29 ); + array[array.length] = new Date( 2000, 0, 1 ); + array[array.length] = new Date( 1999, 11, 31 ); + + var testarr1 = new Array() + clone( array, testarr1 ); + testarr1.sort( comparefn1 ); + + var testarr2 = new Array() + clone( array, testarr2 ); + testarr2.sort( comparefn2 ); + + testarr3 = new Array(); + clone( array, testarr3 ); + testarr3.sort( comparefn3 ); + + // when there's no sort function, sort sorts by the toString value of Date. + + var testarr4 = new Array() + clone( array, testarr4 ); + testarr4.sort(); + + var realarr = new Array(); + clone( array, realarr ); + realarr.sort( realsort ); + + var stringarr = new Array(); + clone( array, stringarr ); + stringarr.sort( stringsort ); + + for ( var i = 0, tc = 0; i < array.length; i++, tc++) { + testcases[tc] = new TestCase( + SECTION, + "testarr1["+i+"]", + realarr[i], + testarr1[i] ); + } + + for ( var i=0; i < array.length; i++, tc++) { + testcases[tc] = new TestCase( + SECTION, + "testarr2["+i+"]", + realarr[i], + testarr2[i] ); + } + + for ( var i=0; i < array.length; i++, tc++) { + testcases[tc] = new TestCase( + SECTION, + "testarr3["+i+"]", + realarr[i], + testarr3[i] ); + } + + for ( var i=0; i < array.length; i++, tc++) { + testcases[tc] = new TestCase( + SECTION, + "testarr4["+i+"]", + stringarr[i].toString(), + testarr4[i].toString() ); + } + +} +function comparefn1( x, y ) { + return x - y; +} +function comparefn2( x, y ) { + return x.valueOf() - y.valueOf(); +} +function realsort( x, y ) { + return ( x.valueOf() == y.valueOf() ? 0 : ( x.valueOf() > y.valueOf() ? 1 : -1 ) ); +} +function comparefn3( x, y ) { + return ( x == y ? 0 : ( x > y ? 1: -1 ) ); +} +function clone( source, target ) { + for (i = 0; i < source.length; i++ ) { + target[i] = source[i]; + } +} +function stringsort( x, y ) { + for ( var i = 0; i < x.toString().length; i++ ) { + var d = (x.toString()).charCodeAt(i) - (y.toString()).charCodeAt(i); + if ( d > 0 ) { + return 1; + } else { + if ( d < 0 ) { + return -1; + } else { + continue; + } + } + + var d = x.length - y.length; + + if ( d > 0 ) { + return 1; + } else { + if ( d < 0 ) { + return -1; + } + } + } + return 0; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Array/15.4.4.js b/tests/mozilla/ecma/Array/15.4.4.js new file mode 100644 index 0000000..4197dfb --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.4.js @@ -0,0 +1,77 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.4.js + ECMA Section: 15.4.4 Properties of the Array Prototype Object + Description: The value of the internal [[Prototype]] property of + the Array prototype object is the Object prototype + object. + + Note that the Array prototype object is itself an + array; it has a length property (whose initial value + is (0) and the special [[Put]] method. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.4.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Array Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// these testcases are ECMA_2 +// array[item++] = new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ ); +// array[item++] = new TestCase( SECTION, "Array.__proto__.valueOf == Object.__proto__.valueOf", true, (Array.__proto__.valueOf == Object.__proto__.valueOf) ); + + array[item++] = new TestCase( SECTION, "Array.prototype.length", 0, Array.prototype.length ); + +// verify that prototype object is an Array object. + array[item++] = new TestCase( SECTION, "typeof Array.prototype", "object", typeof Array.prototype ); + + array[item++] = new TestCase( SECTION, + "Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()", + "[object Array]", + eval("Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.5.1-1.js b/tests/mozilla/ecma/Array/15.4.5.1-1.js new file mode 100644 index 0000000..e57408b --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.5.1-1.js @@ -0,0 +1,172 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.5.1-1.js + ECMA Section: [[ Put]] (P, V) + Description: + Array objects use a variation of the [[Put]] method used for other native + ECMAScript objects (section 8.6.2.2). + + Assume A is an Array object and P is a string. + + When the [[Put]] method of A is called with property P and value V, the + following steps are taken: + + 1. Call the [[CanPut]] method of A with name P. + 2. If Result(1) is false, return. + 3. If A doesn't have a property with name P, go to step 7. + 4. If P is "length", go to step 12. + 5. Set the value of property P of A to V. + 6. Go to step 8. + 7. Create a property with name P, set its value to V and give it empty + attributes. + 8. If P is not an array index, return. + 9. If A itself has a property (not an inherited property) named "length", + andToUint32(P) is less than the value of the length property of A, then + return. + 10. Change (or set) the value of the length property of A to ToUint32(P)+1. + 11. Return. + 12. Compute ToUint32(V). + 13. For every integer k that is less than the value of the length property + of A but not less than Result(12), if A itself has a property (not an + inherited property) named ToString(k), then delete that property. + 14. Set the value of property P of A to Result(12). + 15. Return. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.4.5.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array [[Put]] (P, V)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + + var item = 0; + + // P is "length" + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 1000; A.length", + 1000, + eval("var A = new Array(); A.length = 1000; A.length") ); + + // A has Property P, and P is not length or an array index + array[item++] = new TestCase( SECTION, + "var A = new Array(1000); A.name = 'name of this array'; A.name", + 'name of this array', + eval("var A = new Array(1000); A.name = 'name of this array'; A.name") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(1000); A.name = 'name of this array'; A.length", + 1000, + eval("var A = new Array(1000); A.name = 'name of this array'; A.length") ); + + + // A has Property P, P is not length, P is an array index, and ToUint32(p) is less than the + // value of length + + array[item++] = new TestCase( SECTION, + "var A = new Array(1000); A[123] = 'hola'; A[123]", + 'hola', + eval("var A = new Array(1000); A[123] = 'hola'; A[123]") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(1000); A[123] = 'hola'; A.length", + 1000, + eval("var A = new Array(1000); A[123] = 'hola'; A.length") ); + + + for ( var i = 0X0020, TEST_STRING = "var A = new Array( " ; i < 0x00ff; i++ ) { + TEST_STRING += "\'\\"+ String.fromCharCode( i ) +"\'"; + if ( i < 0x00FF - 1 ) { + TEST_STRING += ","; + } else { + TEST_STRING += ");" + } + } + + var LENGTH = 0x00ff - 0x0020; + + array[item++] = new TestCase( SECTION, + TEST_STRING +" A[150] = 'hello'; A[150]", + 'hello', + eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) ); + + array[item++] = new TestCase( SECTION, + TEST_STRING +" A[150] = 'hello'; A[150]", + LENGTH, + eval( TEST_STRING + " A[150] = 'hello'; A.length" ) ); + + // A has Property P, P is not length, P is an array index, and ToUint32(p) is not less than the + // value of length + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A[123] = true; A.length", + 124, + eval("var A = new Array(); A[123] = true; A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length", + 16, + eval("var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length") ); + + for ( var i = 0; i < A.length; i++, item++ ) { + array[item] = new TestCase( SECTION, + "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A[" +i +"]", + (i <= 10) ? i : ( i == 15 ? '15' : void 0 ), + A[i] ); + } + // P is not an array index, and P is not "length" + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.join.length = 4; A.join.length", + 1, + eval("var A = new Array(); A.join.length = 4; A.join.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.join.length = 4; A.length", + 0, + eval("var A = new Array(); A.join.length = 4; A.length") ); + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.5.1-2.js b/tests/mozilla/ecma/Array/15.4.5.1-2.js new file mode 100644 index 0000000..08b4721 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.5.1-2.js @@ -0,0 +1,150 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.5.1-2.js + ECMA Section: [[ Put]] (P, V) + Description: + Array objects use a variation of the [[Put]] method used for other native + ECMAScript objects (section 8.6.2.2). + + Assume A is an Array object and P is a string. + + When the [[Put]] method of A is called with property P and value V, the + following steps are taken: + + 1. Call the [[CanPut]] method of A with name P. + 2. If Result(1) is false, return. + 3. If A doesn't have a property with name P, go to step 7. + 4. If P is "length", go to step 12. + 5. Set the value of property P of A to V. + 6. Go to step 8. + 7. Create a property with name P, set its value to V and give it empty + attributes. + 8. If P is not an array index, return. + 9. If A itself has a property (not an inherited property) named "length", + andToUint32(P) is less than the value of the length property of A, then + return. + 10. Change (or set) the value of the length property of A to ToUint32(P)+1. + 11. Return. + 12. Compute ToUint32(V). + 13. For every integer k that is less than the value of the length property + of A but not less than Result(12), if A itself has a property (not an + inherited property) named ToString(k), then delete that property. + 14. Set the value of property P of A to Result(12). + 15. Return. + + + These are testcases from Waldemar, detailed in + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123552 + + Author: christine@netscape.com + Date: 15 June 1998 +*/ + + var SECTION = "15.4.5.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array [[Put]] (P,V)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var a = new Array(); + + AddCase( "3.00", "three" ); + AddCase( "00010", "eight" ); + AddCase( "37xyz", "thirty-five" ); + AddCase("5000000000", 5) + AddCase( "-2", -3 ); + + testcases[tc++] = new TestCase( SECTION, + "a[10]", + void 0, + a[10] ); + + testcases[tc++] = new TestCase( SECTION, + "a[3]", + void 0, + a[3] ); + + a[4] = "four"; + + testcases[tc++] = new TestCase( SECTION, + "a[4] = \"four\"; a[4]", + "four", + a[4] ); + + testcases[tc++] = new TestCase( SECTION, + "a[\"4\"]", + "four", + a["4"] ); + + testcases[tc++] = new TestCase( SECTION, + "a[\"4.00\"]", + void 0, + a["4.00"] ); + + testcases[tc++] = new TestCase( SECTION, + "a.length", + 5, + a.length ); + + + a["5000000000"] = 5; + + testcases[tc++] = new TestCase( SECTION, + "a[\"5000000000\"] = 5; a.length", + 5, + a.length ); + + testcases[tc++] = new TestCase( SECTION, + "a[\"-2\"] = -3; a.length", + 5, + a.length ); + + test(); + +function AddCase ( arg, value ) { + + a[arg] = value; + + testcases[tc++] = new TestCase( SECTION, + "a[\"" + arg + "\"] = "+ value +"; a.length", + 0, + a.length ); +} + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.5.2-1.js b/tests/mozilla/ecma/Array/15.4.5.2-1.js new file mode 100644 index 0000000..069ae57 --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.5.2-1.js @@ -0,0 +1,93 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.5.2-1.js + ECMA Section: Array.length + Description: + 15.4.5.2 length + The length property of this Array object is always numerically greater + than the name of every property whose name is an array index. + + The length property has the attributes { DontEnum, DontDelete }. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.4.5.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length", + 0, + eval("var A = new Array(); A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length", + Math.pow(2,32)-1, + eval("var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 123; A.length", + 123, + eval("var A = new Array(); A.length = 123; A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS", + "", + eval("var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS") ); + + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 123; delete A.length", + false , + eval("var A = new Array(); A.length = 123; delete A.length") ); + + array[item++] = new TestCase( SECTION, + "var A = new Array(); A.length = 123; delete A.length; A.length", + 123, + eval("var A = new Array(); A.length = 123; delete A.length; A.length") ); + return array; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Array/15.4.5.2-2.js b/tests/mozilla/ecma/Array/15.4.5.2-2.js new file mode 100644 index 0000000..9d65b2c --- /dev/null +++ b/tests/mozilla/ecma/Array/15.4.5.2-2.js @@ -0,0 +1,123 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.4.5.2-2.js + ECMA Section: Array.length + Description: + 15.4.5.2 length + The length property of this Array object is always numerically greater + than the name of every property whose name is an array index. + + The length property has the attributes { DontEnum, DontDelete }. + + This test verifies that the Array.length property is not Read Only. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.4.5.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Array.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) ); + + addCase( new Array(), 0, 1, 1 ); + + addCase( new Array(Math.pow(2,12)), Math.pow(2,12), 0, 0 ); + addCase( new Array(Math.pow(2,13)), Math.pow(2,13), Math.pow(2,12), Math.pow(2,12) ); + addCase( new Array(Math.pow(2,12)), Math.pow(2,12), Math.pow(2,12), Math.pow(2,12) ); + addCase( new Array(Math.pow(2,14)), Math.pow(2,14), Math.pow(2,12), Math.pow(2,12) ) + + // some tests where array is not empty + // array is populated with strings + for ( var arg = "", i = 0; i < Math.pow(2,12); i++ ) { + arg += String(i) + ( i != Math.pow(2,12)-1 ? "," : "" ); + + } +// print(i +":"+arg); + + var a = eval( "new Array("+arg+")" ); + + addCase( a, i, i, i ); + addCase( a, i, Math.pow(2,12)+i+1, Math.pow(2,12)+i+1, true ); + addCase( a, Math.pow(2,12)+5, 0, 0, true ); + + test(); + +function addCase( object, old_len, set_len, new_len, checkitems ) { + object.length = set_len; + + testcases[testcases.length] = new TestCase( SECTION, + "array = new Array("+ old_len+"); array.length = " + set_len + + "; array.length", + new_len, + object.length ); + + if ( checkitems ) { + // verify that items between old and newlen are all undefined + if ( new_len < old_len ) { + var passed = true; + for ( var i = new_len; i < old_len; i++ ) { + if ( object[i] != void 0 ) { + passed = false; + } + } + testcases[testcases.length] = new TestCase( SECTION, + "verify that array items have been deleted", + true, + passed ); + } + if ( new_len > old_len ) { + var passed = true; + for ( var i = old_len; i < new_len; i++ ) { + if ( object[i] != void 0 ) { + passed = false; + } + } + testcases[testcases.length] = new TestCase( SECTION, + "verify that new items are undefined", + true, + passed ); + } + } + +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.1.js b/tests/mozilla/ecma/Boolean/15.6.1.js new file mode 100644 index 0000000..762b06d --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.1.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.1.js + ECMA Section: 15.6.1 The Boolean Function + 15.6.1.1 Boolean( value ) + 15.6.1.2 Boolean () + Description: Boolean( value ) should return a Boolean value + not a Boolean object) computed by + Boolean.toBooleanValue( value) + + 15.6.1.2 Boolean() returns false + + Author: christine@netscape.com + Date: 27 jun 1997 + + + Data File Fields: + VALUE Argument passed to the Boolean function + TYPE typeof VALUE (not used, but helpful in understanding + the data file) + E_RETURN Expected return value of Boolean( VALUE ) +*/ + var SECTION = "15.6.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Boolean constructor called as a function: Boolean( value ) and Boolean()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); + array[item++] = new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); + array[item++] = new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); + array[item++] = new TestCase( SECTION, "Boolean('1')", true, Boolean("1") ); + array[item++] = new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); + array[item++] = new TestCase( SECTION, "Boolean('-1')", true, Boolean("-1") ); + array[item++] = new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); + array[item++] = new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); + + array[item++] = new TestCase( SECTION, "Boolean('true')", true, Boolean("true") ); + array[item++] = new TestCase( SECTION, "Boolean('false')", true, Boolean("false") ); + array[item++] = new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); + + array[item++] = new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Boolean(void(0))", false, Boolean( void(0) ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=0)", false, Boolean( x=0 ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=1)", true, Boolean( x=1 ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=false)", false, Boolean( x=false ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=true)", true, Boolean( x=true ) ); + array[item++] = new TestCase( SECTION, "Boolean(x=null)", false, Boolean( x=null ) ); + array[item++] = new TestCase( SECTION, "Boolean()", false, Boolean() ); +// array[item++] = new TestCase( SECTION, "Boolean(var someVar)", false, Boolean( someVar ) ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.2.js b/tests/mozilla/ecma/Boolean/15.6.2.js new file mode 100644 index 0000000..2d4e142 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.2.js @@ -0,0 +1,160 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.2.js + ECMA Section: 15.6.2 The Boolean Constructor + 15.6.2.1 new Boolean( value ) + 15.6.2.2 new Boolean() + + This test verifies that the Boolean constructor + initializes a new object (typeof should return + "object"). The prototype of the new object should + be Boolean.prototype. The value of the object + should be ToBoolean( value ) (a boolean value). + + Description: + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "15.6.2 The Boolean Constructor; 15.6.2.1 new Boolean( value ); 15.6.2.2 new Boolean()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof (new Boolean(1))", "object", typeof (new Boolean(1)) ); + array[item++] = new TestCase( SECTION, "(new Boolean(1)).constructor", Boolean.prototype.constructor, (new Boolean(1)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(1)).valueOf()", true, (new Boolean(1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(1)", "object", typeof new Boolean(1) ); + array[item++] = new TestCase( SECTION, "(new Boolean(0)).constructor", Boolean.prototype.constructor, (new Boolean(0)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(0)).valueOf()", false, (new Boolean(0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(0)", "object", typeof new Boolean(0) ); + array[item++] = new TestCase( SECTION, "(new Boolean(-1)).constructor", Boolean.prototype.constructor, (new Boolean(-1)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(-1)).valueOf()", true, (new Boolean(-1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(-1)", "object", typeof new Boolean(-1) ); + array[item++] = new TestCase( SECTION, "(new Boolean('1')).constructor", Boolean.prototype.constructor, (new Boolean('1')).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean('1')).valueOf()", true, (new Boolean('1')).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean('1')", "object", typeof new Boolean('1') ); + array[item++] = new TestCase( SECTION, "(new Boolean('0')).constructor", Boolean.prototype.constructor, (new Boolean('0')).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean('0')).valueOf()", true, (new Boolean('0')).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean('0')", "object", typeof new Boolean('0') ); + array[item++] = new TestCase( SECTION, "(new Boolean('-1')).constructor", Boolean.prototype.constructor, (new Boolean('-1')).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean('-1')).valueOf()", true, (new Boolean('-1')).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean('-1')", "object", typeof new Boolean('-1') ); + array[item++] = new TestCase( SECTION, "(new Boolean(new Boolean(true))).constructor", Boolean.prototype.constructor, (new Boolean(new Boolean(true))).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(new Boolean(true))).valueOf()", true, (new Boolean(new Boolean(true))).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(new Boolean(true))", "object", typeof new Boolean(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NaN)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NaN)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NaN)).valueOf()", false, (new Boolean(Number.NaN)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.NaN)", "object", typeof new Boolean(Number.NaN) ); + array[item++] = new TestCase( SECTION, "(new Boolean(null)).constructor", Boolean.prototype.constructor, (new Boolean(null)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(null)).valueOf()", false, (new Boolean(null)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(null)", "object", typeof new Boolean(null) ); + array[item++] = new TestCase( SECTION, "(new Boolean(void 0)).constructor", Boolean.prototype.constructor, (new Boolean(void 0)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(void 0)).valueOf()", false, (new Boolean(void 0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(void 0)", "object", typeof new Boolean(void 0) ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.POSITIVE_INFINITY)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).valueOf()", true, (new Boolean(Number.POSITIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.POSITIVE_INFINITY)", "object", typeof new Boolean(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); + array[item++] = new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).valueOf()", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.NEGATIVE_INFINITY)", "object", typeof new Boolean(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); + array[item++] = new TestCase( "15.6.2.2", + "TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); + array[item++] = new TestCase( "15.6.2.2", "(new Boolean()).valueOf()", false, (new Boolean()).valueOf() ); + array[item++] = new TestCase( "15.6.2.2", "typeof new Boolean()", "object", typeof new Boolean() ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.3.1-1.js b/tests/mozilla/ecma/Boolean/15.6.3.1-1.js new file mode 100644 index 0000000..c3897e4 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.3.1-1.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.3.1-1.js + ECMA Section: 15.6.3 Boolean.prototype + + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontEnum property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.3.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var str='';for ( p in Boolean ) { str += p } str;", + "", + eval("var str='';for ( p in Boolean ) { str += p } str;") ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Boolean/15.6.3.1-2.js b/tests/mozilla/ecma/Boolean/15.6.3.1-2.js new file mode 100644 index 0000000..0ff248a --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.3.1-2.js @@ -0,0 +1,69 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.3.1-2.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontDelete property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "delete( Boolean.prototype)", + false, + delete( Boolean.prototype) ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.3.1-3.js b/tests/mozilla/ecma/Boolean/15.6.3.1-3.js new file mode 100644 index 0000000..5ba5c95 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.3.1-3.js @@ -0,0 +1,69 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.3.1-3.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontDelete property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.3.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "delete( Boolean.prototype); Boolean.prototype", + Boolean.prototype, + eval("delete( Boolean.prototype); Boolean.prototype") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.3.1-4.js b/tests/mozilla/ecma/Boolean/15.6.3.1-4.js new file mode 100644 index 0000000..56972e8 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.3.1-4.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.3.1-4.js + ECMA Section: 15.6.3.1 Properties of the Boolean Prototype Object + + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the ReadOnly property of Boolean.prototype + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + var SECTION = "15.6.3.1-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var BOOL_PROTO = Boolean.prototype; + + array[item++] = new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO", + true, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO") ); + + array[item++] = new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null", + false, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null") ); + + return ( array ); +} + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Boolean/15.6.3.1-5.js b/tests/mozilla/ecma/Boolean/15.6.3.1-5.js new file mode 100644 index 0000000..fb3605c --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.3.1-5.js @@ -0,0 +1,61 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.3.1-5.js + ECMA Section: 15.6.3.1 Boolean.prototype + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var VERSION = "ECMA_2"; + startTest(); + var SECTION = "15.6.3.1-5"; + var TITLE = "Boolean.prototype" + + writeHeaderToLog( SECTION + " " + TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Function.prototype == Boolean.__proto__", true, Function.prototype == Boolean.__proto__ ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Boolean/15.6.3.1.js b/tests/mozilla/ecma/Boolean/15.6.3.1.js new file mode 100644 index 0000000..55614f5 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.3.1.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.3.1.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + It has the internal [[Call]] and [[Construct]] + properties (not tested), and the length property. + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + + var SECTION = "15.6.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); + array[item++] = new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.3.js b/tests/mozilla/ecma/Boolean/15.6.3.js new file mode 100644 index 0000000..0e9a252 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.3.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.3.js + ECMA Section: 15.6.3 Properties of the Boolean Constructor + + Description: The value of the internal prototype property is + the Function prototype object. + + It has the internal [[Call]] and [[Construct]] + properties, and the length property. + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + var SECTION = "15.6.3"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Properties of the Boolean Constructor" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Boolean.__proto__ == Function.prototype", true, Boolean.__proto__ == Function.prototype ); + array[item++] = new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Boolean/15.6.4-1.js b/tests/mozilla/ecma/Boolean/15.6.4-1.js new file mode 100644 index 0000000..e40d71a --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4-1.js @@ -0,0 +1,73 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4-1.js + ECMA Section: 15.6.4 Properties of the Boolean Prototype Object + + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is + "Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype object + is the Object prototype object (15.2.3.1). + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + + + var VERSION = "ECMA_1" + startTest(); + var SECTION = "15.6.4-1"; + + writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof Boolean.prototype == typeof( new Boolean )", true, typeof Boolean.prototype == typeof( new Boolean ) ); + array[item++] = new TestCase( SECTION, "typeof( Boolean.prototype )", "object", typeof(Boolean.prototype) ); + array[item++] = new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); + array[item++] = new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); + + return ( array ); +} + +function test() { + for (tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.4-2.js b/tests/mozilla/ecma/Boolean/15.6.4-2.js new file mode 100644 index 0000000..760272e --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4-2.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4-2.js + ECMA Section: 15.6.4 Properties of the Boolean Prototype Object + + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is + "Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype object + is the Object prototype object (15.2.3.1). + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + + + var VERSION = "ECMA_2" + startTest(); + var SECTION = "15.6.4-2"; + + writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); + + return ( array ); +} + +function test() { + for (tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.4.1.js b/tests/mozilla/ecma/Boolean/15.6.4.1.js new file mode 100644 index 0000000..848b1f4 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.1.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.1.js + ECMA Section: 15.6.4.1 Boolean.prototype.constructor + + Description: The initial value of Boolean.prototype.constructor + is the built-in Boolean constructor. + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + var SECTION = "15.6.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.constructor" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "( Boolean.prototype.constructor == Boolean )", + true , + (Boolean.prototype.constructor == Boolean) ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.4.2-1.js b/tests/mozilla/ecma/Boolean/15.6.4.2-1.js new file mode 100644 index 0000000..85514fd --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.2-1.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.2.js + ECMA Section: 15.6.4.2-1 Boolean.prototype.toString() + Description: If this boolean value is true, then the string "true" + is returned; otherwise this boolean value must be false, + and the string "false" is returned. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "new Boolean(1)", "true", (new Boolean(1)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(0)", "false", (new Boolean(0)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(-1)", "true", (new Boolean(-1)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean('1')", "true", (new Boolean("1")).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean('0')", "true", (new Boolean("0")).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(true)", "true", (new Boolean(true)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(false)", "false", (new Boolean(false)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean('true')", "true", (new Boolean('true')).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean('false')", "true", (new Boolean('false')).toString() ); + + array[item++] = new TestCase( SECTION, "new Boolean('')", "false", (new Boolean('')).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(null)", "false", (new Boolean(null)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(void(0))", "false", (new Boolean(void(0))).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(-Infinity)", "true", (new Boolean(Number.NEGATIVE_INFINITY)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(NaN)", "false", (new Boolean(Number.NaN)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean()", "false", (new Boolean()).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=1)", "true", (new Boolean(x=1)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=0)", "false", (new Boolean(x=0)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=false)", "false", (new Boolean(x=false)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=true)", "true", (new Boolean(x=true)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=null)", "false", (new Boolean(x=null)).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x='')", "false", (new Boolean(x="")).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=' ')", "true", (new Boolean(x=" ")).toString() ); + + array[item++] = new TestCase( SECTION, "new Boolean(new MyObject(true))", "true", (new Boolean(new MyObject(true))).toString() ); + array[item++] = new TestCase( SECTION, "new Boolean(new MyObject(false))", "true", (new Boolean(new MyObject(false))).toString() ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + return this; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Boolean/15.6.4.2-2.js b/tests/mozilla/ecma/Boolean/15.6.4.2-2.js new file mode 100644 index 0000000..d46c49b --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.2-2.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.2-2.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + + array[item++] = new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()", + "false", + "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()" ); + array[item++] = new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()", + "true", + "tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()" ); + array[item++] = new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(false); x.toString=tostr;x.toString()", + "false", + "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()" ); + return ( array ); + +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Boolean/15.6.4.2-3.js b/tests/mozilla/ecma/Boolean/15.6.4.2-3.js new file mode 100644 index 0000000..faf0a94 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.2-3.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.2-3.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + + var SECTION = "15.6.4.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()", "true", eval("tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()") ); + array[item++] = new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()", "false", eval("tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.4.2-4-n.js b/tests/mozilla/ecma/Boolean/15.6.4.2-4-n.js new file mode 100644 index 0000000..a86ba51 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.2-4-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.2-4.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.2-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.toString()"; + writeHeaderToLog( SECTION +" "+ TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()", + "error", + "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval(testcases[tc].actual); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.4.3-1.js b/tests/mozilla/ecma/Boolean/15.6.4.3-1.js new file mode 100644 index 0000000..3589197 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.3-1.js @@ -0,0 +1,91 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.valueOf()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "new Boolean(1)", true, (new Boolean(1)).valueOf() ); + + array[item++] = new TestCase( SECTION, "new Boolean(0)", false, (new Boolean(0)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean('1')", true, (new Boolean("1")).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean('0')", true, (new Boolean("0")).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(true)", true, (new Boolean(true)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(false)", false, (new Boolean(false)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean('true')", true, (new Boolean("true")).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean('false')", true, (new Boolean('false')).valueOf() ); + + array[item++] = new TestCase( SECTION, "new Boolean('')", false, (new Boolean('')).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(null)", false, (new Boolean(null)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean()", false, (new Boolean()).valueOf() ); + + array[item++] = new TestCase( SECTION, "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); + array[item++] = new TestCase( SECTION, "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.4.3-2.js b/tests/mozilla/ecma/Boolean/15.6.4.3-2.js new file mode 100644 index 0000000..f1bc83d --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.3-2.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.3-2.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.valueOf()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()", false, eval("valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()") ); + array[item++] = new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()", true, eval("valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()") ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Boolean/15.6.4.3-3.js b/tests/mozilla/ecma/Boolean/15.6.4.3-3.js new file mode 100644 index 0000000..f19c168 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.3-3.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.3-3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + var SECTION = "15.6.4.3-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.valueOf()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()", + true, + eval("x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()") ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Boolean/15.6.4.3-4-n.js b/tests/mozilla/ecma/Boolean/15.6.4.3-4-n.js new file mode 100644 index 0000000..fe7b17c --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.3-4-n.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.3-4.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + var SECTION = "15.6.4.3-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean.prototype.valueOf()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()", + "error", + "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Boolean/15.6.4.3.js b/tests/mozilla/ecma/Boolean/15.6.4.3.js new file mode 100644 index 0000000..67b9a1b --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.3.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "15.8.6.4", "new Boolean(1)", true, (new Boolean(1)).valueOf() ); + + array[item++] = new TestCase( "15.8.6.4", "new Boolean(0)", false, (new Boolean(0)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean('1')", true, (new Boolean("1")).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean('0')", true, (new Boolean("0")).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(true)", true, (new Boolean(true)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(false)", false, (new Boolean(false)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean('true')", true, (new Boolean("true")).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean('false')", true, (new Boolean('false')).valueOf() ); + + array[item++] = new TestCase( "15.8.6.4", "new Boolean('')", false, (new Boolean('')).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(null)", false, (new Boolean(null)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean()", false, (new Boolean()).valueOf() ); + + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); + array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); + + return ( array ); +} + +function test( array ) { + var passed = true; + + writeHeaderToLog("15.8.6.4.3 Properties of the Boolean Object: valueOf"); + + for ( i = 0; i < array.length; i++ ) { + + array[i].passed = writeTestCaseResult( + array[i].expect, + array[i].actual, + "( "+ array[i].description +" ).valueOf() = "+ array[i].actual ); + + array[i].reason += ( array[i].passed ) ? "" : "wrong value "; + + passed = ( array[i].passed ) ? passed : false; + + } + + stopTest(); + + // all tests must return a boolean value + return ( array ); +} + +// for TCMS, the testcases array must be global. + var testcases = getTestCases(); + +// all tests must call a function that returns a boolean value + test( testcases ); diff --git a/tests/mozilla/ecma/Boolean/15.6.4.js b/tests/mozilla/ecma/Boolean/15.6.4.js new file mode 100644 index 0000000..44d12c1 --- /dev/null +++ b/tests/mozilla/ecma/Boolean/15.6.4.js @@ -0,0 +1,77 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.6.4.js + ECMA Section: Properties of the Boolean Prototype Object + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is " + Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Boolean + prototype object, the phrase "this Boolean object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Boolean". Also, the phrase "this boolean value" + refers to the boolean value represented by this Boolean object, that is, + the value of the internal [[Value]] property of this Boolean object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.6.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Boolean Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "Boolean.prototype == false", + true, + Boolean.prototype == false ); + + testcases[tc++] = new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.1.1-1.js b/tests/mozilla/ecma/Date/15.9.1.1-1.js new file mode 100644 index 0000000..4d936af --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.1.1-1.js @@ -0,0 +1,87 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.1.1-1.js + ECMA Section: 15.9.1.1 Time Range + Description: + - leap seconds are ignored + - assume 86400000 ms / day + - numbers range fom +/- 9,007,199,254,740,991 + - ms precision for any instant that is within + approximately +/-285,616 years from 1 jan 1970 + UTC + - range of times supported is -100,000,000 days + to 100,000,000 days from 1 jan 1970 12:00 am + - time supported is 8.64e5*10e8 milliseconds from + 1 jan 1970 UTC (+/-273972.6027397 years) + + - this test generates its own data -- it does not + read data from a file. + Author: christine@netscape.com + Date: 7 july 1997 + + Static variables: + FOUR_HUNDRED_YEARS + +*/ + +function test() { + writeHeaderToLog("15.8.1.1 Time Range"); + + for ( M_SECS = 0, CURRENT_YEAR = 1970; + M_SECS < 8640000000000000; + tc++, M_SECS += FOUR_HUNDRED_YEARS, CURRENT_YEAR += 400 ) { + + testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS)).getUTCFullYear() ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + if ( ! testcases[tc].passed ) { + testcases[tc].reason = "wrong year value"; + } + } + + stopTest(); + + return ( testcases ); +} + +// every one hundred years contains: +// 24 years with 366 days +// +// every four hundred years contains: +// 97 years with 366 days +// 303 years with 365 days +// +// 86400000*365*97 = 3067372800000 +// +86400000*366*303 = + 9555408000000 +// = 1.26227808e+13 + var FOUR_HUNDRED_YEARS = 1.26227808e+13; + var SECTION = "15.9.1.1-1"; + var tc = 0; + var testcases = new Array(); + + test(); diff --git a/tests/mozilla/ecma/Date/15.9.1.1-2.js b/tests/mozilla/ecma/Date/15.9.1.1-2.js new file mode 100644 index 0000000..c66ce38 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.1.1-2.js @@ -0,0 +1,82 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.1.1-2.js + ECMA Section: 15.9.1.1 Time Range + Description: + - leap seconds are ignored + - assume 86400000 ms / day + - numbers range fom +/- 9,007,199,254,740,991 + - ms precision for any instant that is within + approximately +/-285,616 years from 1 jan 1970 + UTC + - range of times supported is -100,000,000 days + to 100,000,000 days from 1 jan 1970 12:00 am + - time supported is 8.64e5*10e8 milliseconds from + 1 jan 1970 UTC (+/-273972.6027397 years) + Author: christine@netscape.com + Date: 9 july 1997 +*/ + +function test() { + + writeHeaderToLog("15.8.1.1 Time Range"); + + for ( M_SECS = 0, CURRENT_YEAR = 1970; + M_SECS > -8640000000000000; + tc++, M_SECS -= FOUR_HUNDRED_YEARS, CURRENT_YEAR -= 400 ) { + + testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS )).getUTCFullYear() ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description + " = " + + testcases[tc].actual ); + + if ( ! testcases[tc].passed ) { + testcases[tc].reason = "wrong year value"; + } + } + + stopTest(); + + return ( testcases ); +} + // every one hundred years contains: + // 24 years with 366 days + // + // every four hundred years contains: + // 97 years with 366 days + // 303 years with 365 days + // + // 86400000*366*97 = 3067372800000 + // +86400000*365*303 = + 9555408000000 + // = 1.26227808e+13 + + var FOUR_HUNDRED_YEARS = 1.26227808e+13; + var SECTION = "15.9.1.1-2"; + var tc = 0; + var testcases = new Array(); + + test(); + diff --git a/tests/mozilla/ecma/Date/15.9.2.1.js b/tests/mozilla/ecma/Date/15.9.2.1.js new file mode 100644 index 0000000..3545806 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.2.1.js @@ -0,0 +1,108 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.2.1.js + ECMA Section: 15.9.2.1 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds, ms ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.2.1"; + var TITLE = "Date Constructor used as a function"; + var TYPEOF = "string"; + var TOLERANCE = 1000; + + writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function: " + + "Date( year, month, date, hours, minutes, seconds, ms )" ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var TODAY = new Date(); + + // Dates around 1970 + + array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59,999)", (new Date()).toString(), Date(1969,11,31,15,59,59,999)) + array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0,0)) + array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,0,1)) + + // Dates around 2000 + array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59,999)", (new Date()).toString(), Date(1999,11,15,59,59,999)); + array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0,0)); + array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59,999)", (new Date()).toString(), Date(1999,11,31,23,59,59,999) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,0,1) ); + + // Dates around 1900 + + array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59,999)", (new Date()).toString(), Date(1899,11,31,23,59,59,999)); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0,0)); + + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59,999)", (new Date()).toString(), Date( 2000,1,28,23,59,59,999)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0,0)); + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59,999)", (new Date()).toString(), Date(2004,11,31,23,59,59,999)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59,999)", (new Date()).toString(), Date(2031,11,31,23,59,59,999)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0,0)); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.2.2-1.js b/tests/mozilla/ecma/Date/15.9.2.2-1.js new file mode 100644 index 0000000..8ad5694 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.2.2-1.js @@ -0,0 +1,105 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around 1970 + + array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59)", (new Date()).toString(), Date(1969,11,31,15,59,59)) + array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0)) + array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,1)) +/* + // Dates around 2000 + array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59)); + array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0)); + array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) ); + + // Dates around 1900 + + array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); + + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.2.2-2.js b/tests/mozilla/ecma/Date/15.9.2.2-2.js new file mode 100644 index 0000000..5baaf53 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.2.2-2.js @@ -0,0 +1,99 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around 2000 + array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59)); + array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0)); + array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) ); + +/* + // Dates around 1900 + + array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); + + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.2.2-3.js b/tests/mozilla/ecma/Date/15.9.2.2-3.js new file mode 100644 index 0000000..59255e2 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.2.2-3.js @@ -0,0 +1,92 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around 1900 + + array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); + +/* + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.2.2-4.js b/tests/mozilla/ecma/Date/15.9.2.2-4.js new file mode 100644 index 0000000..b63bb3e --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.2.2-4.js @@ -0,0 +1,85 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around feb 29, 2000 + + array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); + array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); + +/* + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.2.2-5.js b/tests/mozilla/ecma/Date/15.9.2.2-5.js new file mode 100644 index 0000000..5422682 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.2.2-5.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around jan 1, 2005 + array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); +/* + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +*/ + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.2.2-6.js b/tests/mozilla/ecma/Date/15.9.2.2-6.js new file mode 100644 index 0000000..8e269d0 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.2.2-6.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + var VERSION = 9706; + startTest(); + var SECTION = "15.9.2.2"; + var TOLERANCE = 100; + var TITLE = "The Date Constructor Called as a Function"; + + writeHeaderToLog(SECTION+" "+TITLE ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Dates around jan 1, 2032 + array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); + array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); + array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.3.1-1.js b/tests/mozilla/ecma/Date/15.9.3.1-1.js new file mode 100644 index 0000000..3090055 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.1-1.js @@ -0,0 +1,274 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 1970 + + addNewTestCase( new Date( 1969,11,31,15,59,59,999), + "new Date( 1969,11,31,15,59,59,999)", + [TIME_1970-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); + + addNewTestCase( new Date( 1969,11,31,23,59,59,999), + "new Date( 1969,11,31,23,59,59,999)", + [TIME_1970-TZ_ADJUST-1,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); + + addNewTestCase( new Date( 1970,0,1,0,0,0,0), + "new Date( 1970,0,1,0,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date( 1969,11,31,16,0,0,0), + "new Date( 1969,11,31,16,0,0,0)", + [TIME_1970,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date(1969,12,1,0,0,0,0), + "new Date(1969,12,1,0,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,32,0,0,0,0), + "new Date(1969,11,32,0,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,31,24,0,0,0), + "new Date(1969,11,31,24,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,31,23,60,0,0), + "new Date(1969,11,31,23,60,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,31,23,59,60,0), + "new Date(1969,11,31,23,59,60,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date(1969,11,31,23,59,59,1000), + "new Date(1969,11,31,23,59,59,1000)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + // Dates around 2000 + + addNewTestCase( new Date( 1999,11,31,15,59,59,999), + "new Date( 1999,11,31,15,59,59,999)", + [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); + + addNewTestCase( new Date( 1999,11,31,16,0,0,0), + "new Date( 1999,11,31,16,0,0,0)", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + + addNewTestCase( new Date( 1999,11,31,23,59,59,999), + "new Date( 1999,11,31,23,59,59,999)", + [TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0,0), + "new Date( 2000,0,1,0,0,0,0)", + [TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0,1), + "new Date( 2000,0,1,0,0,0,1)", + [TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); + + // Dates around 29 Feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); + + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); + +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} diff --git a/tests/mozilla/ecma/Date/15.9.3.1-2.js b/tests/mozilla/ecma/Date/15.9.3.1-2.js new file mode 100644 index 0000000..13d0ab6 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.1-2.js @@ -0,0 +1,231 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 2000 + + addNewTestCase( new Date( 1999,11,31,15,59,59,999), + "new Date( 1999,11,31,15,59,59,999)", + [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); + + addNewTestCase( new Date( 1999,11,31,16,0,0,0), + "new Date( 1999,11,31,16,0,0,0)", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + + addNewTestCase( new Date( 1999,11,31,23,59,59,999), + "new Date( 1999,11,31,23,59,59,999)", + [TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0,0), + "new Date( 2000,0,1,0,0,0,0)", + [TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0,1), + "new Date( 2000,0,1,0,0,0,1)", + [TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); +/* + // Dates around 29 Feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); + + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} diff --git a/tests/mozilla/ecma/Date/15.9.3.1-3.js b/tests/mozilla/ecma/Date/15.9.3.1-3.js new file mode 100644 index 0000000..ced3027 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.1-3.js @@ -0,0 +1,209 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 29 Feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); + + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +/* + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} diff --git a/tests/mozilla/ecma/Date/15.9.3.1-4.js b/tests/mozilla/ecma/Date/15.9.3.1-4.js new file mode 100644 index 0000000..0f18b12 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.1-4.js @@ -0,0 +1,193 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); +/* + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} diff --git a/tests/mozilla/ecma/Date/15.9.3.1-5.js b/tests/mozilla/ecma/Date/15.9.3.1-5.js new file mode 100644 index 0000000..0b7d436 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.1-5.js @@ -0,0 +1,170 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.9.3.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + getTestCases(); + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = TZ_PST * msPerHour; + + // Dates around 2005 + + var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings test case + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} diff --git a/tests/mozilla/ecma/Date/15.9.3.2-1.js b/tests/mozilla/ecma/Date/15.9.3.2-1.js new file mode 100644 index 0000000..718d314 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.2-1.js @@ -0,0 +1,241 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + // Dates around 1970 + + addNewTestCase( new Date( 1969,11,31,15,59,59), + "new Date( 1969,11,31,15,59,59)", + [-1000,1969,11,31,3,23,59,59,0,1969,11,31,3,15,59,59,0] ); + + addNewTestCase( new Date( 1969,11,31,16,0,0), + "new Date( 1969,11,31,16,0,0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date( 1969,11,31,23,59,59), + "new Date( 1969,11,31,23,59,59)", + [28799000,1970,0,1,4,7,59,59,0,1969,11,31,3,23,59,59,0] ); + + addNewTestCase( new Date( 1970, 0, 1, 0, 0, 0), + "new Date( 1970, 0, 1, 0, 0, 0)", + [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date( 1969,11,31,16,0,0), + "new Date( 1969,11,31,16,0,0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +/* + // Dates around 2000 + + addNewTestCase( new Date( 1999,11,31,15,59,59), + "new Date( 1999,11,31,15,59,59)", + [946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] ); + + addNewTestCase( new Date( 1999,11,31,16,0,0), + "new Date( 1999,11,31,16,0,0)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0), + "new Date( 2000,0,1,0,0,0)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0), + "new Date(1899,11,31,16,0,0)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59), + "new Date(1899,11,31,15,59,59)", + [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0), + "new Date(1900,0,1,0,0,0)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,1), + "new Date(1900,0,1,0,0,1)", + [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); + + var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + + // Dates around Feb 29, 2000 + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); + + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +function test() { + for( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} + diff --git a/tests/mozilla/ecma/Date/15.9.3.2-2.js b/tests/mozilla/ecma/Date/15.9.3.2-2.js new file mode 100644 index 0000000..b110f52 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.2-2.js @@ -0,0 +1,219 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + // Dates around 2000 + + addNewTestCase( new Date( 1999,11,31,15,59,59), + "new Date( 1999,11,31,15,59,59)", + [946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] ); + + addNewTestCase( new Date( 1999,11,31,16,0,0), + "new Date( 1999,11,31,16,0,0)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + + addNewTestCase( new Date( 2000,0,1,0,0,0), + "new Date( 2000,0,1,0,0,0)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +/* + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0), + "new Date(1899,11,31,16,0,0)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59), + "new Date(1899,11,31,15,59,59)", + [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0), + "new Date(1900,0,1,0,0,0)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,1), + "new Date(1900,0,1,0,0,1)", + [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); + + var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + + // Dates around Feb 29, 2000 + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); + + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +function test() { + for( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} + diff --git a/tests/mozilla/ecma/Date/15.9.3.2-3.js b/tests/mozilla/ecma/Date/15.9.3.2-3.js new file mode 100644 index 0000000..9e57730 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.2-3.js @@ -0,0 +1,205 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + // Dates around 1900 + + addNewTestCase( new Date(1899,11,31,16,0,0), + "new Date(1899,11,31,16,0,0)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(1899,11,31,15,59,59), + "new Date(1899,11,31,15,59,59)", + [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,0), + "new Date(1900,0,1,0,0,0)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date(1900,0,1,0,0,1), + "new Date(1900,0,1,0,0,1)", + [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); +/* + var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + + // Dates around Feb 29, 2000 + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); + + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +function test() { + for( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} + diff --git a/tests/mozilla/ecma/Date/15.9.3.2-4.js b/tests/mozilla/ecma/Date/15.9.3.2-4.js new file mode 100644 index 0000000..6b6b0c4 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.2-4.js @@ -0,0 +1,188 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + + var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + + // Dates around Feb 29, 2000 + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); +/* + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +function test() { + for( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} + diff --git a/tests/mozilla/ecma/Date/15.9.3.2-5.js b/tests/mozilla/ecma/Date/15.9.3.2-5.js new file mode 100644 index 0000000..798320b --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.2-5.js @@ -0,0 +1,170 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + +// for TCMS, the testcases array must be global. + var SECTION = "15.9.3.1"; + var TITLE = "Date( year, month, date, hours, minutes, seconds )"; + + writeHeaderToLog( SECTION+" " +TITLE ); + + var testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase object + test(); + +function getTestCases( ) { + + // Dates around Jan 1, 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + // Daylight Savings Time + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} + +function test() { + for( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + return testcases; +} + diff --git a/tests/mozilla/ecma/Date/15.9.3.8-1.js b/tests/mozilla/ecma/Date/15.9.3.8-1.js new file mode 100644 index 0000000..644f37c --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.8-1.js @@ -0,0 +1,300 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + + // Dates around 1970 + addNewTestCase( new Date(0), + "new Date(0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date(1), + "new Date(1)", + [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); + + addNewTestCase( new Date(true), + "new Date(true)", + [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); + + addNewTestCase( new Date(false), + "new Date(false)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(0)).toString() ), + "new Date(\""+ (new Date(0)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +/* +// addNewTestCase( "new Date(\""+ (new Date(0)).toLocaleString()+"\")", [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date((new Date(0)).toUTCString()), + "new Date(\""+ (new Date(0)).toUTCString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date((new Date(1)).toString()), + "new Date(\""+ (new Date(1)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date( TZ_ADJUST ), + "new Date(" + TZ_ADJUST+")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()), + "new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+ (new Date(TZ_ADJUST)).toLocaleString()+"\")",[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ), + "new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + // Dates around 2000 + + addNewTestCase( new Date(TIME_2000+TZ_ADJUST), + "new Date(" +(TIME_2000+TZ_ADJUST)+")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(TIME_2000), + "new Date(" +TIME_2000+")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TIME_2000)).toString()), + "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + +// addNewTestCase( "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toLocaleString()+"\")", [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +// addNewTestCase( "new Date(\"" +(new Date(TIME_2000)).toLocaleString()+"\")", [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; + + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +// Parsing toLocaleString() is not guaranteed by ECMA. +// addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.3.8-2.js b/tests/mozilla/ecma/Date/15.9.3.8-2.js new file mode 100644 index 0000000..4cfcb04 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.8-2.js @@ -0,0 +1,275 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + addNewTestCase( new Date((new Date(0)).toUTCString()), + "new Date(\""+ (new Date(0)).toUTCString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date((new Date(1)).toString()), + "new Date(\""+ (new Date(1)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date( TZ_ADJUST ), + "new Date(" + TZ_ADJUST+")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()), + "new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + + addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ), + "new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +/* + // Dates around 2000 + + addNewTestCase( new Date(TIME_2000+TZ_ADJUST), + "new Date(" +(TIME_2000+TZ_ADJUST)+")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(TIME_2000), + "new Date(" +TIME_2000+")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TIME_2000)).toString()), + "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + +// addNewTestCase( "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toLocaleString()+"\")", [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +// addNewTestCase( "new Date(\"" +(new Date(TIME_2000)).toLocaleString()+"\")", [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; + + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +// Parsing toLocaleString() is not guaranteed by ECMA. +// addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.3.8-3.js b/tests/mozilla/ecma/Date/15.9.3.8-3.js new file mode 100644 index 0000000..aaf430d --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.8-3.js @@ -0,0 +1,253 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + + // Dates around 2000 + + addNewTestCase( new Date(TIME_2000+TZ_ADJUST), + "new Date(" +(TIME_2000+TZ_ADJUST)+")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date(TIME_2000), + "new Date(" +TIME_2000+")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date((new Date(TIME_2000)).toString()), + "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + + addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +/* + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; + + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +// Parsing toLocaleString() is not guaranteed by ECMA. +// addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.3.8-4.js b/tests/mozilla/ecma/Date/15.9.3.8-4.js new file mode 100644 index 0000000..c25bda8 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.8-4.js @@ -0,0 +1,222 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; + + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + + addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +/* + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +*/ +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.3.8-5.js b/tests/mozilla/ecma/Date/15.9.3.8-5.js new file mode 100644 index 0000000..00b3b47 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.3.8-5.js @@ -0,0 +1,190 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.3.8"; + var TYPEOF = "object"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + + +// for TCMS, the testcases array must be global. + var tc= 0; + var TITLE = "Date constructor: new Date( value )"; + var SECTION = "15.9.3.8"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION +" " + TITLE ); + + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns a boolean value + test(); + +function getTestCases( ) { + // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + var TZ_ADJUST = -TZ_PST * msPerHour; + + + // Dates around 1900 + + var PST_1900 = TIME_1900 + 8*msPerHour; + + addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + + addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +/* + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); +*/ +} + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.4.2-1.js b/tests/mozilla/ecma/Date/15.9.4.2-1.js new file mode 100644 index 0000000..2fa4cbf --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.4.2-1.js @@ -0,0 +1,63 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/** + * File Name: + * Reference: http://bugzilla.mozilla.org/show_bug.cgi?id=4088 + * Description: Date parsing gets 12:30 AM wrong. + * New behavior: + * js> d = new Date('1/1/1999 13:30 AM') + * Invalid Date + * js> d = new Date('1/1/1999 13:30 PM') + * Invalid Date + * js> d = new Date('1/1/1999 12:30 AM') + * Fri Jan 01 00:30:00 GMT-0800 (PST) 1999 + * js> d = new Date('1/1/1999 12:30 PM') + * Fri Jan 01 12:30:00 GMT-0800 (PST) 1999 + * Author: christine@netscape.com + */ + + var SECTION = "15.9.4.2-1"; // provide a document reference (ie, ECMA section) + var VERSION = "ECMA"; // Version of JavaScript or ECMA + var TITLE = "Regression Test for Date.parse"; // Provide ECMA section title or a description + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=4088"; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + AddTestCase( "new Date('1/1/1999 12:30 AM').toString()", + new Date(1999,0,1,0,30).toString(), + new Date('1/1/1999 12:30 AM').toString() ); + + AddTestCase( "new Date('1/1/1999 12:30 PM').toString()", + new Date( 1999,0,1,12,30 ).toString(), + new Date('1/1/1999 12:30 PM').toString() ); + + AddTestCase( "new Date('1/1/1999 13:30 AM')", + "Invalid Date", + new Date('1/1/1999 13:30 AM').toString() ); + + + AddTestCase( "new Date('1/1/1999 13:30 PM')", + "Invalid Date", + new Date('1/1/1999 13:30 PM').toString() ); + + test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/tests/mozilla/ecma/Date/15.9.4.2.js b/tests/mozilla/ecma/Date/15.9.4.2.js new file mode 100644 index 0000000..5fd15ba --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.4.2.js @@ -0,0 +1,213 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.4.2.js + ECMA Section: 15.9.4.2 Date.parse() + Description: The parse() function applies the to ToString() operator + to its argument and interprets the resulting string as + a date. It returns a number, the UTC time value + corresponding to the date. + + The string may be interpreted as a local time, a UTC + time, or a time in some other time zone, depending on + the contents of the string. + + (need to test strings containing stuff with the time + zone specified, and verify that parse() returns the + correct GMT time) + + so for any Date object x, all of these things should + be equal: + + value tested in function: + x.valueOf() test_value() + Date.parse(x.toString()) test_tostring() + Date.parse(x.toGMTString()) test_togmt() + + Date.parse(x.toLocaleString()) is not required to + produce the same number value as the preceeding three + expressions. in general the value produced by + Date.parse is implementation dependent when given any + string value that could not be produced in that + implementation by the toString or toGMTString method. + + value tested in function: + Date.parse( x.toLocaleString()) test_tolocale() + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.9.4.2"; + var TITLE = "Date.parse()"; + + var TIME = 0; + var UTC_YEAR = 1; + var UTC_MONTH = 2; + var UTC_DATE = 3; + var UTC_DAY = 4; + var UTC_HOURS = 5; + var UTC_MINUTES = 6; + var UTC_SECONDS = 7; + var UTC_MS = 8; + + var YEAR = 9; + var MONTH = 10; + var DATE = 11; + var DAY = 12; + var HOURS = 13; + var MINUTES = 14; + var SECONDS = 15; + var MS = 16; + var TYPEOF = "object"; + +// for TCMS, the testcases array must be global. + writeHeaderToLog("15.9.4.2 Date.parse()" ); + var tc= 0; + testcases = new Array(); + getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + + // Dates around 1970 + + addNewTestCase( new Date(0), + "new Date(0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + + addNewTestCase( new Date(-1), + "new Date(-1)", + [-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); + addNewTestCase( new Date(28799999), + "new Date(28799999)", + [28799999,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); + addNewTestCase( new Date(28800000), + "new Date(28800000)", + [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + // Dates around 2000 + + addNewTestCase( new Date(946684799999), + "new Date(946684799999)", + [946684799999,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); + addNewTestCase( new Date(946713599999), + "new Date(946713599999)", + [946713599999,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); + addNewTestCase( new Date(946684800000), + "new Date(946684800000)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + addNewTestCase( new Date(946713600000), + "new Date(946713600000)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + + // Dates around 1900 + + addNewTestCase( new Date(-2208988800000), + "new Date(-2208988800000)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + + addNewTestCase( new Date(-2208988800001), + "new Date(-2208988800001)", + [-2208988800001,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + + addNewTestCase( new Date(-2208960000001), + "new Date(-2208960000001)", + [-2208960000001,1900,0,1,1,7,59,59,0,1899,11,31,0,23,59,59,999] ); + addNewTestCase( new Date(-2208960000000), + "new Date(-2208960000000)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + addNewTestCase( new Date(-2208959999999), + "new Date(-2208959999999)", + [-2208959999999,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + + // Dates around Feb 29, 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date(" + UTC_FEB_29_2000 +")", + [UTC_FEB_29_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + addNewTestCase( new Date(PST_FEB_29_2000), + "new Date(" + PST_FEB_29_2000 +")", + [PST_FEB_29_2000,2000,0,1,6,8.0,0,0,2000,0,1,6,0,0,0,0]); + + // Dates around Jan 1 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + + addNewTestCase( new Date(UTC_JAN_1_2005), + "new Date("+ UTC_JAN_1_2005 +")", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); + addNewTestCase( new Date(PST_JAN_1_2005), + "new Date("+ PST_JAN_1_2005 +")", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + +} +function addNewTestCase( DateCase, DateString, ResultArray ) { + DateCase = DateCase; + + item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + testcases[item++] = new TestCase( SECTION, "Date.parse(" + DateCase.toString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toString()) ); + testcases[item++] = new TestCase( SECTION, "Date.parse(" + DateCase.toGMTString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toGMTString()) ); +/* + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() z inutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +*/ +} +function test() { + for( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + stopTest(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.4.3.js b/tests/mozilla/ecma/Date/15.9.4.3.js new file mode 100644 index 0000000..e56f971 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.4.3.js @@ -0,0 +1,209 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + + + var testcases = new Array(); + var SECTION = "15.9.4.3"; + var TITLE = "Date.UTC( year, month, date, hours, minutes, seconds, ms )"; + + getTestCases(); + test(); + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} + +function utc( year, month, date, hours, minutes, seconds, ms ) { + d = new MyDate(); + d.year = Number(year); + + if (month) + d.month = Number(month); + if (date) + d.date = Number(date); + if (hours) + d.hours = Number(hours); + if (minutes) + d.minutes = Number(minutes); + if (seconds) + d.seconds = Number(seconds); + if (ms) + d.ms = Number(ms); + + if ( isNaN(d.year) && 0 <= ToInteger(d.year) && d.year <= 99 ) { + d.year = 1900 + ToInteger(d.year); + } + + if (isNaN(month) || isNaN(year) || isNaN(date) || isNaN(hours) || + isNaN(minutes) || isNaN(seconds) || isNaN(ms) ) { + d.year = Number.NaN; + d.month = Number.NaN; + d.date = Number.NaN; + d.hours = Number.NaN; + d.minutes = Number.NaN; + d.seconds = Number.NaN; + d.ms = Number.NaN; + d.value = Number.NaN; + d.time = Number.NaN; + d.day =Number.NaN; + return d; + } + + d.day = MakeDay( d.year, d.month, d.date ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = (TimeClip( MakeDate(d.day,d.time))); + + return d; +} + +function UTCTime( t ) { + sign = ( t < 0 ) ? -1 : 1; + return ( (t +(TZ_DIFF*msPerHour)) ); +} + +function getTestCases() { + + // Dates around 1970 + + addNewTestCase( Date.UTC( 1970,0,1,0,0,0,0), + "Date.UTC( 1970,0,1,0,0,0,0)", + utc(1970,0,1,0,0,0,0) ); + + addNewTestCase( Date.UTC( 1969,11,31,23,59,59,999), + "Date.UTC( 1969,11,31,23,59,59,999)", + utc(1969,11,31,23,59,59,999) ); + addNewTestCase( Date.UTC( 1972,1,29,23,59,59,999), + "Date.UTC( 1972,1,29,23,59,59,999)", + utc(1972,1,29,23,59,59,999) ); + addNewTestCase( Date.UTC( 1972,2,1,23,59,59,999), + "Date.UTC( 1972,2,1,23,59,59,999)", + utc(1972,2,1,23,59,59,999) ); + addNewTestCase( Date.UTC( 1968,1,29,23,59,59,999), + "Date.UTC( 1968,1,29,23,59,59,999)", + utc(1968,1,29,23,59,59,999) ); + addNewTestCase( Date.UTC( 1968,2,1,23,59,59,999), + "Date.UTC( 1968,2,1,23,59,59,999)", + utc(1968,2,1,23,59,59,999) ); + addNewTestCase( Date.UTC( 1969,0,1,0,0,0,0), + "Date.UTC( 1969,0,1,0,0,0,0)", + utc(1969,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 1969,11,31,23,59,59,1000), + "Date.UTC( 1969,11,31,23,59,59,1000)", + utc(1970,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 1969,Number.NaN,31,23,59,59,999), + "Date.UTC( 1969,Number.NaN,31,23,59,59,999)", + utc(1969,Number.NaN,31,23,59,59,999) ); + + // Dates around 2000 + + addNewTestCase( Date.UTC( 1999,11,31,23,59,59,999), + "Date.UTC( 1999,11,31,23,59,59,999)", + utc(1999,11,31,23,59,59,999) ); + addNewTestCase( Date.UTC( 2000,0,1,0,0,0,0), + "Date.UTC( 2000,0,1,0,0,0,0)", + utc(2000,0,1,0,0,0,0) ); + + // Dates around 1900 + addNewTestCase( Date.UTC( 1899,11,31,23,59,59,999), + "Date.UTC( 1899,11,31,23,59,59,999)", + utc(1899,11,31,23,59,59,999) ); + addNewTestCase( Date.UTC( 1900,0,1,0,0,0,0), + "Date.UTC( 1900,0,1,0,0,0,0)", + utc(1900,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 1973,0,1,0,0,0,0), + "Date.UTC( 1973,0,1,0,0,0,0)", + utc(1973,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 1776,6,4,12,36,13,111), + "Date.UTC( 1776,6,4,12,36,13,111)", + utc(1776,6,4,12,36,13,111) ); + addNewTestCase( Date.UTC( 2525,9,18,15,30,1,123), + "Date.UTC( 2525,9,18,15,30,1,123)", + utc(2525,9,18,15,30,1,123) ); + + // Dates around 29 Feb 2000 + + addNewTestCase( Date.UTC( 2000,1,29,0,0,0,0 ), + "Date.UTC( 2000,1,29,0,0,0,0 )", + utc(2000,1,29,0,0,0,0) ); + addNewTestCase( Date.UTC( 2000,1,29,8,0,0,0 ), + "Date.UTC( 2000,1,29,8,0,0,0 )", + utc(2000,1,29,8,0,0,0) ); + + // Dates around 1 Jan 2005 + + addNewTestCase( Date.UTC( 2005,0,1,0,0,0,0 ), + "Date.UTC( 2005,0,1,0,0,0,0 )", + utc(2005,0,1,0,0,0,0) ); + addNewTestCase( Date.UTC( 2004,11,31,16,0,0,0 ), + "Date.UTC( 2004,11,31,16,0,0,0 )", + utc(2004,11,31,16,0,0,0) ); +} + +function addNewTestCase( DateCase, DateString, ExpectDate) { + DateCase = DateCase; + + item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); + testcases[item++] = new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); +/* + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ExpectDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ExpectDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ExpectDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ExpectDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ExpectDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ExpectDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ExpectDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ExpectDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ExpectDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ExpectDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ExpectDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ExpectDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ExpectDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ExpectDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ExpectDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ExpectDate.ms, DateCase.getMilliseconds() ); +*/ +} +function test() { + for( tc=0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = " + + testcases[tc].actual ); + } + + stopTest(); + return testcases; +} diff --git a/tests/mozilla/ecma/Date/15.9.5.1.js b/tests/mozilla/ecma/Date/15.9.5.1.js new file mode 100644 index 0000000..d605896 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.1.js @@ -0,0 +1,59 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.1.js + ECMA Section: 15.9.5.1 Date.prototype.constructor + Description: + The initial value of Date.prototype.constructor is the built-in Date + constructor. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.constructor == Date", + true, + Date.prototype.constructor == Date ); + test(); +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-1.js b/tests/mozilla/ecma/Date/15.9.5.10-1.js new file mode 100644 index 0000000..f887725 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-1.js @@ -0,0 +1,111 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( now ); +/* + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-10.js b/tests/mozilla/ecma/Date/15.9.5.10-10.js new file mode 100644 index 0000000..1d8060d --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-10.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_START_1998+1 ); +/* + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-11.js b/tests/mozilla/ecma/Date/15.9.5.10-11.js new file mode 100644 index 0000000..752b114 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-11.js @@ -0,0 +1,101 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_END_1998 ); +/* + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-12.js b/tests/mozilla/ecma/Date/15.9.5.10-12.js new file mode 100644 index 0000000..587b023 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-12.js @@ -0,0 +1,100 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_END_1998-1 ); +/* + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-13.js b/tests/mozilla/ecma/Date/15.9.5.10-13.js new file mode 100644 index 0000000..bf9027a --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-13.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_END_1998+1 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-2.js b/tests/mozilla/ecma/Date/15.9.5.10-2.js new file mode 100644 index 0000000..a775643 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-2.js @@ -0,0 +1,110 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( TIME_YEAR_0 ); +/* + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-3.js b/tests/mozilla/ecma/Date/15.9.5.10-3.js new file mode 100644 index 0000000..56fee4b --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-3.js @@ -0,0 +1,109 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( TIME_1970 ); +/* + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-4.js b/tests/mozilla/ecma/Date/15.9.5.10-4.js new file mode 100644 index 0000000..1f22d11 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-4.js @@ -0,0 +1,107 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( TIME_1900 ); +/* + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-5.js b/tests/mozilla/ecma/Date/15.9.5.10-5.js new file mode 100644 index 0000000..4e7c80a --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-5.js @@ -0,0 +1,107 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( TIME_2000 ); +/* + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-6.js b/tests/mozilla/ecma/Date/15.9.5.10-6.js new file mode 100644 index 0000000..6408622 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-6.js @@ -0,0 +1,106 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( UTC_FEB_29_2000 ); +/* + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-7.js b/tests/mozilla/ecma/Date/15.9.5.10-7.js new file mode 100644 index 0000000..d1741e3 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-7.js @@ -0,0 +1,105 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( UTC_JAN_1_2005 ); +/* + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-8.js b/tests/mozilla/ecma/Date/15.9.5.10-8.js new file mode 100644 index 0000000..3ef0398 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-8.js @@ -0,0 +1,104 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_START_1998 ); +/* + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.10-9.js b/tests/mozilla/ecma/Date/15.9.5.10-9.js new file mode 100644 index 0000000..1d8325c --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.10-9.js @@ -0,0 +1,103 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + // some daylight savings time cases + + var DST_START_1998 = UTC( GetSecondSundayInMarch(TimeFromYear(1998)) + 2*msPerHour ) + + var DST_END_1998 = UTC( GetFirstSundayInNovember(TimeFromYear(1998)) + 2*msPerHour ); + + addTestCase( DST_START_1998-1 ); +/* + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); +*/ + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); + test(); +function addTestCase( t ) { + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.11-1.js b/tests/mozilla/ecma/Date/15.9.5.11-1.js new file mode 100644 index 0000000..9b425e8 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.11-1.js @@ -0,0 +1,99 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + addTestCase( now ); + + test() + +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.11-2.js b/tests/mozilla/ecma/Date/15.9.5.11-2.js new file mode 100644 index 0000000..ed946ea --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.11-2.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.11 + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + + addTestCase( TIME_YEAR_0 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.11-3.js b/tests/mozilla/ecma/Date/15.9.5.11-3.js new file mode 100644 index 0000000..f596a83 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.11-3.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_1970 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.11-4.js b/tests/mozilla/ecma/Date/15.9.5.11-4.js new file mode 100644 index 0000000..3b9d480 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.11-4.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_1900 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7* msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.11-5.js b/tests/mozilla/ecma/Date/15.9.5.11-5.js new file mode 100644 index 0000000..d76f392 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.11-5.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_2000 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.11-6.js b/tests/mozilla/ecma/Date/15.9.5.11-6.js new file mode 100644 index 0000000..7cb0509 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.11-6.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); + + addTestCase( UTC_FEB_29_2000 ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.11-7.js b/tests/mozilla/ecma/Date/15.9.5.11-7.js new file mode 100644 index 0000000..08eb7f6 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.11-7.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDate()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); + + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); +*/ + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.12-1.js b/tests/mozilla/ecma/Date/15.9.5.12-1.js new file mode 100644 index 0000000..437a809 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.12-1.js @@ -0,0 +1,105 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); +/* + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.12-2.js b/tests/mozilla/ecma/Date/15.9.5.12-2.js new file mode 100644 index 0000000..dd58cb0 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.12-2.js @@ -0,0 +1,104 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_YEAR_0 ); +/* + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.12-3.js b/tests/mozilla/ecma/Date/15.9.5.12-3.js new file mode 100644 index 0000000..6212458 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.12-3.js @@ -0,0 +1,103 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1970 ); +/* + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.12-4.js b/tests/mozilla/ecma/Date/15.9.5.12-4.js new file mode 100644 index 0000000..e7bde15 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.12-4.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1900 ); +/* + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.12-5.js b/tests/mozilla/ecma/Date/15.9.5.12-5.js new file mode 100644 index 0000000..796187a --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.12-5.js @@ -0,0 +1,101 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_2000 ); +/* + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.12-6.js b/tests/mozilla/ecma/Date/15.9.5.12-6.js new file mode 100644 index 0000000..1aa0a1d --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.12-6.js @@ -0,0 +1,100 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_FEB_29_2000 ); +/* + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.12-7.js b/tests/mozilla/ecma/Date/15.9.5.12-7.js new file mode 100644 index 0000000..c638614 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.12-7.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +*/ + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.12-8.js b/tests/mozilla/ecma/Date/15.9.5.12-8.js new file mode 100644 index 0000000..54260ca --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.12-8.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.12 + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.13-1.js b/tests/mozilla/ecma/Date/15.9.5.13-1.js new file mode 100644 index 0000000..06bd92e --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.13-1.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + addTestCase( now ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.13-2.js b/tests/mozilla/ecma/Date/15.9.5.13-2.js new file mode 100644 index 0000000..bec562c --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.13-2.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.13 + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + + addTestCase( TIME_YEAR_0 ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.13-3.js b/tests/mozilla/ecma/Date/15.9.5.13-3.js new file mode 100644 index 0000000..6124d86 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.13-3.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_1970 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.13-4.js b/tests/mozilla/ecma/Date/15.9.5.13-4.js new file mode 100644 index 0000000..37fd989 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.13-4.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_1900 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.13-5.js b/tests/mozilla/ecma/Date/15.9.5.13-5.js new file mode 100644 index 0000000..2af2e9e --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.13-5.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + addTestCase( TIME_2000 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.13-6.js b/tests/mozilla/ecma/Date/15.9.5.13-6.js new file mode 100644 index 0000000..ce5e335 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.13-6.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + addTestCase( UTC_FEB_29_2000 ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.13-7.js b/tests/mozilla/ecma/Date/15.9.5.13-7.js new file mode 100644 index 0000000..2870bc5 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.13-7.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.13-8.js b/tests/mozilla/ecma/Date/15.9.5.13-8.js new file mode 100644 index 0000000..703483e --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.13-8.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCDay()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCDay()", + NaN, + (new Date(NaN)).getUTCDay() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCDay.length", + 0, + Date.prototype.getUTCDay.length ); + + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); + + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { + t += d; + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); + } + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.14.js b/tests/mozilla/ecma/Date/15.9.5.14.js new file mode 100644 index 0000000..4d95ada --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.14.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.14.js + ECMA Section: 15.9.5.14 + Description: Date.prototype.getHours + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return HourFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.14"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getHours()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getHours()", + NaN, + (new Date(NaN)).getHours() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getHours.length", + 0, + Date.prototype.getHours.length ); + test(); +function addTestCase( t ) { + for ( h = 0; h < 24; h+=4 ) { + t += msPerHour; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getHours()", + HourFromTime((LocalTime(t))), + (new Date(t)).getHours() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.15.js b/tests/mozilla/ecma/Date/15.9.5.15.js new file mode 100644 index 0000000..de4a132 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.15.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.15.js + ECMA Section: 15.9.5.15 + Description: Date.prototype.getUTCHours + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return HourFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.15"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCHours()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCHours()", + NaN, + (new Date(NaN)).getUTCHours() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCHours.length", + 0, + Date.prototype.getUTCHours.length ); + test(); +function addTestCase( t ) { + for ( h = 0; h < 24; h+=3 ) { + t += msPerHour; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCHours()", + HourFromTime((t)), + (new Date(t)).getUTCHours() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.16.js b/tests/mozilla/ecma/Date/15.9.5.16.js new file mode 100644 index 0000000..2a02370 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.16.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.16.js + ECMA Section: 15.9.5.16 + Description: Date.prototype.getMinutes + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return MinFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.16"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getMinutes()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getMinutes()", + NaN, + (new Date(NaN)).getMinutes() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getMinutes.length", + 0, + Date.prototype.getMinutes.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += msPerMinute; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getMinutes()", + MinFromTime((LocalTime(t))), + (new Date(t)).getMinutes() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.17.js b/tests/mozilla/ecma/Date/15.9.5.17.js new file mode 100644 index 0000000..0afaa7b --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.17.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.17.js + ECMA Section: 15.9.5.17 + Description: Date.prototype.getUTCMinutes + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MinFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.17"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMinutes()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMinutes()", + NaN, + (new Date(NaN)).getUTCMinutes() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMinutes.length", + 0, + Date.prototype.getUTCMinutes.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += msPerMinute; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMinutes()", + MinFromTime(t), + (new Date(t)).getUTCMinutes() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.18.js b/tests/mozilla/ecma/Date/15.9.5.18.js new file mode 100644 index 0000000..1537683 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.18.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.18.js + ECMA Section: 15.9.5.18 + Description: Date.prototype.getSeconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return SecFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.18"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getSeconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getSeconds()", + NaN, + (new Date(NaN)).getSeconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getSeconds.length", + 0, + Date.prototype.getSeconds.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += 1000; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getSeconds()", + SecFromTime(LocalTime(t)), + (new Date(t)).getSeconds() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.19.js b/tests/mozilla/ecma/Date/15.9.5.19.js new file mode 100644 index 0000000..91f2a0a --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.19.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.19.js + ECMA Section: 15.9.5.19 + Description: Date.prototype.getUTCSeconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return SecFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.19"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCSeconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCSeconds()", + NaN, + (new Date(NaN)).getUTCSeconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCSeconds.length", + 0, + Date.prototype.getUTCSeconds.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += 1000; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCSeconds()", + SecFromTime(t), + (new Date(t)).getUTCSeconds() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.2-1.js b/tests/mozilla/ecma/Date/15.9.5.2-1.js new file mode 100644 index 0000000..bb0fb02 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.2-1.js @@ -0,0 +1,152 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.toString.length", + 0, + Date.prototype.toString.length ); + + var now = new Date(); + + // can't test the content of the string, but can verify that the string is + // parsable by Date.parse + + testcases[tc++] = new TestCase( SECTION, + "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", + true, + Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); + + testcases[tc++] = new TestCase( SECTION, + "typeof now.toString()", + "string", + typeof now.toString() ); + // 1970 + + TZ_ADJUST = TZ_DIFF * msPerHour; + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date(0)).toString() )", + 0, + Date.parse( (new Date(0)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", + TZ_ADJUST, + Date.parse( (new Date(TZ_ADJUST)).toString() ) ) + + // 1900 + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900+")).toString() )", + TIME_1900, + Date.parse( (new Date(TIME_1900)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", + TIME_1900 -TZ_ADJUST, + Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ) + + // 2000 + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000+")).toString() )", + TIME_2000, + Date.parse( (new Date(TIME_2000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", + TIME_2000 -TZ_ADJUST, + Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ) + + // 29 Feb 2000 + + var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+UTC_29_FEB_2000+")).toString() )", + UTC_29_FEB_2000, + Date.parse( (new Date(UTC_29_FEB_2000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-1000)+")).toString() )", + UTC_29_FEB_2000-1000, + Date.parse( (new Date(UTC_29_FEB_2000-1000)).toString() ) ) + + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-TZ_ADJUST)+")).toString() )", + UTC_29_FEB_2000-TZ_ADJUST, + Date.parse( (new Date(UTC_29_FEB_2000-TZ_ADJUST)).toString() ) ) + // 2O05 + + var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+UTC_1_JAN_2005+")).toString() )", + UTC_1_JAN_2005, + Date.parse( (new Date(UTC_1_JAN_2005)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-1000)+")).toString() )", + UTC_1_JAN_2005-1000, + Date.parse( (new Date(UTC_1_JAN_2005-1000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-TZ_ADJUST)+")).toString() )", + UTC_1_JAN_2005-TZ_ADJUST, + Date.parse( (new Date(UTC_1_JAN_2005-TZ_ADJUST)).toString() ) ) + + test(); +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.2-2-n.js b/tests/mozilla/ecma/Date/15.9.5.2-2-n.js new file mode 100644 index 0000000..8044dd8 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.2-2-n.js @@ -0,0 +1,77 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.2-2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + + This verifies that calling toString on an object that is not a string + generates a runtime error. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var OBJ = new MyObject( new Date(0) ); + + testcases[tc++] = new TestCase( SECTION, + "var OBJ = new MyObject( new Date(0) ); OBJ.toString()", + "error", + OBJ.toString() ); + test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = Date.prototype.toString; + return this; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.2.js b/tests/mozilla/ecma/Date/15.9.5.2.js new file mode 100644 index 0000000..bb0fb02 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.2.js @@ -0,0 +1,152 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.toString.length", + 0, + Date.prototype.toString.length ); + + var now = new Date(); + + // can't test the content of the string, but can verify that the string is + // parsable by Date.parse + + testcases[tc++] = new TestCase( SECTION, + "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", + true, + Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); + + testcases[tc++] = new TestCase( SECTION, + "typeof now.toString()", + "string", + typeof now.toString() ); + // 1970 + + TZ_ADJUST = TZ_DIFF * msPerHour; + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date(0)).toString() )", + 0, + Date.parse( (new Date(0)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", + TZ_ADJUST, + Date.parse( (new Date(TZ_ADJUST)).toString() ) ) + + // 1900 + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900+")).toString() )", + TIME_1900, + Date.parse( (new Date(TIME_1900)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", + TIME_1900 -TZ_ADJUST, + Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ) + + // 2000 + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000+")).toString() )", + TIME_2000, + Date.parse( (new Date(TIME_2000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", + TIME_2000 -TZ_ADJUST, + Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ) + + // 29 Feb 2000 + + var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+UTC_29_FEB_2000+")).toString() )", + UTC_29_FEB_2000, + Date.parse( (new Date(UTC_29_FEB_2000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-1000)+")).toString() )", + UTC_29_FEB_2000-1000, + Date.parse( (new Date(UTC_29_FEB_2000-1000)).toString() ) ) + + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-TZ_ADJUST)+")).toString() )", + UTC_29_FEB_2000-TZ_ADJUST, + Date.parse( (new Date(UTC_29_FEB_2000-TZ_ADJUST)).toString() ) ) + // 2O05 + + var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+UTC_1_JAN_2005+")).toString() )", + UTC_1_JAN_2005, + Date.parse( (new Date(UTC_1_JAN_2005)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-1000)+")).toString() )", + UTC_1_JAN_2005-1000, + Date.parse( (new Date(UTC_1_JAN_2005-1000)).toString() ) ) + + testcases[tc++] = new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-TZ_ADJUST)+")).toString() )", + UTC_1_JAN_2005-TZ_ADJUST, + Date.parse( (new Date(UTC_1_JAN_2005-TZ_ADJUST)).toString() ) ) + + test(); +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.20.js b/tests/mozilla/ecma/Date/15.9.5.20.js new file mode 100644 index 0000000..3ef81f2 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.20.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.20.js + ECMA Section: 15.9.5.20 + Description: Date.prototype.getMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.20"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getMilliseconds()", + NaN, + (new Date(NaN)).getMilliseconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getMilliseconds.length", + 0, + Date.prototype.getMilliseconds.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getMilliseconds()", + msFromTime(LocalTime(t)), + (new Date(t)).getMilliseconds() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.21-1.js b/tests/mozilla/ecma/Date/15.9.5.21-1.js new file mode 100644 index 0000000..eb89ba4 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.21-1.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); +/* + addTestCase( TIME_YEAR_0 ); + + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); +*/ + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.21-2.js b/tests/mozilla/ecma/Date/15.9.5.21-2.js new file mode 100644 index 0000000..5a70d47 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.21-2.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_YEAR_0 ); +/* + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); +*/ + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.21-3.js b/tests/mozilla/ecma/Date/15.9.5.21-3.js new file mode 100644 index 0000000..bfd80c8 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.21-3.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1970 ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.21-4.js b/tests/mozilla/ecma/Date/15.9.5.21-4.js new file mode 100644 index 0000000..3f0e4e8 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.21-4.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1900 ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.21-5.js b/tests/mozilla/ecma/Date/15.9.5.21-5.js new file mode 100644 index 0000000..2ef6e21 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.21-5.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_2000 ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.21-6.js b/tests/mozilla/ecma/Date/15.9.5.21-6.js new file mode 100644 index 0000000..3973472 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.21-6.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_FEB_29_2000 ); + + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.21-7.js b/tests/mozilla/ecma/Date/15.9.5.21-7.js new file mode 100644 index 0000000..e50aa04 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.21-7.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.21-8.js b/tests/mozilla/ecma/Date/15.9.5.21-8.js new file mode 100644 index 0000000..b23dfc3 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.21-8.js @@ -0,0 +1,86 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.21"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMilliseconds()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.22-1.js b/tests/mozilla/ecma/Date/15.9.5.22-1.js new file mode 100644 index 0000000..cd84a9b --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.22-1.js @@ -0,0 +1,100 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + +// addTestCase( now ); + + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); + + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.22-2.js b/tests/mozilla/ecma/Date/15.9.5.22-2.js new file mode 100644 index 0000000..e516135 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.22-2.js @@ -0,0 +1,99 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_YEAR_0 ); +/* + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.22-3.js b/tests/mozilla/ecma/Date/15.9.5.22-3.js new file mode 100644 index 0000000..371cbc2 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.22-3.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1970 ); +/* + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.22-4.js b/tests/mozilla/ecma/Date/15.9.5.22-4.js new file mode 100644 index 0000000..1c63441 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.22-4.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_1900 ); +/* + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.22-5.js b/tests/mozilla/ecma/Date/15.9.5.22-5.js new file mode 100644 index 0000000..3f20ea4 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.22-5.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( TIME_2000 ); +/* + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.22-6.js b/tests/mozilla/ecma/Date/15.9.5.22-6.js new file mode 100644 index 0000000..0aee4a0 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.22-6.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_FEB_29_2000 ); +/* + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.22-7.js b/tests/mozilla/ecma/Date/15.9.5.22-7.js new file mode 100644 index 0000000..2d6ecfc --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.22-7.js @@ -0,0 +1,93 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( UTC_JAN_1_2005 ); +/* + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +*/ + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.22-8.js b/tests/mozilla/ecma/Date/15.9.5.22-8.js new file mode 100644 index 0000000..f7d6520 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.22-8.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.22"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTimezoneOffset()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); + test(); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-1.js b/tests/mozilla/ecma/Date/15.9.5.23-1.js new file mode 100644 index 0000000..3a74450 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-1.js @@ -0,0 +1,157 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + var testcases = new Array(); + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( 0, 0 ); +/* + addTestCase( now, -2208988800000 ); + addTestCase( now, -86400000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, -2208988800000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-10.js b/tests/mozilla/ecma/Date/15.9.5.23-10.js new file mode 100644 index 0000000..406123b --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-10.js @@ -0,0 +1,156 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + var testcases = new Array(); + + getTestCases(); + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, -2208988800000 ); +/* + addTestCase( now, -86400000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, -2208988800000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-11.js b/tests/mozilla/ecma/Date/15.9.5.23-11.js new file mode 100644 index 0000000..377edd5 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-11.js @@ -0,0 +1,155 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, -86400000 ); +/* + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, -2208988800000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-12.js b/tests/mozilla/ecma/Date/15.9.5.23-12.js new file mode 100644 index 0000000..b0820c0 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-12.js @@ -0,0 +1,153 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + var testcases = new Array(); + getTestCases(); + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, 946684800000 ); +/* + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, -2208988800000 ); + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-13.js b/tests/mozilla/ecma/Date/15.9.5.23-13.js new file mode 100644 index 0000000..058a7c7 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-13.js @@ -0,0 +1,150 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, -2208988800000 ); +/* + addTestCase( now, 946684800000 ); + + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-14.js b/tests/mozilla/ecma/Date/15.9.5.23-14.js new file mode 100644 index 0000000..135e808 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-14.js @@ -0,0 +1,148 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-14"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, 946684800000 ); +/* + // this daylight savings case fails -- need to fix date test functions +// addTestCase( now, -69609600000 ); + addTestCase( now, 0 ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-15.js b/tests/mozilla/ecma/Date/15.9.5.23-15.js new file mode 100644 index 0000000..0f4e587 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-15.js @@ -0,0 +1,144 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, 0 ); +/* + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-16.js b/tests/mozilla/ecma/Date/15.9.5.23-16.js new file mode 100644 index 0000000..7390eb5 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-16.js @@ -0,0 +1,143 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, String( TIME_1900 ) ); +/* + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-17.js b/tests/mozilla/ecma/Date/15.9.5.23-17.js new file mode 100644 index 0000000..0ac866e --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-17.js @@ -0,0 +1,142 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, String( TZ_DIFF* msPerHour ) ); +/* + addTestCase( now, String( TIME_2000 ) ); +*/ +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-18.js b/tests/mozilla/ecma/Date/15.9.5.23-18.js new file mode 100644 index 0000000..902f411 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-18.js @@ -0,0 +1,139 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.9.5.23-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function getTestCases() { + var now = "now"; + addTestCase( now, String( TIME_2000 ) ); +} + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-2.js b/tests/mozilla/ecma/Date/15.9.5.23-2.js new file mode 100644 index 0000000..e471514 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-2.js @@ -0,0 +1,111 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + test_times = new Array( now, TIME_1970, TIME_1900, TIME_2000 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(now), test_times[j] ); + } + + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-3-n.js b/tests/mozilla/ecma/Date/15.9.5.23-3-n.js new file mode 100644 index 0000000..44fffdf --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-3-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-3-n.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var MYDATE = new MyDate(TIME_1970); + + testcases[tc++] = new TestCase( SECTION, + "MYDATE.setTime(TIME_2000)", + "error", + MYDATE.setTime(TIME_2000) ); + +function MyDate(value) { + this.value = value; + this.setTime = Date.prototype.setTime; + return this; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-4.js b/tests/mozilla/ecma/Date/15.9.5.23-4.js new file mode 100644 index 0000000..633bbf6 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-4.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_YEAR_0), test_times[j] ); + } + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); + +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-5.js b/tests/mozilla/ecma/Date/15.9.5.23-5.js new file mode 100644 index 0000000..ab8d9a7 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-5.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_1970), test_times[j] ); + } + + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-6.js b/tests/mozilla/ecma/Date/15.9.5.23-6.js new file mode 100644 index 0000000..3f0c3f7 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-6.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_1900), test_times[j] ); + } + + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-7.js b/tests/mozilla/ecma/Date/15.9.5.23-7.js new file mode 100644 index 0000000..328642f --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-7.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_2000), test_times[j] ); + } + + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-8.js b/tests/mozilla/ecma/Date/15.9.5.23-8.js new file mode 100644 index 0000000..4b9fbb3 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-8.js @@ -0,0 +1,111 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(UTC_FEB_29_2000), test_times[j] ); + } + + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.23-9.js b/tests/mozilla/ecma/Date/15.9.5.23-9.js new file mode 100644 index 0000000..cbf8f18 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.23-9.js @@ -0,0 +1,112 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.23-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.setTime()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + test_times = new Array( now, TIME_YEAR_0, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + + for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(UTC_JAN_1_2005), test_times[j] ); + } + + test(); +function addTestCase( d, t ) { + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + testcases[tc++] = new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.24-1.js b/tests/mozilla/ecma/Date/15.9.5.24-1.js new file mode 100644 index 0000000..4e7a4fb --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.24-1.js @@ -0,0 +1,151 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + addTestCase( 0, 0 ); +/* + addTestCase( 0, -86400000 ); + addTestCase( 0, -2208988800000 ); + addTestCase( 0, 946684800000 ); + +// This test case is incorrect. Need to fix the DaylightSavings functions in +// shell.js for this to work properly. +// addTestCase( 0, -69609600000 ); +// addTestCase( 0, "-69609600000" ); + + addTestCase( 0, "0" ); + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.24-2.js b/tests/mozilla/ecma/Date/15.9.5.24-2.js new file mode 100644 index 0000000..8995cf2 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.24-2.js @@ -0,0 +1,150 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + addTestCase( 0, -86400000 ); +/* + addTestCase( 0, -2208988800000 ); + addTestCase( 0, 946684800000 ); + +// This test case is incorrect. Need to fix the DaylightSavings functions in +// shell.js for this to work properly. +// addTestCase( 0, -69609600000 ); +// addTestCase( 0, "-69609600000" ); + + addTestCase( 0, "0" ); + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.24-3.js b/tests/mozilla/ecma/Date/15.9.5.24-3.js new file mode 100644 index 0000000..788fc80 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.24-3.js @@ -0,0 +1,149 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + addTestCase( 0, -2208988800000 ); +/* + addTestCase( 0, 946684800000 ); + +// This test case is incorrect. Need to fix the DaylightSavings functions in +// shell.js for this to work properly. +// addTestCase( 0, -69609600000 ); +// addTestCase( 0, "-69609600000" ); + + addTestCase( 0, "0" ); + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.24-4.js b/tests/mozilla/ecma/Date/15.9.5.24-4.js new file mode 100644 index 0000000..b003de4 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.24-4.js @@ -0,0 +1,148 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + addTestCase( 0, 946684800000 ); +/* + +// This test case is incorrect. Need to fix the DaylightSavings functions in +// shell.js for this to work properly. +// addTestCase( 0, -69609600000 ); +// addTestCase( 0, "-69609600000" ); + + addTestCase( 0, "0" ); + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.24-5.js b/tests/mozilla/ecma/Date/15.9.5.24-5.js new file mode 100644 index 0000000..ccfadc0 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.24-5.js @@ -0,0 +1,141 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + addTestCase( 0, "0" ); +/* + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.24-6.js b/tests/mozilla/ecma/Date/15.9.5.24-6.js new file mode 100644 index 0000000..cd2d9d1 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.24-6.js @@ -0,0 +1,140 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + addTestCase( 0, "-2208988800000" ); +/* + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.24-7.js b/tests/mozilla/ecma/Date/15.9.5.24-7.js new file mode 100644 index 0000000..8e5846e --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.24-7.js @@ -0,0 +1,139 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + addTestCase( 0, "-86400000" ); +/* + addTestCase( 0, "946684800000" ); +*/ +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.24-8.js b/tests/mozilla/ecma/Date/15.9.5.24-8.js new file mode 100644 index 0000000..956bc9d --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.24-8.js @@ -0,0 +1,135 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addTestCase( 0, "946684800000" ); +} +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.25-1.js b/tests/mozilla/ecma/Date/15.9.5.25-1.js new file mode 100644 index 0000000..65cecdc --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.25-1.js @@ -0,0 +1,190 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.25-1.js + ECMA Section: 15.9.5.25 Date.prototype.setUTCMilliseconds(ms) + Description: + 1. Let t be this time value. + 2. Call ToNumber(ms). + 3. Compute MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), Result(2)). + 4. Compute MakeDate(Day(t), Result(3)). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.25-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCMilliseconds(ms)"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( 0, 0, "TDATE = new Date(0);(TDATE).setUTCMilliseconds(0);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,0)), + LocalDateFromTime(SetUTCMilliseconds(0,0)) ); + addNewTestCase( 28800000,999, + "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(28800000,999)), + LocalDateFromTime(SetUTCMilliseconds(28800000,999)) ); + addNewTestCase( 28800000,-28800000, + "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(-28800000);TDATE", + UTCDateFromTime(SetUTCMilliseconds(28800000,-28800000)), + LocalDateFromTime(SetUTCMilliseconds(28800000,-28800000)) ); + addNewTestCase( 946684800000,1234567, + "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(1234567);TDATE", + UTCDateFromTime(SetUTCMilliseconds(946684800000,1234567)), + LocalDateFromTime(SetUTCMilliseconds(946684800000,1234567)) ); + addNewTestCase( 946684800000, 123456789, + "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(946684800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(946684800000,123456789)) ); + + addNewTestCase( -2208988800000,123456789, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( -2208988800000,123456, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( -2208988800000,-123456, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( 0,-999, + "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +/* + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(0);TEST_DATE", UTCDateFromTime(0), LocalDateFromTime(0) ); +// addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(-2208988800000);TEST_DATE", UTCDateFromTime(-2208988800000), LocalDateFromTime(-2208988800000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(-86400000);TEST_DATE", UTCDateFromTime(-86400000), LocalDateFromTime(-86400000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(946684800000);TEST_DATE", UTCDateFromTime(946684800000), LocalDateFromTime(946684800000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds(-69609600000);TEST_DATE", UTCDateFromTime(-69609600000), LocalDateFromTime(-69609600000) ); + + + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('0');TEST_DATE", UTCDateFromTime(0), LocalDateFromTime(0) ); +// addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('-2208988800000');TEST_DATE", UTCDateFromTime(-2208988800000), LocalDateFromTime(-2208988800000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('-86400000');TEST_DATE", UTCDateFromTime(-86400000), LocalDateFromTime(-86400000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('946684800000');TEST_DATE", UTCDateFromTime(946684800000), LocalDateFromTime(946684800000) ); + addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('-69609600000');TEST_DATE", UTCDateFromTime(-69609600000), LocalDateFromTime(-69609600000) ); +*/ +} +function addNewTestCase( initialTime, ms, DateString, UTCDate, LocalDate) { + DateCase = new Date(initialTime); + DateCase.setUTCMilliseconds(ms); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetUTCMilliseconds( T, MS ) { + T = Number( T ); + TIME = MakeTime( HourFromTime(T), + MinFromTime(T), + SecFromTime(T), + MS ); + return( MakeDate( Day(T), TIME )); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.26-1.js b/tests/mozilla/ecma/Date/15.9.5.26-1.js new file mode 100644 index 0000000..58f70ff --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.26-1.js @@ -0,0 +1,203 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** File Name: 15.9.5.26-1.js + ECMA Section: 15.9.5.26 Date.prototype.setSeconds(sec [,ms]) + Description: + + If ms is not specified, this behaves as if ms were specified with the + value getMilliseconds( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(sec). + 3. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), + Result(3)). + 5. Compute UTC(MakeDate(Day(t), Result(4))). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.26-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setSeconds(sec [,ms] )"); + + var testcases = new Array(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( 0, 0, 0, + "TDATE = new Date(0);(TDATE).setSeconds(0,0);TDATE", + UTCDateFromTime(SetSeconds(0,0,0)), + LocalDateFromTime(SetSeconds(0,0,0)) ); + + addNewTestCase( 28800000,59,999, + "TDATE = new Date(28800000);(TDATE).setSeconds(59,999);TDATE", + UTCDateFromTime(SetSeconds(28800000,59,999)), + LocalDateFromTime(SetSeconds(28800000,59,999)) ); + + addNewTestCase( 28800000,999,999, + "TDATE = new Date(28800000);(TDATE).setSeconds(999,999);TDATE", + UTCDateFromTime(SetSeconds(28800000,999,999)), + LocalDateFromTime(SetSeconds(28800000,999,999)) ); + + addNewTestCase( 28800000,999, void 0, + "TDATE = new Date(28800000);(TDATE).setSeconds(999);TDATE", + UTCDateFromTime(SetSeconds(28800000,999,0)), + LocalDateFromTime(SetSeconds(28800000,999,0)) ); + + addNewTestCase( 28800000,-28800, void 0, + "TDATE = new Date(28800000);(TDATE).setSeconds(-28800);TDATE", + UTCDateFromTime(SetSeconds(28800000,-28800)), + LocalDateFromTime(SetSeconds(28800000,-28800)) ); + + addNewTestCase( 946684800000,1234567,void 0, + "TDATE = new Date(946684800000);(TDATE).setSeconds(1234567);TDATE", + UTCDateFromTime(SetSeconds(946684800000,1234567)), + LocalDateFromTime(SetSeconds(946684800000,1234567)) ); + + addNewTestCase( -2208988800000,59,999, + "TDATE = new Date(-2208988800000);(TDATE).setSeconds(59,999);TDATE", + UTCDateFromTime(SetSeconds(-2208988800000,59,999)), + LocalDateFromTime(SetSeconds(-2208988800000,59,999)) ); + +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ +} +function addNewTestCase( startTime, sec, ms, DateString,UTCDate, LocalDate) { + DateCase = new Date( startTime ); + if ( ms != void 0 ) { + DateCase.setSeconds( sec, ms ); + } else { + DateCase.setSeconds( sec ); + } + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetSeconds( t, s, m ) { + var MS = ( m == void 0 ) ? msFromTime(t) : Number( m ); + var TIME = LocalTime( t ); + var SEC = Number(s); + var RESULT4 = MakeTime( HourFromTime( TIME ), + MinFromTime( TIME ), + SEC, + MS ); + var UTC_TIME = UTC(MakeDate(Day(TIME), RESULT4)); + return ( TimeClip(UTC_TIME) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.27-1.js b/tests/mozilla/ecma/Date/15.9.5.27-1.js new file mode 100644 index 0000000..38cd843 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.27-1.js @@ -0,0 +1,202 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.27-1.js + ECMA Section: 15.9.5.27 Date.prototype.setUTCSeconds(sec [,ms]) + Description: + + If ms is not specified, this behaves as if ms were specified with the + value getUTCMilliseconds( ). + + 1. Let t be this time value. + 2. Call ToNumber(sec). + 3. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms) + 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), Result(3)) + 5. Compute MakeDate(Day(t), Result(4)). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.27-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCSeconds(sec [,ms] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( 0, 0, 0, "TDATE = new Date(0);(TDATE).setUTCSeconds(0,0);TDATE", + UTCDateFromTime(SetUTCSeconds(0,0,0)), + LocalDateFromTime(SetUTCSeconds(0,0,0)) ); + + addNewTestCase( 28800000,59,999, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(59,999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,59,999)), + LocalDateFromTime(SetUTCSeconds(28800000,59,999)) ); + + addNewTestCase( 28800000,999,999, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999,999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,999,999)), + LocalDateFromTime(SetUTCSeconds(28800000,999,999)) ); + + addNewTestCase( 28800000, 999, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,999,0)), + LocalDateFromTime(SetUTCSeconds(28800000,999,0)) ); + + addNewTestCase( 28800000, -28800, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(-28800);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,-28800)), + LocalDateFromTime(SetUTCSeconds(28800000,-28800)) ); + + addNewTestCase( 946684800000, 1234567, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCSeconds(1234567);TDATE", + UTCDateFromTime(SetUTCSeconds(946684800000,1234567)), + LocalDateFromTime(SetUTCSeconds(946684800000,1234567)) ); + + addNewTestCase( -2208988800000,59,999, + "TDATE = new Date(-2208988800000);(TDATE).setUTCSeconds(59,999);TDATE", + UTCDateFromTime(SetUTCSeconds(-2208988800000,59,999)), + LocalDateFromTime(SetUTCSeconds(-2208988800000,59,999)) ); +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ +} +function addNewTestCase( startTime, sec, ms, DateString, UTCDate, LocalDate) { + DateCase = new Date( startTime ); + if ( ms == void 0) { + DateCase.setSeconds( sec ); + } else { + DateCase.setSeconds( sec, ms ); + } + + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetUTCSeconds( t, s, m ) { + var TIME = t; + var SEC = Number(s); + var MS = ( m == void 0 ) ? msFromTime(TIME) : Number( m ); + var RESULT4 = MakeTime( HourFromTime( TIME ), + MinFromTime( TIME ), + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME), RESULT4)) ); +} + diff --git a/tests/mozilla/ecma/Date/15.9.5.28-1.js b/tests/mozilla/ecma/Date/15.9.5.28-1.js new file mode 100644 index 0000000..8fd97d1 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.28-1.js @@ -0,0 +1,216 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.28-1.js + ECMA Section: 15.9.5.28 Date.prototype.setMinutes(min [, sec [, ms ]] ) + Description: + If sec is not specified, this behaves as if sec were specified with the + value getSeconds ( ). + + If ms is not specified, this behaves as if ms were specified with the + value getMilliseconds( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(min). + 3. If sec is not specified, compute SecFromTime(t); otherwise, call ToNumber(sec). + 4. If ms is not specified, compute msFromTime(t); otherwise, call ToNumber(ms). + 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Day(t), Result(5))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.28-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMinutes(sec [,ms] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( 0, 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setMinutes(0);TDATE", + UTCDateFromTime(SetMinutes(0,0,0,0)), + LocalDateFromTime(SetMinutes(0,0,0,0)) ); + + addNewTestCase( 28800000, 59, 59, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(59,59);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,59)), + LocalDateFromTime(SetMinutes(28800000,59,59)) ); + + addNewTestCase( 28800000, 59, 59, 999, + "TDATE = new Date(28800000);(TDATE).setMinutes(59,59,999);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,59,999)), + LocalDateFromTime(SetMinutes(28800000,59,59,999)) ); + + addNewTestCase( 28800000, 59, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(59);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,0)), + LocalDateFromTime(SetMinutes(28800000,59,0)) ); + + addNewTestCase( 28800000, -480, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(-480);TDATE", + UTCDateFromTime(SetMinutes(28800000,-480)), + LocalDateFromTime(SetMinutes(28800000,-480)) ); + + addNewTestCase( 946684800000, 1234567, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setMinutes(1234567);TDATE", + UTCDateFromTime(SetMinutes(946684800000,1234567)), + LocalDateFromTime(SetMinutes(946684800000,1234567)) ); + + addNewTestCase( -2208988800000,59, 59, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59);TDATE", + UTCDateFromTime(SetMinutes(-2208988800000,59,59)), + LocalDateFromTime(SetMinutes(-2208988800000,59,59)) ); + + addNewTestCase( -2208988800000, 59, 59, 999, + "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59,999);TDATE", + UTCDateFromTime(SetMinutes(-2208988800000,59,59,999)), + LocalDateFromTime(SetMinutes(-2208988800000,59,59,999)) ); +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ + +} +function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) { + DateCase = new Date( time ); + + if ( sec == void 0 ) { + DateCase.setMinutes( min ); + } else { + if ( ms == void 0 ) { + DateCase.setMinutes( min, sec ); + } else { + DateCase.setMinutes( min, sec, ms ); + } + } + + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetMinutes( t, min, sec, ms ) { + var TIME = LocalTime(t); + var MIN = Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT5 = MakeTime( HourFromTime( TIME ), + MIN, + SEC, + MS ); + return ( TimeClip(UTC( MakeDate(Day(TIME),RESULT5))) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.29-1.js b/tests/mozilla/ecma/Date/15.9.5.29-1.js new file mode 100644 index 0000000..0640a74 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.29-1.js @@ -0,0 +1,210 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.29-1.js + ECMA Section: 15.9.5.29 Date.prototype.setUTCMinutes(min [, sec [, ms ]] ) + Description: + If sec is not specified, this behaves as if sec were specified with the + value getUTCSeconds ( ). + + If ms is not specified, this behaves as if ms were specified with the value + getUTCMilliseconds( ). + + 1. Let t be this time value. + 2. Call ToNumber(min). + 3. If sec is not specified, compute SecFromTime(t); otherwise, call + ToNumber(sec). + 4. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Day(t), Result(5)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.29-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCMinutes( min [, sec, ms] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( 0, 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setUTCMinutes(0);TDATE", + UTCDateFromTime(SetUTCMinutes(0,0,0,0)), + LocalDateFromTime(SetUTCMinutes(0,0,0,0)) ); + + addNewTestCase( 28800000, 59, 59, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59,59)), + LocalDateFromTime(SetUTCMinutes(28800000,59,59)) ); + + addNewTestCase( 28800000, 59, 59, 999, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59,999);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59,59,999)), + LocalDateFromTime(SetUTCMinutes(28800000,59,59,999)) ); + + addNewTestCase( 28800000, 59, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59)), + LocalDateFromTime(SetUTCMinutes(28800000,59)) ); + + addNewTestCase( 28800000, -480, 0, 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(-480);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,-480)), + LocalDateFromTime(SetUTCMinutes(28800000,-480)) ); + + addNewTestCase( 946684800000, 1234567, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCMinutes(1234567);TDATE", + UTCDateFromTime(SetUTCMinutes(946684800000,1234567)), + LocalDateFromTime(SetUTCMinutes(946684800000,1234567)) ); + + addNewTestCase( -2208988800000, 59, 999, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMinutes(59,999);TDATE", + UTCDateFromTime(SetUTCMinutes(-2208988800000,59,999)), + LocalDateFromTime(SetUTCMinutes(-2208988800000,59,999)) ); +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ + +} +function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) { + var DateCase = new Date( time ); + + if ( sec == void 0 ) { + DateCase.setUTCMinutes( min ); + } else { + if ( ms == void 0 ) { + DateCase.setUTCMinutes( min, sec ); + } else { + DateCase.setUTCMinutes( min, sec, ms ); + } + } + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCMinutes( t, min, sec, ms ) { + var TIME = t; + var MIN = Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT5 = MakeTime( HourFromTime( TIME ), + MIN, + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME),RESULT5)) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.3-1-n.js b/tests/mozilla/ecma/Date/15.9.5.3-1-n.js new file mode 100644 index 0000000..109fc26 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.3-1-n.js @@ -0,0 +1,73 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.3-1.js + ECMA Section: 15.9.5.3-1 Date.prototype.valueOf + Description: + + The valueOf function returns a number, which is this time value. + + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.3-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var OBJ = new MyObject( new Date(0) ); + + testcases[tc++] = new TestCase( SECTION, + "var OBJ = new MyObject( new Date(0) ); OBJ.valueOf()", + "error", + OBJ.valueOf() ); + test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = Date.prototype.valueOf; +// The following line causes an infinte loop +// this.toString = new Function( "return this+\"\";"); + return this; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.3-2.js b/tests/mozilla/ecma/Date/15.9.5.3-2.js new file mode 100644 index 0000000..7698ac1 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.3-2.js @@ -0,0 +1,107 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.3-2.js + ECMA Section: 15.9.5.3-2 Date.prototype.valueOf + Description: + + The valueOf function returns a number, which is this time value. + + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var TZ_ADJUST = TZ_DIFF * msPerHour; + var now = (new Date()).valueOf(); + var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_29_FEB_2000 ); + addTestCase( UTC_1_JAN_2005 ); + + test(); + +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+").valueOf()", + t, + (new Date(t)).valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+").valueOf()", + t+1, + (new Date(t+1)).valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+").valueOf()", + t-1, + (new Date(t-1)).valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+").valueOf()", + t-TZ_ADJUST, + (new Date(t-TZ_ADJUST)).valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+").valueOf()", + t+TZ_ADJUST, + (new Date(t+TZ_ADJUST)).valueOf() ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = Date.prototype.valueOf; + this.toString = new Function( "return this+\"\";"); + return this; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.30-1.js b/tests/mozilla/ecma/Date/15.9.5.30-1.js new file mode 100644 index 0000000..6e6715f --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.30-1.js @@ -0,0 +1,215 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.30-1.js + ECMA Section: 15.9.5.30 Date.prototype.setHours(hour [, min [, sec [, ms ]]] ) + Description: + If min is not specified, this behaves as if min were specified with the + value getMinutes( ). If sec is not specified, this behaves as if sec were + specified with the value getSeconds ( ). If ms is not specified, this + behaves as if ms were specified with the value getMilliseconds( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(hour). + 3. If min is not specified, compute MinFromTime(t); otherwise, call + ToNumber(min). + 4. If sec is not specified, compute SecFromTime(t); otherwise, call + ToNumber(sec). + 5. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 6. Compute MakeTime(Result(2), Result(3), Result(4), Result(5)). + 7. Compute UTC(MakeDate(Day(t), Result(6))). + 8. Set the [[Value]] property of the this value to TimeClip(Result(7)). + 9. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.30-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setHours( hour [, min, sec, ms] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( 0,0,0,0,void 0, + "TDATE = new Date(0);(TDATE).setHours(0);TDATE" ); + + addNewTestCase( 28800000, 23, 59, 999,void 0, + "TDATE = new Date(28800000);(TDATE).setHours(23,59,999);TDATE" ); + + addNewTestCase( 28800000, 999, 999, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(999,999);TDATE" ); + + addNewTestCase( 28800000,999,0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(999);TDATE" ); + + addNewTestCase( 28800000,-8, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(-8);TDATE" ); + + addNewTestCase( 946684800000,8760, void 0, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setHours(8760);TDATE" ); + + addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 999, + "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,999)" ); + + addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 1000, + "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,1000)" ); + + +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setHours(59,999);TDATE", + UTCDateFromTime(SetHours(-2208988800000,59,999)), + LocalDateFromTime(SetHours(-2208988800000,59,999)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ + +} +function addNewTestCase( time, hours, min, sec, ms, DateString) { + var UTCDate = UTCDateFromTime( SetHours( time, hours, min, sec, ms )); + var LocalDate = LocalDateFromTime( SetHours( time, hours, min, sec, ms )); + + var DateCase = new Date( time ); + + if ( min == void 0 ) { + DateCase.setHours( hours ); + } else { + if ( sec == void 0 ) { + DateCase.setHours( hours, min ); + } else { + if ( ms == void 0 ) { + DateCase.setHours( hours, min, sec ); + } else { + DateCase.setHours( hours, min, sec, ms ); + } + } + } + + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.day = WeekDay( t ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + + return (d); +} +function SetHours( t, hour, min, sec, ms ) { + var TIME = LocalTime(t); + var HOUR = Number(hour); + var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT6 = MakeTime( HOUR, + MIN, + SEC, + MS ); + var UTC_TIME = UTC( MakeDate(Day(TIME), RESULT6) ); + return ( TimeClip(UTC_TIME) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.31-1.js b/tests/mozilla/ecma/Date/15.9.5.31-1.js new file mode 100644 index 0000000..b6a2fee --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.31-1.js @@ -0,0 +1,212 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.31-1.js + ECMA Section: 15.9.5.31 Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] ) + Description: + If min is not specified, this behaves as if min were specified with the value getUTCMinutes( ). + If sec is not specified, this behaves as if sec were specified with the value getUTCSeconds ( ). + If ms is not specified, this behaves as if ms were specified with the value getUTCMilliseconds( ). + + 1.Let t be this time value. + 2.Call ToNumber(hour). + 3.If min is not specified, compute MinFromTime(t); otherwise, call ToNumber(min). + 4.If sec is not specified, compute SecFromTime(t); otherwise, call ToNumber(sec). + 5.If ms is not specified, compute msFromTime(t); otherwise, call ToNumber(ms). + 6.Compute MakeTime(Result(2), Result(3), Result(4), Result(5)). + 7.Compute MakeDate(Day(t), Result(6)). + 8.Set the [[Value]] property of the this value to TimeClip(Result(7)). + + 1.Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.31-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( 0, 0, void 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setUTCHours(0);TDATE", + UTCDateFromTime(SetUTCHours(0,0,0,0)), + LocalDateFromTime(SetUTCHours(0,0,0,0)) ); + + addNewTestCase( 28800000, 23, 59, 999, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(23,59,999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,23,59,999)), + LocalDateFromTime(SetUTCHours(28800000,23,59,999)) ); + + addNewTestCase( 28800000,999,999, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(999,999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,999,999)), + LocalDateFromTime(SetUTCHours(28800000,999,999)) ); + + addNewTestCase( 28800000, 999, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,999,0)), + LocalDateFromTime(SetUTCHours(28800000,999,0)) ); + + addNewTestCase( 28800000, -8670, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(-8670);TDATE", + UTCDateFromTime(SetUTCHours(28800000,-8670)), + LocalDateFromTime(SetUTCHours(28800000,-8670)) ); + + addNewTestCase( 946684800000, 1234567, void 0, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCHours(1234567);TDATE", + UTCDateFromTime(SetUTCHours(946684800000,1234567)), + LocalDateFromTime(SetUTCHours(946684800000,1234567)) ); + + addNewTestCase( -2208988800000, 59, 999, void 0, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setUTCHours(59,999);TDATE", + UTCDateFromTime(SetUTCHours(-2208988800000,59,999)), + LocalDateFromTime(SetUTCHours(-2208988800000,59,999)) ); +/* + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); +*/ + +} +function addNewTestCase( time, hours, min, sec, ms, DateString, UTCDate, LocalDate) { + + DateCase = new Date(time); + if ( min == void 0 ) { + DateCase.setUTCHours( hours ); + } else { + if ( sec == void 0 ) { + DateCase.setUTCHours( hours, min ); + } else { + if ( ms == void 0 ) { + DateCase.setUTCHours( hours, min, sec ); + } else { + DateCase.setUTCHours( hours, min, sec, ms ); + } + } + } + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCHours( t, hour, min, sec, ms ) { + var TIME = t; + var HOUR = Number(hour); + var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT6 = MakeTime( HOUR, + MIN, + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME), RESULT6)) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.32-1.js b/tests/mozilla/ecma/Date/15.9.5.32-1.js new file mode 100644 index 0000000..eded146 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.32-1.js @@ -0,0 +1,157 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 15.9.5.32-1.js + ECMA Section: 15.9.5.32 Date.prototype.setDate(date) + Description: + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(date). + 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). + 4. Compute UTC(MakeDate(Result(3), TimeWithinDay(t))). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.32-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setDate(date) "); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( 0, 1, + "TDATE = new Date(0);(TDATE).setDate(1);TDATE" ); + +/* + addNewTestCase( "TDATE = new Date(86400000);(TDATE).setDate(1);TDATE", + UTCDateFromTime(SetDate(86400000,1)), + LocalDateFromTime(SetDate(86400000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); +*/ +} +function addNewTestCase( t, d, DateString ) { + var DateCase = new Date( t ); + DateCase.setDate( d ); + + var UTCDate = UTCDateFromTime(SetDate(t, d)); + var LocalDate=LocalDateFromTime(SetDate(t,d)); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetDate( t, date ) { + var T = LocalTime( t ); + var DATE = Number( date ); + var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); + var UTC_DATE = UTC( MakeDate(RESULT3, TimeWithinDay(T)) ); + return ( TimeClip(UTC_DATE) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.33-1.js b/tests/mozilla/ecma/Date/15.9.5.33-1.js new file mode 100644 index 0000000..017d43e --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.33-1.js @@ -0,0 +1,156 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 15.9.5.33-1.js + ECMA Section: 15.9.5.33 Date.prototype.setUTCDate(date) + Description: + 1. Let t be this time value. + 2. Call ToNumber(date). + 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). + 4. Compute MakeDate(Result(3), TimeWithinDay(t)). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.33-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCDate(date) "); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(31);TDATE", + UTCDateFromTime(SetUTCDate(0,31)), + LocalDateFromTime(SetUTCDate(0,31)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(1);TDATE", + UTCDateFromTime(SetUTCDate(0,1)), + LocalDateFromTime(SetUTCDate(0,1)) ); + + addNewTestCase( "TDATE = new Date(86400000);(TDATE).setUTCDate(1);TDATE", + UTCDateFromTime(SetUTCDate(86400000,1)), + LocalDateFromTime(SetUTCDate(86400000,1)) ); +/* + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCDate( t, date ) { + var T = t; + var DATE = Number( date ); + var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); + return ( TimeClip(MakeDate(RESULT3, TimeWithinDay(t))) ); +} + diff --git a/tests/mozilla/ecma/Date/15.9.5.34-1.js b/tests/mozilla/ecma/Date/15.9.5.34-1.js new file mode 100644 index 0000000..e042ab9 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.34-1.js @@ -0,0 +1,220 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.34-1.js + ECMA Section: 15.9.5.34 Date.prototype.setMonth(mon [, date ] ) + Description: + If date is not specified, this behaves as if date were specified with the + value getDate( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(date). + 3. If date is not specified, compute DateFromTime(t); otherwise, call ToNumber(date). + 4. Compute MakeDay(YearFromTime(t), Result(2), Result(3)). + 5. Compute UTC(MakeDate(Result(4), TimeWithinDay(t))). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.34-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setMonth(mon [, date ] )"); + + var now = (new Date()).valueOf(); + + getFunctionCases(); + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getFunctionCases() { + // some tests for all functions + testcases[testcases.length] = new TestCase( + SECTION, + "Date.prototype.setMonth.length", + 2, + Date.prototype.setMonth.length ); + + testcases[testcases.length] = new TestCase( + SECTION, + "typeof Date.prototype.setMonth", + "function", + typeof Date.prototype.setMonth ); + + +/* + + testcases[testcases.length] = new TestCase( + SECTION, + "delete Date.prototype.setMonth", + false, + delete Date.prototype.setMonth ); +*/ + +} + + +function getTestCases() { + // regression test for http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112404 + d = new Date(0); + d.setMonth(1,1,1,1,1,1); + + addNewTestCase( + "TDATE = new Date(0); TDATE.setMonth(1,1,1,1,1,1); TDATE", + UTCDateFromTime(SetMonth(0,1,1)), + LocalDateFromTime(SetMonth(0,1,1)) ); + + + // whatever today is + + addNewTestCase( "TDATE = new Date(now); (TDATE).setMonth(11,31); TDATE", + UTCDateFromTime(SetMonth(now,11,31)), + LocalDateFromTime(SetMonth(now,11,31)) ); + + // 1970 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setMonth(0,1);TDATE", + UTCDateFromTime(SetMonth(0,0,1)), + LocalDateFromTime(SetMonth(0,0,1)) ); + + addNewTestCase( "TDATE = new Date("+TIME_1900+"); "+ + "(TDATE).setMonth(11,31); TDATE", + UTCDateFromTime( SetMonth(TIME_1900,11,31) ), + LocalDateFromTime( SetMonth(TIME_1900,11,31) ) ); + + + + +/* + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(11,23,59,999);TDATE", + UTCDateFromTime(SetMonth(28800000,11,23,59,999)), + LocalDateFromTime(SetMonth(28800000,11,23,59,999)) ); + + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(99,99);TDATE", + UTCDateFromTime(SetMonth(28800000,99,99)), + LocalDateFromTime(SetMonth(28800000,99,99)) ); + + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(11);TDATE", + UTCDateFromTime(SetMonth(28800000,11,0)), + LocalDateFromTime(SetMonth(28800000,11,0)) ); + + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(-11);TDATE", + UTCDateFromTime(SetMonth(28800000,-11)), + LocalDateFromTime(SetMonth(28800000,-11)) ); + + // 1900 + +// addNewTestCase( "TDATE = new Date(); (TDATE).setMonth(11,31); TDATE;" +*/ + +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetMonth( t, mon, date ) { + var TIME = LocalTime(t); + var MONTH = Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(TIME) : Number( date ); + var DAY = MakeDay( YearFromTime(TIME), MONTH, DATE ); + return ( TimeClip (UTC(MakeDate( DAY, TimeWithinDay(TIME) ))) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.35-1.js b/tests/mozilla/ecma/Date/15.9.5.35-1.js new file mode 100644 index 0000000..242c0d8 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.35-1.js @@ -0,0 +1,143 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 15.9.5.35-1.js + ECMA Section: 15.9.5.35 Date.prototype.setUTCMonth(mon [,date]) + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.35-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCMonth(mon [,date] ) "); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(0);TDATE", + UTCDateFromTime(SetUTCMonth(0,0)), + LocalDateFromTime(SetUTCMonth(0,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(11);TDATE", + UTCDateFromTime(SetUTCMonth(0,11)), + LocalDateFromTime(SetUTCMonth(0,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(3,4);TDATE", + UTCDateFromTime(SetUTCMonth(0,3,4)), + LocalDateFromTime(SetUTCMonth(0,3,4)) ); + +} + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCMonth( t, month, date ) { + var T = t; + var MONTH = Number( month ); + var DATE = ( date == void 0) ? DateFromTime(T) : Number( date ); + + var RESULT4 = MakeDay(YearFromTime(T), MONTH, DATE ); + var RESULT5 = MakeDate( RESULT4, TimeWithinDay(T)); + + return ( TimeClip(RESULT5) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.36-1.js b/tests/mozilla/ecma/Date/15.9.5.36-1.js new file mode 100644 index 0000000..f046829 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.36-1.js @@ -0,0 +1,245 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + + // 1969 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969);TDATE", + UTCDateFromTime(SetFullYear(0,1969)), + LocalDateFromTime(SetFullYear(0,1969)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11);TDATE", + UTCDateFromTime(SetFullYear(0,1969,11)), + LocalDateFromTime(SetFullYear(0,1969,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1969,11,31)), + LocalDateFromTime(SetFullYear(0,1969,11,31)) ); +/* + // 1970 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970);TDATE", + UTCDateFromTime(SetFullYear(0,1970)), + LocalDateFromTime(SetFullYear(0,1970)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0)), + LocalDateFromTime(SetFullYear(0,1970,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0,1)), + LocalDateFromTime(SetFullYear(0,1970,0,1)) ); + // 1971 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", + UTCDateFromTime(SetFullYear(0,1971)), + LocalDateFromTime(SetFullYear(0,1971)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0)), + LocalDateFromTime(SetFullYear(0,1971,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0,1)), + LocalDateFromTime(SetFullYear(0,1971,0,1)) ); + + // 1999 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); + + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Date/15.9.5.36-2.js b/tests/mozilla/ecma/Date/15.9.5.36-2.js new file mode 100644 index 0000000..1e207ed --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.36-2.js @@ -0,0 +1,231 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-2"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + // 1970 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970);TDATE", + UTCDateFromTime(SetFullYear(0,1970)), + LocalDateFromTime(SetFullYear(0,1970)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0)), + LocalDateFromTime(SetFullYear(0,1970,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0,1)), + LocalDateFromTime(SetFullYear(0,1970,0,1)) ); +/* + // 1971 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", + UTCDateFromTime(SetFullYear(0,1971)), + LocalDateFromTime(SetFullYear(0,1971)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0)), + LocalDateFromTime(SetFullYear(0,1971,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0,1)), + LocalDateFromTime(SetFullYear(0,1971,0,1)) ); + + // 1999 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); + + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Date/15.9.5.36-3.js b/tests/mozilla/ecma/Date/15.9.5.36-3.js new file mode 100644 index 0000000..c1e9c81 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.36-3.js @@ -0,0 +1,218 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + // 1971 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", + UTCDateFromTime(SetFullYear(0,1971)), + LocalDateFromTime(SetFullYear(0,1971)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0)), + LocalDateFromTime(SetFullYear(0,1971,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0,1)), + LocalDateFromTime(SetFullYear(0,1971,0,1)) ); + +/* + // 1999 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); + + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Date/15.9.5.36-4.js b/tests/mozilla/ecma/Date/15.9.5.36-4.js new file mode 100644 index 0000000..4d7f08b --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.36-4.js @@ -0,0 +1,205 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + // 1999 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); + +/* + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Date/15.9.5.36-5.js b/tests/mozilla/ecma/Date/15.9.5.36-5.js new file mode 100644 index 0000000..41dc143 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.36-5.js @@ -0,0 +1,192 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + // 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + +/* + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Date/15.9.5.36-6.js b/tests/mozilla/ecma/Date/15.9.5.36-6.js new file mode 100644 index 0000000..8bed8d2 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.36-6.js @@ -0,0 +1,179 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + // feb 29, 2000 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + +/* + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Date/15.9.5.36-7.js b/tests/mozilla/ecma/Date/15.9.5.36-7.js new file mode 100644 index 0000000..8520844 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.36-7.js @@ -0,0 +1,164 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ + var SECTION = "15.9.5.36-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + // Jan 1, 2005 + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Date/15.9.5.37-1.js b/tests/mozilla/ecma/Date/15.9.5.37-1.js new file mode 100644 index 0000000..9eaf49d --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.37-1.js @@ -0,0 +1,235 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + // Dates around 1970 + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1970);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1970)), + LocalDateFromTime(SetUTCFullYear(0,1970)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1971);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1971)), + LocalDateFromTime(SetUTCFullYear(0,1971)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); + + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); +/* + // Dates around 2000 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2000)), + LocalDateFromTime(SetUTCFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2001);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2001)), + LocalDateFromTime(SetUTCFullYear(0,2001)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1999);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1999)), + LocalDateFromTime(SetUTCFullYear(0,1999)) ); + + // Dates around 29 February 2000 + + var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + + 31*msPerDay + 28*msPerDay; + + var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; + + addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); + + addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); + + // Dates around 2005 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); + + + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.37-2.js b/tests/mozilla/ecma/Date/15.9.5.37-2.js new file mode 100644 index 0000000..ffb8fda --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.37-2.js @@ -0,0 +1,209 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + // Dates around 2000 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2000)), + LocalDateFromTime(SetUTCFullYear(0,2000)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2001);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2001)), + LocalDateFromTime(SetUTCFullYear(0,2001)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1999);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1999)), + LocalDateFromTime(SetUTCFullYear(0,1999)) ); +/* + // Dates around 29 February 2000 + + var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + + 31*msPerDay + 28*msPerDay; + + var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; + + addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); + + addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); + + // Dates around 2005 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); + + + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.37-3.js b/tests/mozilla/ecma/Date/15.9.5.37-3.js new file mode 100644 index 0000000..136ec89 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.37-3.js @@ -0,0 +1,195 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + + // Dates around 29 February 2000 + + var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + + 31*msPerDay + 28*msPerDay; + + var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; + + addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); + + addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); +/* + // Dates around 2005 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); + + + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.37-4.js b/tests/mozilla/ecma/Date/15.9.5.37-4.js new file mode 100644 index 0000000..c7876d1 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.37-4.js @@ -0,0 +1,177 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + // Dates around 2005 + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); + +/* + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); + +*/ +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.37-5.js b/tests/mozilla/ecma/Date/15.9.5.37-5.js new file mode 100644 index 0000000..cee31ed --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.37-5.js @@ -0,0 +1,160 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ + var SECTION = "15.9.5.37-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + // Dates around 1900 + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + + addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); +} +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + var item = testcases.length; + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + testcases[item++] = new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.4-1.js b/tests/mozilla/ecma/Date/15.9.5.4-1.js new file mode 100644 index 0000000..81c3740 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.4-1.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.4-1.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.9.5.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTime"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + var now = (new Date()).valueOf(); + var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; + var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_29_FEB_2000 ); + addTestCase( UTC_1_JAN_2005 ); + + test(); + +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+").getTime()", + t, + (new Date(t)).getTime() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+").getTime()", + t+1, + (new Date(t+1)).getTime() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+").getTime()", + t-1, + (new Date(t-1)).getTime() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+").getTime()", + t-TZ_ADJUST, + (new Date(t-TZ_ADJUST)).getTime() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+").getTime()", + t+TZ_ADJUST, + (new Date(t+TZ_ADJUST)).getTime() ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.4-2-n.js b/tests/mozilla/ecma/Date/15.9.5.4-2-n.js new file mode 100644 index 0000000..c90559a --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.4-2-n.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.4-2-n.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "15.9.5.4-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getTime"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var MYDATE = new MyDate( TIME_2000 ); + + testcases[tc++] = new TestCase( SECTION, + "MYDATE.getTime()", + "error", + MYDATE.getTime() ); + +function MyDate( value ) { + this.value = value; + this.getTime = Date.prototype.getTime; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.5.js b/tests/mozilla/ecma/Date/15.9.5.5.js new file mode 100644 index 0000000..5660c4c --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.5.js @@ -0,0 +1,123 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.5.js + ECMA Section: 15.9.5.5 + Description: Date.prototype.getYear + + This function is specified here for backwards compatibility only. The + function getFullYear is much to be preferred for nearly all purposes, + because it avoids the "year 2000 problem." + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)) 1900. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getYear()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getYear()", + NaN, + (new Date(NaN)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getYear.length", + 0, + Date.prototype.getYear.length ); + + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getYear()", + GetYear(YearFromTime(LocalTime(t))), + (new Date(t)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getYear()", + GetYear(YearFromTime(LocalTime(t+1))), + (new Date(t+1)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getYear()", + GetYear(YearFromTime(LocalTime(t-1))), + (new Date(t-1)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getYear()", + GetYear(YearFromTime(LocalTime(t-TZ_ADJUST))), + (new Date(t-TZ_ADJUST)).getYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getYear()", + GetYear(YearFromTime(LocalTime(t+TZ_ADJUST))), + (new Date(t+TZ_ADJUST)).getYear() ); +} +function GetYear( year ) { +/* + if ( year >= 1900 && year < 2000 ) { + return year - 1900; + } else { + return year; + } +*/ + return year - 1900; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.6.js b/tests/mozilla/ecma/Date/15.9.5.6.js new file mode 100644 index 0000000..5a9cf38 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.6.js @@ -0,0 +1,114 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.6.js + ECMA Section: 15.9.5.6 + Description: Date.prototype.getFullYear + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getFullYear()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getFullYear()", + NaN, + (new Date(NaN)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getFullYear.length", + 0, + Date.prototype.getFullYear.length ); + + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getFullYear()", + YearFromTime(LocalTime(t)), + (new Date(t)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getFullYear()", + YearFromTime(LocalTime(t+1)), + (new Date(t+1)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getFullYear()", + YearFromTime(LocalTime(t-1)), + (new Date(t-1)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getFullYear()", + YearFromTime(LocalTime(t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getFullYear()", + YearFromTime(LocalTime(t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getFullYear() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.7.js b/tests/mozilla/ecma/Date/15.9.5.7.js new file mode 100644 index 0000000..8a7f5c0 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.7.js @@ -0,0 +1,114 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.7.js + ECMA Section: 15.9.5.7 + Description: Date.prototype.getUTCFullYear + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return YearFromTime(t). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCFullYear()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCFullYear()", + NaN, + (new Date(NaN)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCFullYear.length", + 0, + Date.prototype.getUTCFullYear.length ); + + test(); +function addTestCase( t ) { + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCFullYear()", + YearFromTime(t), + (new Date(t)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCFullYear()", + YearFromTime(t+1), + (new Date(t+1)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCFullYear()", + YearFromTime(t-1), + (new Date(t-1)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCFullYear()", + YearFromTime(t-TZ_ADJUST), + (new Date(t-TZ_ADJUST)).getUTCFullYear() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCFullYear()", + YearFromTime(t+TZ_ADJUST), + (new Date(t+TZ_ADJUST)).getUTCFullYear() ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.8.js b/tests/mozilla/ecma/Date/15.9.5.8.js new file mode 100644 index 0000000..038eda9 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.8.js @@ -0,0 +1,120 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.8.js + ECMA Section: 15.9.5.8 + Description: Date.prototype.getMonth + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getMonth()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getMonth()", + NaN, + (new Date(NaN)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getMonth.length", + 0, + Date.prototype.getMonth.length ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + + t += TimeInMonth(m); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getMonth()", + MonthFromTime(LocalTime(t)), + (new Date(t)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getMonth()", + MonthFromTime(LocalTime(t+1)), + (new Date(t+1)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getMonth()", + MonthFromTime(LocalTime(t-1)), + (new Date(t-1)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getMonth()", + MonthFromTime(LocalTime(t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getMonth()", + MonthFromTime(LocalTime(t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getMonth() ); + + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.9.js b/tests/mozilla/ecma/Date/15.9.5.9.js new file mode 100644 index 0000000..9fda4ea --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.9.js @@ -0,0 +1,120 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.9.js + ECMA Section: 15.9.5.9 + Description: Date.prototype.getUTCMonth + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5.8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Date.prototype.getUTCMonth()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var TZ_ADJUST = TZ_DIFF * msPerHour; + + // get the current time + var now = (new Date()).valueOf(); + + // get time for 29 feb 2000 + + var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; + + // get time for 1 jan 2005 + + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ + TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); + + addTestCase( now ); + addTestCase( TIME_YEAR_0 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date(NaN)).getUTCMonth()", + NaN, + (new Date(NaN)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getUTCMonth.length", + 0, + Date.prototype.getUTCMonth.length ); + test(); +function addTestCase( t ) { + for ( var m = 0; m < 12; m++ ) { + + t += TimeInMonth(m); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getUTCMonth()", + MonthFromTime(t), + (new Date(t)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCMonth()", + MonthFromTime(t+1), + (new Date(t+1)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCMonth()", + MonthFromTime(t-1), + (new Date(t-1)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCMonth()", + MonthFromTime(t-TZ_ADJUST), + (new Date(t-TZ_ADJUST)).getUTCMonth() ); + + testcases[tc++] = new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCMonth()", + MonthFromTime(t+TZ_ADJUST), + (new Date(t+TZ_ADJUST)).getUTCMonth() ); + + } +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Date/15.9.5.js b/tests/mozilla/ecma/Date/15.9.5.js new file mode 100644 index 0000000..d7bd303 --- /dev/null +++ b/tests/mozilla/ecma/Date/15.9.5.js @@ -0,0 +1,81 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.9.5.js + ECMA Section: 15.9.5 Properties of the Date prototype object + Description: + + The Date prototype object is itself a Date object (its [[Class]] is + "Date") whose value is NaN. + + The value of the internal [[Prototype]] property of the Date prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Date + prototype object, the phrase "this Date object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Date". Also, the phrase "this time value" refers + to the number value for the time represented by this Date object, that is, + the value of the internal [[Value]] property of this Date object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.9.5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Date Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + Date.prototype.getClass = Object.prototype.toString; + + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getClass", + "[object Date]", + Date.prototype.getClass() ); + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.valueOf()", + NaN, + Date.prototype.valueOf() ); + testcases[tc++] = new TestCase( SECTION, + "Date.prototype.__proto__ == Object.prototype", + true, + Date.prototype.__proto__ == Object.prototype ); + test(); +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js b/tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js new file mode 100644 index 0000000..f827cc7 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js @@ -0,0 +1,107 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.3-1.js + ECMA Section: 10.1.3 + Description: + + For each formal parameter, as defined in the FormalParameterList, create + a property of the variable object whose name is the Identifier and whose + attributes are determined by the type of code. The values of the + parameters are supplied by the caller. If the caller supplies fewer + parameter values than there are formal parameters, the extra formal + parameters have value undefined. If two or more formal parameters share + the same name, hence the same property, the corresponding property is + given the value that was supplied for the last parameter with this name. + If the value of this last parameter was not supplied by the caller, + the value of the corresponding property is undefined. + + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104191 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Variable Instantiation: Formal Parameters"; + var BUGNUMBER="104191"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var myfun1 = new Function( "a", "a", "return a" ); + var myfun2 = new Function( "a", "b", "a", "return a" ); + + function myfun3(a, b, a) { + return a; + } + + // myfun1, myfun2, myfun3 tostring + + + testcases[tc++] = new TestCase( + SECTION, + String(myfun2) +"; myfun2(2,4,8)", + 8, + myfun2(2,4,8) ); + + testcases[tc++] = new TestCase( + SECTION, + "myfun2(2,4)", + void 0, + myfun2(2,4)); + + testcases[tc++] = new TestCase( + SECTION, + String(myfun3) +"; myfun3(2,4,8)", + 8, + myfun3(2,4,8) ); + + testcases[tc++] = new TestCase( + SECTION, + "myfun3(2,4)", + void 0, + myfun3(2,4) ); + + + + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.3.js b/tests/mozilla/ecma/ExecutionContexts/10.1.3.js new file mode 100644 index 0000000..be75451 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.3.js @@ -0,0 +1,160 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.3.js + ECMA Section: 10.1.3.js Variable Instantiation + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "10.1.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Variable instantiation"; +var BUGNUMBER = "20256"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcases = getTestCases(); + +test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + // overriding a variable or function name with a function should succeed + array[item++] = + new TestCase(SECTION, + "function t() { return \"first\" };" + + "function t() { return \"second\" };t() ", + "second", + eval("function t() { return \"first\" };" + + "function t() { return \"second\" };t()")); + + array[item++] = + new TestCase(SECTION, + "var t; function t(){}; typeof(t)", + "function", + eval("var t; function t(){}; typeof(t)")); + + + // formal parameter tests + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( 4 );", + void 0, + eval("function t1(a,b) { return b; }; t1( 4 );") ); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(4);", + 4, + eval("function t1(a,b) { return a; }; t1(4)")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1();", + void 0, + eval("function t1(a,b) { return a; }; t1()")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(1,2,4);", + 1, + eval("function t1(a,b) { return a; }; t1(1,2,4)")); +/* + array[item++] = + new TestCase(SECTION, "function t1(a,a) { return a; }; t1( 4 );", + void 0, + eval("function t1(a,a) { return a; }; t1( 4 )")); + array[item++] = + new TestCase(SECTION, + "function t1(a,a) { return a; }; t1( 1,2 );", + 2, + eval("function t1(a,a) { return a; }; t1( 1,2 )")); +*/ + // variable declarations + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1( false, true );", + false, + eval("function t1(a,b) { return a; }; t1( false, true );")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( false, true );", + true, + eval("function t1(a,b) { return b; }; t1( false, true );")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4, 2 );", + 6, + eval("function t1(a,b) { return a+b; }; t1( 4, 2 );")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4 );", + Number.NaN, + eval("function t1(a,b) { return a+b; }; t1( 4 );")); + + // overriding a function name with a variable should fail + array[item++] = + new TestCase(SECTION, + "function t() { return 'function' };" + + "var t = 'variable'; typeof(t)", + "string", + eval("function t() { return 'function' };" + + "var t = 'variable'; typeof(t)")); + + // function as a constructor + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { var a = b; return a; } t1(1,3);", + 3, + eval("function t1(a, b){ var a = b; return a;}; t1(1,3)")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = b; } x = new t2(1,3); x.a", + 3, + eval("function t2(a,b) { this.a = b; };" + + "x = new t2(1,3); x.a")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = a; } x = new t2(1,3); x.a", + 1, + eval("function t2(a,b) { this.a = a; };" + + "x = new t2(1,3); x.a")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; } " + + "x = new t2(1,3);x.a;", + 3, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.a;")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; }" + + "x = new t2(1,3);x.b;", + 1, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.b;") ); + + return (array); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js new file mode 100644 index 0000000..6390960 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js @@ -0,0 +1,100 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += "( " + INPUT +" )" ; + + with ( MYOBJECT ) { + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,2); + } + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should return square of " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js new file mode 100644 index 0000000..6966acf --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js @@ -0,0 +1,94 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-10.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-10"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + var VALUE = 12345; + var MYOBJECT = new Number( VALUE ); + + with ( MYOBJECT ) { + testcases[tc].actual = toString(); + testcases[tc].expect = String(VALUE); + } + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "MYOBJECT.toString()" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js new file mode 100644 index 0000000..b42697a --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-2"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += "( "+INPUT +" )" ; + + with ( this ) { + with ( MYOBJECT ) { + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,2); + } + } + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should return square of " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js new file mode 100644 index 0000000..54980af --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-3"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval( INPUT ); + } + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js new file mode 100644 index 0000000..88f8241 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js @@ -0,0 +1,101 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval( INPUT ); + } + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js new file mode 100644 index 0000000..f03d120 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js @@ -0,0 +1,101 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval = null; + } + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js new file mode 100644 index 0000000..def668a --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + getTestCases(); + test(); + +function getTestCases() { + testcases[0] = new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[0].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + ; + } + testcases[0].actual = eval( INPUT ); + testcases[0].expect = INPUT; + +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js new file mode 100644 index 0000000..7f900b5 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js @@ -0,0 +1,100 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-7"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + delete( eval ); + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + } + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js new file mode 100644 index 0000000..288f0ed --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js @@ -0,0 +1,101 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval = new Function ( "x", "return(Math.pow(Number(x),3))" ); + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,3); + } + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should cube INPUT: " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js b/tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js new file mode 100644 index 0000000..ec72ecd --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.4-9.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-9"; + var VERSION = "ECMA_2"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var RESULT = "hello"; + + with ( MYOBJECT ) { + NEW_PROPERTY = RESULT; + } + testcases[tc].actual = NEW_PROPERTY; + testcases[tc].expect = RESULT; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "NEW_PROPERTY = " ); + + return ( array ); +} +function MyObject( n ) { + this.__proto__ = Number.prototype; +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js b/tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js new file mode 100644 index 0000000..0cfb7c3 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js @@ -0,0 +1,118 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.5-1.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + if ( Object == null ) { + testcases[0].reason += " Object == null" ; + } + if ( Function == null ) { + testcases[0].reason += " Function == null"; + } + if ( String == null ) { + testcases[0].reason += " String == null"; + } + if ( Array == null ) { + testcases[0].reason += " Array == null"; + } + if ( Number == null ) { + testcases[0].reason += " Function == null"; + } + if ( Math == null ) { + testcases[0].reason += " Math == null"; + } + if ( Boolean == null ) { + testcases[0].reason += " Boolean == null"; + } + if ( Date == null ) { + testcases[0].reason += " Date == null"; + } +/* + if ( NaN == null ) { + testcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + testcases[0].reason += " Infinity == null"; + } +*/ + if ( eval == null ) { + testcases[0].reason += " eval == null"; + } + if ( parseInt == null ) { + testcases[0].reason += " parseInt == null"; + } + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Global Code check" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js b/tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js new file mode 100644 index 0000000..a09c1ae --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js @@ -0,0 +1,101 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 10.1.5-2.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-2"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + var EVAL_STRING = 'if ( Object == null ) { testcases[0].reason += " Object == null" ; }' + + 'if ( Function == null ) { testcases[0].reason += " Function == null"; }' + + 'if ( String == null ) { testcases[0].reason += " String == null"; }' + + 'if ( Array == null ) { testcases[0].reason += " Array == null"; }' + + 'if ( Number == null ) { testcases[0].reason += " Function == null";}' + + 'if ( Math == null ) { testcases[0].reason += " Math == null"; }' + + 'if ( Boolean == null ) { testcases[0].reason += " Boolean == null"; }' + + 'if ( Date == null ) { testcases[0].reason += " Date == null"; }' + + 'if ( eval == null ) { testcases[0].reason += " eval == null"; }' + + 'if ( parseInt == null ) { testcases[0].reason += " parseInt == null"; }' ; + + eval( EVAL_STRING ); + +/* + if ( NaN == null ) { + testcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + testcases[0].reason += " Infinity == null"; + } +*/ + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual + " "+ + testcases[tc].reason ); + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Eval Code check" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js b/tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js new file mode 100644 index 0000000..7b0f85f --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js @@ -0,0 +1,119 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.5-3.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-3"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + test(); + +function test() { + if ( Object == null ) { + testcases[0].reason += " Object == null" ; + } + if ( Function == null ) { + testcases[0].reason += " Function == null"; + } + if ( String == null ) { + testcases[0].reason += " String == null"; + } + if ( Array == null ) { + testcases[0].reason += " Array == null"; + } + if ( Number == null ) { + testcases[0].reason += " Function == null"; + } + if ( Math == null ) { + testcases[0].reason += " Math == null"; + } + if ( Boolean == null ) { + testcases[0].reason += " Boolean == null"; + } + if ( Date == null ) { + testcases[0].reason += " Date == null"; + } +/* + if ( NaN == null ) { + testcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + testcases[0].reason += " Infinity == null"; + } +*/ + if ( eval == null ) { + testcases[0].reason += " eval == null"; + } + if ( parseInt == null ) { + testcases[0].reason += " parseInt == null"; + } + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + for ( tc=0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Function Code check" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js b/tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js new file mode 100644 index 0000000..2954346 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js @@ -0,0 +1,94 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.5-4.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-4"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + var EVAL_STRING = 'if ( Object == null ) { testcases[0].reason += " Object == null" ; }' + + 'if ( Function == null ) { testcases[0].reason += " Function == null"; }' + + 'if ( String == null ) { testcases[0].reason += " String == null"; }' + + 'if ( Array == null ) { testcases[0].reason += " Array == null"; }' + + 'if ( Number == null ) { testcases[0].reason += " Function == null";}' + + 'if ( Math == null ) { testcases[0].reason += " Math == null"; }' + + 'if ( Boolean == null ) { testcases[0].reason += " Boolean == null"; }' + + 'if ( Date == null ) { testcases[0].reason += " Date == null"; }' + + 'if ( eval == null ) { testcases[0].reason += " eval == null"; }' + + 'if ( parseInt == null ) { testcases[0].reason += " parseInt == null"; }' ; + + var NEW_FUNCTION = new Function( EVAL_STRING ); + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual + " "+ + testcases[tc].reason ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Anonymous Code check" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.6.js b/tests/mozilla/ecma/ExecutionContexts/10.1.6.js new file mode 100644 index 0000000..8224cb2 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.6.js @@ -0,0 +1,124 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.6 + ECMA Section: Activation Object + Description: + + If the function object being invoked has an arguments property, let x be + the value of that property; the activation object is also given an internal + property [[OldArguments]] whose initial value is x; otherwise, an arguments + property is created for the function object but the activation object is + not given an [[OldArguments]] property. Next, arguments object described + below (the same one stored in the arguments property of the activation + object) is used as the new value of the arguments property of the function + object. This new value is installed even if the arguments property already + exists and has the ReadOnly attribute (as it will for native Function + objects). (These actions are taken to provide compatibility with a form of + program syntax that is now discouraged: to access the arguments object for + function f within the body of f by using the expression f.arguments. + The recommended way to access the arguments object for function f within + the body of f is simply to refer to the variable arguments.) + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Activation Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var arguments = "FAILED!"; + + var ARG_STRING = "value of the argument property"; + + testcases[tc++] = new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5)).length", + 6, + (new TestObject(0,1,2,3,4,5)).length ); + + for ( i = 0; i < 6; i++ ) { + + testcases[tc++] = new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5))["+i+"]", + i, + (new TestObject(0,1,2,3,4,5))[i]); + } + + + // The current object already has an arguments property. + + testcases[tc++] = new TestCase( SECTION, + "(new AnotherTestObject(1,2,3)).arguments", + ARG_STRING, + (new AnotherTestObject(1,2,3)).arguments ); + + // The function invoked with [[Call]] + + testcases[tc++] = new TestCase( SECTION, + "TestFunction(1,2,3)", + ARG_STRING, + TestFunction() + '' ); + + + test(); + + + +function Prototype() { + this.arguments = ARG_STRING; +} +function TestObject() { + this.__proto__ = new Prototype(); + return arguments; +} +function AnotherTestObject() { + this.__proto__ = new Prototype(); + return this; +} +function TestFunction() { + arguments = ARG_STRING; + return arguments; +} +function AnotherTestFunction() { + this.__proto__ = new Prototype(); + return this; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js b/tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js new file mode 100644 index 0000000..28b403f --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js @@ -0,0 +1,132 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.8 + ECMA Section: Arguments Object + Description: + + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: + + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). + + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. + + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. + + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Arguments Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var ARG_STRING = "value of the argument property"; + + testcases[tc++] = new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); + + var LIMIT = 100; + + for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); + + } + + var LENGTH = eval( "GetLength("+ args +")" ); + + testcases[tc++] = new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); + + var ARGUMENTS = eval( "GetArguments( " +args+")" ); + + for ( var i = 0; i < 100; i++ ) { + testcases[tc++] = new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); + } + + test(); + +function TestFunction() { + var arg_proto = arguments.__proto__; +} +function GetCallee() { + var c = arguments.callee; + return c; +} +function GetArguments() { + var a = arguments; + return a; +} +function GetLength() { + var l = arguments.length; + return l; +} + +function AnotherTestFunction() { + this.__proto__ = new Prototype(); + return this; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.1.8-2.js b/tests/mozilla/ecma/ExecutionContexts/10.1.8-2.js new file mode 100644 index 0000000..b4ff578 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.1.8-2.js @@ -0,0 +1,117 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.1.8-2 + ECMA Section: Arguments Object + Description: + + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: + + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). + + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. + + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. + + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.8-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Arguments Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +// Tests for anonymous functions + + var GetCallee = new Function( "var c = arguments.callee; return c" ); + var GetArguments = new Function( "var a = arguments; return a" ); + var GetLength = new Function( "var l = arguments.length; return l" ); + + var ARG_STRING = "value of the argument property"; + + testcases[tc++] = new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); + + var LIMIT = 100; + + for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); + + } + + var LENGTH = eval( "GetLength("+ args +")" ); + + testcases[tc++] = new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); + + var ARGUMENTS = eval( "GetArguments( " +args+")" ); + + for ( var i = 0; i < 100; i++ ) { + testcases[tc++] = new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.2.1.js b/tests/mozilla/ecma/ExecutionContexts/10.2.1.js new file mode 100644 index 0000000..5e5737b --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.2.1.js @@ -0,0 +1,82 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.2.1.js + ECMA Section: 10.2.1 Global Code + Description: + + The scope chain is created and initialized to contain the global object and + no others. + + Variable instantiation is performed using the global object as the variable + object and using empty property attributes. + + The this value is the global object. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Global Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var THIS = this; + + testcases[tc++] = new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); + + var GLOBAL_PROPERTIES = new Array(); + var i = 0; + + for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; + } + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == void 0", + false, + eval("GLOBAL_PROPERTIES["+i+"] == void 0")); + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js b/tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js new file mode 100644 index 0000000..db03ad6 --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js @@ -0,0 +1,119 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.2.2-1.js + ECMA Section: 10.2.2 Eval Code + Description: + + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. + + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. + + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. + + The this value is the same as the this value of the calling context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Eval Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var THIS = eval("this"); + + testcases[tc++] = new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); + + var GLOBAL_PROPERTIES = new Array(); + var i = 0; + + for ( p in THIS ) { + GLOBAL_PROPERTIES[i++] = p; + } + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == THIS["+GLOBAL_PROPERTIES[i]+"]", + true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); + } + + // this in eval statements is the same as this value of the calling context + + var RESULT = THIS == this; + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + RESULT ); + + var RESULT = THIS +''; + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + RESULT ); + + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + eval( "this == THIS" ) ); + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + eval( "this +''") ); + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js b/tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js new file mode 100644 index 0000000..c73feff --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js @@ -0,0 +1,105 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.2.2-2.js + ECMA Section: 10.2.2 Eval Code + Description: + + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. + + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. + + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. + + The this value is the same as the this value of the calling context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Eval Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // Test Objects + + var OBJECT = new MyObject( "hello" ); + var GLOBAL_PROPERTIES = new Array(); + var i = 0; + + for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; + } + + with ( OBJECT ) { + var THIS = this; + testcases[tc++] = new TestCase( SECTION, "eval( 'this == THIS' )", true, eval("this == THIS") ); + testcases[tc++] = new TestCase( SECTION, "this in a with() block", GLOBAL, this+"" ); + testcases[tc++] = new TestCase( SECTION, "new MyObject('hello').value", "hello", value ); + testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').value)", "hello", eval("value") ); + testcases[tc++] = new TestCase( SECTION, "new MyObject('hello').getClass()", "[object Object]", getClass() ); + testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').getClass())", "[object Object]", eval("getClass()") ); + testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').toString())", "hello", eval("toString()") ); + testcases[tc++] = new TestCase( SECTION, "eval('getClass') == Object.prototype.toString", true, eval("getClass") == Object.prototype.toString ); + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, GLOBAL_PROPERTIES[i] + + " == THIS["+GLOBAL_PROPERTIES[i]+"]", true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); + } + + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.getClass = Object.prototype.toString; + this.toString = new Function( "return this.value+''" ); + return this; +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js b/tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js new file mode 100644 index 0000000..be1a00f --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.2.3-1.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: + + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Eval Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var o = new MyObject("hello") + + testcases[tc++] = new TestCase( SECTION, + "var o = new MyObject('hello'); o.THIS == x", + true, + o.THIS == o ); + + var o = MyFunction(); + + testcases[tc++] = new TestCase( SECTION, + "var o = MyFunction(); o == this", + true, + o == this ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function MyFunction( value ) { + return this; +} +function MyObject( value ) { + this.THIS = this; +} diff --git a/tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js b/tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js new file mode 100644 index 0000000..084d72f --- /dev/null +++ b/tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js @@ -0,0 +1,89 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 10.2.3-2.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: + + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function and Anonymous Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var o = new MyObject("hello") + + testcases[tc++] = new TestCase( SECTION, + "MyFunction(\"PASSED!\")", + "PASSED!", + MyFunction("PASSED!") ); + + var o = MyFunction(); + + testcases[tc++] = new TestCase( SECTION, + "MyOtherFunction(true);", + false, + MyOtherFunction(true) ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function MyFunction( value ) { + var x = value; + delete x; + return x; +} +function MyOtherFunction(value) { + var x = value; + return delete x; +} +function MyObject( value ) { + this.THIS = this; +} diff --git a/tests/mozilla/ecma/Expressions/11.1.1.js b/tests/mozilla/ecma/Expressions/11.1.1.js new file mode 100644 index 0000000..5801961 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.1.1.js @@ -0,0 +1,135 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.1.1.js + ECMA Section: 11.1.1 The this keyword + Description: + + The this keyword evaluates to the this value of the execution context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.1.1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " The this keyword"); + + var testcases = new Array(); + var item = 0; + + var GLOBAL_OBJECT = this.toString(); + + // this in global code and eval(this) in global code should return the global object. + + testcases[item++] = new TestCase( SECTION, + "Global Code: this.toString()", + GLOBAL_OBJECT, + this.toString() ); + + testcases[item++] = new TestCase( SECTION, + "Global Code: eval('this.toString()')", + GLOBAL_OBJECT, + eval('this.toString()') ); + + // this in anonymous code called as a function should return the global object. + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('return this.toString()'); MYFUNC()", + GLOBAL_OBJECT, + eval("var MYFUNC = new Function('return this.toString()'); MYFUNC()") ); + + // eval( this ) in anonymous code called as a function should return that function's activation object + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('return (eval(\"this.toString()\")'); (MYFUNC()).toString()", + GLOBAL_OBJECT, + eval("var MYFUNC = new Function('return eval(\"this.toString()\")'); (MYFUNC()).toString()") ); + + // this and eval( this ) in anonymous code called as a constructor should return the object + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()", + "[object Object]", + eval("var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()") ); + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", + true, + eval("var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC().THIS).toString()", + "[object Object]", + eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC()).THIS).toString()") ); + + testcases[item++] = new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", + true, + eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); + + // this and eval(this) in function code called as a function should return the global object. + testcases[item++] = new TestCase( SECTION, + "Function Code: ReturnThis()", + GLOBAL_OBJECT, + ReturnThis() ); + + testcases[item++] = new TestCase( SECTION, + "Function Code: ReturnEvalThis()", + GLOBAL_OBJECT, + ReturnEvalThis() ); + + // this and eval(this) in function code called as a contructor should return the object. + testcases[item++] = new TestCase( SECTION, + "var MYOBJECT = new ReturnThis(); MYOBJECT.toString()", + "[object Object]", + eval("var MYOBJECT = new ReturnThis(); MYOBJECT.toString()") ); + + testcases[item++] = new TestCase( SECTION, + "var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()", + "[object Object]", + eval("var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()") ); + + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function ReturnThis() { + return this.toString(); +} +function ReturnEvalThis() { + return( eval("this.toString()") ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.10-1.js b/tests/mozilla/ecma/Expressions/11.10-1.js new file mode 100644 index 0000000..c5f6911 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.10-1.js @@ -0,0 +1,270 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.10-1.js + ECMA Section: 11.10-1 Binary Bitwise Operators: & + Description: + Semantics + + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: + + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.10-1"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Binary Bitwise Operators: &"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + var shiftexp = 0; + var addexp = 0; + +// for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + for ( shiftpow = 0; shiftpow < 1; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); + + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + array[item++] = new TestCase( SECTION, + shiftexp + " & " + addexp, + And( shiftexp, addexp ), + shiftexp & addexp ); + } + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function And( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + return ToInt32Decimal(result); +} +function Xor( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} +function Or( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} diff --git a/tests/mozilla/ecma/Expressions/11.10-2.js b/tests/mozilla/ecma/Expressions/11.10-2.js new file mode 100644 index 0000000..fc2e10e --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.10-2.js @@ -0,0 +1,269 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.10-2.js + ECMA Section: 11.10-2 Binary Bitwise Operators: | + Description: + Semantics + + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: + + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.10-2"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Binary Bitwise Operators: |"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + var shiftexp = 0; + var addexp = 0; + + for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); + + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + array[item++] = new TestCase( SECTION, + shiftexp + " | " + addexp, + Or( shiftexp, addexp ), + shiftexp | addexp ); + } + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function And( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + return ToInt32Decimal(result); +} +function Xor( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} +function Or( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} diff --git a/tests/mozilla/ecma/Expressions/11.10-3.js b/tests/mozilla/ecma/Expressions/11.10-3.js new file mode 100644 index 0000000..0d55357 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.10-3.js @@ -0,0 +1,268 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.10-3.js + ECMA Section: 11.10-3 Binary Bitwise Operators: ^ + Description: + Semantics + + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: + + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.10-3"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Binary Bitwise Operators: ^"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + var shiftexp = 0; + var addexp = 0; + + for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); + + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + array[item++] = new TestCase( SECTION, + shiftexp + " ^ " + addexp, + Xor( shiftexp, addexp ), + shiftexp ^ addexp ); + } + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function And( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + return ToInt32Decimal(result); +} +function Xor( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} +function Or( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} diff --git a/tests/mozilla/ecma/Expressions/11.12-1.js b/tests/mozilla/ecma/Expressions/11.12-1.js new file mode 100644 index 0000000..ae0a263 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.12-1.js @@ -0,0 +1,86 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.12.js + ECMA Section: 11.12 Conditional Operator + Description: + Logi + + calORExpression ? AssignmentExpression : AssignmentExpression + + Semantics + + The production ConditionalExpression : + LogicalORExpression ? AssignmentExpression : AssignmentExpression + is evaluated as follows: + + 1. Evaluate LogicalORExpression. + 2. Call GetValue(Result(1)). + 3. Call ToBoolean(Result(2)). + 4. If Result(3) is false, go to step 8. + 5. Evaluate the first AssignmentExpression. + 6. Call GetValue(Result(5)). + 7. Return Result(6). + 8. Evaluate the second AssignmentExpression. + 9. Call GetValue(Result(8)). + 10. Return Result(9). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.12"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Conditional operator( ? : )"); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + array[item++] = new TestCase( SECTION, "false ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); + + array[item++] = new TestCase( SECTION, "1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + array[item++] = new TestCase( SECTION, "0 ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); + array[item++] = new TestCase( SECTION, "-1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + + array[item++] = new TestCase( SECTION, "NaN ? 'FAILED' : 'PASSED'", "PASSED", (Number.NaN?"FAILED":"PASSED")); + + array[item++] = new TestCase( SECTION, "var VAR = true ? , : 'FAILED'", "PASSED", (VAR = true ? "PASSED" : "FAILED") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.12-2-n.js b/tests/mozilla/ecma/Expressions/11.12-2-n.js new file mode 100644 index 0000000..05e42dc --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.12-2-n.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.12-2-n.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.12-2-n"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); + + var testcases = new Array(); + + // the following expression should be an error in JS. + + testcases[tc] = new TestCase( SECTION, + "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR", + "error", + "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR" ); + + // get around parse time error by putting expression in an eval statement + + testcases[tc].actual = eval ( testcases[tc].actual ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.12-3.js b/tests/mozilla/ecma/Expressions/11.12-3.js new file mode 100644 index 0000000..eb79c16 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.12-3.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.12-3.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.12-3"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); + + var testcases = new Array(); + + // the following expression should NOT be an error in JS. + + testcases[tc] = new TestCase( SECTION, + "var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR", + "PASSED", + "var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR" ); + + // get around potential parse time error by putting expression in an eval statement + + testcases[tc].actual = eval ( testcases[tc].actual ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.12-4.js b/tests/mozilla/ecma/Expressions/11.12-4.js new file mode 100644 index 0000000..017cf4b --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.12-4.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.12-4.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.12-4"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); + + var testcases = new Array(); + + // the following expression should NOT be an error in JS. + + testcases[tc] = new TestCase( SECTION, + "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1", + "PASSED", + "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1" ); + + // get around potential parse time error by putting expression in an eval statement + + testcases[tc].actual = eval ( testcases[tc].actual ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.13.1.js b/tests/mozilla/ecma/Expressions/11.13.1.js new file mode 100644 index 0000000..537ec28 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.13.1.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 11.13.1.js + ECMA Section: 11.13.1 Simple assignment + Description: + + 11.13.1 Simple Assignment ( = ) + + The production AssignmentExpression : + LeftHandSideExpression = AssignmentExpression is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Evaluate AssignmentExpression. + 3. Call GetValue(Result(2)). + 4. Call PutValue(Result(1), Result(3)). + 5. Return Result(3). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Simple Assignment ( = )"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "SOMEVAR = true", true, SOMEVAR = true ); + + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.13.2-1.js b/tests/mozilla/ecma/Expressions/11.13.2-1.js new file mode 100644 index 0000000..721fb19 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.13.2-1.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 11.13.2-1.js + ECMA Section: 11.13.2 Compound Assignment: *= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: *="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // NaN cases + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 *= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 *= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2; VAR1") ); + + // number cases + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 *= VAR2", 0, eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0xFF; VAR2 = 0xA, VAR1 *= VAR2", 2550, eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 *= VAR2") ); + + // special multiplication cases + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 *= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 *= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 *= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 *= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + + // string cases + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '255', VAR1 *= VAR2", 2550, eval("VAR1 = 10; VAR2 = '255', VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2", 2550, eval("VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 *= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 *= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 *= VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2", 225, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2") ); + + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.13.2-2.js b/tests/mozilla/ecma/Expressions/11.13.2-2.js new file mode 100644 index 0000000..5838acf --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.13.2-2.js @@ -0,0 +1,136 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 11.13.2-2js + ECMA Section: 11.13.2 Compound Assignment: /= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: /="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // NaN cases + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2; VAR1") ); + + // number cases + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0xFF; VAR2 = 0xA, VAR1 /= VAR2", 25.5, eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 /= VAR2") ); + + // special division cases + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 /= VAR2", 0, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 /= VAR2", 0, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 /= VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 /= VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 /= VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 /= VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= 0; VAR1 /= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = 1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -0; VAR1 /= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = 1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= 0; VAR1 /= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = -1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -0; VAR1 /= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = -1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + + // string cases + array[item++] = new TestCase( SECTION, "VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1", 100, eval("VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1", 100, eval("VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1") ); +/* + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 /= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 /= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 /= VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2") ); + +*/ + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.13.2-3.js b/tests/mozilla/ecma/Expressions/11.13.2-3.js new file mode 100644 index 0000000..cf151db --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.13.2-3.js @@ -0,0 +1,149 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 11.13.2-4.js + ECMA Section: 11.13.2 Compound Assignment: %= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: +="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // If either operand is NaN, result is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 %= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2; VAR1") ); + + // if the dividend is infinity or the divisor is zero or both, the result is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + + // if the dividend is finite and the divisor is an infinity, the result equals the dividend. + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 %= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 %= VAR2;VAR1", -0, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", -0, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= Infinity; VAR1 %= VAR2;VAR1", 1, eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= Infinity; VAR1 %= VAR2;VAR1", -1, eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", -1, eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", 1, eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + + // if the dividend is a zero and the divisor is finite, the result is the same as the dividend + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 %= VAR2; VAR1", -0, eval("VAR1 = -0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 %= VAR2; VAR1", -0, eval("VAR1 = -0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); + + // string cases + array[item++] = new TestCase( SECTION, "VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1", 0, eval("VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1") ); +/* + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 %= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 %= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 %= VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2") ); + +*/ + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason %= ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.13.2-4.js b/tests/mozilla/ecma/Expressions/11.13.2-4.js new file mode 100644 index 0000000..edf79a7 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.13.2-4.js @@ -0,0 +1,137 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 11.13.2-4.js + ECMA Section: 11.13.2 Compound Assignment:+= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-4"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: +="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // If either operand is NaN, result is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2; VAR1") ); + + // the sum of two Infinities the same sign is the infinity of that sign + // the sum of two Infinities of opposite sign is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 += VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + + // the sum of an infinity and a finite value is equal to the infinite operand + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + + // the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 += VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 += VAR2; VAR1") ); + + // the sum of a zero and a nonzero finite value is eqal to the nonzero operand + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = 0; VAR2 = 1; VAR2 += VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = -0; VAR2 = 1; VAR2 += VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = -0; VAR2 = -1; VAR2 += VAR1; VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = 0; VAR2 = -1; VAR2 += VAR1; VAR2") ); + + // the sum of a zero and a nozero finite value is equal to the nonzero operand. + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1") ); + + // the sum of two nonzero finite values of the same magnitude and opposite sign is +0 + array[item++] = new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1") ); + +/* + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 += VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 += VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 += VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 += VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 += VAR2") ); + +*/ + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.13.2-5.js b/tests/mozilla/ecma/Expressions/11.13.2-5.js new file mode 100644 index 0000000..6923bef --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.13.2-5.js @@ -0,0 +1,137 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 11.13.2-5.js + ECMA Section: 11.13.2 Compound Assignment: -= + Description: + + *= /= %= -= -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.13.2-5"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Compound Assignment: -="); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // If either operand is NaN, result is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2; VAR1") ); + + // the sum of two Infinities the same sign is the infinity of that sign + // the sum of two Infinities of opposite sign is NaN + + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 -= VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + + // the sum of an infinity and a finite value is equal to the infinite operand + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + + // the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 -= VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); + + // the sum of a zero and a nonzero finite value is eqal to the nonzero operand + + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = 0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = -0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = -0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = 0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); + + // the sum of a zero and a nozero finite value is equal to the nonzero operand. + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); + + // the sum of two nonzero finite values of the same magnitude and opposite sign is +0 + array[item++] = new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1") ); + +/* + array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); + + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); + + // boolean cases + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 -= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 -= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 -= VAR2") ); + + // object cases + array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1") ); + array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2") ); + array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2") ); + +*/ + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason -= ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.13.js b/tests/mozilla/ecma/Expressions/11.13.js new file mode 100644 index 0000000..73b4d19 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.13.js @@ -0,0 +1,86 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 11.12.js + ECMA Section: 11.12 Conditional Operator + Description: + Logi + + calORExpression ? AssignmentExpression : AssignmentExpression + + Semantics + + The production ConditionalExpression : + LogicalORExpression ? AssignmentExpression : AssignmentExpression + is evaluated as follows: + + 1. Evaluate LogicalORExpression. + 2. Call GetValue(Result(1)). + 3. Call ToBoolean(Result(2)). + 4. If Result(3) is false, go to step 8. + 5. Evaluate the first AssignmentExpression. + 6. Call GetValue(Result(5)). + 7. Return Result(6). + 8. Evaluate the second AssignmentExpression. + 9. Call GetValue(Result(8)). + 10. Return Result(9). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.12"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Conditional operator( ? : )"); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + array[item++] = new TestCase( SECTION, "false ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); + + array[item++] = new TestCase( SECTION, "1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + array[item++] = new TestCase( SECTION, "0 ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); + array[item++] = new TestCase( SECTION, "-1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + + array[item++] = new TestCase( SECTION, "NaN ? 'FAILED' : 'PASSED'", "PASSED", (Number.NaN?"FAILED":"PASSED")); + + array[item++] = new TestCase( SECTION, "var VAR = true ? , : 'FAILED'", "PASSED", (VAR = true ? "PASSED" : "FAILED") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.14-1.js b/tests/mozilla/ecma/Expressions/11.14-1.js new file mode 100644 index 0000000..bd3e8f1 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.14-1.js @@ -0,0 +1,73 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.14-1.js + ECMA Section: 11.14 Comma operator (,) + Description: + Expression : + + AssignmentExpression + Expression , AssignmentExpression + + Semantics + + The production Expression : Expression , AssignmentExpression is evaluated as follows: + + 1. Evaluate Expression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Return Result(4). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.14-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Comma operator (,)"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true, false", false, eval("true, false") ); + array[item++] = new TestCase( SECTION, "VAR1=true, VAR2=false", false, eval("VAR1=true, VAR2=false") ); + array[item++] = new TestCase( SECTION, "VAR1=true, VAR2=false;VAR1", true, eval("VAR1=true, VAR2=false; VAR1") ); + return ( array ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.1-1.js b/tests/mozilla/ecma/Expressions/11.2.1-1.js new file mode 100644 index 0000000..6144c9a --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.1-1.js @@ -0,0 +1,268 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.1-1.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // properties and functions of the global object + + PROPERTY[p++] = new Property( "this", "NaN", "number" ); + PROPERTY[p++] = new Property( "this", "Infinity", "number" ); + PROPERTY[p++] = new Property( "this", "eval", "function" ); + PROPERTY[p++] = new Property( "this", "parseInt", "function" ); + PROPERTY[p++] = new Property( "this", "parseFloat", "function" ); + PROPERTY[p++] = new Property( "this", "escape", "function" ); + PROPERTY[p++] = new Property( "this", "unescape", "function" ); + PROPERTY[p++] = new Property( "this", "isNaN", "function" ); + PROPERTY[p++] = new Property( "this", "isFinite", "function" ); + PROPERTY[p++] = new Property( "this", "Object", "function" ); + PROPERTY[p++] = new Property( "this", "Number", "function" ); + PROPERTY[p++] = new Property( "this", "Function", "function" ); + PROPERTY[p++] = new Property( "this", "Array", "function" ); + PROPERTY[p++] = new Property( "this", "String", "function" ); + PROPERTY[p++] = new Property( "this", "Boolean", "function" ); + PROPERTY[p++] = new Property( "this", "Date", "function" ); + PROPERTY[p++] = new Property( "this", "Math", "object" ); + + // properties and methods of Object objects + + PROPERTY[p++] = new Property( "Object", "prototype", "object" ); + PROPERTY[p++] = new Property( "Object", "toString", "function" ); + PROPERTY[p++] = new Property( "Object", "valueOf", "function" ); + PROPERTY[p++] = new Property( "Object", "constructor", "function" ); + + // properties of the Function object + + PROPERTY[p++] = new Property( "Function", "prototype", "function" ); + PROPERTY[p++] = new Property( "Function.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "Function.prototype", "length", "number" ); + PROPERTY[p++] = new Property( "Function.prototype", "valueOf", "function" ); + + Function.prototype.myProperty = "hi"; + + PROPERTY[p++] = new Property( "Function.prototype", "myProperty", "string" ); + + // properties of the Array object + PROPERTY[p++] = new Property( "Array", "prototype", "object" ); + PROPERTY[p++] = new Property( "Array", "length", "number" ); + PROPERTY[p++] = new Property( "Array.prototype", "constructor", "function" ); + PROPERTY[p++] = new Property( "Array.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "Array.prototype", "join", "function" ); + PROPERTY[p++] = new Property( "Array.prototype", "reverse", "function" ); + PROPERTY[p++] = new Property( "Array.prototype", "sort", "function" ); + + // properties of the String object + PROPERTY[p++] = new Property( "String", "prototype", "object" ); + PROPERTY[p++] = new Property( "String", "fromCharCode", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "constructor", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "valueOf", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "charAt", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "charCodeAt", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "indexOf", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "lastIndexOf", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "split", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "substring", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "toLowerCase", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "toUpperCase", "function" ); + PROPERTY[p++] = new Property( "String.prototype", "length", "number" ); + + // properties of the Boolean object + PROPERTY[p++] = new Property( "Boolean", "prototype", "object" ); + PROPERTY[p++] = new Property( "Boolean", "constructor", "function" ); + PROPERTY[p++] = new Property( "Boolean.prototype", "valueOf", "function" ); + PROPERTY[p++] = new Property( "Boolean.prototype", "toString", "function" ); + + // properties of the Number object + + PROPERTY[p++] = new Property( "Number", "MAX_VALUE", "number" ); + PROPERTY[p++] = new Property( "Number", "MIN_VALUE", "number" ); + PROPERTY[p++] = new Property( "Number", "NaN", "number" ); + PROPERTY[p++] = new Property( "Number", "NEGATIVE_INFINITY", "number" ); + PROPERTY[p++] = new Property( "Number", "POSITIVE_INFINITY", "number" ); + PROPERTY[p++] = new Property( "Number.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "Number.prototype", "constructor", "function" ); + PROPERTY[p++] = new Property( "Number.prototype", "valueOf", "function" ); + + // properties of the Math Object. + PROPERTY[p++] = new Property( "Math", "E", "number" ); + PROPERTY[p++] = new Property( "Math", "LN10", "number" ); + PROPERTY[p++] = new Property( "Math", "LN2", "number" ); + PROPERTY[p++] = new Property( "Math", "LOG2E", "number" ); + PROPERTY[p++] = new Property( "Math", "LOG10E", "number" ); + PROPERTY[p++] = new Property( "Math", "PI", "number" ); + PROPERTY[p++] = new Property( "Math", "SQRT1_2", "number" ); + PROPERTY[p++] = new Property( "Math", "SQRT2", "number" ); + PROPERTY[p++] = new Property( "Math", "abs", "function" ); + PROPERTY[p++] = new Property( "Math", "acos", "function" ); + PROPERTY[p++] = new Property( "Math", "asin", "function" ); + PROPERTY[p++] = new Property( "Math", "atan", "function" ); + PROPERTY[p++] = new Property( "Math", "atan2", "function" ); + PROPERTY[p++] = new Property( "Math", "ceil", "function" ); + PROPERTY[p++] = new Property( "Math", "cos", "function" ); + PROPERTY[p++] = new Property( "Math", "exp", "function" ); + PROPERTY[p++] = new Property( "Math", "floor", "function" ); + PROPERTY[p++] = new Property( "Math", "log", "function" ); + PROPERTY[p++] = new Property( "Math", "max", "function" ); + PROPERTY[p++] = new Property( "Math", "min", "function" ); + PROPERTY[p++] = new Property( "Math", "pow", "function" ); + PROPERTY[p++] = new Property( "Math", "random", "function" ); + PROPERTY[p++] = new Property( "Math", "round", "function" ); + PROPERTY[p++] = new Property( "Math", "sin", "function" ); + PROPERTY[p++] = new Property( "Math", "sqrt", "function" ); + PROPERTY[p++] = new Property( "Math", "tan", "function" ); + + // properties of the Date object + PROPERTY[p++] = new Property( "Date", "parse", "function" ); + PROPERTY[p++] = new Property( "Date", "prototype", "object" ); + PROPERTY[p++] = new Property( "Date", "UTC", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "constructor", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "toString", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "valueOf", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getTime", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getFullYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCFullYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getMonth", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCMonth", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getDate", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCDate", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getDay", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCDay", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getHours", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCHours", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getMinutes", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCMinutes", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getSeconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCSeconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getMilliseconds","function" ); + PROPERTY[p++] = new Property( "Date.prototype", "getUTCMilliseconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setTime", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setMilliseconds","function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCMilliseconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setSeconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCSeconds", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setMinutes", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCMinutes", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setHours", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCHours", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setDate", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCDate", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setMonth", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCMonth", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setFullYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setUTCFullYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "setYear", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "toLocaleString", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "toUTCString", "function" ); + PROPERTY[p++] = new Property( "Date.prototype", "toGMTString", "function" ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + RESULT = eval("typeof " + PROPERTY[i].object + "." + PROPERTY[i].name ); + + testcases[tc++] = new TestCase( SECTION, + "typeof " + PROPERTY[i].object + "." + PROPERTY[i].name, + PROPERTY[i].type, + RESULT ); + + RESULT = eval("typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']"); + + testcases[tc++] = new TestCase( SECTION, + "typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']", + PROPERTY[i].type, + RESULT ); + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( arg0, arg1, arg2, arg3, arg4 ) { + this.name = arg0; +} +function Property( object, name, type ) { + this.object = object; + this.name = name; + this.type = type; +} diff --git a/tests/mozilla/ecma/Expressions/11.2.1-2.js b/tests/mozilla/ecma/Expressions/11.2.1-2.js new file mode 100644 index 0000000..fa3056b --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.1-2.js @@ -0,0 +1,124 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.1-2.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + PROPERTY[p++] = new Property( "\"hi\"", "hi", "hi", NaN ); + PROPERTY[p++] = new Property( NaN, NaN, "NaN", NaN ); +// PROPERTY[p++] = new Property( 3, 3, "3", 3 ); + PROPERTY[p++] = new Property( true, true, "true", 1 ); + PROPERTY[p++] = new Property( false, false, "false", 0 ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); + + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( PROPERTY[i].object+ ".toString()" ) ); + + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.2.1-3-n.js b/tests/mozilla/ecma/Expressions/11.2.1-3-n.js new file mode 100644 index 0000000..f84bb28 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.1-3-n.js @@ -0,0 +1,120 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.1-2.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + PROPERTY[p++] = new Property( "undefined", void 0, "undefined", NaN ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); + + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( PROPERTY[i].object+ ".toString()" ) ); + + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.2.1-4-n.js b/tests/mozilla/ecma/Expressions/11.2.1-4-n.js new file mode 100644 index 0000000..0127253 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.1-4-n.js @@ -0,0 +1,120 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.1-4-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + PROPERTY[p++] = new Property( "null", null, "null", 0 ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); + + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( PROPERTY[i].object+ ".toString()" ) ); + + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.2.1-5.js b/tests/mozilla/ecma/Expressions/11.2.1-5.js new file mode 100644 index 0000000..0cb19c9 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.1-5.js @@ -0,0 +1,124 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.1-5.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.1-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + PROPERTY[p++] = new Property( new String("hi"), "hi", "hi", NaN ); + PROPERTY[p++] = new Property( new Number(NaN), NaN, "NaN", NaN ); + PROPERTY[p++] = new Property( new Number(3), 3, "3", 3 ); + PROPERTY[p++] = new Property( new Boolean(true), true, "true", 1 ); + PROPERTY[p++] = new Property( new Boolean(false), false, "false", 0 ); + + for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( "PROPERTY[i].object.valueOf()" ) ); + + testcases[tc++] = new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( "PROPERTY[i].object.toString()" ) ); + + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.2.2-1-n.js b/tests/mozilla/ecma/Expressions/11.2.2-1-n.js new file mode 100644 index 0000000..db73cad --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-1-n.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-1.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-1-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var OBJECT = new Object(); + + testcases[tc++] = new TestCase( SECTION, + "OBJECT = new Object; var o = new OBJECT()", + "error", + o = new OBJECT() ); + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-1.js b/tests/mozilla/ecma/Expressions/11.2.2-1.js new file mode 100644 index 0000000..48c2e6a --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-1.js @@ -0,0 +1,99 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-1.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + testcases[tc++] = new TestCase( SECTION, + "(new TestFunction(0,1,2,3,4,5)).length", + 6, + (new TestFunction(0,1,2,3,4,5)).length ); + + + + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-10-n.js b/tests/mozilla/ecma/Expressions/11.2.2-10-n.js new file mode 100644 index 0000000..619554d --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-10-n.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-9-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + testcases[tc++] = new TestCase( SECTION, + "var m = new Math()", + "error", + m = new Math() ); + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-11.js b/tests/mozilla/ecma/Expressions/11.2.2-11.js new file mode 100644 index 0000000..a6f7364 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-11.js @@ -0,0 +1,99 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-9-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var FUNCTION = new Function(); + + testcases[tc++] = new TestCase( SECTION, + "var FUNCTION = new Function(); f = new FUNCTION(); typeof f", + "object", + eval("var FUNCTION = new Function(); f = new FUNCTION(); typeof f") ); + + testcases[tc++] = new TestCase( SECTION, + "var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f", + "object", + eval("var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f") ); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-2-n.js b/tests/mozilla/ecma/Expressions/11.2.2-2-n.js new file mode 100644 index 0000000..4e74cd4 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-2-n.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-2.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-2-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var UNDEFINED = void 0; + + testcases[tc++] = new TestCase( SECTION, + "UNDEFINED = void 0; var o = new UNDEFINED()", + "error", + o = new UNDEFINED() ); + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-3-n.js b/tests/mozilla/ecma/Expressions/11.2.2-3-n.js new file mode 100644 index 0000000..2c6b509 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-3-n.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-3-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-3-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var NULL = null; + + testcases[tc++] = new TestCase( SECTION, + "NULL = null; var o = new NULL()", + "error", + o = new NULL() ); + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-4-n.js b/tests/mozilla/ecma/Expressions/11.2.2-4-n.js new file mode 100644 index 0000000..a9e5f4a --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-4-n.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-4-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-4-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var STRING = ""; + + testcases[tc++] = new TestCase( SECTION, + "STRING = '', var s = new STRING()", + "error", + s = new STRING() ); + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-5-n.js b/tests/mozilla/ecma/Expressions/11.2.2-5-n.js new file mode 100644 index 0000000..304f1d3 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-5-n.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-5-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-5-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var NUMBER = 0; + + testcases[tc++] = new TestCase( SECTION, + "NUMBER=0, var n = new NUMBER()", + "error", + n = new NUMBER() ); + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-6-n.js b/tests/mozilla/ecma/Expressions/11.2.2-6-n.js new file mode 100644 index 0000000..fd24e4f --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-6-n.js @@ -0,0 +1,81 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.2.2-6-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var BOOLEAN = true; + + testcases[tc++] = new TestCase( SECTION, + "BOOLEAN = true; var b = new BOOLEAN()", + "error", + b = new BOOLEAN() ); + test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-7-n.js b/tests/mozilla/ecma/Expressions/11.2.2-7-n.js new file mode 100644 index 0000000..4a54726 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-7-n.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-6-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var STRING = new String("hi"); + + testcases[tc++] = new TestCase( SECTION, + "var STRING = new String('hi'); var s = new STRING()", + "error", + s = new STRING() ); + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-8-n.js b/tests/mozilla/ecma/Expressions/11.2.2-8-n.js new file mode 100644 index 0000000..eb58ff5 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-8-n.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-8-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-8-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var NUMBER = new Number(1); + + testcases[tc++] = new TestCase( SECTION, + "var NUMBER = new Number(1); var n = new NUMBER()", + "error", + n = new NUMBER() ); + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.2-9-n.js b/tests/mozilla/ecma/Expressions/11.2.2-9-n.js new file mode 100644 index 0000000..56199cf --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.2-9-n.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.2-9-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The new operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var BOOLEAN = new Boolean(); + + testcases[tc++] = new TestCase( SECTION, + "var BOOLEAN = new Boolean(); var b = new BOOLEAN()", + "error", + b = new BOOLEAN() ); + test(); + +function TestFunction() { + return arguments; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.3-1.js b/tests/mozilla/ecma/Expressions/11.2.3-1.js new file mode 100644 index 0000000..7653900 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.3-1.js @@ -0,0 +1,121 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.3-1.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +/* this.eval() is no longer legal syntax. + // MemberExpression : this + + testcases[tc++] = new TestCase( SECTION, + "this.eval()", + void 0, + this.eval() ); + + testcases[tc++] = new TestCase( SECTION, + "this.eval('NaN')", + NaN, + this.eval("NaN") ); +*/ + // MemberExpression: Identifier + + var OBJECT = true; + + testcases[tc++] = new TestCase( SECTION, + "OBJECT.toString()", + "true", + OBJECT.toString() ); + + // MemberExpression[ Expression] + + testcases[tc++] = new TestCase( SECTION, + "(new Array())['length'].valueOf()", + 0, + (new Array())["length"].valueOf() ); + + // MemberExpression . Identifier + testcases[tc++] = new TestCase( SECTION, + "(new Array()).length.valueOf()", + 0, + (new Array()).length.valueOf() ); + // new MemberExpression Arguments + + testcases[tc++] = new TestCase( SECTION, + "(new Array(20))['length'].valueOf()", + 20, + (new Array(20))["length"].valueOf() ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.3-2-n.js b/tests/mozilla/ecma/Expressions/11.2.3-2-n.js new file mode 100644 index 0000000..e5ba65c --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.3-2-n.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.3-2-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-2-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "3.valueOf()", + 3, + 3.valueOf() ); + + testcases[tc++] = new TestCase( SECTION, + "(3).valueOf()", + 3, + (3).valueOf() ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.3-3-n.js b/tests/mozilla/ecma/Expressions/11.2.3-3-n.js new file mode 100644 index 0000000..da58907 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.3-3-n.js @@ -0,0 +1,81 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.3-3-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-3-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, "(void 0).valueOf()", "error", (void 0).valueOf() ); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.3-4-n.js b/tests/mozilla/ecma/Expressions/11.2.3-4-n.js new file mode 100644 index 0000000..eed49b2 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.3-4-n.js @@ -0,0 +1,81 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.3-4-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-4-n.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, "null.valueOf()", "error", null.valueOf() ); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.2.3-5.js b/tests/mozilla/ecma/Expressions/11.2.3-5.js new file mode 100644 index 0000000..77a0f6c --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.2.3-5.js @@ -0,0 +1,81 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.2.3-5-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1. Evaluate MemberExpression. + 2. Evaluate Arguments, producing an internal list of argument values + (section 0). + 3. Call GetValue(Result(1)). + 4. If Type(Result(3)) is not Object, generate a runtime error. + 5. If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6. If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7. If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8. Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9. Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "11.2.3-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function Calls"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, "true.valueOf()", true, true.valueOf() ); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.3.1.js b/tests/mozilla/ecma/Expressions/11.3.1.js new file mode 100644 index 0000000..0e1e8aa --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.3.1.js @@ -0,0 +1,154 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.3.1.js + ECMA Section: 11.3.1 Postfix increment operator + Description: + The production MemberExpression : MemberExpression ++ is evaluated as + follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Add the value 1 to Result(3), using the same rules as for the + + operator (section 0). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(3). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.3.1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Postfix increment operator"); + + testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // special numbers + array[item++] = new TestCase( SECTION, "var MYVAR; MYVAR++", NaN, eval("var MYVAR; MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR= void 0; MYVAR++", NaN, eval("var MYVAR=void 0; MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=null; MYVAR++", 0, eval("var MYVAR=null; MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=true; MYVAR++", 1, eval("var MYVAR=true; MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false; MYVAR++", 0, eval("var MYVAR=false; MYVAR++") ); + + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++;MYVAR") ); + + // number primitives + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++", 0, eval("var MYVAR=0;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++", 0.2345, eval("var MYVAR=0.2345;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++", -0.2345, eval("var MYVAR=-0.2345;MYVAR++") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++;MYVAR", 1.2345, eval("var MYVAR=0.2345;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++;MYVAR", 0.7655, eval("var MYVAR=-0.2345;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); + + // boolean values + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR++;MYVAR", 2, eval("var MYVAR=true;MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR++;MYVAR", 1, eval("var MYVAR=false;MYVAR++;MYVAR") ); + + // boolean objects + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++;MYVAR", 2, eval("var MYVAR=new Boolean(true);MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++;MYVAR", 1, eval("var MYVAR=new Boolean(false);MYVAR++;MYVAR") ); + + // string primitives + array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR++", Number.NaN, eval("var MYVAR='string';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR++", 12345, eval("var MYVAR='12345';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR++", -12345, eval("var MYVAR='-12345';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';MYVAR++", 15, eval("var MYVAR='0Xf';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR++", 77, eval("var MYVAR='077';MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=''; MYVAR++", 0, eval("var MYVAR='';MYVAR++") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR++;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR++;MYVAR", 12346, eval("var MYVAR='12345';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR++;MYVAR", -12344, eval("var MYVAR='-12345';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0xf';MYVAR++;MYVAR", 16, eval("var MYVAR='0xf';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR++;MYVAR", 78, eval("var MYVAR='077';MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='';MYVAR++;MYVAR", 1, eval("var MYVAR='';MYVAR++;MYVAR") ); + + // string objects + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++", Number.NaN, eval("var MYVAR=new String('string');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++", 12345, eval("var MYVAR=new String('12345');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++", -12345, eval("var MYVAR=new String('-12345');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR++", 15, eval("var MYVAR=new String('0Xf');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++", 77, eval("var MYVAR=new String('077');MYVAR++") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); MYVAR++", 0, eval("var MYVAR=new String('');MYVAR++") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++;MYVAR", 12346, eval("var MYVAR=new String('12345');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++;MYVAR", -12344, eval("var MYVAR=new String('-12345');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR++;MYVAR", 16, eval("var MYVAR=new String('0xf');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++;MYVAR", 78, eval("var MYVAR=new String('077');MYVAR++;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('');MYVAR++;MYVAR", 1, eval("var MYVAR=new String('');MYVAR++;MYVAR") ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Expressions/11.3.2.js b/tests/mozilla/ecma/Expressions/11.3.2.js new file mode 100644 index 0000000..1042f85 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.3.2.js @@ -0,0 +1,154 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.3.2.js + ECMA Section: 11.3.2 Postfix decrement operator + Description: + + 11.3.2 Postfix decrement operator + + The production MemberExpression : MemberExpression -- is evaluated as follows: + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Subtract the value 1 from Result(3), using the same rules as for the - + operator (section 0). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(3). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.3.2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Postfix decrement operator"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // special numbers + array[item++] = new TestCase( SECTION, "var MYVAR; MYVAR--", NaN, eval("var MYVAR; MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR= void 0; MYVAR--", NaN, eval("var MYVAR=void 0; MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=null; MYVAR--", 0, eval("var MYVAR=null; MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=true; MYVAR--", 1, eval("var MYVAR=true; MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false; MYVAR--", 0, eval("var MYVAR=false; MYVAR--") ); + + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--;MYVAR") ); + + // number primitives + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--", 0, eval("var MYVAR=0;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--", 0.2345, eval("var MYVAR=0.2345;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--", -0.2345, eval("var MYVAR=-0.2345;MYVAR--") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--;MYVAR", -0.7655, eval("var MYVAR=0.2345;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--;MYVAR", -1.2345, eval("var MYVAR=-0.2345;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); + + // boolean values + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR--;MYVAR", 0, eval("var MYVAR=true;MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR--;MYVAR", -1, eval("var MYVAR=false;MYVAR--;MYVAR") ); + + // boolean objects + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--;MYVAR", 0, eval("var MYVAR=new Boolean(true);MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--;MYVAR", -1, eval("var MYVAR=new Boolean(false);MYVAR--;MYVAR") ); + + // string primitives + array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR--", Number.NaN, eval("var MYVAR='string';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR--", 12345, eval("var MYVAR='12345';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR--", -12345, eval("var MYVAR='-12345';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';MYVAR--", 15, eval("var MYVAR='0Xf';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR--", 77, eval("var MYVAR='077';MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=''; MYVAR--", 0, eval("var MYVAR='';MYVAR--") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR--;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR--;MYVAR", 12344, eval("var MYVAR='12345';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR--;MYVAR", -12346, eval("var MYVAR='-12345';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0xf';MYVAR--;MYVAR", 14, eval("var MYVAR='0xf';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR--;MYVAR", 76, eval("var MYVAR='077';MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='';MYVAR--;MYVAR", -1, eval("var MYVAR='';MYVAR--;MYVAR") ); + + // string objects + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--", Number.NaN, eval("var MYVAR=new String('string');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--", 12345, eval("var MYVAR=new String('12345');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--", -12345, eval("var MYVAR=new String('-12345');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR--", 15, eval("var MYVAR=new String('0Xf');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--", 77, eval("var MYVAR=new String('077');MYVAR--") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); MYVAR--", 0, eval("var MYVAR=new String('');MYVAR--") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--;MYVAR", 12344, eval("var MYVAR=new String('12345');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--;MYVAR", -12346, eval("var MYVAR=new String('-12345');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR--;MYVAR", 14, eval("var MYVAR=new String('0xf');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--;MYVAR", 76, eval("var MYVAR=new String('077');MYVAR--;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('');MYVAR--;MYVAR", -1, eval("var MYVAR=new String('');MYVAR--;MYVAR") ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Expressions/11.4.1.js b/tests/mozilla/ecma/Expressions/11.4.1.js new file mode 100644 index 0000000..766b786 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.4.1.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.4.1.js + ECMA Section: 11.4.1 the Delete Operator + Description: returns true if the property could be deleted + returns false if it could not be deleted + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + + + var SECTION = "11.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The delete operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// array[item++] = new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.length", 2, eval("x=[9,8,7];delete(x[2]);x.length") ); +// array[item++] = new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.toString()", "9,8", eval("x=[9,8,7];delete(x[2]);x.toString()") ); + array[item++] = new TestCase( SECTION, "x=new Date();delete x;typeof(x)", "undefined", eval("x=new Date();delete x;typeof(x)") ); + +// array[item++] = new TestCase( SECTION, "delete(x=new Date())", true, delete(x=new Date()) ); +// array[item++] = new TestCase( SECTION, "delete('string primitive')", true, delete("string primitive") ); +// array[item++] = new TestCase( SECTION, "delete(new String( 'string object' ) )", true, delete(new String("string object")) ); +// array[item++] = new TestCase( SECTION, "delete(new Number(12345) )", true, delete(new Number(12345)) ); + array[item++] = new TestCase( SECTION, "delete(Math.PI)", false, delete(Math.PI) ); +// array[item++] = new TestCase( SECTION, "delete(null)", true, delete(null) ); +// array[item++] = new TestCase( SECTION, "delete(void(0))", true, delete(void(0)) ); + + // variables declared with the var statement are not deletable. + + var abc; + array[item++] = new TestCase( SECTION, "var abc; delete(abc)", false, delete abc ); + + array[item++] = new TestCase( SECTION, + "var OB = new MyObject(); for ( p in OB ) { delete p }", + true, + eval("var OB = new MyObject(); for ( p in OB ) { delete p }") ); + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + + } + stopTest(); + return ( testcases ); +} + +function MyObject() { + this.prop1 = true; + this.prop2 = false; + this.prop3 = null + this.prop4 = void 0; + this.prop5 = "hi"; + this.prop6 = 42; + this.prop7 = new Date(); + this.prop8 = Math.PI; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.4.2.js b/tests/mozilla/ecma/Expressions/11.4.2.js new file mode 100644 index 0000000..c889ec6 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.4.2.js @@ -0,0 +1,85 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.4.2.js + ECMA Section: 11.4.2 the Void Operator + Description: always returns undefined (?) + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "11.4.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The void operator"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "void(new String('string object'))", void 0, void(new String( 'string object' )) ); + array[item++] = new TestCase( SECTION, "void('string primitive')", void 0, void("string primitive") ); + array[item++] = new TestCase( SECTION, "void(Number.NaN)", void 0, void(Number.NaN) ); + array[item++] = new TestCase( SECTION, "void(Number.POSITIVE_INFINITY)", void 0, void(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "void(1)", void 0, void(1) ); + array[item++] = new TestCase( SECTION, "void(0)", void 0, void(0) ); + array[item++] = new TestCase( SECTION, "void(-1)", void 0, void(-1) ); + array[item++] = new TestCase( SECTION, "void(Number.NEGATIVE_INFINITY)", void 0, void(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "void(Math.PI)", void 0, void(Math.PI) ); + array[item++] = new TestCase( SECTION, "void(true)", void 0, void(true) ); + array[item++] = new TestCase( SECTION, "void(false)", void 0, void(false) ); + array[item++] = new TestCase( SECTION, "void(null)", void 0, void(null) ); + array[item++] = new TestCase( SECTION, "void new String('string object')", void 0, void new String( 'string object' ) ); + array[item++] = new TestCase( SECTION, "void 'string primitive'", void 0, void "string primitive" ); + array[item++] = new TestCase( SECTION, "void Number.NaN", void 0, void Number.NaN ); + array[item++] = new TestCase( SECTION, "void Number.POSITIVE_INFINITY", void 0, void Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "void 1", void 0, void 1 ); + array[item++] = new TestCase( SECTION, "void 0", void 0, void 0 ); + array[item++] = new TestCase( SECTION, "void -1", void 0, void -1 ); + array[item++] = new TestCase( SECTION, "void Number.NEGATIVE_INFINITY", void 0, void Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "void Math.PI", void 0, void Math.PI ); + array[item++] = new TestCase( SECTION, "void true", void 0, void true ); + array[item++] = new TestCase( SECTION, "void false", void 0, void false ); + array[item++] = new TestCase( SECTION, "void null", void 0, void null ); + +// array[item++] = new TestCase( SECTION, "void()", void 0, void() ); + + return ( array ); +} + +function test() { + for ( i = 0; i < testcases.length; i++ ) { + testcases[i].passed = writeTestCaseResult( + testcases[i].expect, + testcases[i].actual, + testcases[i].description +" = "+ testcases[i].actual ); + testcases[i].reason += ( testcases[i].passed ) ? "" : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.4.3.js b/tests/mozilla/ecma/Expressions/11.4.3.js new file mode 100644 index 0000000..eccfa0d --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.4.3.js @@ -0,0 +1,109 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: typeof_1.js + ECMA Section: 11.4.3 typeof operator + Description: typeof evaluates unary expressions: + undefined "undefined" + null "object" + Boolean "boolean" + Number "number" + String "string" + Object "object" [native, doesn't implement Call] + Object "function" [native, implements [Call]] + Object implementation dependent + [not sure how to test this] + Author: christine@netscape.com + Date: june 30, 1997 + +*/ + + var SECTION = "11.4.3"; + + var VERSION = "ECMA_1"; + startTest(); + var TITLE = " The typeof operator"; + + var testcases = new Array(); + + + testcases[testcases.length] = new TestCase( SECTION, "typeof(void(0))", "undefined", typeof(void(0)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(null)", "object", typeof(null) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(true)", "boolean", typeof(true) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(false)", "boolean", typeof(false) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Boolean())", "object", typeof(new Boolean()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Boolean(true))", "object", typeof(new Boolean(true)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Boolean())", "boolean", typeof(Boolean()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Boolean(false))", "boolean", typeof(Boolean(false)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Boolean(true))", "boolean", typeof(Boolean(true)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(NaN)", "number", typeof(Number.NaN) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Infinity)", "number", typeof(Number.POSITIVE_INFINITY) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(-Infinity)", "number", typeof(Number.NEGATIVE_INFINITY) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Math.PI)", "number", typeof(Math.PI) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(0)", "number", typeof(0) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(1)", "number", typeof(1) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(-1)", "number", typeof(-1) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof('0')", "string", typeof("0") ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Number())", "number", typeof(Number()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Number(0))", "number", typeof(Number(0)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Number(1))", "number", typeof(Number(1)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(Nubmer(-1))", "number", typeof(Number(-1)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Number())", "object", typeof(new Number()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Number(0))", "object", typeof(new Number(0)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Number(1))", "object", typeof(new Number(1)) ); + + // Math does not implement [[Construct]] or [[Call]] so its type is object. + + testcases[testcases.length] = new TestCase( SECTION, "typeof(Math)", "object", typeof(Math) ); + + testcases[testcases.length] = new TestCase( SECTION, "typeof(Number.prototype.toString)", "function", typeof(Number.prototype.toString) ); + + testcases[testcases.length] = new TestCase( SECTION, "typeof('a string')", "string", typeof("a string") ); + testcases[testcases.length] = new TestCase( SECTION, "typeof('')", "string", typeof("") ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Date())", "object", typeof(new Date()) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Array(1,2,3))", "object", typeof(new Array(1,2,3)) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new String('string object'))", "object", typeof(new String("string object")) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(String('string primitive'))", "string", typeof(String("string primitive")) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(['array', 'of', 'strings'])", "object", typeof(["array", "of", "strings"]) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(new Function())", "function", typeof( new Function() ) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(parseInt)", "function", typeof( parseInt ) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(test)", "function", typeof( test ) ); + testcases[testcases.length] = new TestCase( SECTION, "typeof(String.fromCharCode)", "function", typeof( String.fromCharCode ) ); + + + writeHeaderToLog( SECTION + " "+ TITLE); + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.4.4.js b/tests/mozilla/ecma/Expressions/11.4.4.js new file mode 100644 index 0000000..7a7a547 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.4.4.js @@ -0,0 +1,156 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.4.4.js + ECMA Section: 11.4.4 Prefix increment operator + Description: + The production UnaryExpression : ++ UnaryExpression is evaluated as + follows: + + 1. Evaluate UnaryExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Add the value 1 to Result(3), using the same rules as for the + + operator (section 11.6.3). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(4). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.4.4"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Prefix increment operator"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // special case: var is not defined + + array[item++] = new TestCase( SECTION, "var MYVAR; ++MYVAR", NaN, eval("var MYVAR; ++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR= void 0; ++MYVAR", NaN, eval("var MYVAR=void 0; ++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=null; ++MYVAR", 1, eval("var MYVAR=null; ++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=true; ++MYVAR", 2, eval("var MYVAR=true; ++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false; ++MYVAR", 1, eval("var MYVAR=false; ++MYVAR") ); + + // special numbers + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR;MYVAR") ); + + + // number primitives + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR", 1, eval("var MYVAR=0;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR;MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR;MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); + + // boolean values + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=true;++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=true;++MYVAR;MYVAR", 2, eval("var MYVAR=true;++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;++MYVAR;MYVAR", 1, eval("var MYVAR=false;++MYVAR;MYVAR") ); + + // boolean objects + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR;MYVAR", 2, eval("var MYVAR=new Boolean(true);++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR;MYVAR", 1, eval("var MYVAR=new Boolean(false);++MYVAR;MYVAR") ); + + // string primitives + array[item++] = new TestCase( SECTION, "var MYVAR='string';++MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';++MYVAR", 12346, eval("var MYVAR='12345';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';++MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';++MYVAR", 16, eval("var MYVAR='0Xf';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';++MYVAR", 78, eval("var MYVAR='077';++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=''; ++MYVAR", 1, eval("var MYVAR='';++MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR='string';++MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';++MYVAR;MYVAR", 12346, eval("var MYVAR='12345';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';++MYVAR;MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0xf';++MYVAR;MYVAR", 16, eval("var MYVAR='0xf';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';++MYVAR;MYVAR", 78, eval("var MYVAR='077';++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='';++MYVAR;MYVAR", 1, eval("var MYVAR='';++MYVAR;MYVAR") ); + + // string objects + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');++MYVAR", 16, eval("var MYVAR=new String('0Xf');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); ++MYVAR", 1, eval("var MYVAR=new String('');++MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR;MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR;MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');++MYVAR;MYVAR", 16, eval("var MYVAR=new String('0xf');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR;MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('');++MYVAR;MYVAR", 1, eval("var MYVAR=new String('');++MYVAR;MYVAR") ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Expressions/11.4.5.js b/tests/mozilla/ecma/Expressions/11.4.5.js new file mode 100644 index 0000000..d82ac60 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.4.5.js @@ -0,0 +1,154 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.4.5.js + ECMA Section: 11.4.5 Prefix decrement operator + Description: + + The production UnaryExpression : -- UnaryExpression is evaluated as follows: + + 1.Evaluate UnaryExpression. + 2.Call GetValue(Result(1)). + 3.Call ToNumber(Result(2)). + 4.Subtract the value 1 from Result(3), using the same rules as for the - operator (section 11.6.3). + 5.Call PutValue(Result(1), Result(4)). + + 1.Return Result(4). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.4.5"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Prefix decrement operator"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // + array[item++] = new TestCase( SECTION, "var MYVAR; --MYVAR", NaN, eval("var MYVAR; --MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR= void 0; --MYVAR", NaN, eval("var MYVAR=void 0; --MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=null; --MYVAR", -1, eval("var MYVAR=null; --MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=true; --MYVAR", 0, eval("var MYVAR=true; --MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false; --MYVAR", -1, eval("var MYVAR=false; --MYVAR") ); + + // special numbers + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR;MYVAR") ); + + + // number primitives + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR", -1, eval("var MYVAR=0;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR;MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR;MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); + + // boolean values + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=true;--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=true;--MYVAR;MYVAR", 0, eval("var MYVAR=true;--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=false;--MYVAR;MYVAR", -1, eval("var MYVAR=false;--MYVAR;MYVAR") ); + + // boolean objects + // verify return value + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR;MYVAR", 0, eval("var MYVAR=new Boolean(true);--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR;MYVAR", -1, eval("var MYVAR=new Boolean(false);--MYVAR;MYVAR") ); + + // string primitives + array[item++] = new TestCase( SECTION, "var MYVAR='string';--MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';--MYVAR", 12344, eval("var MYVAR='12345';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';--MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';--MYVAR", 14, eval("var MYVAR='0Xf';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';--MYVAR", 76, eval("var MYVAR='077';--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=''; --MYVAR", -1, eval("var MYVAR='';--MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR='string';--MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='12345';--MYVAR;MYVAR", 12344, eval("var MYVAR='12345';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='-12345';--MYVAR;MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='0xf';--MYVAR;MYVAR", 14, eval("var MYVAR='0xf';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='077';--MYVAR;MYVAR", 76, eval("var MYVAR='077';--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR='';--MYVAR;MYVAR", -1, eval("var MYVAR='';--MYVAR;MYVAR") ); + + // string objects + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');--MYVAR", 14, eval("var MYVAR=new String('0Xf');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); --MYVAR", -1, eval("var MYVAR=new String('');--MYVAR") ); + + // verify value of variable + + array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR;MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR;MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');--MYVAR;MYVAR", 14, eval("var MYVAR=new String('0xf');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR;MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR;MYVAR") ); + array[item++] = new TestCase( SECTION, "var MYVAR=new String('');--MYVAR;MYVAR", -1, eval("var MYVAR=new String('');--MYVAR;MYVAR") ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Expressions/11.4.6.js b/tests/mozilla/ecma/Expressions/11.4.6.js new file mode 100644 index 0000000..31d9551 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.4.6.js @@ -0,0 +1,299 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.4.6.js + ECMA Section: 11.4.6 Unary + Operator + Description: convert operand to Number type + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "11.4.6"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + var BUGNUMBER="77391"; + + writeHeaderToLog( SECTION + " Unary + operator"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "+('')", 0, +("") ); + array[item++] = new TestCase( SECTION, "+(' ')", 0, +(" ") ); + array[item++] = new TestCase( SECTION, "+(\\t)", 0, +("\t") ); + array[item++] = new TestCase( SECTION, "+(\\n)", 0, +("\n") ); + array[item++] = new TestCase( SECTION, "+(\\r)", 0, +("\r") ); + array[item++] = new TestCase( SECTION, "+(\\f)", 0, +("\f") ); + + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x0009)", 0, +(String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x0020)", 0, +(String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000C)", 0, +(String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000B)", 0, +(String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000D)", 0, +(String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000A)", 0, +(String.fromCharCode(0x000A)) ); + + // a StringNumericLiteral may be preceeded or followed by whitespace and/or + // line terminators + + array[item++] = new TestCase( SECTION, "+( ' ' + 999 )", 999, +( ' '+999) ); + array[item++] = new TestCase( SECTION, "+( '\\n' + 999 )", 999, +( '\n' +999) ); + array[item++] = new TestCase( SECTION, "+( '\\r' + 999 )", 999, +( '\r' +999) ); + array[item++] = new TestCase( SECTION, "+( '\\t' + 999 )", 999, +( '\t' +999) ); + array[item++] = new TestCase( SECTION, "+( '\\f' + 999 )", 999, +( '\f' +999) ); + + array[item++] = new TestCase( SECTION, "+( 999 + ' ' )", 999, +( 999+' ') ); + array[item++] = new TestCase( SECTION, "+( 999 + '\\n' )", 999, +( 999+'\n' ) ); + array[item++] = new TestCase( SECTION, "+( 999 + '\\r' )", 999, +( 999+'\r' ) ); + array[item++] = new TestCase( SECTION, "+( 999 + '\\t' )", 999, +( 999+'\t' ) ); + array[item++] = new TestCase( SECTION, "+( 999 + '\\f' )", 999, +( 999+'\f' ) ); + + array[item++] = new TestCase( SECTION, "+( '\\n' + 999 + '\\n' )", 999, +( '\n' +999+'\n' ) ); + array[item++] = new TestCase( SECTION, "+( '\\r' + 999 + '\\r' )", 999, +( '\r' +999+'\r' ) ); + array[item++] = new TestCase( SECTION, "+( '\\t' + 999 + '\\t' )", 999, +( '\t' +999+'\t' ) ); + array[item++] = new TestCase( SECTION, "+( '\\f' + 999 + '\\f' )", 999, +( '\f' +999+'\f' ) ); + + array[item++] = new TestCase( SECTION, "+( ' ' + '999' )", 999, +( ' '+'999') ); + array[item++] = new TestCase( SECTION, "+( '\\n' + '999' )", 999, +( '\n' +'999') ); + array[item++] = new TestCase( SECTION, "+( '\\r' + '999' )", 999, +( '\r' +'999') ); + array[item++] = new TestCase( SECTION, "+( '\\t' + '999' )", 999, +( '\t' +'999') ); + array[item++] = new TestCase( SECTION, "+( '\\f' + '999' )", 999, +( '\f' +'999') ); + + array[item++] = new TestCase( SECTION, "+( '999' + ' ' )", 999, +( '999'+' ') ); + array[item++] = new TestCase( SECTION, "+( '999' + '\\n' )", 999, +( '999'+'\n' ) ); + array[item++] = new TestCase( SECTION, "+( '999' + '\\r' )", 999, +( '999'+'\r' ) ); + array[item++] = new TestCase( SECTION, "+( '999' + '\\t' )", 999, +( '999'+'\t' ) ); + array[item++] = new TestCase( SECTION, "+( '999' + '\\f' )", 999, +( '999'+'\f' ) ); + + array[item++] = new TestCase( SECTION, "+( '\\n' + '999' + '\\n' )", 999, +( '\n' +'999'+'\n' ) ); + array[item++] = new TestCase( SECTION, "+( '\\r' + '999' + '\\r' )", 999, +( '\r' +'999'+'\r' ) ); + array[item++] = new TestCase( SECTION, "+( '\\t' + '999' + '\\t' )", 999, +( '\t' +'999'+'\t' ) ); + array[item++] = new TestCase( SECTION, "+( '\\f' + '999' + '\\f' )", 999, +( '\f' +'999'+'\f' ) ); + + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' )", 99, +( String.fromCharCode(0x0009) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' )", 99, +( String.fromCharCode(0x0020) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' )", 99, +( String.fromCharCode(0x000C) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' )", 99, +( String.fromCharCode(0x000B) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' )", 99, +( String.fromCharCode(0x000D) + '99' ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' )", 99, +( String.fromCharCode(0x000A) + '99' ) ); + + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0009)", 99, +( '99' + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0020)", 99, +( '99' + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000C)", 99, +( '99' + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000D)", 99, +( '99' + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000B)", 99, +( '99' + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000A)", 99, +( '99' + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 )", 99, +( String.fromCharCode(0x0009) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 )", 99, +( String.fromCharCode(0x0020) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 )", 99, +( String.fromCharCode(0x000C) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 )", 99, +( String.fromCharCode(0x000B) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 )", 99, +( String.fromCharCode(0x000D) + 99 ) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 )", 99, +( String.fromCharCode(0x000A) + 99 ) ); + + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0009)", 99, +( 99 + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0020)", 99, +( 99 + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000C)", 99, +( 99 + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000D)", 99, +( 99 + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000B)", 99, +( 99 + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000A)", 99, +( 99 + String.fromCharCode(0x000A)) ); + + + // StrNumericLiteral:::StrDecimalLiteral:::Infinity + + array[item++] = new TestCase( SECTION, "+('Infinity')", Math.pow(10,10000), +("Infinity") ); + array[item++] = new TestCase( SECTION, "+('-Infinity')", -Math.pow(10,10000), +("-Infinity") ); + array[item++] = new TestCase( SECTION, "+('+Infinity')", Math.pow(10,10000), +("+Infinity") ); + + // StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt + + array[item++] = new TestCase( SECTION, "+('0')", 0, +("0") ); + array[item++] = new TestCase( SECTION, "+('-0')", -0, +("-0") ); + array[item++] = new TestCase( SECTION, "+('+0')", 0, +("+0") ); + + array[item++] = new TestCase( SECTION, "+('1')", 1, +("1") ); + array[item++] = new TestCase( SECTION, "+('-1')", -1, +("-1") ); + array[item++] = new TestCase( SECTION, "+('+1')", 1, +("+1") ); + + array[item++] = new TestCase( SECTION, "+('2')", 2, +("2") ); + array[item++] = new TestCase( SECTION, "+('-2')", -2, +("-2") ); + array[item++] = new TestCase( SECTION, "+('+2')", 2, +("+2") ); + + array[item++] = new TestCase( SECTION, "+('3')", 3, +("3") ); + array[item++] = new TestCase( SECTION, "+('-3')", -3, +("-3") ); + array[item++] = new TestCase( SECTION, "+('+3')", 3, +("+3") ); + + array[item++] = new TestCase( SECTION, "+('4')", 4, +("4") ); + array[item++] = new TestCase( SECTION, "+('-4')", -4, +("-4") ); + array[item++] = new TestCase( SECTION, "+('+4')", 4, +("+4") ); + + array[item++] = new TestCase( SECTION, "+('5')", 5, +("5") ); + array[item++] = new TestCase( SECTION, "+('-5')", -5, +("-5") ); + array[item++] = new TestCase( SECTION, "+('+5')", 5, +("+5") ); + + array[item++] = new TestCase( SECTION, "+('6')", 6, +("6") ); + array[item++] = new TestCase( SECTION, "+('-6')", -6, +("-6") ); + array[item++] = new TestCase( SECTION, "+('+6')", 6, +("+6") ); + + array[item++] = new TestCase( SECTION, "+('7')", 7, +("7") ); + array[item++] = new TestCase( SECTION, "+('-7')", -7, +("-7") ); + array[item++] = new TestCase( SECTION, "+('+7')", 7, +("+7") ); + + array[item++] = new TestCase( SECTION, "+('8')", 8, +("8") ); + array[item++] = new TestCase( SECTION, "+('-8')", -8, +("-8") ); + array[item++] = new TestCase( SECTION, "+('+8')", 8, +("+8") ); + + array[item++] = new TestCase( SECTION, "+('9')", 9, +("9") ); + array[item++] = new TestCase( SECTION, "+('-9')", -9, +("-9") ); + array[item++] = new TestCase( SECTION, "+('+9')", 9, +("+9") ); + + array[item++] = new TestCase( SECTION, "+('3.14159')", 3.14159, +("3.14159") ); + array[item++] = new TestCase( SECTION, "+('-3.14159')", -3.14159, +("-3.14159") ); + array[item++] = new TestCase( SECTION, "+('+3.14159')", 3.14159, +("+3.14159") ); + + array[item++] = new TestCase( SECTION, "+('3.')", 3, +("3.") ); + array[item++] = new TestCase( SECTION, "+('-3.')", -3, +("-3.") ); + array[item++] = new TestCase( SECTION, "+('+3.')", 3, +("+3.") ); + + array[item++] = new TestCase( SECTION, "+('3.e1')", 30, +("3.e1") ); + array[item++] = new TestCase( SECTION, "+('-3.e1')", -30, +("-3.e1") ); + array[item++] = new TestCase( SECTION, "+('+3.e1')", 30, +("+3.e1") ); + + array[item++] = new TestCase( SECTION, "+('3.e+1')", 30, +("3.e+1") ); + array[item++] = new TestCase( SECTION, "+('-3.e+1')", -30, +("-3.e+1") ); + array[item++] = new TestCase( SECTION, "+('+3.e+1')", 30, +("+3.e+1") ); + + array[item++] = new TestCase( SECTION, "+('3.e-1')", .30, +("3.e-1") ); + array[item++] = new TestCase( SECTION, "+('-3.e-1')", -.30, +("-3.e-1") ); + array[item++] = new TestCase( SECTION, "+('+3.e-1')", .30, +("+3.e-1") ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "+('.00001')", 0.00001, +(".00001") ); + array[item++] = new TestCase( SECTION, "+('+.00001')", 0.00001, +("+.00001") ); + array[item++] = new TestCase( SECTION, "+('-0.0001')", -0.00001, +("-.00001") ); + + array[item++] = new TestCase( SECTION, "+('.01e2')", 1, +(".01e2") ); + array[item++] = new TestCase( SECTION, "+('+.01e2')", 1, +("+.01e2") ); + array[item++] = new TestCase( SECTION, "+('-.01e2')", -1, +("-.01e2") ); + + array[item++] = new TestCase( SECTION, "+('.01e+2')", 1, +(".01e+2") ); + array[item++] = new TestCase( SECTION, "+('+.01e+2')", 1, +("+.01e+2") ); + array[item++] = new TestCase( SECTION, "+('-.01e+2')", -1, +("-.01e+2") ); + + array[item++] = new TestCase( SECTION, "+('.01e-2')", 0.0001, +(".01e-2") ); + array[item++] = new TestCase( SECTION, "+('+.01e-2')", 0.0001, +("+.01e-2") ); + array[item++] = new TestCase( SECTION, "+('-.01e-2')", -0.0001, +("-.01e-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "+('1234e5')", 123400000, +("1234e5") ); + array[item++] = new TestCase( SECTION, "+('+1234e5')", 123400000, +("+1234e5") ); + array[item++] = new TestCase( SECTION, "+('-1234e5')", -123400000, +("-1234e5") ); + + array[item++] = new TestCase( SECTION, "+('1234e+5')", 123400000, +("1234e+5") ); + array[item++] = new TestCase( SECTION, "+('+1234e+5')", 123400000, +("+1234e+5") ); + array[item++] = new TestCase( SECTION, "+('-1234e+5')", -123400000, +("-1234e+5") ); + + array[item++] = new TestCase( SECTION, "+('1234e-5')", 0.01234, +("1234e-5") ); + array[item++] = new TestCase( SECTION, "+('+1234e-5')", 0.01234, +("+1234e-5") ); + array[item++] = new TestCase( SECTION, "+('-1234e-5')", -0.01234, +("-1234e-5") ); + + // StrNumericLiteral::: HexIntegerLiteral + + array[item++] = new TestCase( SECTION, "+('0x0')", 0, +("0x0")); + array[item++] = new TestCase( SECTION, "+('0x1')", 1, +("0x1")); + array[item++] = new TestCase( SECTION, "+('0x2')", 2, +("0x2")); + array[item++] = new TestCase( SECTION, "+('0x3')", 3, +("0x3")); + array[item++] = new TestCase( SECTION, "+('0x4')", 4, +("0x4")); + array[item++] = new TestCase( SECTION, "+('0x5')", 5, +("0x5")); + array[item++] = new TestCase( SECTION, "+('0x6')", 6, +("0x6")); + array[item++] = new TestCase( SECTION, "+('0x7')", 7, +("0x7")); + array[item++] = new TestCase( SECTION, "+('0x8')", 8, +("0x8")); + array[item++] = new TestCase( SECTION, "+('0x9')", 9, +("0x9")); + array[item++] = new TestCase( SECTION, "+('0xa')", 10, +("0xa")); + array[item++] = new TestCase( SECTION, "+('0xb')", 11, +("0xb")); + array[item++] = new TestCase( SECTION, "+('0xc')", 12, +("0xc")); + array[item++] = new TestCase( SECTION, "+('0xd')", 13, +("0xd")); + array[item++] = new TestCase( SECTION, "+('0xe')", 14, +("0xe")); + array[item++] = new TestCase( SECTION, "+('0xf')", 15, +("0xf")); + array[item++] = new TestCase( SECTION, "+('0xA')", 10, +("0xA")); + array[item++] = new TestCase( SECTION, "+('0xB')", 11, +("0xB")); + array[item++] = new TestCase( SECTION, "+('0xC')", 12, +("0xC")); + array[item++] = new TestCase( SECTION, "+('0xD')", 13, +("0xD")); + array[item++] = new TestCase( SECTION, "+('0xE')", 14, +("0xE")); + array[item++] = new TestCase( SECTION, "+('0xF')", 15, +("0xF")); + + array[item++] = new TestCase( SECTION, "+('0X0')", 0, +("0X0")); + array[item++] = new TestCase( SECTION, "+('0X1')", 1, +("0X1")); + array[item++] = new TestCase( SECTION, "+('0X2')", 2, +("0X2")); + array[item++] = new TestCase( SECTION, "+('0X3')", 3, +("0X3")); + array[item++] = new TestCase( SECTION, "+('0X4')", 4, +("0X4")); + array[item++] = new TestCase( SECTION, "+('0X5')", 5, +("0X5")); + array[item++] = new TestCase( SECTION, "+('0X6')", 6, +("0X6")); + array[item++] = new TestCase( SECTION, "+('0X7')", 7, +("0X7")); + array[item++] = new TestCase( SECTION, "+('0X8')", 8, +("0X8")); + array[item++] = new TestCase( SECTION, "+('0X9')", 9, +("0X9")); + array[item++] = new TestCase( SECTION, "+('0Xa')", 10, +("0Xa")); + array[item++] = new TestCase( SECTION, "+('0Xb')", 11, +("0Xb")); + array[item++] = new TestCase( SECTION, "+('0Xc')", 12, +("0Xc")); + array[item++] = new TestCase( SECTION, "+('0Xd')", 13, +("0Xd")); + array[item++] = new TestCase( SECTION, "+('0Xe')", 14, +("0Xe")); + array[item++] = new TestCase( SECTION, "+('0Xf')", 15, +("0Xf")); + array[item++] = new TestCase( SECTION, "+('0XA')", 10, +("0XA")); + array[item++] = new TestCase( SECTION, "+('0XB')", 11, +("0XB")); + array[item++] = new TestCase( SECTION, "+('0XC')", 12, +("0XC")); + array[item++] = new TestCase( SECTION, "+('0XD')", 13, +("0XD")); + array[item++] = new TestCase( SECTION, "+('0XE')", 14, +("0XE")); + array[item++] = new TestCase( SECTION, "+('0XF')", 15, +("0XF")); + + return array; + +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.4.8.js b/tests/mozilla/ecma/Expressions/11.4.8.js new file mode 100644 index 0000000..491167f --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.4.8.js @@ -0,0 +1,215 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 11.4.8.js + ECMA Section: 11.4.8 Bitwise NOT Operator + Description: flip bits up to 32 bits + no special cases + Author: christine@netscape.com + Date: 7 july 1997 + + Data File Fields: + VALUE value passed as an argument to the ~ operator + E_RESULT expected return value of ~ VALUE; + + Static variables: + none + +*/ + + var SECTION = "11.4.8"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Bitwise Not operator"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( var i = 0; i < 35; i++ ) { + var p = Math.pow(2,i); + + array[item++] = new TestCase( SECTION, "~"+p, Not(p), ~p ); + + } + for ( i = 0; i < 35; i++ ) { + var p = -Math.pow(2,i); + + array[item++] = new TestCase( SECTION, "~"+p, Not(p), ~p ); + + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function Not( n ) { + n = ToInt32(n); + n = ToInt32BitString(n); + + r = "" + + for( var l = 0; l < n.length; l++ ) { + r += ( n.charAt(l) == "0" ) ? "1" : "0"; + } + + n = ToInt32Decimal(r); + + return n; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.4.9.js b/tests/mozilla/ecma/Expressions/11.4.9.js new file mode 100644 index 0000000..90ef06d --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.4.9.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.4.9.js + ECMA Section: 11.4.9 Logical NOT Operator (!) + Description: if the ToBoolean( VALUE ) result is true, return + true. else return false. + Author: christine@netscape.com + Date: 7 july 1997 + + Static variables: + none +*/ + var SECTION = "11.4.9"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Logical NOT operator (!)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + +// version("130") + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, "!(null)", true, !(null) ); + testcases[tc++] = new TestCase( SECTION, "!(var x)", true, !(eval("var x")) ); + testcases[tc++] = new TestCase( SECTION, "!(void 0)", true, !(void 0) ); + + testcases[tc++] = new TestCase( SECTION, "!(false)", true, !(false) ); + testcases[tc++] = new TestCase( SECTION, "!(true)", false, !(true) ); + testcases[tc++] = new TestCase( SECTION, "!()", true, !(eval()) ); + testcases[tc++] = new TestCase( SECTION, "!(0)", true, !(0) ); + testcases[tc++] = new TestCase( SECTION, "!(-0)", true, !(-0) ); + testcases[tc++] = new TestCase( SECTION, "!(NaN)", true, !(Number.NaN) ); + testcases[tc++] = new TestCase( SECTION, "!(Infinity)", false, !(Number.POSITIVE_INFINITY) ); + testcases[tc++] = new TestCase( SECTION, "!(-Infinity)", false, !(Number.NEGATIVE_INFINITY) ); + testcases[tc++] = new TestCase( SECTION, "!(Math.PI)", false, !(Math.PI) ); + testcases[tc++] = new TestCase( SECTION, "!(1)", false, !(1) ); + testcases[tc++] = new TestCase( SECTION, "!(-1)", false, !(-1) ); + testcases[tc++] = new TestCase( SECTION, "!('')", true, !("") ); + testcases[tc++] = new TestCase( SECTION, "!('\t')", false, !("\t") ); + testcases[tc++] = new TestCase( SECTION, "!('0')", false, !("0") ); + testcases[tc++] = new TestCase( SECTION, "!('string')", false, !("string") ); + testcases[tc++] = new TestCase( SECTION, "!(new String(''))", false, !(new String("")) ); + testcases[tc++] = new TestCase( SECTION, "!(new String('string'))", false, !(new String("string")) ); + testcases[tc++] = new TestCase( SECTION, "!(new String())", false, !(new String()) ); + testcases[tc++] = new TestCase( SECTION, "!(new Boolean(true))", false, !(new Boolean(true)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Boolean(false))", false, !(new Boolean(false)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Array())", false, !(new Array()) ); + testcases[tc++] = new TestCase( SECTION, "!(new Array(1,2,3)", false, !(new Array(1,2,3)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Number())", false, !(new Number()) ); + testcases[tc++] = new TestCase( SECTION, "!(new Number(0))", false, !(new Number(0)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Number(NaN))", false, !(new Number(Number.NaN)) ); + testcases[tc++] = new TestCase( SECTION, "!(new Number(Infinity))", false, !(new Number(Number.POSITIVE_INFINITY)) ); + + test(); + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Expressions/11.5.1.js b/tests/mozilla/ecma/Expressions/11.5.1.js new file mode 100644 index 0000000..67c0a8a --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.5.1.js @@ -0,0 +1,115 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.5.1.js + ECMA Section: 11.5.1 Applying the * operator + Description: + + 11.5.1 Applying the * operator + + The * operator performs multiplication, producing the product of its + operands. Multiplication is commutative. Multiplication is not always + associative in ECMAScript, because of finite precision. + + The result of a floating-point multiplication is governed by the rules + of IEEE 754 double-precision arithmetic: + + If either operand is NaN, the result is NaN. + The sign of the result is positive if both operands have the same sign, + negative if the operands have different signs. + Multiplication of an infinity by a zero results in NaN. + Multiplication of an infinity by an infinity results in an infinity. + The sign is determined by the rule already stated above. + Multiplication of an infinity by a finite non-zero value results in a + signed infinity. The sign is determined by the rule already stated above. + In the remaining cases, where neither an infinity or NaN is involved, the + product is computed and rounded to the nearest representable value using IEEE + 754 round-to-nearest mode. If the magnitude is too large to represent, + the result is then an infinity of appropriate sign. If the magnitude is + oo small to represent, the result is then a zero + of appropriate sign. The ECMAScript language requires support of gradual + underflow as defined by IEEE 754. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Applying the * operator"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Number.NaN * Number.NaN", Number.NaN, Number.NaN * Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN * 1", Number.NaN, Number.NaN * 1 ); + array[item++] = new TestCase( SECTION, "1 * Number.NaN", Number.NaN, 1 * Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * 0", Number.NaN, Number.POSITIVE_INFINITY * 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 0", Number.NaN, Number.NEGATIVE_INFINITY * 0 ); + array[item++] = new TestCase( SECTION, "0 * Number.POSITIVE_INFINITY", Number.NaN, 0 * Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "0 * Number.NEGATIVE_INFINITY", Number.NaN, 0 * Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-0 * Number.POSITIVE_INFINITY", Number.NaN, -0 * Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 * Number.NEGATIVE_INFINITY", Number.NaN, -0 * Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * -0", Number.NaN, Number.POSITIVE_INFINITY * -0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -0", Number.NaN, Number.NEGATIVE_INFINITY * -0 ); + + array[item++] = new TestCase( SECTION, "0 * -0", -0, 0 * -0 ); + array[item++] = new TestCase( SECTION, "-0 * 0", -0, -0 * 0 ); + array[item++] = new TestCase( SECTION, "-0 * -0", 0, -0 * -0 ); + array[item++] = new TestCase( SECTION, "0 * 0", 0, 0 * 0 ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * 1 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * -1 ); + array[item++] = new TestCase( SECTION, "1 * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, 1 * Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, -1 * Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * 1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * -1 ); + array[item++] = new TestCase( SECTION, "1 * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, 1 * Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, -1 * Number.POSITIVE_INFINITY ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Expressions/11.5.2.js b/tests/mozilla/ecma/Expressions/11.5.2.js new file mode 100644 index 0000000..c681a35 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.5.2.js @@ -0,0 +1,154 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.5.2.js + ECMA Section: 11.5.2 Applying the / operator + Description: + + The / operator performs division, producing the quotient of its operands. + The left operand is the dividend and the right operand is the divisor. + ECMAScript does not perform integer division. The operands and result of all + division operations are double-precision floating-point numbers. + The result of division is determined by the specification of IEEE 754 arithmetic: + + If either operand is NaN, the result is NaN. + The sign of the result is positive if both operands have the same sign, negative if the operands have different + signs. + Division of an infinity by an infinity results in NaN. + Division of an infinity by a zero results in an infinity. The sign is determined by the rule already stated above. + Division of an infinity by a non-zero finite value results in a signed infinity. The sign is determined by the rule + already stated above. + Division of a finite value by an infinity results in zero. The sign is determined by the rule already stated above. + Division of a zero by a zero results in NaN; division of zero by any other finite value results in zero, with the sign + determined by the rule already stated above. + Division of a non-zero finite value by a zero results in a signed infinity. The sign is determined by the rule + already stated above. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the quotient is computed and + rounded to the nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too + large to represent, we say the operation overflows; the result is then an infinity of appropriate sign. If the + magnitude is too small to represent, we say the operation underflows and the result is a zero of the appropriate + sign. The ECMAScript language requires support of gradual underflow as defined by IEEE 754. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.5.2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + var BUGNUMBER="111202"; + + writeHeaderToLog( SECTION + " Applying the / operator"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // if either operand is NaN, the result is NaN. + + array[item++] = new TestCase( SECTION, "Number.NaN / Number.NaN", Number.NaN, Number.NaN / Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN / 1", Number.NaN, Number.NaN / 1 ); + array[item++] = new TestCase( SECTION, "1 / Number.NaN", Number.NaN, 1 / Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NaN", Number.NaN, Number.POSITIVE_INFINITY / Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY / Number.NaN ); + + // Division of an infinity by an infinity results in NaN. + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY ); + + // Division of an infinity by a zero results in an infinity. + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / 0", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 0", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 0 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / -0", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -0", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -0 ); + + // Division of an infinity by a non-zero finite value results in a signed infinity. + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 1 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -1 ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / -Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -Number.MAX_VALUE ); + + // Division of a finite value by an infinity results in zero. + + array[item++] = new TestCase( SECTION, "1 / Number.NEGATIVE_INFINITY", -0, 1 / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "1 / Number.POSITIVE_INFINITY", 0, 1 / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 / Number.POSITIVE_INFINITY", -0, -1 / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 / Number.NEGATIVE_INFINITY", 0, -1 / Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE / Number.NEGATIVE_INFINITY", -0, Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE / Number.POSITIVE_INFINITY", 0, Number.MAX_VALUE / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE / Number.POSITIVE_INFINITY", -0, -Number.MAX_VALUE / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE / Number.NEGATIVE_INFINITY", 0, -Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); + + // Division of a zero by a zero results in NaN + + array[item++] = new TestCase( SECTION, "0 / -0", Number.NaN, 0 / -0 ); + array[item++] = new TestCase( SECTION, "-0 / 0", Number.NaN, -0 / 0 ); + array[item++] = new TestCase( SECTION, "-0 / -0", Number.NaN, -0 / -0 ); + array[item++] = new TestCase( SECTION, "0 / 0", Number.NaN, 0 / 0 ); + + // division of zero by any other finite value results in zero + + array[item++] = new TestCase( SECTION, "0 / 1", 0, 0 / 1 ); + array[item++] = new TestCase( SECTION, "0 / -1", -0, 0 / -1 ); + array[item++] = new TestCase( SECTION, "-0 / 1", -0, -0 / 1 ); + array[item++] = new TestCase( SECTION, "-0 / -1", 0, -0 / -1 ); + + // Division of a non-zero finite value by a zero results in a signed infinity. + + array[item++] = new TestCase( SECTION, "1 / 0", Number.POSITIVE_INFINITY, 1/0 ); + array[item++] = new TestCase( SECTION, "1 / -0", Number.NEGATIVE_INFINITY, 1/-0 ); + array[item++] = new TestCase( SECTION, "-1 / 0", Number.NEGATIVE_INFINITY, -1/0 ); + array[item++] = new TestCase( SECTION, "-1 / -0", Number.POSITIVE_INFINITY, -1/-0 ); + + array[item++] = new TestCase( SECTION, "0 / Number.POSITIVE_INFINITY", 0, 0 / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "0 / Number.NEGATIVE_INFINITY", -0, 0 / Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 / Number.POSITIVE_INFINITY", -0, -0 / Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 / Number.NEGATIVE_INFINITY", 0, -0 / Number.NEGATIVE_INFINITY ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Expressions/11.5.3.js b/tests/mozilla/ecma/Expressions/11.5.3.js new file mode 100644 index 0000000..8b9722c --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.5.3.js @@ -0,0 +1,160 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.5.3.js + ECMA Section: 11.5.3 Applying the % operator + Description: + + The binary % operator is said to yield the remainder of its operands from + an implied division; the left operand is the dividend and the right operand + is the divisor. In C and C++, the remainder operator accepts only integral + operands, but in ECMAScript, it also accepts floating-point operands. + + The result of a floating-point remainder operation as computed by the % + operator is not the same as the "remainder" operation defined by IEEE 754. + The IEEE 754 "remainder" operation computes the remainder from a rounding + division, not a truncating division, and so its behavior is not analogous + to that of the usual integer remainder operator. Instead the ECMAScript + language defines % on floating-point operations to behave in a manner + analogous to that of the Java integer remainder operator; this may be + compared with the C library function fmod. + + The result of a ECMAScript floating-point remainder operation is determined by the rules of IEEE arithmetic: + + If either operand is NaN, the result is NaN. + The sign of the result equals the sign of the dividend. + If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. + If the dividend is finite and the divisor is an infinity, the result equals the dividend. + If the dividend is a zero and the divisor is finite, the result is the same as the dividend. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the floating-point remainder r + from a dividend n and a divisor d is defined by the mathematical relation r = n (d * q) where q is an integer that + is negative only if n/d is negative and positive only if n/d is positive, and whose magnitude is as large as + possible without exceeding the magnitude of the true mathematical quotient of n and d. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.5.3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + var BUGNUMBER="111202"; + + writeHeaderToLog( SECTION + " Applying the % operator"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // if either operand is NaN, the result is NaN. + + array[item++] = new TestCase( SECTION, "Number.NaN % Number.NaN", Number.NaN, Number.NaN % Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN % 1", Number.NaN, Number.NaN % 1 ); + array[item++] = new TestCase( SECTION, "1 % Number.NaN", Number.NaN, 1 % Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NaN", Number.NaN, Number.POSITIVE_INFINITY % Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY % Number.NaN ); + + // If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. + // dividend is an infinity + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % 0", Number.NaN, Number.POSITIVE_INFINITY % 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 0", Number.NaN, Number.NEGATIVE_INFINITY % 0 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % -0", Number.NaN, Number.POSITIVE_INFINITY % -0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -0", Number.NaN, Number.NEGATIVE_INFINITY % -0 ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 1 ", Number.NaN, Number.NEGATIVE_INFINITY % 1 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -1 ", Number.NaN, Number.NEGATIVE_INFINITY % -1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % 1 ", Number.NaN, Number.POSITIVE_INFINITY % 1 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % -1 ", Number.NaN, Number.POSITIVE_INFINITY % -1 ); + + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % -Number.MAX_VALUE ); + + // divisor is 0 + array[item++] = new TestCase( SECTION, "0 % -0", Number.NaN, 0 % -0 ); + array[item++] = new TestCase( SECTION, "-0 % 0", Number.NaN, -0 % 0 ); + array[item++] = new TestCase( SECTION, "-0 % -0", Number.NaN, -0 % -0 ); + array[item++] = new TestCase( SECTION, "0 % 0", Number.NaN, 0 % 0 ); + + array[item++] = new TestCase( SECTION, "1 % 0", Number.NaN, 1%0 ); + array[item++] = new TestCase( SECTION, "1 % -0", Number.NaN, 1%-0 ); + array[item++] = new TestCase( SECTION, "-1 % 0", Number.NaN, -1%0 ); + array[item++] = new TestCase( SECTION, "-1 % -0", Number.NaN, -1%-0 ); + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % 0", Number.NaN, Number.MAX_VALUE%0 ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % -0", Number.NaN, Number.MAX_VALUE%-0 ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % 0", Number.NaN, -Number.MAX_VALUE%0 ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % -0", Number.NaN, -Number.MAX_VALUE%-0 ); + + // If the dividend is finite and the divisor is an infinity, the result equals the dividend. + + array[item++] = new TestCase( SECTION, "1 % Number.NEGATIVE_INFINITY", 1, 1 % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "1 % Number.POSITIVE_INFINITY", 1, 1 % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 % Number.POSITIVE_INFINITY", -1, -1 % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-1 % Number.NEGATIVE_INFINITY", -1, -1 % Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % Number.NEGATIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % Number.POSITIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % Number.POSITIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % Number.NEGATIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 % Number.POSITIVE_INFINITY", 0, 0 % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "0 % Number.NEGATIVE_INFINITY", 0, 0 % Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 % Number.POSITIVE_INFINITY", -0, -0 % Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-0 % Number.NEGATIVE_INFINITY", -0, -0 % Number.NEGATIVE_INFINITY ); + + // If the dividend is a zero and the divisor is finite, the result is the same as the dividend. + + array[item++] = new TestCase( SECTION, "0 % 1", 0, 0 % 1 ); + array[item++] = new TestCase( SECTION, "0 % -1", -0, 0 % -1 ); + array[item++] = new TestCase( SECTION, "-0 % 1", -0, -0 % 1 ); + array[item++] = new TestCase( SECTION, "-0 % -1", 0, -0 % -1 ); + +// In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the floating-point remainder r +// from a dividend n and a divisor d is defined by the mathematical relation r = n (d * q) where q is an integer that +// is negative only if n/d is negative and positive only if n/d is positive, and whose magnitude is as large as +// possible without exceeding the magnitude of the true mathematical quotient of n and d. + + return ( array ); +} diff --git a/tests/mozilla/ecma/Expressions/11.6.1-1.js b/tests/mozilla/ecma/Expressions/11.6.1-1.js new file mode 100644 index 0000000..58e5edc --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.6.1-1.js @@ -0,0 +1,211 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.6.1-1.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does not cover cases where the Additive or Mulplicative expression + ToPrimitive is string. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.1-1"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The Addition operator ( + )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function getTestCases() { + var array = new Array(); + var item = 0; + + // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is + // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2", + 1, + eval("var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", + "truefalse", + eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); + + // tests for number primitive, number object, Object object, a "MyObject" whose value is + // a number primitive and a number object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2", + 99, + eval("var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") ); + + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", + "100-1", + eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1", + "truetrue", + eval("var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1") ); + + return ( array ); +} + + +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} + +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} + +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} + +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/mozilla/ecma/Expressions/11.6.1-2.js b/tests/mozilla/ecma/Expressions/11.6.1-2.js new file mode 100644 index 0000000..400ec71 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.6.1-2.js @@ -0,0 +1,203 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.6.1-2.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does only covers cases where the Additive or Mulplicative expression + ToPrimitive is a string. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.1-2"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The Addition operator ( + )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is + // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); + + // tests for number primitive, number object, Object object, a "MyObject" whose value is + // a number primitive and a number object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); + return ( array ); +} +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/mozilla/ecma/Expressions/11.6.1-3.js b/tests/mozilla/ecma/Expressions/11.6.1-3.js new file mode 100644 index 0000000..a5fdc88 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.6.1-3.js @@ -0,0 +1,181 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.6.1-3.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does only covers cases where the Additive or Mulplicative expression + is a Date. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The Addition operator ( + )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is + // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + var DATE1 = new Date(); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + DATE1", + DATE1.toString() + DATE1.toString(), + DATE1 + DATE1 ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + 0", + DATE1.toString() + 0, + DATE1 + 0 ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Number(0)", + DATE1.toString() + 0, + DATE1 + new Number(0) ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + true", + DATE1.toString() + "true", + DATE1 + true ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Boolean(true)", + DATE1.toString() + "true", + DATE1 + new Boolean(true) ); + + array[item++] = new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Boolean(true)", + DATE1.toString() + "true", + DATE1 + new Boolean(true) ); + + var MYOB1 = new MyObject( DATE1 ); + var MYOB2 = new MyValuelessObject( DATE1 ); + var MYOB3 = new MyProtolessObject( DATE1 ); + var MYOB4 = new MyProtoValuelessObject( DATE1 ); + + array[item++] = new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + new Number(1)", + "[object Object]1", + MYOB1 + new Number(1) ); + + array[item++] = new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + 1", + "[object Object]1", + MYOB1 + 1 ); + + array[item++] = new TestCase( SECTION, + "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + 'string'", + DATE1.toString() + "string", + MYOB2 + 'string' ); + + array[item++] = new TestCase( SECTION, + "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + new String('string')", + DATE1.toString() + "string", + MYOB2 + new String('string') ); +/* + array[item++] = new TestCase( SECTION, + "MYOB3 = new MyProtolessObject(DATE1); MYOB3 + new Boolean(true)", + DATE1.toString() + "true", + MYOB3 + new Boolean(true) ); +*/ + array[item++] = new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + true", + "[object Object]true", + MYOB1 + true ); + + return ( array ); +} +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/mozilla/ecma/Expressions/11.6.2-1.js b/tests/mozilla/ecma/Expressions/11.6.2-1.js new file mode 100644 index 0000000..3c1bd91 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.6.2-1.js @@ -0,0 +1,199 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.6.2-1.js + ECMA Section: 11.6.2 The Subtraction operator ( - ) + Description: + + The production AdditiveExpression : AdditiveExpression - + MultiplicativeExpression is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToNumber(Result(2)). + 6. Call ToNumber(Result(4)). + 7. Apply the subtraction operation to Result(5) and Result(6). See the + discussion below (11.6.3). + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The subtraction operator ( - )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is + // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2", + 1, + eval("var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2") ); + + // tests for number primitive, number object, Object object, a "MyObject" whose value is + // a number primitive and a number object, and "MyValuelessObject", where the value is + // set in the object's prototype, not the object itself. + + array[item++] = new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2", + 99, + eval("var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2") ); + + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2") ); +/* + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2") ); +*/ + // same thing with string! + array[item++] = new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1'); EXP_1 - EXP_2", + 254, + eval("var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1')); EXP_1 - EXP_2") ); + + return ( array ); +} +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} +function MyOtherObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.toString = new Function ( "return this.value + ''" ); + this.value = value; +} diff --git a/tests/mozilla/ecma/Expressions/11.6.3.js b/tests/mozilla/ecma/Expressions/11.6.3.js new file mode 100644 index 0000000..91af1b7 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.6.3.js @@ -0,0 +1,116 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.6.3.js + ECMA Section: 11.6.3 Applying the additive operators + (+, -) to numbers + Description: + The + operator performs addition when applied to two operands of numeric + type, producing the sum of the operands. The - operator performs + subtraction, producing the difference of two numeric operands. + + Addition is a commutative operation, but not always associative. + + The result of an addition is determined using the rules of IEEE 754 + double-precision arithmetic: + + If either operand is NaN, the result is NaN. + The sum of two infinities of opposite sign is NaN. + The sum of two infinities of the same sign is the infinity of that sign. + The sum of an infinity and a finite value is equal to the infinite operand. + The sum of two negative zeros is 0. The sum of two positive zeros, or of + two zeros of opposite sign, is +0. + The sum of a zero and a nonzero finite value is equal to the nonzero + operand. + The sum of two nonzero finite values of the same magnitude and opposite + sign is +0. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is + involved, and the operands have the same sign or have different + magnitudes, the sum is computed and rounded to the nearest + representable value using IEEE 754 round-to-nearest mode. If the + magnitude is too large to represent, the operation overflows and + the result is then an infinity of appropriate sign. The ECMAScript + language requires support of gradual underflow as defined by IEEE 754. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.6.3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Applying the additive operators (+,-) to numbers"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Number.NaN + 1", Number.NaN, Number.NaN + 1 ); + array[item++] = new TestCase( SECTION, "1 + Number.NaN", Number.NaN, 1 + Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.NaN - 1", Number.NaN, Number.NaN - 1 ); + array[item++] = new TestCase( SECTION, "1 - Number.NaN", Number.NaN, 1 - Number.NaN ); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY); + + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY); + + array[item++] = new TestCase( SECTION, "-0 + -0", -0, -0 + -0 ); + array[item++] = new TestCase( SECTION, "-0 - 0", -0, -0 - 0 ); + + array[item++] = new TestCase( SECTION, "0 + 0", 0, 0 + 0 ); + array[item++] = new TestCase( SECTION, "0 + -0", 0, 0 + -0 ); + array[item++] = new TestCase( SECTION, "0 - -0", 0, 0 - -0 ); + array[item++] = new TestCase( SECTION, "0 - 0", 0, 0 - 0 ); + array[item++] = new TestCase( SECTION, "-0 - -0", 0, -0 - -0 ); + array[item++] = new TestCase( SECTION, "-0 + 0", 0, -0 + 0 ); + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE - Number.MAX_VALUE", 0, Number.MAX_VALUE - Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "1/Number.MAX_VALUE - 1/Number.MAX_VALUE", 0, 1/Number.MAX_VALUE - 1/Number.MAX_VALUE ); + + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE - Number.MIN_VALUE", 0, Number.MIN_VALUE - Number.MIN_VALUE ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Expressions/11.7.1.js b/tests/mozilla/ecma/Expressions/11.7.1.js new file mode 100644 index 0000000..23e2ab5 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.7.1.js @@ -0,0 +1,229 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.7.1.js + ECMA Section: 11.7.1 The Left Shift Operator ( << ) + Description: + Performs a bitwise left shift operation on the left argument by the amount + specified by the right argument. + + The production ShiftExpression : ShiftExpression << AdditiveExpression is + evaluated as follows: + + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Left shift Result(5) by Result(7) bits. The result is a signed 32 bit + integer. + 9. Return Result(8). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.7.1"; + var VERSION = "ECMA_1"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The left shift operator ( << )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( power = 0; power < 33; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp < 33; addexp++ ) { + array[item++] = new TestCase( SECTION, + shiftexp + " << " + addexp, + LeftShift( shiftexp, addexp ), + shiftexp << addexp ); + } + } + + return ( array ); +} +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function LeftShift( s, a ) { + var shift = ToInt32( s ); + var add = ToUint32( a ); + add = Mask( add, 5 ); + var exp = LShift( shift, add ); + + return ( exp ); +} +function LShift( s, a ) { + s = ToInt32BitString( s ); + + for ( var z = 0; z < a; z++ ) { + s += "0"; + } + + s = s.substring( a, s.length); + + return ToInt32(ToInt32Decimal(s)); +} diff --git a/tests/mozilla/ecma/Expressions/11.7.2.js b/tests/mozilla/ecma/Expressions/11.7.2.js new file mode 100644 index 0000000..b2761cf --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.7.2.js @@ -0,0 +1,246 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.7.2.js + ECMA Section: 11.7.2 The signed right shift operator ( >> ) + Description: + Performs a sign-filling bitwise right shift operation on the left argument + by the amount specified by the right argument. + + The production ShiftExpression : ShiftExpression >> AdditiveExpression is + evaluated as follows: + + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Perform sign-extending right shift of Result(5) by Result(7) bits. The + most significant bit is propagated. The result is a signed 32 bit + integer. + 9. Return Result(8). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.7.2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The signed right shift operator ( >> )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + var power = 0; + var addexp = 0; + + for ( power = 0; power <= 32; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + array[item++] = new TestCase( SECTION, + shiftexp + " >> " + addexp, + SignedRightShift( shiftexp, addexp ), + shiftexp >> addexp ); + } + } + + for ( power = 0; power <= 32; power++ ) { + shiftexp = -Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + array[item++] = new TestCase( SECTION, + shiftexp + " >> " + addexp, + SignedRightShift( shiftexp, addexp ), + shiftexp >> addexp ); + } + } + + return ( array ); +} + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function SignedRightShift( s, a ) { + s = ToInt32( s ); + a = ToUint32( a ); + a = Mask( a, 5 ); + return ( SignedRShift( s, a ) ); +} +function SignedRShift( s, a ) { + s = ToInt32BitString( s ); + + var firstbit = s.substring(0,1); + + s = s.substring( 1, s.length ); + + for ( var z = 0; z < a; z++ ) { + s = firstbit + s; + } + + s = s.substring( 0, s.length - a); + + s = firstbit +s; + + + return ToInt32(ToInt32Decimal(s)); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.7.3.js b/tests/mozilla/ecma/Expressions/11.7.3.js new file mode 100644 index 0000000..9c963e1 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.7.3.js @@ -0,0 +1,230 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.7.3.js + ECMA Section: 11.7.3 The unsigned right shift operator ( >>> ) + Description: + 11.7.3 The unsigned right shift operator ( >>> ) + Performs a zero-filling bitwise right shift operation on the left argument + by the amount specified by the right argument. + + The production ShiftExpression : ShiftExpression >>> AdditiveExpression is + evaluated as follows: + + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToUint32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Perform zero-filling right shift of Result(5) by Result(7) bits. + Vacated bits are filled with zero. The result is an unsigned 32 bit + integer. + 9. Return Result(8). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.7.3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The unsigned right shift operator ( >>> )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + var addexp = 0; + var power = 0; + + for ( power = 0; power <= 32; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + array[item++] = new TestCase( SECTION, + shiftexp + " >>> " + addexp, + UnsignedRightShift( shiftexp, addexp ), + shiftexp >>> addexp ); + } + } + + return ( array ); +} + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 32; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function RShift( s, a ) { + s = ToUint32BitString( s ); + for ( z = 0; z < a; z++ ) { + s = "0" + s; + } + s = s.substring( 0, s.length - a ); + + return ToUint32Decimal(s); +} +function UnsignedRightShift( s, a ) { + s = ToUint32( s ); + a = ToUint32( a ); + a = Mask( a, 5 ); + return ( RShift( s, a ) ); +} diff --git a/tests/mozilla/ecma/Expressions/11.8.1.js b/tests/mozilla/ecma/Expressions/11.8.1.js new file mode 100644 index 0000000..db2c701 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.8.1.js @@ -0,0 +1,121 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.8.1.js + ECMA Section: 11.8.1 The less-than operator ( < ) + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.8.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The less-than operator ( < )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true < false", false, true < false ); + array[item++] = new TestCase( SECTION, "false < true", true, false < true ); + array[item++] = new TestCase( SECTION, "false < false", false, false < false ); + array[item++] = new TestCase( SECTION, "true < true", false, true < true ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) < new Boolean(true)", false, new Boolean(true) < new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) < new Boolean(false)", false, new Boolean(true) < new Boolean(false) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) < new Boolean(true)", true, new Boolean(false) < new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) < new Boolean(false)", false, new Boolean(false) < new Boolean(false) ); + + array[item++] = new TestCase( SECTION, "new MyObject(Infinity) < new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(true)", true, new MyValueObject(false) < new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(true) < new MyValueObject(true)", false, new MyValueObject(true) < new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(false)", false, new MyValueObject(false) < new MyValueObject(false) ); + + array[item++] = new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(true)", true, new MyStringObject(false) < new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(true) < new MyStringObject(true)", false, new MyStringObject(true) < new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(false)", false, new MyStringObject(false) < new MyStringObject(false) ); + + array[item++] = new TestCase( SECTION, "Number.NaN < Number.NaN", false, Number.NaN < Number.NaN ); + array[item++] = new TestCase( SECTION, "0 < Number.NaN", false, 0 < Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN < 0", false, Number.NaN < 0 ); + + array[item++] = new TestCase( SECTION, "0 < -0", false, 0 < -0 ); + array[item++] = new TestCase( SECTION, "-0 < 0", false, -0 < 0 ); + + array[item++] = new TestCase( SECTION, "Infinity < 0", false, Number.POSITIVE_INFINITY < 0 ); + array[item++] = new TestCase( SECTION, "Infinity < Number.MAX_VALUE", false, Number.POSITIVE_INFINITY < Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Infinity < Infinity", false, Number.POSITIVE_INFINITY < Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 < Infinity", true, 0 < Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE < Infinity", true, Number.MAX_VALUE < Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 < -Infinity", false, 0 < Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE < -Infinity", false, Number.MAX_VALUE < Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Infinity < -Infinity", false, Number.NEGATIVE_INFINITY < Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-Infinity < 0", true, Number.NEGATIVE_INFINITY < 0 ); + array[item++] = new TestCase( SECTION, "-Infinity < -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY < -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "-Infinity < Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY < Number.MIN_VALUE ); + + array[item++] = new TestCase( SECTION, "'string' < 'string'", false, 'string' < 'string' ); + array[item++] = new TestCase( SECTION, "'astring' < 'string'", true, 'astring' < 'string' ); + array[item++] = new TestCase( SECTION, "'strings' < 'stringy'", true, 'strings' < 'stringy' ); + array[item++] = new TestCase( SECTION, "'strings' < 'stringier'", false, 'strings' < 'stringier' ); + array[item++] = new TestCase( SECTION, "'string' < 'astring'", false, 'string' < 'astring' ); + array[item++] = new TestCase( SECTION, "'string' < 'strings'", true, 'string' < 'strings' ); + + return ( array ); +} +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.8.2.js b/tests/mozilla/ecma/Expressions/11.8.2.js new file mode 100644 index 0000000..962c33e --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.8.2.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.8.2.js + ECMA Section: 11.8.2 The greater-than operator ( > ) + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.8.2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The greater-than operator ( > )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true > false", true, true > false ); + array[item++] = new TestCase( SECTION, "false > true", false, false > true ); + array[item++] = new TestCase( SECTION, "false > false", false, false > false ); + array[item++] = new TestCase( SECTION, "true > true", false, true > true ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) > new Boolean(true)", false, new Boolean(true) > new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) > new Boolean(false)", true, new Boolean(true) > new Boolean(false) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) > new Boolean(true)", false, new Boolean(false) > new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) > new Boolean(false)", false, new Boolean(false) > new Boolean(false) ); + + array[item++] = new TestCase( SECTION, "new MyObject(Infinity) > new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(true)", false, new MyValueObject(false) > new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(true) > new MyValueObject(true)", false, new MyValueObject(true) > new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(false)", false, new MyValueObject(false) > new MyValueObject(false) ); + + array[item++] = new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(true)", false, new MyStringObject(false) > new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(true) > new MyStringObject(true)", false, new MyStringObject(true) > new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(false)", false, new MyStringObject(false) > new MyStringObject(false) ); + + array[item++] = new TestCase( SECTION, "Number.NaN > Number.NaN", false, Number.NaN > Number.NaN ); + array[item++] = new TestCase( SECTION, "0 > Number.NaN", false, 0 > Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN > 0", false, Number.NaN > 0 ); + + array[item++] = new TestCase( SECTION, "0 > -0", false, 0 > -0 ); + array[item++] = new TestCase( SECTION, "-0 > 0", false, -0 > 0 ); + + array[item++] = new TestCase( SECTION, "Infinity > 0", true, Number.POSITIVE_INFINITY > 0 ); + array[item++] = new TestCase( SECTION, "Infinity > Number.MAX_VALUE", true, Number.POSITIVE_INFINITY > Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Infinity > Infinity", false, Number.POSITIVE_INFINITY > Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 > Infinity", false, 0 > Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE > Infinity", false, Number.MAX_VALUE > Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 > -Infinity", true, 0 > Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE > -Infinity", true, Number.MAX_VALUE > Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Infinity > -Infinity", false, Number.NEGATIVE_INFINITY > Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-Infinity > 0", false, Number.NEGATIVE_INFINITY > 0 ); + array[item++] = new TestCase( SECTION, "-Infinity > -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY > -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "-Infinity > Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY > Number.MIN_VALUE ); + + array[item++] = new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); + array[item++] = new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); + array[item++] = new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); + array[item++] = new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); + array[item++] = new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); + array[item++] = new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); + + + return ( array ); +} +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.8.3.js b/tests/mozilla/ecma/Expressions/11.8.3.js new file mode 100644 index 0000000..5da73d6 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.8.3.js @@ -0,0 +1,120 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.8.3.js + ECMA Section: 11.8.3 The less-than-or-equal operator ( <= ) + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.8.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The less-than-or-equal operator ( <= )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true <= false", false, true <= false ); + array[item++] = new TestCase( SECTION, "false <= true", true, false <= true ); + array[item++] = new TestCase( SECTION, "false <= false", true, false <= false ); + array[item++] = new TestCase( SECTION, "true <= true", true, true <= true ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) <= new Boolean(true)", true, new Boolean(true) <= new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) <= new Boolean(false)", false, new Boolean(true) <= new Boolean(false) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) <= new Boolean(true)", true, new Boolean(false) <= new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) <= new Boolean(false)", true, new Boolean(false) <= new Boolean(false) ); + + array[item++] = new TestCase( SECTION, "new MyObject(Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(true)", true, new MyValueObject(false) <= new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(true) <= new MyValueObject(true)", true, new MyValueObject(true) <= new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(false)", true, new MyValueObject(false) <= new MyValueObject(false) ); + + array[item++] = new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(true)", true, new MyStringObject(false) <= new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(true) <= new MyStringObject(true)", true, new MyStringObject(true) <= new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(false)", true, new MyStringObject(false) <= new MyStringObject(false) ); + + array[item++] = new TestCase( SECTION, "Number.NaN <= Number.NaN", false, Number.NaN <= Number.NaN ); + array[item++] = new TestCase( SECTION, "0 <= Number.NaN", false, 0 <= Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN <= 0", false, Number.NaN <= 0 ); + + array[item++] = new TestCase( SECTION, "0 <= -0", true, 0 <= -0 ); + array[item++] = new TestCase( SECTION, "-0 <= 0", true, -0 <= 0 ); + + array[item++] = new TestCase( SECTION, "Infinity <= 0", false, Number.POSITIVE_INFINITY <= 0 ); + array[item++] = new TestCase( SECTION, "Infinity <= Number.MAX_VALUE", false, Number.POSITIVE_INFINITY <= Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Infinity <= Infinity", true, Number.POSITIVE_INFINITY <= Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 <= Infinity", true, 0 <= Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE <= Infinity", true, Number.MAX_VALUE <= Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 <= -Infinity", false, 0 <= Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE <= -Infinity", false, Number.MAX_VALUE <= Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Infinity <= -Infinity", true, Number.NEGATIVE_INFINITY <= Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-Infinity <= 0", true, Number.NEGATIVE_INFINITY <= 0 ); + array[item++] = new TestCase( SECTION, "-Infinity <= -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY <= -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "-Infinity <= Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY <= Number.MIN_VALUE ); + + array[item++] = new TestCase( SECTION, "'string' <= 'string'", true, 'string' <= 'string' ); + array[item++] = new TestCase( SECTION, "'astring' <= 'string'", true, 'astring' <= 'string' ); + array[item++] = new TestCase( SECTION, "'strings' <= 'stringy'", true, 'strings' <= 'stringy' ); + array[item++] = new TestCase( SECTION, "'strings' <= 'stringier'", false, 'strings' <= 'stringier' ); + array[item++] = new TestCase( SECTION, "'string' <= 'astring'", false, 'string' <= 'astring' ); + array[item++] = new TestCase( SECTION, "'string' <= 'strings'", true, 'string' <= 'strings' ); + + return ( array ); +} +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +} diff --git a/tests/mozilla/ecma/Expressions/11.8.4.js b/tests/mozilla/ecma/Expressions/11.8.4.js new file mode 100644 index 0000000..7e25b05 --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.8.4.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.8.4.js + ECMA Section: 11.8.4 The greater-than-or-equal operator ( >= ) + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.8.4"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The greater-than-or-equal operator ( >= )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "true >= false", true, true >= false ); + array[item++] = new TestCase( SECTION, "false >= true", false, false >= true ); + array[item++] = new TestCase( SECTION, "false >= false", true, false >= false ); + array[item++] = new TestCase( SECTION, "true >= true", true, true >= true ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) >= new Boolean(true)", true, new Boolean(true) >= new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) >= new Boolean(false)", true, new Boolean(true) >= new Boolean(false) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) >= new Boolean(true)", false, new Boolean(false) >= new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) >= new Boolean(false)", true, new Boolean(false) >= new Boolean(false) ); + + array[item++] = new TestCase( SECTION, "new MyObject(Infinity) >= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(true)", false, new MyValueObject(false) >= new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(true) >= new MyValueObject(true)", true, new MyValueObject(true) >= new MyValueObject(true) ); + array[item++] = new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(false)", true, new MyValueObject(false) >= new MyValueObject(false) ); + + array[item++] = new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(true)", false, new MyStringObject(false) >= new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(true) >= new MyStringObject(true)", true, new MyStringObject(true) >= new MyStringObject(true) ); + array[item++] = new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(false)", true, new MyStringObject(false) >= new MyStringObject(false) ); + + array[item++] = new TestCase( SECTION, "Number.NaN >= Number.NaN", false, Number.NaN >= Number.NaN ); + array[item++] = new TestCase( SECTION, "0 >= Number.NaN", false, 0 >= Number.NaN ); + array[item++] = new TestCase( SECTION, "Number.NaN >= 0", false, Number.NaN >= 0 ); + + array[item++] = new TestCase( SECTION, "0 >= -0", true, 0 >= -0 ); + array[item++] = new TestCase( SECTION, "-0 >= 0", true, -0 >= 0 ); + + array[item++] = new TestCase( SECTION, "Infinity >= 0", true, Number.POSITIVE_INFINITY >= 0 ); + array[item++] = new TestCase( SECTION, "Infinity >= Number.MAX_VALUE", true, Number.POSITIVE_INFINITY >= Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Infinity >= Infinity", true, Number.POSITIVE_INFINITY >= Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 >= Infinity", false, 0 >= Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE >= Infinity", false, Number.MAX_VALUE >= Number.POSITIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "0 >= -Infinity", true, 0 >= Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE >= -Infinity", true, Number.MAX_VALUE >= Number.NEGATIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "-Infinity >= -Infinity", true, Number.NEGATIVE_INFINITY >= Number.NEGATIVE_INFINITY ); + + array[item++] = new TestCase( SECTION, "-Infinity >= 0", false, Number.NEGATIVE_INFINITY >= 0 ); + array[item++] = new TestCase( SECTION, "-Infinity >= -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY >= -Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "-Infinity >= Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY >= Number.MIN_VALUE ); + + array[item++] = new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); + array[item++] = new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); + array[item++] = new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); + array[item++] = new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); + array[item++] = new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); + array[item++] = new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); + + + return ( array ); +} +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.9.1.js b/tests/mozilla/ecma/Expressions/11.9.1.js new file mode 100644 index 0000000..b64df9a --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.9.1.js @@ -0,0 +1,162 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.9.1.js + ECMA Section: 11.9.1 The equals operator ( == ) + Description: + + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: + + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.9.1"; + var VERSION = "ECMA_1"; + startTest(); + var BUGNUMBER="77391"; + + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The equals operator ( == )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // type x and type y are the same. if type x is undefined or null, return true + + array[item++] = new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); + array[item++] = new TestCase( SECTION, "null == null", true, null == null ); + + // if x is NaN, return false. if y is NaN, return false. + + array[item++] = new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); + array[item++] = new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); + + // if x is the same number value as y, return true. + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); + + // if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + + array[item++] = new TestCase( SECTION, "0 == 0", true, 0 == 0 ); + array[item++] = new TestCase( SECTION, "0 == -0", true, 0 == -0 ); + array[item++] = new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); + array[item++] = new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); + + // return false. + + array[item++] = new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); + array[item++] = new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); + + // type x and type y are the same type, but not numbers. + + + // x and y are strings. return true if x and y are exactly the same sequence of characters. + // otherwise, return false. + + array[item++] = new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); + + // x and y are booleans. return true if both are true or both are false. + + array[item++] = new TestCase( SECTION, "true == true", true, true == true ); + array[item++] = new TestCase( SECTION, "false == false", true, false == false ); + array[item++] = new TestCase( SECTION, "true == false", false, true == false ); + array[item++] = new TestCase( SECTION, "false == true", false, false == true ); + + // return true if x and y refer to the same object. otherwise return false. + + array[item++] = new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + + array[item++] = new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + // if x is null and y is undefined, return true. if x is undefined and y is null return true. + + array[item++] = new TestCase( SECTION, "null == void 0", true, null == void 0 ); + array[item++] = new TestCase( SECTION, "void 0 == null", true, void 0 == null ); + + // if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). + + array[item++] = new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); + array[item++] = new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); + array[item++] = new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); + array[item++] = new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); + + + array[item++] = new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); + array[item++] = new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); + + array[item++] = new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); + array[item++] = new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); + + return ( array ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.9.2.js b/tests/mozilla/ecma/Expressions/11.9.2.js new file mode 100644 index 0000000..9eb4bfc --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.9.2.js @@ -0,0 +1,161 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.9.2.js + ECMA Section: 11.9.2 The equals operator ( == ) + Description: + + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: + + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.9.2"; + var VERSION = "ECMA_1"; + startTest(); + var BUGNUMBER="77391"; + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The equals operator ( == )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // type x and type y are the same. if type x is undefined or null, return true + + array[item++] = new TestCase( SECTION, "void 0 == void 0", false, void 0 != void 0 ); + array[item++] = new TestCase( SECTION, "null == null", false, null != null ); + + // if x is NaN, return false. if y is NaN, return false. + + array[item++] = new TestCase( SECTION, "NaN != NaN", true, Number.NaN != Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN != 0", true, Number.NaN != 0 ); + array[item++] = new TestCase( SECTION, "0 != NaN", true, 0 != Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN != Infinity", true, Number.NaN != Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Infinity != NaN", true, Number.POSITIVE_INFINITY != Number.NaN ); + + // if x is the same number value as y, return true. + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE != Number.MAX_VALUE", false, Number.MAX_VALUE != Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE != Number.MIN_VALUE", false, Number.MIN_VALUE != Number.MIN_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY", false, Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY", false, Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY ); + + // if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + + array[item++] = new TestCase( SECTION, "0 != 0", false, 0 != 0 ); + array[item++] = new TestCase( SECTION, "0 != -0", false, 0 != -0 ); + array[item++] = new TestCase( SECTION, "-0 != 0", false, -0 != 0 ); + array[item++] = new TestCase( SECTION, "-0 != -0", false, -0 != -0 ); + + // return false. + + array[item++] = new TestCase( SECTION, "0.9 != 1", true, 0.9 != 1 ); + array[item++] = new TestCase( SECTION, "0.999999 != 1", true, 0.999999 != 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999 != 1", true, 0.9999999999 != 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999999 != 1", true, 0.9999999999999 != 1 ); + + // type x and type y are the same type, but not numbers. + + + // x and y are strings. return true if x and y are exactly the same sequence of characters. + // otherwise, return false. + + array[item++] = new TestCase( SECTION, "'hello' != 'hello'", false, "hello" != "hello" ); + + // x and y are booleans. return true if both are true or both are false. + + array[item++] = new TestCase( SECTION, "true != true", false, true != true ); + array[item++] = new TestCase( SECTION, "false != false", false, false != false ); + array[item++] = new TestCase( SECTION, "true != false", true, true != false ); + array[item++] = new TestCase( SECTION, "false != true", true, false != true ); + + // return true if x and y refer to the same object. otherwise return false. + + array[item++] = new TestCase( SECTION, "new MyObject(true) != new MyObject(true)", true, new MyObject(true) != new MyObject(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); + + + array[item++] = new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z != y", false, eval("x = new MyObject(true); y = x; z = x; z != y") ); + array[item++] = new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z != y", false, eval("x = new MyObject(false); y = x; z = x; z != y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z != y", false, eval("x = new Boolean(true); y = x; z = x; z != y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z != y", false, eval("x = new Boolean(false); y = x; z = x; z != y") ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); + + // if x is null and y is undefined, return true. if x is undefined and y is null return true. + + array[item++] = new TestCase( SECTION, "null != void 0", false, null != void 0 ); + array[item++] = new TestCase( SECTION, "void 0 != null", false, void 0 != null ); + + // if type(x) is Number and type(y) is string, return the result of the comparison x != ToNumber(y). + + array[item++] = new TestCase( SECTION, "1 != '1'", false, 1 != '1' ); + array[item++] = new TestCase( SECTION, "255 != '0xff'", false, 255 != '0xff' ); + array[item++] = new TestCase( SECTION, "0 != '\r'", false, 0 != "\r" ); + array[item++] = new TestCase( SECTION, "1e19 != '1e19'", false, 1e19 != "1e19" ); + + + array[item++] = new TestCase( SECTION, "new Boolean(true) != true", false, true != new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new MyObject(true) != true", false, true != new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "new Boolean(false) != false", false, new Boolean(false) != false ); + array[item++] = new TestCase( SECTION, "new MyObject(false) != false", false, new MyObject(false) != false ); + + array[item++] = new TestCase( SECTION, "true != new Boolean(true)", false, true != new Boolean(true) ); + array[item++] = new TestCase( SECTION, "true != new MyObject(true)", false, true != new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "false != new Boolean(false)", false, false != new Boolean(false) ); + array[item++] = new TestCase( SECTION, "false != new MyObject(false)", false, false != new MyObject(false) ); + + return ( array ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Expressions/11.9.3.js b/tests/mozilla/ecma/Expressions/11.9.3.js new file mode 100644 index 0000000..134060b --- /dev/null +++ b/tests/mozilla/ecma/Expressions/11.9.3.js @@ -0,0 +1,161 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 11.9.3.js + ECMA Section: 11.9.3 The equals operator ( == ) + Description: + + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: + + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "11.9.3"; + var VERSION = "ECMA_1"; + startTest(); + var BUGNUMBER="77391"; + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The equals operator ( == )"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // type x and type y are the same. if type x is undefined or null, return true + + array[item++] = new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); + array[item++] = new TestCase( SECTION, "null == null", true, null == null ); + + // if x is NaN, return false. if y is NaN, return false. + + array[item++] = new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); + array[item++] = new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); + array[item++] = new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); + + // if x is the same number value as y, return true. + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); + + // if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + + array[item++] = new TestCase( SECTION, "0 == 0", true, 0 == 0 ); + array[item++] = new TestCase( SECTION, "0 == -0", true, 0 == -0 ); + array[item++] = new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); + array[item++] = new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); + + // return false. + + array[item++] = new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); + array[item++] = new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); + array[item++] = new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); + + // type x and type y are the same type, but not numbers. + + + // x and y are strings. return true if x and y are exactly the same sequence of characters. + // otherwise, return false. + + array[item++] = new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); + + // x and y are booleans. return true if both are true or both are false. + + array[item++] = new TestCase( SECTION, "true == true", true, true == true ); + array[item++] = new TestCase( SECTION, "false == false", true, false == false ); + array[item++] = new TestCase( SECTION, "true == false", false, true == false ); + array[item++] = new TestCase( SECTION, "false == true", false, false == true ); + + // return true if x and y refer to the same object. otherwise return false. + + array[item++] = new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + + array[item++] = new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); + + array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + // if x is null and y is undefined, return true. if x is undefined and y is null return true. + + array[item++] = new TestCase( SECTION, "null == void 0", true, null == void 0 ); + array[item++] = new TestCase( SECTION, "void 0 == null", true, void 0 == null ); + + // if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). + + array[item++] = new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); + array[item++] = new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); + array[item++] = new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); + array[item++] = new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); + + + array[item++] = new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); + array[item++] = new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); + + array[item++] = new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); + array[item++] = new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); + + array[item++] = new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); + array[item++] = new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); + + return ( array ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.1.1-1.js b/tests/mozilla/ecma/FunctionObjects/15.3.1.1-1.js new file mode 100644 index 0000000..c20dd37 --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.1.1-1.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.1.1.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, body + (where n might be 0, that is, there are no "p" arguments, and where body might + also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor had + been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.1.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var myfunc = Function(); + myfunc.toString = Object.prototype.toString; + +// not going to test toString here since it is implementation dependent. +// array[item++] = new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + + myfunc.toString = Object.prototype.toString; + array[item++] = new TestCase( SECTION, + "myfunc = Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + array[item++] = new TestCase( SECTION, "myfunc.length", 0, myfunc.length ); + array[item++] = new TestCase( SECTION, "myfunc.prototype.toString()", "[object Object]", myfunc.prototype.toString() ); + array[item++] = new TestCase( SECTION, "myfunc.prototype.constructor", myfunc, myfunc.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc.arguments", null, myfunc.arguments ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "OBJ.toString()", "true", OBJ.toString() ); + array[item++] = new TestCase( SECTION, "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + array[item++] = new TestCase( SECTION, "MyObject.toString = Object.prototype.toString; MyObject.toString()", "[object Function]", eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + array[item++] = new TestCase( SECTION, "MyObject.__proto__ == Function.prototype", true, MyObject.__proto__ == Function.prototype ); + array[item++] = new TestCase( SECTION, "MyObject.length", 1, MyObject.length ); + array[item++] = new TestCase( SECTION, "MyObject.prototype.constructor", MyObject, MyObject.prototype.constructor ); + array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.1.1-2.js b/tests/mozilla/ecma/FunctionObjects/15.3.1.1-2.js new file mode 100644 index 0000000..ce6994e --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.1.1-2.js @@ -0,0 +1,118 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.1.1-2.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + Function(p1, p2, ..., pn, body ) + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, + body (where n might be 0, that is, there are no "p" arguments, and where body + might also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor + had been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.1.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + var myfunc1 = Function("a","b","c", "return a+b+c" ); + var myfunc2 = Function("a, b, c", "return a+b+c" ); + var myfunc3 = Function("a,b", "c", "return a+b+c" ); + + myfunc1.toString = Object.prototype.toString; + myfunc2.toString = Object.prototype.toString; + myfunc3.toString = Object.prototype.toString; + + array[item++] = new TestCase( SECTION, "myfunc1 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length ); + array[item++] = new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments ); + array[item++] = new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) ); + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "myfunc2 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); + array[item++] = new TestCase( SECTION, "myfunc2.__proto__", Function.prototype, myfunc2.__proto__ ); + array[item++] = new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length ); + array[item++] = new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments ); + array[item++] = new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) ); + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "myfunc3 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); + array[item++] = new TestCase( SECTION, "myfunc3.__proto__", Function.prototype, myfunc3.__proto__ ); + array[item++] = new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments ); + array[item++] = new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) ); + + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.1.1-3.js b/tests/mozilla/ecma/FunctionObjects/15.3.1.1-3.js new file mode 100644 index 0000000..459a6bf --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.1.1-3.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.1.1-3.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.1.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + + var testcases = new Array(); + + var args = ""; + + for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } + } + + var s = ""; + + for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } + } + + MyFunc = Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); + MyObject = Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + + var MY_OB = eval( "MyFunc("+ s +")" ); + + testcases[testcases.length] = new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); + testcases[testcases.length] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, MY_OB ); + testcases[testcases.length] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + + testcases[testcases.length] = new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + + testcases[testcases.length] = new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); + testcases[testcases.length] = new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); + testcases[testcases.length] = new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.2.1-1.js b/tests/mozilla/ecma/FunctionObjects/15.3.2.1-1.js new file mode 100644 index 0000000..ec1b86b --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.2.1-1.js @@ -0,0 +1,94 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.2.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var MyObject = new Function( "value", "this.value = value; this.valueOf = new Function( 'return this.value' ); this.toString = new Function( 'return String(this.value);' )" ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var myfunc = new Function(); + +// not going to test toString here since it is implementation dependent. +// array[item++] = new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + + myfunc.toString = Object.prototype.toString; + + array[item++] = new TestCase( SECTION, "myfunc = new Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + array[item++] = new TestCase( SECTION, "myfunc.length", 0, myfunc.length ); + array[item++] = new TestCase( SECTION, "myfunc.prototype.toString()", "[object Object]", myfunc.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc.prototype.constructor", myfunc, myfunc.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc.arguments", null, myfunc.arguments ); + + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "OBJ.toString()", "true", OBJ.toString() ); + array[item++] = new TestCase( SECTION, "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + array[item++] = new TestCase( SECTION, "MyObject.toString = Object.prototype.toString; MyObject.toString()", "[object Function]", eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + + array[item++] = new TestCase( SECTION, "MyObject.__proto__ == Function.prototype", true, MyObject.__proto__ == Function.prototype ); + array[item++] = new TestCase( SECTION, "MyObject.length", 1, MyObject.length ); + array[item++] = new TestCase( SECTION, "MyObject.prototype.constructor", MyObject, MyObject.prototype.constructor ); + array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.2.1-2.js b/tests/mozilla/ecma/FunctionObjects/15.3.2.1-2.js new file mode 100644 index 0000000..b8f403c --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.2.1-2.js @@ -0,0 +1,111 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + var myfunc1 = new Function("a","b","c", "return a+b+c" ); + var myfunc2 = new Function("a, b, c", "return a+b+c" ); + var myfunc3 = new Function("a,b", "c", "return a+b+c" ); + + myfunc1.toString = Object.prototype.toString; + myfunc2.toString = Object.prototype.toString; + myfunc3.toString = Object.prototype.toString; + + array[item++] = new TestCase( SECTION, "myfunc1 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length ); + array[item++] = new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments ); + array[item++] = new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) ); + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "myfunc2 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); + array[item++] = new TestCase( SECTION, "myfunc2.__proto__", Function.prototype, myfunc2.__proto__ ); + array[item++] = new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length ); + array[item++] = new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() ); + + array[item++] = new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments ); + array[item++] = new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) ); + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "myfunc3 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); + array[item++] = new TestCase( SECTION, "myfunc3.__proto__", Function.prototype, myfunc3.__proto__ ); + array[item++] = new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' ); + array[item++] = new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor ); + array[item++] = new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments ); + array[item++] = new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) ); + + array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.2.1-3.js b/tests/mozilla/ecma/FunctionObjects/15.3.2.1-3.js new file mode 100644 index 0000000..76c5e2f --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.2.1-3.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.2.1-3.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.2.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Function Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var args = ""; + + for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } + } + + var s = ""; + + for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } + } + + MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); + MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + + array[item++] = new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); + array[item++] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + + array[item++] = new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.3.1-1.js b/tests/mozilla/ecma/FunctionObjects/15.3.3.1-1.js new file mode 100644 index 0000000..4442e27 --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.3.1-1.js @@ -0,0 +1,62 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.3.1-1.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the value of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.3.1-1"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Function.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + testcases[tc++] = new TestCase( SECTION, "Function.prototype == Function.proto", true, Function.__proto__ == Function.prototype ); + + test(); + +function test() { + for (tc=0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.3.1-2.js b/tests/mozilla/ecma/FunctionObjects/15.3.3.1-2.js new file mode 100644 index 0000000..e39abbf --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.3.1-2.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.3.1-2.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the DontEnum property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "var str='';for (prop in Function ) str += prop; str;", + "", + eval("var str='';for (prop in Function) str += prop; str;") + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.3.1-3.js b/tests/mozilla/ecma/FunctionObjects/15.3.3.1-3.js new file mode 100644 index 0000000..b95752c --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.3.1-3.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.3.1-3.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the DontDelete property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.3.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var FUN_PROTO = Function.prototype; + + array[item++] = new TestCase( SECTION, + "delete Function.prototype", + false, + delete Function.prototype + ); + + array[item++] = new TestCase( SECTION, + "delete Function.prototype; Function.prototype", + FUN_PROTO, + eval("delete Function.prototype; Function.prototype") + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.3.1-4.js b/tests/mozilla/ecma/FunctionObjects/15.3.3.1-4.js new file mode 100644 index 0000000..5b4e811 --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.3.1-4.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.3.1-4.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the ReadOnly property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.3.1-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "Function.prototype = null; Function.prototype", + Function.prototype, + eval("Function.prototype = null; Function.prototype") + ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.3.2.js b/tests/mozilla/ecma/FunctionObjects/15.3.3.2.js new file mode 100644 index 0000000..821f93e --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.3.2.js @@ -0,0 +1,60 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.3.2.js + ECMA Section: 15.3.3.2 Properties of the Function Constructor + Function.length + + Description: The length property is 1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.3.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Function.length", 1, Function.length ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.4-1.js b/tests/mozilla/ecma/FunctionObjects/15.3.4-1.js new file mode 100644 index 0000000..d919d41 --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.4-1.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.4-1.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Function Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// array[item++] = new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Function.prototype.valueOf", Object.prototype.valueOf, Function.prototype.valueOf ); + array[item++] = new TestCase( SECTION, "Function.prototype()", (void 0), Function.prototype() ); + array[item++] = new TestCase( SECTION, "Function.prototype(1,true,false,'string', new Date(),null)", (void 0), Function.prototype(1,true,false,'string', new Date(),null) ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.4.1.js b/tests/mozilla/ecma/FunctionObjects/15.3.4.1.js new file mode 100644 index 0000000..ce75a14 --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.4.1.js @@ -0,0 +1,62 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.4.1.js + ECMA Section: 15.3.4.1 Function.prototype.constructor + + Description: The initial value of Function.prototype.constructor + is the built-in Function constructor. + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Function.prototype.constructor", Function, Function.prototype.constructor ); + + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.4.js b/tests/mozilla/ecma/FunctionObjects/15.3.4.js new file mode 100644 index 0000000..df519d2 --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.4.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.4.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.3.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Function Prototype Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// array[item++] = new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Function.prototype.valueOf", Object.prototype.valueOf, Function.prototype.valueOf ); + array[item++] = new TestCase( SECTION, "Function.prototype()", (void 0), Function.prototype() ); + array[item++] = new TestCase( SECTION, "Function.prototype(1,true,false,'string', new Date(),null)", (void 0), Function.prototype(1,true,false,'string', new Date(),null) ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.5-1.js b/tests/mozilla/ecma/FunctionObjects/15.3.5-1.js new file mode 100644 index 0000000..1e63370 --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.5-1.js @@ -0,0 +1,118 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) + + Description: + + 15.3.5.1 length + + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. + + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. + + 15.3.5.3 arguments + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of Function Instances"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var args = ""; + + for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } + } + + var s = ""; + + for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } + } + + MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); + MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + + + array[item++] = new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); + array[item++] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + array[item++] = new TestCase( SECTION, "MyFunc.prototype.toString()", "[object Object]", MyFunc.prototype.toString() ); + array[item++] = new TestCase( SECTION, "typeof MyFunc.prototype", "object", typeof MyFunc.prototype ); + + + array[item++] = new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); + array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.5-2.js b/tests/mozilla/ecma/FunctionObjects/15.3.5-2.js new file mode 100644 index 0000000..fe24e32 --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.5-2.js @@ -0,0 +1,92 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) + + Description: + + 15.3.5.1 length + + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. + + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. + + 15.3.5.3 arguments + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.3.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of Function Instances"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MyObject = new Function( 'a', 'b', 'c', 'this.a = a; this.b = b; this.c = c; this.value = a+b+c; this.valueOf = new Function( "return this.value" )' ); + + array[item++] = new TestCase( SECTION, "MyObject.length", 3, MyObject.length ); + array[item++] = new TestCase( SECTION, "typeof MyObject.prototype", "object", typeof MyObject.prototype ); + array[item++] = new TestCase( SECTION, "typeof MyObject.prototype.constructor", "function", typeof MyObject.prototype.constructor ); + array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.5.1.js b/tests/mozilla/ecma/FunctionObjects/15.3.5.1.js new file mode 100644 index 0000000..3da3b0e --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.5.1.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.5.1.js + ECMA Section: Function.length + Description: + + The value of the length property is usually an integer that indicates the + "typical" number of arguments expected by the function. However, the + language permits the function to be invoked with some other number of + arguments. The behavior of a function when invoked on a number of arguments + other than the number specified by its length property depends on the function. + + this test needs a 1.2 version check. + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204 + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.3.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.length"; + var BUGNUMBER="104204"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var f = new Function( "a","b", "c", "return f.length"); + + testcases[tc++] = new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f()', + 3, + f() ); + + + testcases[tc++] = new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', + 3, + f(1,2,3,4,5) ); + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/FunctionObjects/15.3.5.3.js b/tests/mozilla/ecma/FunctionObjects/15.3.5.3.js new file mode 100644 index 0000000..eaf6dbe --- /dev/null +++ b/tests/mozilla/ecma/FunctionObjects/15.3.5.3.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.5.3.js + ECMA Section: Function.arguments + Description: + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the + function has been called but has not yet returned). When a non-internal + Function object (15.3.2.1) is invoked, its arguments property is + "dynamically bound" to a newly created object that contains the arguments + on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility + with existing old code. + + See sections 10.1.6 and 10.1.8 for more extensive tests. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.3.5.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.arguments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array =new Array(); + var item = 0; + + var MYFUNCTION = new Function( "return this.arguments" ); + + + array[item++] = new TestCase( SECTION, "var MYFUNCTION = new Function( 'return this.arguments' ); MYFUNCTION.arguments", null, MYFUNCTION.arguments ); + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1-1-n.js b/tests/mozilla/ecma/GlobalObject/15.1-1-n.js new file mode 100644 index 0000000..906b0b4 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1-1-n.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1-1-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.1-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Global Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc] = new TestCase( SECTION, + "var MY_GLOBAL = new this()", + "error", + "var MY_GLOBAL = new this()" ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval(testcases[tc].actual); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1-2-n.js b/tests/mozilla/ecma/GlobalObject/15.1-2-n.js new file mode 100644 index 0000000..327c685 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1-2-n.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1-2-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Call]] property; it is not possible + to invoke the global object as a function. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.1-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Global Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc] = new TestCase( SECTION, + "var MY_GLOBAL = this()", + "error", + "var MY_GLOBAL = this()" ); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval(testcases[tc].actual); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.1.1.js b/tests/mozilla/ecma/GlobalObject/15.1.1.1.js new file mode 100644 index 0000000..4310a51 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.1.1.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.1.1.js + ECMA Section: 15.1.1.1 NaN + + Description: The initial value of NaN is NaN. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.1.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "NaN"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[array.length] = new TestCase( SECTION, "NaN", Number.NaN, NaN ); + array[array.length] = new TestCase( SECTION, "this.NaN", Number.NaN, this.NaN ); + array[array.length] = new TestCase( SECTION, "typeof NaN", "number", typeof NaN ); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/GlobalObject/15.1.1.2.js b/tests/mozilla/ecma/GlobalObject/15.1.1.2.js new file mode 100644 index 0000000..35324d6 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.1.2.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.1.2.js + ECMA Section: 15.1.1.2 Infinity + + Description: The initial value of Infinity is +Infinity. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.1.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Infinity"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Infinity", Number.POSITIVE_INFINITY, Infinity ); + array[item++] = new TestCase( SECTION, "this.Infinity", Number.POSITIVE_INFINITY, this.Infinity ); + array[item++] = new TestCase( SECTION, "typeof Infinity", "number", typeof Infinity ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + } + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.1-1.js b/tests/mozilla/ecma/GlobalObject/15.1.2.1-1.js new file mode 100644 index 0000000..d4f38a7 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.1-1.js @@ -0,0 +1,91 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.1-1.js + ECMA Section: 15.1.2.1 eval(x) + + if x is not a string object, return x. + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.1.2.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "eval(x)"; + + var BUGNUMBER = "111199"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "eval.length", 1, eval.length ); + array[item++] = new TestCase( SECTION, "delete eval.length", false, delete eval.length ); + array[item++] = new TestCase( SECTION, "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS", "", eval("var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS") ); + array[item++] = new TestCase( SECTION, "eval.length = null; eval.length", 1, eval( "eval.length = null; eval.length") ); +// array[item++] = new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); + + // test cases where argument is not a string. should return the argument. + + array[item++] = new TestCase( SECTION, "eval()", void 0, eval() ); + array[item++] = new TestCase( SECTION, "eval(void 0)", void 0, eval( void 0) ); + array[item++] = new TestCase( SECTION, "eval(null)", null, eval( null ) ); + array[item++] = new TestCase( SECTION, "eval(true)", true, eval( true ) ); + array[item++] = new TestCase( SECTION, "eval(false)", false, eval( false ) ); + + array[item++] = new TestCase( SECTION, "typeof eval(new String('Infinity/-0')", "object", typeof eval(new String('Infinity/-0')) ); + + array[item++] = new TestCase( SECTION, "eval([1,2,3,4,5,6])", "1,2,3,4,5,6", ""+eval([1,2,3,4,5,6]) ); + array[item++] = new TestCase( SECTION, "eval(new Array(0,1,2,3)", "1,2,3", ""+ eval(new Array(1,2,3)) ); + array[item++] = new TestCase( SECTION, "eval(1)", 1, eval(1) ); + array[item++] = new TestCase( SECTION, "eval(0)", 0, eval(0) ); + array[item++] = new TestCase( SECTION, "eval(-1)", -1, eval(-1) ); + array[item++] = new TestCase( SECTION, "eval(Number.NaN)", Number.NaN, eval(Number.NaN) ); + array[item++] = new TestCase( SECTION, "eval(Number.MIN_VALUE)", 5e-308, eval(Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "eval(-Number.MIN_VALUE)", -5e-308, eval(-Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "eval(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, eval(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "eval(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, eval(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "eval( 4294967296 )", 4294967296, eval(4294967296) ); + array[item++] = new TestCase( SECTION, "eval( 2147483648 )", 2147483648, eval(2147483648) ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.1-2.js b/tests/mozilla/ecma/GlobalObject/15.1.2.1-2.js new file mode 100644 index 0000000..203cd4d --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.1-2.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.1-2.js + ECMA Section: 15.1.2.1 eval(x) + + Parse x as an ECMAScript Program. If the parse fails, + generate a runtime error. Evaluate the program. If + result is "Normal completion after value V", return + the value V. Else, return undefined. + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.1.2.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "eval(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[0] = new TestCase( SECTION, + "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x", + "0/1/1970", + eval( "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x" ) + ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.2-1.js b/tests/mozilla/ecma/GlobalObject/15.1.2.2-1.js new file mode 100644 index 0000000..422109d --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.2-1.js @@ -0,0 +1,291 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.2-1.js + ECMA Section: 15.1.2.2 Function properties of the global object + parseInt( string, radix ) + + Description: + + The parseInt function produces an integer value dictated by intepretation + of the contents of the string argument according to the specified radix. + + When the parseInt function is called, the following steps are taken: + + 1. Call ToString(string). + 2. Compute a substring of Result(1) consisting of the leftmost character + that is not a StrWhiteSpaceChar and all characters to the right of + that character. (In other words, remove leading whitespace.) + 3. Let sign be 1. + 4. If Result(2) is not empty and the first character of Result(2) is a + minus sign -, let sign be -1. + 5. If Result(2) is not empty and the first character of Result(2) is a + plus sign + or a minus sign -, then Result(5) is the substring of + Result(2) produced by removing the first character; otherwise, Result(5) + is Result(2). + 6. If the radix argument is not supplied, go to step 12. + 7. Call ToInt32(radix). + 8. If Result(7) is zero, go to step 12; otherwise, if Result(7) < 2 or + Result(7) > 36, return NaN. + 9. Let R be Result(7). + 10. If R = 16 and the length of Result(5) is at least 2 and the first two + characters of Result(5) are either "0x" or "0X", let S be the substring + of Result(5) consisting of all but the first two characters; otherwise, + let S be Result(5). + 11. Go to step 22. + 12. If Result(5) is empty or the first character of Result(5) is not 0, + go to step 20. + 13. If the length of Result(5) is at least 2 and the second character of + Result(5) is x or X, go to step 17. + 14. Let R be 8. + 15. Let S be Result(5). + 16. Go to step 22. + 17. Let R be 16. + 18. Let S be the substring of Result(5) consisting of all but the first + two characters. + 19. Go to step 22. + 20. Let R be 10. + 21. Let S be Result(5). + 22. If S contains any character that is not a radix-R digit, then let Z be + the substring of S consisting of all characters to the left of the + leftmost such character; otherwise, let Z be S. + 23. If Z is empty, return NaN. + 24. Compute the mathematical integer value that is represented by Z in + radix-R notation. (But if R is 10 and Z contains more than 20 + significant digits, every digit after the 20th may be replaced by a 0 + digit, at the option of the implementation; and if R is not 2, 4, 8, + 10, 16, or 32, then Result(24) may be an implementation-dependent + approximation to the mathematical integer value that is represented + by Z in radix-R notation.) + 25. Compute the number value for Result(24). + 26. Return sign Result(25). + + Note that parseInt may interpret only a leading portion of the string as + an integer value; it ignores any characters that cannot be interpreted as + part of the notation of an integer, and no indication is given that any + such characters were ignored. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "parseInt(string, radix)"; + var BUGNUMBER="111199"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var HEX_STRING = "0x0"; + var HEX_VALUE = 0; + + array[item++] = new TestCase( SECTION, "parseInt.length", 2, parseInt.length ); + array[item++] = new TestCase( SECTION, "parseInt.length = 0; parseInt.length", 2, eval("parseInt.length = 0; parseInt.length") ); + array[item++] = new TestCase( SECTION, "var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS", "", eval("var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS") ); + array[item++] = new TestCase( SECTION, "delete parseInt.length", false, delete parseInt.length ); + array[item++] = new TestCase( SECTION, "delete parseInt.length; parseInt.length", 2, eval("delete parseInt.length; parseInt.length") ); + array[item++] = new TestCase( SECTION, "parseInt.length = null; parseInt.length", 2, eval("parseInt.length = null; parseInt.length") ); + + array[item++] = new TestCase( SECTION, "parseInt()", NaN, parseInt() ); + array[item++] = new TestCase( SECTION, "parseInt('')", NaN, parseInt("") ); + array[item++] = new TestCase( SECTION, "parseInt('','')", NaN, parseInt("","") ); + array[item++] = new TestCase( SECTION, + "parseInt(\" 0xabcdef ", + 11259375, + parseInt( " 0xabcdef " )); + + array[item++] = new TestCase( SECTION, + "parseInt(\" 0XABCDEF ", + 11259375, + parseInt( " 0XABCDEF " ) ); + + array[item++] = new TestCase( SECTION, + "parseInt( 0xabcdef )", + 11259375, + parseInt( "0xabcdef") ); + + array[item++] = new TestCase( SECTION, + "parseInt( 0XABCDEF )", + 11259375, + parseInt( "0XABCDEF") ); + + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",null)", HEX_VALUE, parseInt(HEX_STRING,null) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+", void 0)", HEX_VALUE, parseInt(HEX_STRING, void 0) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + + // a few tests with spaces + + for ( var space = " ", HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; + POWER < 15; + POWER++, HEX_STRING = HEX_STRING +"f", space += " ") + { + array[item++] = new TestCase( SECTION, "parseInt("+space+HEX_STRING+space+", void 0)", HEX_VALUE, parseInt(space+HEX_STRING+space, void 0) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + + // a few tests with negative numbers + for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + + // we should stop parsing when we get to a value that is not a numeric literal for the type we expect + + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"g",16) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"G",16) ); + HEX_VALUE += Math.pow(16,POWER)*15; + } + + for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "-0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE -= Math.pow(16,POWER)*15; + } + + // let us do some octal tests. numbers that start with 0 and do not provid a radix should + // default to using "0" as a radix. + + var OCT_STRING = "0"; + var OCT_VALUE = 0; + + for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); + OCT_VALUE += Math.pow(8,POWER)*7; + } + + for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); + OCT_VALUE -= Math.pow(8,POWER)*7; + } + + // should get the same results as above if we provid the radix of 8 (or 010) + + for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+",8)", OCT_VALUE, parseInt(OCT_STRING,8) ); + OCT_VALUE += Math.pow(8,POWER)*7; + } + for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+",010)", OCT_VALUE, parseInt(OCT_STRING,010) ); + OCT_VALUE -= Math.pow(8,POWER)*7; + } + + // we shall stop parsing digits when we get one that isn't a numeric literal of the type we think + // it should be. + for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+"8,8)", OCT_VALUE, parseInt(OCT_STRING+"8",8) ); + OCT_VALUE += Math.pow(8,POWER)*7; + } + for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+"8,010)", OCT_VALUE, parseInt(OCT_STRING+"8",010) ); + OCT_VALUE -= Math.pow(8,POWER)*7; + } + + array[item++] = new TestCase( SECTION, "parseInt( '0x' )", NaN, parseInt("0x") ); + array[item++] = new TestCase( SECTION, "parseInt( '0X' )", NaN, parseInt("0X") ); + + array[item++] = new TestCase( SECTION, "parseInt( '11111111112222222222' )", 11111111112222222222, parseInt("11111111112222222222") ); + array[item++] = new TestCase( SECTION, "parseInt( '111111111122222222223' )", 111111111122222222220, parseInt("111111111122222222223") ); + array[item++] = new TestCase( SECTION, "parseInt( '11111111112222222222',10 )", 11111111112222222222, parseInt("11111111112222222222",10) ); + array[item++] = new TestCase( SECTION, "parseInt( '111111111122222222223',10 )", 111111111122222222220, parseInt("111111111122222222223",10) ); + + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', -1 )", Number.NaN, parseInt("01234567890",-1) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 0 )", Number.NaN, parseInt("01234567890",1) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 1 )", Number.NaN, parseInt("01234567890",1) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 2 )", 1, parseInt("01234567890",2) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 3 )", 5, parseInt("01234567890",3) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 4 )", 27, parseInt("01234567890",4) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 5 )", 194, parseInt("01234567890",5) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 6 )", 1865, parseInt("01234567890",6) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 7 )", 22875, parseInt("01234567890",7) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 8 )", 342391, parseInt("01234567890",8) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 9 )", 6053444, parseInt("01234567890",9) ); + array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 10 )", 1234567890, parseInt("01234567890",10) ); + + // need more test cases with hex radix + + array[item++] = new TestCase( SECTION, "parseInt( '1234567890', '0xa')", 1234567890, parseInt("1234567890","0xa") ); + + array[item++] = new TestCase( SECTION, "parseInt( '012345', 11 )", 17715, parseInt("012345",11) ); + + array[item++] = new TestCase( SECTION, "parseInt( '012345', 35 )", 1590195, parseInt("012345",35) ); + array[item++] = new TestCase( SECTION, "parseInt( '012345', 36 )", 1776965, parseInt("012345",36) ); + array[item++] = new TestCase( SECTION, "parseInt( '012345', 37 )", Number.NaN, parseInt("012345",37) ); + + return ( array ); +} +function test( array ) { + for ( tc=0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.2-2.js b/tests/mozilla/ecma/GlobalObject/15.1.2.2-2.js new file mode 100644 index 0000000..27d31be --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.2-2.js @@ -0,0 +1,232 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.2-1.js + ECMA Section: 15.1.2.2 Function properties of the global object + parseInt( string, radix ) + + Description: parseInt test cases written by waldemar, and documented in + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.2.2-2"; +var VERSION = "ECMA_1"; + startTest(); +var TITLE = "parseInt(string, radix)"; +var BUGNUMBER="123874"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcases = new Array(); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111100",2)', + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111101",2)', + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111101",2)); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111111",2)', + 9027215253084864, + parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)', + 18054430506169720, + parseInt("0000001000000001001000110100010101100111100010011010101111010",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)', + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111011",2)); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)', + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111100",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)', + 18054430506169728, + parseInt("0000001000000001001000110100010101100111100010011010101111110",2) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("yz",35)', + 34, + parseInt("yz",35) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("yz",36)', + 1259, + parseInt("yz",36) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("yz",37)', + NaN, + parseInt("yz",37) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("+77")', + 77, + parseInt("+77") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("-77",9)', + -70, + parseInt("-77",9) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("\u20001234\u2000")', + 1234, + parseInt("\u20001234\u2000") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("123456789012345678")', + 123456789012345680, + parseInt("123456789012345678") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("9",8)', + NaN, + parseInt("9",8) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("1e2")', + 1, + parseInt("1e2") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("1.9999999999999999999")', + 1, + parseInt("1.9999999999999999999") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0x10")', + 16, + parseInt("0x10") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0x10",10)', + 0, + parseInt("0x10",10)); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0022")', + 18, + parseInt("0022")); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0022",10)', + 22, + parseInt("0022",10) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0x1000000000000080")', + 1152921504606847000, + parseInt("0x1000000000000080") ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt("0x1000000000000081")', + 1152921504606847200, + parseInt("0x1000000000000081") ); + +s = +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + +s += "0000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, + "s = " + s +"; -s", + -1.7976931348623157e+308, + -s ); + +s = +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; +s += "0000000000000000000000000000000000001"; + +testcases[tc++] = new TestCase( SECTION, + "s = " + s +"; -s", + -1.7976931348623157e+308, + -s ); + + +s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +s += "0000000000000000000000000000000000000" + + +testcases[tc++] = new TestCase( SECTION, + "s = " + s + "; -s", + -Infinity, + -s ); + +s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; +s += "0000000000000000000000000000000000001"; + +testcases[tc++] = new TestCase( SECTION, + "s = " + s + "; -s", + -1.7976931348623157e+308, + -s ); + +s += "0" + +testcases[tc++] = new TestCase( SECTION, + "s = " + s + "; -s", + -Infinity, + -s ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt(s)', + Infinity, + parseInt(s) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt(s,32)', + 0, + parseInt(s,32) ); + +testcases[tc++] = new TestCase( SECTION, + 'parseInt(s,36)', + Infinity, + parseInt(s,36)); + +test(); + +function test( array ) { + for ( tc=0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.3-1.js b/tests/mozilla/ecma/GlobalObject/15.1.2.3-1.js new file mode 100644 index 0000000..0efec6b --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.3-1.js @@ -0,0 +1,444 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.3.js + ECMA Section: 15.1.2.3 Function properties of the global object: + parseFloat( string ) + + Description: The parseFloat function produces a number value dictated + by the interpretation of the contents of the string + argument defined as a decimal literal. + + When the parseFloat function is called, the following + steps are taken: + + 1. Call ToString( string ). + 2. Remove leading whitespace Result(1). + 3. If neither Result(2) nor any prefix of Result(2) + satisfies the syntax of a StrDecimalLiteral, + return NaN. + 4. Compute the longest prefix of Result(2) which might + be Resusult(2) itself, that satisfies the syntax of + a StrDecimalLiteral + 5. Return the number value for the MV of Result(4). + + Note that parseFloate may interpret only a leading + portion of the string as a number value; it ignores any + characters that cannot be interpreted as part of the + notation of a decimal literal, and no indication is given + that such characters were ignored. + + StrDecimalLiteral:: + Infinity + DecimalDigits.DecimalDigits opt ExponentPart opt + .DecimalDigits ExponentPart opt + DecimalDigits ExponentPart opt + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.1.2.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "parseFloat(string)"; + var BUGNUMBER= "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "parseFloat.length", 1, parseFloat.length ); + + array[item++] = new TestCase( SECTION, "parseFloat.length = null; parseFloat.length", 1, eval("parseFloat.length = null; parseFloat.length") ); + array[item++] = new TestCase( SECTION, "delete parseFloat.length", false, delete parseFloat.length ); + array[item++] = new TestCase( SECTION, "delete parseFloat.length; parseFloat.length", 1, eval("delete parseFloat.length; parseFloat.length") ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "parseFloat()", Number.NaN, parseFloat() ); + array[item++] = new TestCase( SECTION, "parseFloat('')", Number.NaN, parseFloat('') ); + + array[item++] = new TestCase( SECTION, "parseFloat(' ')", Number.NaN, parseFloat(' ') ); + array[item++] = new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); + array[item++] = new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); + array[item++] = new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' Infinity')", Infinity, parseFloat("Infinity") ); + array[item++] = new TestCase( SECTION, "parseFloat(' Infinity ')", Infinity, parseFloat(' Infinity ') ); + + array[item++] = new TestCase( SECTION, "parseFloat('Infinity')", Infinity, parseFloat("Infinity") ); + array[item++] = new TestCase( SECTION, "parseFloat(Infinity)", Infinity, parseFloat(Infinity) ); + + + array[item++] = new TestCase( SECTION, "parseFloat(' +Infinity')", +Infinity, parseFloat("+Infinity") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -Infinity ')", -Infinity, parseFloat(' -Infinity ') ); + + array[item++] = new TestCase( SECTION, "parseFloat('+Infinity')", +Infinity, parseFloat("+Infinity") ); + array[item++] = new TestCase( SECTION, "parseFloat(-Infinity)", -Infinity, parseFloat(-Infinity) ); + + array[item++] = new TestCase( SECTION, "parseFloat('0')", 0, parseFloat("0") ); + array[item++] = new TestCase( SECTION, "parseFloat('-0')", -0, parseFloat("-0") ); + array[item++] = new TestCase( SECTION, "parseFloat('+0')", 0, parseFloat("+0") ); + + array[item++] = new TestCase( SECTION, "parseFloat('1')", 1, parseFloat("1") ); + array[item++] = new TestCase( SECTION, "parseFloat('-1')", -1, parseFloat("-1") ); + array[item++] = new TestCase( SECTION, "parseFloat('+1')", 1, parseFloat("+1") ); + + array[item++] = new TestCase( SECTION, "parseFloat('2')", 2, parseFloat("2") ); + array[item++] = new TestCase( SECTION, "parseFloat('-2')", -2, parseFloat("-2") ); + array[item++] = new TestCase( SECTION, "parseFloat('+2')", 2, parseFloat("+2") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3')", 3, parseFloat("3") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3')", -3, parseFloat("-3") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3')", 3, parseFloat("+3") ); + + array[item++] = new TestCase( SECTION, "parseFloat('4')", 4, parseFloat("4") ); + array[item++] = new TestCase( SECTION, "parseFloat('-4')", -4, parseFloat("-4") ); + array[item++] = new TestCase( SECTION, "parseFloat('+4')", 4, parseFloat("+4") ); + + array[item++] = new TestCase( SECTION, "parseFloat('5')", 5, parseFloat("5") ); + array[item++] = new TestCase( SECTION, "parseFloat('-5')", -5, parseFloat("-5") ); + array[item++] = new TestCase( SECTION, "parseFloat('+5')", 5, parseFloat("+5") ); + + array[item++] = new TestCase( SECTION, "parseFloat('6')", 6, parseFloat("6") ); + array[item++] = new TestCase( SECTION, "parseFloat('-6')", -6, parseFloat("-6") ); + array[item++] = new TestCase( SECTION, "parseFloat('+6')", 6, parseFloat("+6") ); + + array[item++] = new TestCase( SECTION, "parseFloat('7')", 7, parseFloat("7") ); + array[item++] = new TestCase( SECTION, "parseFloat('-7')", -7, parseFloat("-7") ); + array[item++] = new TestCase( SECTION, "parseFloat('+7')", 7, parseFloat("+7") ); + + array[item++] = new TestCase( SECTION, "parseFloat('8')", 8, parseFloat("8") ); + array[item++] = new TestCase( SECTION, "parseFloat('-8')", -8, parseFloat("-8") ); + array[item++] = new TestCase( SECTION, "parseFloat('+8')", 8, parseFloat("+8") ); + + array[item++] = new TestCase( SECTION, "parseFloat('9')", 9, parseFloat("9") ); + array[item++] = new TestCase( SECTION, "parseFloat('-9')", -9, parseFloat("-9") ); + array[item++] = new TestCase( SECTION, "parseFloat('+9')", 9, parseFloat("+9") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.14159')", 3.14159, parseFloat("3.14159") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.14159')", -3.14159, parseFloat("-3.14159") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.14159')", 3.14159, parseFloat("+3.14159") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.')", 3, parseFloat("3.") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.')", -3, parseFloat("-3.") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.')", 3, parseFloat("+3.") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.e1')", 30, parseFloat("3.e1") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.e1')", -30, parseFloat("-3.e1") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.e1')", 30, parseFloat("+3.e1") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.e+1')", 30, parseFloat("3.e+1") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.e+1')", -30, parseFloat("-3.e+1") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.e+1')", 30, parseFloat("+3.e+1") ); + + array[item++] = new TestCase( SECTION, "parseFloat('3.e-1')", .30, parseFloat("3.e-1") ); + array[item++] = new TestCase( SECTION, "parseFloat('-3.e-1')", -.30, parseFloat("-3.e-1") ); + array[item++] = new TestCase( SECTION, "parseFloat('+3.e-1')", .30, parseFloat("+3.e-1") ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat('.00001')", 0.00001, parseFloat(".00001") ); + array[item++] = new TestCase( SECTION, "parseFloat('+.00001')", 0.00001, parseFloat("+.00001") ); + array[item++] = new TestCase( SECTION, "parseFloat('-0.0001')", -0.00001, parseFloat("-.00001") ); + + array[item++] = new TestCase( SECTION, "parseFloat('.01e2')", 1, parseFloat(".01e2") ); + array[item++] = new TestCase( SECTION, "parseFloat('+.01e2')", 1, parseFloat("+.01e2") ); + array[item++] = new TestCase( SECTION, "parseFloat('-.01e2')", -1, parseFloat("-.01e2") ); + + array[item++] = new TestCase( SECTION, "parseFloat('.01e+2')", 1, parseFloat(".01e+2") ); + array[item++] = new TestCase( SECTION, "parseFloat('+.01e+2')", 1, parseFloat("+.01e+2") ); + array[item++] = new TestCase( SECTION, "parseFloat('-.01e+2')", -1, parseFloat("-.01e+2") ); + + array[item++] = new TestCase( SECTION, "parseFloat('.01e-2')", 0.0001, parseFloat(".01e-2") ); + array[item++] = new TestCase( SECTION, "parseFloat('+.01e-2')", 0.0001, parseFloat("+.01e-2") ); + array[item++] = new TestCase( SECTION, "parseFloat('-.01e-2')", -0.0001, parseFloat("-.01e-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat('1234e5')", 123400000, parseFloat("1234e5") ); + array[item++] = new TestCase( SECTION, "parseFloat('+1234e5')", 123400000, parseFloat("+1234e5") ); + array[item++] = new TestCase( SECTION, "parseFloat('-1234e5')", -123400000, parseFloat("-1234e5") ); + + array[item++] = new TestCase( SECTION, "parseFloat('1234e+5')", 123400000, parseFloat("1234e+5") ); + array[item++] = new TestCase( SECTION, "parseFloat('+1234e+5')", 123400000, parseFloat("+1234e+5") ); + array[item++] = new TestCase( SECTION, "parseFloat('-1234e+5')", -123400000, parseFloat("-1234e+5") ); + + array[item++] = new TestCase( SECTION, "parseFloat('1234e-5')", 0.01234, parseFloat("1234e-5") ); + array[item++] = new TestCase( SECTION, "parseFloat('+1234e-5')", 0.01234, parseFloat("+1234e-5") ); + array[item++] = new TestCase( SECTION, "parseFloat('-1234e-5')", -0.01234, parseFloat("-1234e-5") ); + + + array[item++] = new TestCase( SECTION, "parseFloat(0)", 0, parseFloat(0) ); + array[item++] = new TestCase( SECTION, "parseFloat(-0)", -0, parseFloat(-0) ); + + array[item++] = new TestCase( SECTION, "parseFloat(1)", 1, parseFloat(1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-1)", -1, parseFloat(-1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(2)", 2, parseFloat(2) ); + array[item++] = new TestCase( SECTION, "parseFloat(-2)", -2, parseFloat(-2) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3)", 3, parseFloat(3) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3)", -3, parseFloat(-3) ); + + array[item++] = new TestCase( SECTION, "parseFloat(4)", 4, parseFloat(4) ); + array[item++] = new TestCase( SECTION, "parseFloat(-4)", -4, parseFloat(-4) ); + + array[item++] = new TestCase( SECTION, "parseFloat(5)", 5, parseFloat(5) ); + array[item++] = new TestCase( SECTION, "parseFloat(-5)", -5, parseFloat(-5) ); + + array[item++] = new TestCase( SECTION, "parseFloat(6)", 6, parseFloat(6) ); + array[item++] = new TestCase( SECTION, "parseFloat(-6)", -6, parseFloat(-6) ); + + array[item++] = new TestCase( SECTION, "parseFloat(7)", 7, parseFloat(7) ); + array[item++] = new TestCase( SECTION, "parseFloat(-7)", -7, parseFloat(-7) ); + + array[item++] = new TestCase( SECTION, "parseFloat(8)", 8, parseFloat(8) ); + array[item++] = new TestCase( SECTION, "parseFloat(-8)", -8, parseFloat(-8) ); + + array[item++] = new TestCase( SECTION, "parseFloat(9)", 9, parseFloat(9) ); + array[item++] = new TestCase( SECTION, "parseFloat(-9)", -9, parseFloat(-9) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.14159)", 3.14159, parseFloat(3.14159) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.14159)", -3.14159, parseFloat(-3.14159) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.)", 3, parseFloat(3.) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.)", -3, parseFloat(-3.) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.e1)", 30, parseFloat(3.e1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.e1)", -30, parseFloat(-3.e1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.e+1)", 30, parseFloat(3.e+1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.e+1)", -30, parseFloat(-3.e+1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.e-1)", .30, parseFloat(3.e-1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.e-1)", -.30, parseFloat(-3.e-1) ); + + + array[item++] = new TestCase( SECTION, "parseFloat(3.E1)", 30, parseFloat(3.E1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.E1)", -30, parseFloat(-3.E1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.E+1)", 30, parseFloat(3.E+1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.E+1)", -30, parseFloat(-3.E+1) ); + + array[item++] = new TestCase( SECTION, "parseFloat(3.E-1)", .30, parseFloat(3.E-1) ); + array[item++] = new TestCase( SECTION, "parseFloat(-3.E-1)", -.30, parseFloat(-3.E-1) ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat(.00001)", 0.00001, parseFloat(.00001) ); + array[item++] = new TestCase( SECTION, "parseFloat(-0.0001)", -0.00001, parseFloat(-.00001) ); + + array[item++] = new TestCase( SECTION, "parseFloat(.01e2)", 1, parseFloat(.01e2) ); + array[item++] = new TestCase( SECTION, "parseFloat(-.01e2)", -1, parseFloat(-.01e2) ); + + array[item++] = new TestCase( SECTION, "parseFloat(.01e+2)", 1, parseFloat(.01e+2) ); + array[item++] = new TestCase( SECTION, "parseFloat(-.01e+2)", -1, parseFloat(-.01e+2) ); + + array[item++] = new TestCase( SECTION, "parseFloat(.01e-2)", 0.0001, parseFloat(.01e-2) ); + array[item++] = new TestCase( SECTION, "parseFloat(-.01e-2)", -0.0001, parseFloat(-.01e-2) ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat(1234e5)", 123400000, parseFloat(1234e5) ); + array[item++] = new TestCase( SECTION, "parseFloat(-1234e5)", -123400000, parseFloat(-1234e5) ); + + array[item++] = new TestCase( SECTION, "parseFloat(1234e+5)", 123400000, parseFloat(1234e+5) ); + array[item++] = new TestCase( SECTION, "parseFloat(-1234e+5)", -123400000, parseFloat(-1234e+5) ); + + array[item++] = new TestCase( SECTION, "parseFloat(1234e-5)", 0.01234, parseFloat(1234e-5) ); + array[item++] = new TestCase( SECTION, "parseFloat(-1234e-5)", -0.01234, parseFloat(-1234e-5) ); + + // hex cases should all return 0 (0 is the longest string that satisfies a StringDecimalLiteral) + + array[item++] = new TestCase( SECTION, "parseFloat('0x0')", 0, parseFloat("0x0")); + array[item++] = new TestCase( SECTION, "parseFloat('0x1')", 0, parseFloat("0x1")); + array[item++] = new TestCase( SECTION, "parseFloat('0x2')", 0, parseFloat("0x2")); + array[item++] = new TestCase( SECTION, "parseFloat('0x3')", 0, parseFloat("0x3")); + array[item++] = new TestCase( SECTION, "parseFloat('0x4')", 0, parseFloat("0x4")); + array[item++] = new TestCase( SECTION, "parseFloat('0x5')", 0, parseFloat("0x5")); + array[item++] = new TestCase( SECTION, "parseFloat('0x6')", 0, parseFloat("0x6")); + array[item++] = new TestCase( SECTION, "parseFloat('0x7')", 0, parseFloat("0x7")); + array[item++] = new TestCase( SECTION, "parseFloat('0x8')", 0, parseFloat("0x8")); + array[item++] = new TestCase( SECTION, "parseFloat('0x9')", 0, parseFloat("0x9")); + array[item++] = new TestCase( SECTION, "parseFloat('0xa')", 0, parseFloat("0xa")); + array[item++] = new TestCase( SECTION, "parseFloat('0xb')", 0, parseFloat("0xb")); + array[item++] = new TestCase( SECTION, "parseFloat('0xc')", 0, parseFloat("0xc")); + array[item++] = new TestCase( SECTION, "parseFloat('0xd')", 0, parseFloat("0xd")); + array[item++] = new TestCase( SECTION, "parseFloat('0xe')", 0, parseFloat("0xe")); + array[item++] = new TestCase( SECTION, "parseFloat('0xf')", 0, parseFloat("0xf")); + array[item++] = new TestCase( SECTION, "parseFloat('0xA')", 0, parseFloat("0xA")); + array[item++] = new TestCase( SECTION, "parseFloat('0xB')", 0, parseFloat("0xB")); + array[item++] = new TestCase( SECTION, "parseFloat('0xC')", 0, parseFloat("0xC")); + array[item++] = new TestCase( SECTION, "parseFloat('0xD')", 0, parseFloat("0xD")); + array[item++] = new TestCase( SECTION, "parseFloat('0xE')", 0, parseFloat("0xE")); + array[item++] = new TestCase( SECTION, "parseFloat('0xF')", 0, parseFloat("0xF")); + + array[item++] = new TestCase( SECTION, "parseFloat('0X0')", 0, parseFloat("0X0")); + array[item++] = new TestCase( SECTION, "parseFloat('0X1')", 0, parseFloat("0X1")); + array[item++] = new TestCase( SECTION, "parseFloat('0X2')", 0, parseFloat("0X2")); + array[item++] = new TestCase( SECTION, "parseFloat('0X3')", 0, parseFloat("0X3")); + array[item++] = new TestCase( SECTION, "parseFloat('0X4')", 0, parseFloat("0X4")); + array[item++] = new TestCase( SECTION, "parseFloat('0X5')", 0, parseFloat("0X5")); + array[item++] = new TestCase( SECTION, "parseFloat('0X6')", 0, parseFloat("0X6")); + array[item++] = new TestCase( SECTION, "parseFloat('0X7')", 0, parseFloat("0X7")); + array[item++] = new TestCase( SECTION, "parseFloat('0X8')", 0, parseFloat("0X8")); + array[item++] = new TestCase( SECTION, "parseFloat('0X9')", 0, parseFloat("0X9")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xa')", 0, parseFloat("0Xa")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xb')", 0, parseFloat("0Xb")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xc')", 0, parseFloat("0Xc")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xd')", 0, parseFloat("0Xd")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xe')", 0, parseFloat("0Xe")); + array[item++] = new TestCase( SECTION, "parseFloat('0Xf')", 0, parseFloat("0Xf")); + array[item++] = new TestCase( SECTION, "parseFloat('0XA')", 0, parseFloat("0XA")); + array[item++] = new TestCase( SECTION, "parseFloat('0XB')", 0, parseFloat("0XB")); + array[item++] = new TestCase( SECTION, "parseFloat('0XC')", 0, parseFloat("0XC")); + array[item++] = new TestCase( SECTION, "parseFloat('0XD')", 0, parseFloat("0XD")); + array[item++] = new TestCase( SECTION, "parseFloat('0XE')", 0, parseFloat("0XE")); + array[item++] = new TestCase( SECTION, "parseFloat('0XF')", 0, parseFloat("0XF")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XF ')", 0, parseFloat(" 0XF ")); + + // hex literals should still succeed + + array[item++] = new TestCase( SECTION, "parseFloat(0x0)", 0, parseFloat(0x0)); + array[item++] = new TestCase( SECTION, "parseFloat(0x1)", 1, parseFloat(0x1)); + array[item++] = new TestCase( SECTION, "parseFloat(0x2)", 2, parseFloat(0x2)); + array[item++] = new TestCase( SECTION, "parseFloat(0x3)", 3, parseFloat(0x3)); + array[item++] = new TestCase( SECTION, "parseFloat(0x4)", 4, parseFloat(0x4)); + array[item++] = new TestCase( SECTION, "parseFloat(0x5)", 5, parseFloat(0x5)); + array[item++] = new TestCase( SECTION, "parseFloat(0x6)", 6, parseFloat(0x6)); + array[item++] = new TestCase( SECTION, "parseFloat(0x7)", 7, parseFloat(0x7)); + array[item++] = new TestCase( SECTION, "parseFloat(0x8)", 8, parseFloat(0x8)); + array[item++] = new TestCase( SECTION, "parseFloat(0x9)", 9, parseFloat(0x9)); + array[item++] = new TestCase( SECTION, "parseFloat(0xa)", 10, parseFloat(0xa)); + array[item++] = new TestCase( SECTION, "parseFloat(0xb)", 11, parseFloat(0xb)); + array[item++] = new TestCase( SECTION, "parseFloat(0xc)", 12, parseFloat(0xc)); + array[item++] = new TestCase( SECTION, "parseFloat(0xd)", 13, parseFloat(0xd)); + array[item++] = new TestCase( SECTION, "parseFloat(0xe)", 14, parseFloat(0xe)); + array[item++] = new TestCase( SECTION, "parseFloat(0xf)", 15, parseFloat(0xf)); + array[item++] = new TestCase( SECTION, "parseFloat(0xA)", 10, parseFloat(0xA)); + array[item++] = new TestCase( SECTION, "parseFloat(0xB)", 11, parseFloat(0xB)); + array[item++] = new TestCase( SECTION, "parseFloat(0xC)", 12, parseFloat(0xC)); + array[item++] = new TestCase( SECTION, "parseFloat(0xD)", 13, parseFloat(0xD)); + array[item++] = new TestCase( SECTION, "parseFloat(0xE)", 14, parseFloat(0xE)); + array[item++] = new TestCase( SECTION, "parseFloat(0xF)", 15, parseFloat(0xF)); + + array[item++] = new TestCase( SECTION, "parseFloat(0X0)", 0, parseFloat(0X0)); + array[item++] = new TestCase( SECTION, "parseFloat(0X1)", 1, parseFloat(0X1)); + array[item++] = new TestCase( SECTION, "parseFloat(0X2)", 2, parseFloat(0X2)); + array[item++] = new TestCase( SECTION, "parseFloat(0X3)", 3, parseFloat(0X3)); + array[item++] = new TestCase( SECTION, "parseFloat(0X4)", 4, parseFloat(0X4)); + array[item++] = new TestCase( SECTION, "parseFloat(0X5)", 5, parseFloat(0X5)); + array[item++] = new TestCase( SECTION, "parseFloat(0X6)", 6, parseFloat(0X6)); + array[item++] = new TestCase( SECTION, "parseFloat(0X7)", 7, parseFloat(0X7)); + array[item++] = new TestCase( SECTION, "parseFloat(0X8)", 8, parseFloat(0X8)); + array[item++] = new TestCase( SECTION, "parseFloat(0X9)", 9, parseFloat(0X9)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xa)", 10, parseFloat(0Xa)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xb)", 11, parseFloat(0Xb)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xc)", 12, parseFloat(0Xc)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xd)", 13, parseFloat(0Xd)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xe)", 14, parseFloat(0Xe)); + array[item++] = new TestCase( SECTION, "parseFloat(0Xf)", 15, parseFloat(0Xf)); + array[item++] = new TestCase( SECTION, "parseFloat(0XA)", 10, parseFloat(0XA)); + array[item++] = new TestCase( SECTION, "parseFloat(0XB)", 11, parseFloat(0XB)); + array[item++] = new TestCase( SECTION, "parseFloat(0XC)", 12, parseFloat(0XC)); + array[item++] = new TestCase( SECTION, "parseFloat(0XD)", 13, parseFloat(0XD)); + array[item++] = new TestCase( SECTION, "parseFloat(0XE)", 14, parseFloat(0XE)); + array[item++] = new TestCase( SECTION, "parseFloat(0XF)", 15, parseFloat(0XF)); + + + // A StringNumericLiteral may not use octal notation + + array[item++] = new TestCase( SECTION, "parseFloat('00')", 0, parseFloat("00")); + array[item++] = new TestCase( SECTION, "parseFloat('01')", 1, parseFloat("01")); + array[item++] = new TestCase( SECTION, "parseFloat('02')", 2, parseFloat("02")); + array[item++] = new TestCase( SECTION, "parseFloat('03')", 3, parseFloat("03")); + array[item++] = new TestCase( SECTION, "parseFloat('04')", 4, parseFloat("04")); + array[item++] = new TestCase( SECTION, "parseFloat('05')", 5, parseFloat("05")); + array[item++] = new TestCase( SECTION, "parseFloat('06')", 6, parseFloat("06")); + array[item++] = new TestCase( SECTION, "parseFloat('07')", 7, parseFloat("07")); + array[item++] = new TestCase( SECTION, "parseFloat('010')", 10, parseFloat("010")); + array[item++] = new TestCase( SECTION, "parseFloat('011')", 11, parseFloat("011")); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "parseFloat('001')", 1, parseFloat("001")); + array[item++] = new TestCase( SECTION, "parseFloat('0001')", 1, parseFloat("0001")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0001 ')", 1, parseFloat(" 0001 ")); + + // an octal numeric literal should be treated as an octal + + array[item++] = new TestCase( SECTION, "parseFloat(00)", 0, parseFloat(00)); + array[item++] = new TestCase( SECTION, "parseFloat(01)", 1, parseFloat(01)); + array[item++] = new TestCase( SECTION, "parseFloat(02)", 2, parseFloat(02)); + array[item++] = new TestCase( SECTION, "parseFloat(03)", 3, parseFloat(03)); + array[item++] = new TestCase( SECTION, "parseFloat(04)", 4, parseFloat(04)); + array[item++] = new TestCase( SECTION, "parseFloat(05)", 5, parseFloat(05)); + array[item++] = new TestCase( SECTION, "parseFloat(06)", 6, parseFloat(06)); + array[item++] = new TestCase( SECTION, "parseFloat(07)", 7, parseFloat(07)); + array[item++] = new TestCase( SECTION, "parseFloat(010)", 8, parseFloat(010)); + array[item++] = new TestCase( SECTION, "parseFloat(011)", 9, parseFloat(011)); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); + array[item++] = new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); + + // make sure it's reflexive + array[item++] = new TestCase( SECTION, "parseFloat(Math.PI)", Math.PI, parseFloat(Math.PI)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LN2)", Math.LN2, parseFloat(Math.LN2)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LN10)", Math.LN10, parseFloat(Math.LN10)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG2E)", Math.LOG2E, parseFloat(Math.LOG2E)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG10E)", Math.LOG10E, parseFloat(Math.LOG10E)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT2)", Math.SQRT2, parseFloat(Math.SQRT2)); + array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT1_2)", Math.SQRT1_2, parseFloat(Math.SQRT1_2)); + + array[item++] = new TestCase( SECTION, "parseFloat(Math.PI+'')", Math.PI, parseFloat(Math.PI+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LN2+'')", Math.LN2, parseFloat(Math.LN2+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LN10+'')", Math.LN10, parseFloat(Math.LN10+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG2E+'')", Math.LOG2E, parseFloat(Math.LOG2E+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG10E+'')", Math.LOG10E, parseFloat(Math.LOG10E+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT2+'')", Math.SQRT2, parseFloat(Math.SQRT2+'')); + array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT1_2+'')", Math.SQRT1_2, parseFloat(Math.SQRT1_2+'')); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.3-2.js b/tests/mozilla/ecma/GlobalObject/15.1.2.3-2.js new file mode 100644 index 0000000..c3905c0 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.3-2.js @@ -0,0 +1,295 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.3-2.js + ECMA Section: 15.1.2.3 Function properties of the global object: + parseFloat( string ) + + Description: The parseFloat function produces a number value dictated + by the interpretation of the contents of the string + argument defined as a decimal literal. + + When the parseFloat function is called, the following + steps are taken: + + 1. Call ToString( string ). + 2. Remove leading whitespace Result(1). + 3. If neither Result(2) nor any prefix of Result(2) + satisfies the syntax of a StrDecimalLiteral, + return NaN. + 4. Compute the longest prefix of Result(2) which might + be Resusult(2) itself, that satisfies the syntax of + a StrDecimalLiteral + 5. Return the number value for the MV of Result(4). + + Note that parseFloate may interpret only a leading + portion of the string as a number value; it ignores any + characters that cannot be interpreted as part of the + notation of a decimal literal, and no indication is given + that such characters were ignored. + + StrDecimalLiteral:: + Infinity + DecimalDigits.DecimalDigits opt ExponentPart opt + .DecimalDigits ExponentPart opt + DecimalDigits ExponentPart opt + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.3-2"; + var VERSION = "ECMA_1"; + startTest(); + + var BUGNUMBER = "77391"; + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " parseFloat(string)"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); + array[item++] = new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); + array[item++] = new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' Infinity')", Number.POSITIVE_INFINITY, parseFloat("Infinity") ); +// array[item++] = new TestCase( SECTION, "parseFloat(Infinity)", Number.POSITIVE_INFINITY, parseFloat(Infinity) ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 0')", 0, parseFloat(" 0") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -0')", -0, parseFloat(" -0") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +0')", 0, parseFloat(" +0") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1')", 1, parseFloat(" 1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1')", -1, parseFloat(" -1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1')", 1, parseFloat(" +1") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 2')", 2, parseFloat(" 2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -2')", -2, parseFloat(" -2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +2')", 2, parseFloat(" +2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3')", 3, parseFloat(" 3") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3')", -3, parseFloat(" -3") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3')", 3, parseFloat(" +3") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 4')", 4, parseFloat(" 4") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -4')", -4, parseFloat(" -4") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +4')", 4, parseFloat(" +4") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 5')", 5, parseFloat(" 5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -5')", -5, parseFloat(" -5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +5')", 5, parseFloat(" +5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 6')", 6, parseFloat(" 6") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -6')", -6, parseFloat(" -6") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +6')", 6, parseFloat(" +6") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 7')", 7, parseFloat(" 7") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -7')", -7, parseFloat(" -7") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +7')", 7, parseFloat(" +7") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 8')", 8, parseFloat(" 8") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -8')", -8, parseFloat(" -8") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +8')", 8, parseFloat(" +8") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 9')", 9, parseFloat(" 9") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -9')", -9, parseFloat(" -9") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +9')", 9, parseFloat(" +9") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.14159')", 3.14159, parseFloat(" 3.14159") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.14159')", -3.14159, parseFloat(" -3.14159") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.14159')", 3.14159, parseFloat(" +3.14159") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.')", 3, parseFloat(" 3.") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.')", -3, parseFloat(" -3.") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.')", 3, parseFloat(" +3.") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.e1')", 30, parseFloat(" 3.e1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.e1')", -30, parseFloat(" -3.e1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.e1')", 30, parseFloat(" +3.e1") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.e+1')", 30, parseFloat(" 3.e+1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.e+1')", -30, parseFloat(" -3.e+1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.e+1')", 30, parseFloat(" +3.e+1") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 3.e-1')", .30, parseFloat(" 3.e-1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -3.e-1')", -.30, parseFloat(" -3.e-1") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +3.e-1')", .30, parseFloat(" +3.e-1") ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat(' .00001')", 0.00001, parseFloat(" .00001") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.00001')", 0.00001, parseFloat(" +.00001") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -0.0001')", -0.00001, parseFloat(" -.00001") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01e2')", 1, parseFloat(" .01e2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01e2')", 1, parseFloat(" +.01e2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01e2')", -1, parseFloat(" -.01e2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01e+2')", 1, parseFloat(" .01e+2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01e+2')", 1, parseFloat(" +.01e+2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01e+2')", -1, parseFloat(" -.01e+2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01e-2')", 0.0001, parseFloat(" .01e-2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01e-2')", 0.0001, parseFloat(" +.01e-2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01e-2')", -0.0001, parseFloat(" -.01e-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234e5')", 123400000, parseFloat(" 1234e5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234e5')", 123400000, parseFloat(" +1234e5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234e5')", -123400000, parseFloat(" -1234e5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234e+5')", 123400000, parseFloat(" 1234e+5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234e+5')", 123400000, parseFloat(" +1234e+5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234e+5')", -123400000, parseFloat(" -1234e+5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234e-5')", 0.01234, parseFloat(" 1234e-5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234e-5')", 0.01234, parseFloat(" +1234e-5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234e-5')", -0.01234, parseFloat(" -1234e-5") ); + + + array[item++] = new TestCase( SECTION, "parseFloat(' .01E2')", 1, parseFloat(" .01E2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01E2')", 1, parseFloat(" +.01E2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01E2')", -1, parseFloat(" -.01E2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01E+2')", 1, parseFloat(" .01E+2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01E+2')", 1, parseFloat(" +.01E+2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01E+2')", -1, parseFloat(" -.01E+2") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' .01E-2')", 0.0001, parseFloat(" .01E-2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +.01E-2')", 0.0001, parseFloat(" +.01E-2") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -.01E-2')", -0.0001, parseFloat(" -.01E-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + array[item++] = new TestCase( SECTION, "parseFloat(' 1234E5')", 123400000, parseFloat(" 1234E5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234E5')", 123400000, parseFloat(" +1234E5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234E5')", -123400000, parseFloat(" -1234E5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234E+5')", 123400000, parseFloat(" 1234E+5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234E+5')", 123400000, parseFloat(" +1234E+5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234E+5')", -123400000, parseFloat(" -1234E+5") ); + + array[item++] = new TestCase( SECTION, "parseFloat(' 1234E-5')", 0.01234, parseFloat(" 1234E-5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' +1234E-5')", 0.01234, parseFloat(" +1234E-5") ); + array[item++] = new TestCase( SECTION, "parseFloat(' -1234E-5')", -0.01234, parseFloat(" -1234E-5") ); + + + // hex cases should all return NaN + + array[item++] = new TestCase( SECTION, "parseFloat(' 0x0')", 0, parseFloat(" 0x0")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x1')", 0, parseFloat(" 0x1")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x2')", 0, parseFloat(" 0x2")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x3')", 0, parseFloat(" 0x3")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x4')", 0, parseFloat(" 0x4")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x5')", 0, parseFloat(" 0x5")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x6')", 0, parseFloat(" 0x6")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x7')", 0, parseFloat(" 0x7")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x8')", 0, parseFloat(" 0x8")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0x9')", 0, parseFloat(" 0x9")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xa')", 0, parseFloat(" 0xa")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xb')", 0, parseFloat(" 0xb")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xc')", 0, parseFloat(" 0xc")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xd')", 0, parseFloat(" 0xd")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xe')", 0, parseFloat(" 0xe")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xf')", 0, parseFloat(" 0xf")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xA')", 0, parseFloat(" 0xA")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xB')", 0, parseFloat(" 0xB")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xC')", 0, parseFloat(" 0xC")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xD')", 0, parseFloat(" 0xD")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xE')", 0, parseFloat(" 0xE")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0xF')", 0, parseFloat(" 0xF")); + + array[item++] = new TestCase( SECTION, "parseFloat(' 0X0')", 0, parseFloat(" 0X0")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X1')", 0, parseFloat(" 0X1")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X2')", 0, parseFloat(" 0X2")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X3')", 0, parseFloat(" 0X3")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X4')", 0, parseFloat(" 0X4")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X5')", 0, parseFloat(" 0X5")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X6')", 0, parseFloat(" 0X6")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X7')", 0, parseFloat(" 0X7")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X8')", 0, parseFloat(" 0X8")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0X9')", 0, parseFloat(" 0X9")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xa')", 0, parseFloat(" 0Xa")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xb')", 0, parseFloat(" 0Xb")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xc')", 0, parseFloat(" 0Xc")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xd')", 0, parseFloat(" 0Xd")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xe')", 0, parseFloat(" 0Xe")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0Xf')", 0, parseFloat(" 0Xf")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XA')", 0, parseFloat(" 0XA")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XB')", 0, parseFloat(" 0XB")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XC')", 0, parseFloat(" 0XC")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XD')", 0, parseFloat(" 0XD")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XE')", 0, parseFloat(" 0XE")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0XF')", 0, parseFloat(" 0XF")); + + // A StringNumericLiteral may not use octal notation + + array[item++] = new TestCase( SECTION, "parseFloat(' 00')", 0, parseFloat(" 00")); + array[item++] = new TestCase( SECTION, "parseFloat(' 01')", 1, parseFloat(" 01")); + array[item++] = new TestCase( SECTION, "parseFloat(' 02')", 2, parseFloat(" 02")); + array[item++] = new TestCase( SECTION, "parseFloat(' 03')", 3, parseFloat(" 03")); + array[item++] = new TestCase( SECTION, "parseFloat(' 04')", 4, parseFloat(" 04")); + array[item++] = new TestCase( SECTION, "parseFloat(' 05')", 5, parseFloat(" 05")); + array[item++] = new TestCase( SECTION, "parseFloat(' 06')", 6, parseFloat(" 06")); + array[item++] = new TestCase( SECTION, "parseFloat(' 07')", 7, parseFloat(" 07")); + array[item++] = new TestCase( SECTION, "parseFloat(' 010')", 10, parseFloat(" 010")); + array[item++] = new TestCase( SECTION, "parseFloat(' 011')", 11, parseFloat(" 011")); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "parseFloat(' 001')", 1, parseFloat(" 001")); + array[item++] = new TestCase( SECTION, "parseFloat(' 0001')", 1, parseFloat(" 0001")); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); + array[item++] = new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); + + // make sure it' s reflexive + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.PI+' ')", Math.PI, parseFloat( ' ' +Math.PI+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LN2+' ')", Math.LN2, parseFloat( ' ' +Math.LN2+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LN10+' ')", Math.LN10, parseFloat( ' ' +Math.LN10+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LOG2E+' ')", Math.LOG2E, parseFloat( ' ' +Math.LOG2E+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LOG10E+' ')", Math.LOG10E, parseFloat( ' ' +Math.LOG10E+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT2+' ')", Math.SQRT2, parseFloat( ' ' +Math.SQRT2+' ')); + array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT1_2+' ')", Math.SQRT1_2, parseFloat( ' ' +Math.SQRT1_2+' ')); + + + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.4.js b/tests/mozilla/ecma/GlobalObject/15.1.2.4.js new file mode 100644 index 0000000..386f3a6 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.4.js @@ -0,0 +1,206 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.4.js + ECMA Section: 15.1.2.4 Function properties of the global object + escape( string ) + + Description: + The escape function computes a new version of a string value in which + certain characters have been replaced by a hexadecimal escape sequence. + The result thus contains no special characters that might have special + meaning within a URL. + + For characters whose Unicode encoding is 0xFF or less, a two-digit + escape sequence of the form %xx is used in accordance with RFC1738. + For characters whose Unicode encoding is greater than 0xFF, a four- + digit escape sequence of the form %uxxxx is used. + + When the escape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Get the character at position k within Result(1). + 7. If Result(6) is one of the 69 nonblank ASCII characters + ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz + 0123456789 @*_+-./, go to step 14. + 8. Compute the 16-bit unsigned integer that is the Unicode character + encoding of Result(6). + 9. If Result(8), is less than 256, go to step 12. + 10. Let S be a string containing six characters "%uwxyz" where wxyz are + four hexadecimal digits encoding the value of Result(8). + 11. Go to step 15. + 12. Let S be a string containing three characters "%xy" where xy are two + hexadecimal digits encoding the value of Result(8). + 13. Go to step 15. + 14. Let S be a string containing the single character Result(6). + 15. Let R be a new string value computed by concatenating the previous value + of R and S. + 16. Increase k by 1. + 17. Go to step 5. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "escape(string)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "escape.length", 1, escape.length ); + array[item++] = new TestCase( SECTION, "escape.length = null; escape.length", 1, eval("escape.length = null; escape.length") ); + array[item++] = new TestCase( SECTION, "delete escape.length", false, delete escape.length ); + array[item++] = new TestCase( SECTION, "delete escape.length; escape.length", 1, eval("delete escape.length; escape.length") ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS", "", eval("var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "escape()", "undefined", escape() ); + array[item++] = new TestCase( SECTION, "escape('')", "", escape('') ); + array[item++] = new TestCase( SECTION, "escape( null )", "null", escape(null) ); + array[item++] = new TestCase( SECTION, "escape( void 0 )", "undefined", escape(void 0) ); + array[item++] = new TestCase( SECTION, "escape( true )", "true", escape( true ) ); + array[item++] = new TestCase( SECTION, "escape( false )", "false", escape( false ) ); + + array[item++] = new TestCase( SECTION, "escape( new Boolean(true) )", "true", escape(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "escape( new Boolean(false) )", "false", escape(new Boolean(false)) ); + + array[item++] = new TestCase( SECTION, "escape( Number.NaN )", "NaN", escape(Number.NaN) ); + array[item++] = new TestCase( SECTION, "escape( -0 )", "0", escape( -0 ) ); + array[item++] = new TestCase( SECTION, "escape( 'Infinity' )", "Infinity", escape( "Infinity" ) ); + array[item++] = new TestCase( SECTION, "escape( Number.POSITIVE_INFINITY )", "Infinity", escape( Number.POSITIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "escape( Number.NEGATIVE_INFINITY )", "-Infinity", escape( Number.NEGATIVE_INFINITY ) ); + + var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; + + array[item++] = new TestCase( SECTION, "escape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, escape( ASCII_TEST_STRING ) ); + + // ASCII value less than + + for ( var CHARCODE = 0; CHARCODE < 32; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%"+ToHexString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); + } + for ( var CHARCODE = 128; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%"+ToHexString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); + } + + for ( var CHARCODE = 256; CHARCODE < 1024; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%u"+ ToUnicodeString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); + } + for ( var CHARCODE = 65500; CHARCODE < 65536; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%u"+ ToUnicodeString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); + } + + return ( array ); +} + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.5-1.js b/tests/mozilla/ecma/GlobalObject/15.1.2.5-1.js new file mode 100644 index 0000000..da1a6f9 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.5-1.js @@ -0,0 +1,207 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.5-1.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + + Description: + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + + var SECTION = "15.1.2.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "unescape(string)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "unescape.length", 1, unescape.length ); + array[item++] = new TestCase( SECTION, "unescape.length = null; unescape.length", 1, eval("unescape.length=null; unescape.length") ); + array[item++] = new TestCase( SECTION, "delete unescape.length", false, delete unescape.length ); + array[item++] = new TestCase( SECTION, "delete unescape.length; unescape.length", 1, eval("delete unescape.length; unescape.length") ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "unescape()", "undefined", unescape() ); + array[item++] = new TestCase( SECTION, "unescape('')", "", unescape('') ); + array[item++] = new TestCase( SECTION, "unescape( null )", "null", unescape(null) ); + array[item++] = new TestCase( SECTION, "unescape( void 0 )", "undefined", unescape(void 0) ); + array[item++] = new TestCase( SECTION, "unescape( true )", "true", unescape( true ) ); + array[item++] = new TestCase( SECTION, "unescape( false )", "false", unescape( false ) ); + + array[item++] = new TestCase( SECTION, "unescape( new Boolean(true) )", "true", unescape(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "unescape( new Boolean(false) )", "false", unescape(new Boolean(false)) ); + + array[item++] = new TestCase( SECTION, "unescape( Number.NaN )", "NaN", unescape(Number.NaN) ); + array[item++] = new TestCase( SECTION, "unescape( -0 )", "0", unescape( -0 ) ); + array[item++] = new TestCase( SECTION, "unescape( 'Infinity' )", "Infinity", unescape( "Infinity" ) ); + array[item++] = new TestCase( SECTION, "unescape( Number.POSITIVE_INFINITY )", "Infinity", unescape( Number.POSITIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "unescape( Number.NEGATIVE_INFINITY )", "-Infinity", unescape( Number.NEGATIVE_INFINITY ) ); + + var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; + + array[item++] = new TestCase( SECTION, "unescape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, unescape( ASCII_TEST_STRING ) ); + + // escaped chars with ascii values less than 256 + + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "unescape( %"+ ToHexString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%" + ToHexString(CHARCODE) ) ); + } + + // unicode chars represented by two hex digits + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "unescape( %u"+ ToHexString(CHARCODE)+" )", + "%u"+ToHexString(CHARCODE), + unescape( "%u" + ToHexString(CHARCODE) ) ); + } +/* + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%u" + ToUnicodeString(CHARCODE) ) ); + } + for ( var CHARCODE = 256; CHARCODE < 65536; CHARCODE+= 333 ) { + array[item++] = new TestCase( SECTION, + "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%u" + ToUnicodeString(CHARCODE) ) ); + } +*/ + return ( array ); +} + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.5-2.js b/tests/mozilla/ecma/GlobalObject/15.1.2.5-2.js new file mode 100644 index 0000000..d8fc253 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.5-2.js @@ -0,0 +1,184 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.5-2.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + Description: + + This tests the cases where there are fewer than 4 characters following "%u", + or fewer than 2 characters following "%" or "%u". + + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + + var SECTION = "15.1.2.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "unescape(string)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // since there is only one character following "%", no conversion should occur. + + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE += 16 ) { + array[item++] = new TestCase( SECTION, + "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) +" )", + "%"+(ToHexString(CHARCODE)).substring(0,1), + unescape( "%" + (ToHexString(CHARCODE)).substring(0,1) ) ); + } + + // since there is only one character following "%u", no conversion should occur. + + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE +=16 ) { + array[item++] = new TestCase( SECTION, + "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) +" )", + "%u"+(ToHexString(CHARCODE)).substring(0,1), + unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1) ) ); + } + + + // three char unicode string. no conversion should occur + + for ( var CHARCODE = 1024; CHARCODE < 65536; CHARCODE+= 1234 ) { + array[item++] = new TestCase + ( SECTION, + "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3)+ " )", + + "%u"+(ToUnicodeString(CHARCODE)).substring(0,3), + unescape( "%u"+(ToUnicodeString(CHARCODE)).substring(0,3) ) + ); + } + + return ( array ); +} + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.5-3.js b/tests/mozilla/ecma/GlobalObject/15.1.2.5-3.js new file mode 100644 index 0000000..9fa83f3 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.5-3.js @@ -0,0 +1,207 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.5-3.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + + Description: + This tests the cases where one of the four characters following "%u" is + not a hexidecimal character, or one of the two characters following "%" + or "%u" is not a hexidecimal character. + + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + + + var SECTION = "15.1.2.5-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "unescape(string)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + array[item++] = new TestCase( SECTION, + "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + "%"+(ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ), + unescape( "%" + (ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); + } + for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + array[item++] = new TestCase( SECTION, + "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + "%u"+(ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ), + unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); + } + + for ( var CHARCODE = 0, NONHEXCHARCODE = 0 ; CHARCODE < 65536; CHARCODE+= 54321, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + array[item++] = new TestCase( SECTION, + "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + + String.fromCharCode(eval("0x"+ (ToUnicodeString(CHARCODE)).substring(0,2))) + + (ToUnicodeString(CHARCODE)).substring(2,3) + + String.fromCharCode( NONHEXCHARCODE ), + + unescape( "%" + (ToUnicodeString(CHARCODE)).substring(0,3)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); + } + + return ( array ); +} +function getNextNonHexCharCode( n ) { + for ( ; n < Math.pow(2,16); n++ ) { + if ( ( n == 43 || n == 45 || n == 46 || n == 47 || + (n >= 71 && n <= 90) || (n >= 103 && n <= 122) || + n == 64 || n == 95 ) ) { + break; + } else { + n = ( n > 122 ) ? 0 : n; + } + } + return n; +} +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.6.js b/tests/mozilla/ecma/GlobalObject/15.1.2.6.js new file mode 100644 index 0000000..053dab4 --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.6.js @@ -0,0 +1,127 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.6.js + ECMA Section: 15.1.2.6 isNaN( x ) + + Description: Applies ToNumber to its argument, then returns true if + the result isNaN and otherwise returns false. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "isNaN( x )"; + + var BUGNUMBER = "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "isNaN.length", 1, isNaN.length ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS") ); + array[item++] = new TestCase( SECTION, "isNaN.length = null; isNaN.length", 1, eval("isNaN.length=null; isNaN.length") ); + array[item++] = new TestCase( SECTION, "delete isNaN.length", false, delete isNaN.length ); + array[item++] = new TestCase( SECTION, "delete isNaN.length; isNaN.length", 1, eval("delete isNaN.length; isNaN.length") ); + +// array[item++] = new TestCase( SECTION, "isNaN.__proto__", Function.prototype, isNaN.__proto__ ); + + array[item++] = new TestCase( SECTION, "isNaN()", true, isNaN() ); + array[item++] = new TestCase( SECTION, "isNaN( null )", false, isNaN(null) ); + array[item++] = new TestCase( SECTION, "isNaN( void 0 )", true, isNaN(void 0) ); + array[item++] = new TestCase( SECTION, "isNaN( true )", false, isNaN(true) ); + array[item++] = new TestCase( SECTION, "isNaN( false)", false, isNaN(false) ); + array[item++] = new TestCase( SECTION, "isNaN( ' ' )", false, isNaN( " " ) ); + + array[item++] = new TestCase( SECTION, "isNaN( 0 )", false, isNaN(0) ); + array[item++] = new TestCase( SECTION, "isNaN( 1 )", false, isNaN(1) ); + array[item++] = new TestCase( SECTION, "isNaN( 2 )", false, isNaN(2) ); + array[item++] = new TestCase( SECTION, "isNaN( 3 )", false, isNaN(3) ); + array[item++] = new TestCase( SECTION, "isNaN( 4 )", false, isNaN(4) ); + array[item++] = new TestCase( SECTION, "isNaN( 5 )", false, isNaN(5) ); + array[item++] = new TestCase( SECTION, "isNaN( 6 )", false, isNaN(6) ); + array[item++] = new TestCase( SECTION, "isNaN( 7 )", false, isNaN(7) ); + array[item++] = new TestCase( SECTION, "isNaN( 8 )", false, isNaN(8) ); + array[item++] = new TestCase( SECTION, "isNaN( 9 )", false, isNaN(9) ); + + array[item++] = new TestCase( SECTION, "isNaN( '0' )", false, isNaN('0') ); + array[item++] = new TestCase( SECTION, "isNaN( '1' )", false, isNaN('1') ); + array[item++] = new TestCase( SECTION, "isNaN( '2' )", false, isNaN('2') ); + array[item++] = new TestCase( SECTION, "isNaN( '3' )", false, isNaN('3') ); + array[item++] = new TestCase( SECTION, "isNaN( '4' )", false, isNaN('4') ); + array[item++] = new TestCase( SECTION, "isNaN( '5' )", false, isNaN('5') ); + array[item++] = new TestCase( SECTION, "isNaN( '6' )", false, isNaN('6') ); + array[item++] = new TestCase( SECTION, "isNaN( '7' )", false, isNaN('7') ); + array[item++] = new TestCase( SECTION, "isNaN( '8' )", false, isNaN('8') ); + array[item++] = new TestCase( SECTION, "isNaN( '9' )", false, isNaN('9') ); + + + array[item++] = new TestCase( SECTION, "isNaN( 0x0a )", false, isNaN( 0x0a ) ); + array[item++] = new TestCase( SECTION, "isNaN( 0xaa )", false, isNaN( 0xaa ) ); + array[item++] = new TestCase( SECTION, "isNaN( 0x0A )", false, isNaN( 0x0A ) ); + array[item++] = new TestCase( SECTION, "isNaN( 0xAA )", false, isNaN( 0xAA ) ); + + array[item++] = new TestCase( SECTION, "isNaN( '0x0a' )", false, isNaN( "0x0a" ) ); + array[item++] = new TestCase( SECTION, "isNaN( '0xaa' )", false, isNaN( "0xaa" ) ); + array[item++] = new TestCase( SECTION, "isNaN( '0x0A' )", false, isNaN( "0x0A" ) ); + array[item++] = new TestCase( SECTION, "isNaN( '0xAA' )", false, isNaN( "0xAA" ) ); + + array[item++] = new TestCase( SECTION, "isNaN( 077 )", false, isNaN( 077 ) ); + array[item++] = new TestCase( SECTION, "isNaN( '077' )", false, isNaN( "077" ) ); + + + array[item++] = new TestCase( SECTION, "isNaN( Number.NaN )", true, isNaN(Number.NaN) ); + array[item++] = new TestCase( SECTION, "isNaN( Number.POSITIVE_INFINITY )", false, isNaN(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "isNaN( Number.NEGATIVE_INFINITY )", false, isNaN(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "isNaN( Number.MAX_VALUE )", false, isNaN(Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "isNaN( Number.MIN_VALUE )", false, isNaN(Number.MIN_VALUE) ); + + array[item++] = new TestCase( SECTION, "isNaN( NaN )", true, isNaN(NaN) ); + array[item++] = new TestCase( SECTION, "isNaN( Infinity )", false, isNaN(Infinity) ); + + array[item++] = new TestCase( SECTION, "isNaN( 'Infinity' )", false, isNaN("Infinity") ); + array[item++] = new TestCase( SECTION, "isNaN( '-Infinity' )", false, isNaN("-Infinity") ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/GlobalObject/15.1.2.7.js b/tests/mozilla/ecma/GlobalObject/15.1.2.7.js new file mode 100644 index 0000000..df384fa --- /dev/null +++ b/tests/mozilla/ecma/GlobalObject/15.1.2.7.js @@ -0,0 +1,131 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.1.2.7.js + ECMA Section: 15.1.2.7 isFinite(number) + + Description: Applies ToNumber to its argument, then returns false if + the result is NaN, Infinity, or -Infinity, and otherwise + returns true. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.1.2.7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "isFinite( x )"; + + var BUGNUMBER= "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "isFinite.length", 1, isFinite.length ); + array[item++] = new TestCase( SECTION, "isFinite.length = null; isFinite.length", 1, eval("isFinite.length=null; isFinite.length") ); + array[item++] = new TestCase( SECTION, "delete isFinite.length", false, delete isFinite.length ); + array[item++] = new TestCase( SECTION, "delete isFinite.length; isFinite.length", 1, eval("delete isFinite.length; isFinite.length") ); + array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( p in isFinite ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( p in isFinite ) { MYPROPS += p }; MYPROPS") ); + + array[item++] = new TestCase( SECTION, "isFinite()", false, isFinite() ); + array[item++] = new TestCase( SECTION, "isFinite( null )", true, isFinite(null) ); + array[item++] = new TestCase( SECTION, "isFinite( void 0 )", false, isFinite(void 0) ); + array[item++] = new TestCase( SECTION, "isFinite( false )", true, isFinite(false) ); + array[item++] = new TestCase( SECTION, "isFinite( true)", true, isFinite(true) ); + array[item++] = new TestCase( SECTION, "isFinite( ' ' )", true, isFinite( " " ) ); + + array[item++] = new TestCase( SECTION, "isFinite( new Boolean(true) )", true, isFinite(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "isFinite( new Boolean(false) )", true, isFinite(new Boolean(false)) ); + + array[item++] = new TestCase( SECTION, "isFinite( 0 )", true, isFinite(0) ); + array[item++] = new TestCase( SECTION, "isFinite( 1 )", true, isFinite(1) ); + array[item++] = new TestCase( SECTION, "isFinite( 2 )", true, isFinite(2) ); + array[item++] = new TestCase( SECTION, "isFinite( 3 )", true, isFinite(3) ); + array[item++] = new TestCase( SECTION, "isFinite( 4 )", true, isFinite(4) ); + array[item++] = new TestCase( SECTION, "isFinite( 5 )", true, isFinite(5) ); + array[item++] = new TestCase( SECTION, "isFinite( 6 )", true, isFinite(6) ); + array[item++] = new TestCase( SECTION, "isFinite( 7 )", true, isFinite(7) ); + array[item++] = new TestCase( SECTION, "isFinite( 8 )", true, isFinite(8) ); + array[item++] = new TestCase( SECTION, "isFinite( 9 )", true, isFinite(9) ); + + array[item++] = new TestCase( SECTION, "isFinite( '0' )", true, isFinite('0') ); + array[item++] = new TestCase( SECTION, "isFinite( '1' )", true, isFinite('1') ); + array[item++] = new TestCase( SECTION, "isFinite( '2' )", true, isFinite('2') ); + array[item++] = new TestCase( SECTION, "isFinite( '3' )", true, isFinite('3') ); + array[item++] = new TestCase( SECTION, "isFinite( '4' )", true, isFinite('4') ); + array[item++] = new TestCase( SECTION, "isFinite( '5' )", true, isFinite('5') ); + array[item++] = new TestCase( SECTION, "isFinite( '6' )", true, isFinite('6') ); + array[item++] = new TestCase( SECTION, "isFinite( '7' )", true, isFinite('7') ); + array[item++] = new TestCase( SECTION, "isFinite( '8' )", true, isFinite('8') ); + array[item++] = new TestCase( SECTION, "isFinite( '9' )", true, isFinite('9') ); + + array[item++] = new TestCase( SECTION, "isFinite( 0x0a )", true, isFinite( 0x0a ) ); + array[item++] = new TestCase( SECTION, "isFinite( 0xaa )", true, isFinite( 0xaa ) ); + array[item++] = new TestCase( SECTION, "isFinite( 0x0A )", true, isFinite( 0x0A ) ); + array[item++] = new TestCase( SECTION, "isFinite( 0xAA )", true, isFinite( 0xAA ) ); + + array[item++] = new TestCase( SECTION, "isFinite( '0x0a' )", true, isFinite( "0x0a" ) ); + array[item++] = new TestCase( SECTION, "isFinite( '0xaa' )", true, isFinite( "0xaa" ) ); + array[item++] = new TestCase( SECTION, "isFinite( '0x0A' )", true, isFinite( "0x0A" ) ); + array[item++] = new TestCase( SECTION, "isFinite( '0xAA' )", true, isFinite( "0xAA" ) ); + + array[item++] = new TestCase( SECTION, "isFinite( 077 )", true, isFinite( 077 ) ); + array[item++] = new TestCase( SECTION, "isFinite( '077' )", true, isFinite( "077" ) ); + + array[item++] = new TestCase( SECTION, "isFinite( new String('Infinity') )", false, isFinite(new String("Infinity")) ); + array[item++] = new TestCase( SECTION, "isFinite( new String('-Infinity') )", false, isFinite(new String("-Infinity")) ); + + array[item++] = new TestCase( SECTION, "isFinite( 'Infinity' )", false, isFinite("Infinity") ); + array[item++] = new TestCase( SECTION, "isFinite( '-Infinity' )", false, isFinite("-Infinity") ); + array[item++] = new TestCase( SECTION, "isFinite( Number.POSITIVE_INFINITY )", false, isFinite(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "isFinite( Number.NEGATIVE_INFINITY )", false, isFinite(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "isFinite( Number.NaN )", false, isFinite(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "isFinite( Infinity )", false, isFinite(Infinity) ); + array[item++] = new TestCase( SECTION, "isFinite( -Infinity )", false, isFinite(-Infinity) ); + array[item++] = new TestCase( SECTION, "isFinite( NaN )", false, isFinite(NaN) ); + + + array[item++] = new TestCase( SECTION, "isFinite( Number.MAX_VALUE )", true, isFinite(Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "isFinite( Number.MIN_VALUE )", true, isFinite(Number.MIN_VALUE) ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.1-1.js b/tests/mozilla/ecma/LexicalConventions/7.1-1.js new file mode 100644 index 0000000..d801063 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.1-1.js @@ -0,0 +1,86 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.1-1.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token + + white space characters are: + unicode name formal name string representation + \u0009 tab \t + \u000B veritical tab \v + \U000C form feed \f + \u0020 space " " + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "7.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "White Space"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + // whitespace between var keyword and identifier + + array[item++] = new TestCase( SECTION, 'var'+'\t'+'MYVAR1=10;MYVAR1', 10, eval('var'+'\t'+'MYVAR1=10;MYVAR1') ); + array[item++] = new TestCase( SECTION, 'var'+'\f'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\f'+'MYVAR2=10;MYVAR2') ); + array[item++] = new TestCase( SECTION, 'var'+'\v'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\v'+'MYVAR2=10;MYVAR2') ); + array[item++] = new TestCase( SECTION, 'var'+'\ '+'MYVAR2=10;MYVAR2', 10, eval('var'+'\ '+'MYVAR2=10;MYVAR2') ); + + // use whitespace between tokens object name, dot operator, and object property + + array[item++] = new TestCase( SECTION, + "var a = new Array(12345); a\t\v\f .\\u0009\\000B\\u000C\\u0020length", + 12345, + eval("var a = new Array(12345); a\t\v\f .\u0009\u0020\u000C\u000Blength") ); + + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/LexicalConventions/7.1-2.js b/tests/mozilla/ecma/LexicalConventions/7.1-2.js new file mode 100644 index 0000000..04da3c9 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.1-2.js @@ -0,0 +1,74 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.1-2.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token + + white space characters are: + unicode name formal name string representation + \u0009 tab \t + \u000B veritical tab ?? + \U000C form feed \f + \u0020 space " " + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "7.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "White Space"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); + array[item++] = new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); + array[item++] = new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); + array[item++] = new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/LexicalConventions/7.1-3.js b/tests/mozilla/ecma/LexicalConventions/7.1-3.js new file mode 100644 index 0000000..c9c6ae1 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.1-3.js @@ -0,0 +1,92 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.1-3.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token + + white space characters are: + unicode name formal name string representation + \u0009 tab \t + \u000B veritical tab ?? + \U000C form feed \f + \u0020 space " " + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "7.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "White Space"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); + array[item++] = new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); + array[item++] = new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); + array[item++] = new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); + + // ++ should be interpreted as the unary + operator twice, not as a post or prefix increment operator + + array[item++] = new TestCase( SECTION, + "var VAR = 12345; + + VAR", + 12345, + eval("var VAR = 12345; + + VAR") ); + + array[item++] = new TestCase( SECTION, + "var VAR = 12345;VAR+ + VAR", + 24690, + eval("var VAR = 12345;VAR+ +VAR") ); + array[item++] = new TestCase( SECTION, + "var VAR = 12345;VAR - - VAR", + 24690, + eval("var VAR = 12345;VAR- -VAR") ); + + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.2-1.js b/tests/mozilla/ecma/LexicalConventions/7.2-1.js new file mode 100644 index 0000000..4936984 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.2-1.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.2-1.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var a\nb = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); + array[item++] = new TestCase( SECTION, "var a\nb = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); + array[item++] = new TestCase( SECTION, "var a\rb = 5; ab=10;ab;", 10, eval("var a\rb = 5; ab=10;ab") ); + array[item++] = new TestCase( SECTION, "var a\rb = 5; ab=10;b;", 5, eval("var a\rb = 5; ab=10;b") ); + array[item++] = new TestCase( SECTION, "var a\r\nb = 5; ab=10;ab;", 10, eval("var a\r\nb = 5; ab=10;ab") ); + array[item++] = new TestCase( SECTION, "var a\r\nb = 5; ab=10;b;", 5, eval("var a\r\nb = 5; ab=10;b") ); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.2-2-n.js b/tests/mozilla/ecma/LexicalConventions/7.2-2-n.js new file mode 100644 index 0000000..268fc56 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.2-2-n.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + // this is line 29 + a = "\r\r\r\nb"; + eval( a ); + + // if we get this far, the test failed. + testcases[tc].passed = writeTestCaseResult( + "failure on line" + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[0].passed = false; + + testcases[tc].reason = "test should have caused runtime error "; + + stopTest(); + + return ( testcases ); +} + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[0] = new TestCase( "7.2", "a", "error", ""); + + return ( array ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.2-3-n.js b/tests/mozilla/ecma/LexicalConventions/7.2-3-n.js new file mode 100644 index 0000000..ff3753d --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.2-3-n.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.2-3.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + + // this is line 27 + + a = "\r\nb"; + eval( a ); + + // if we get this far, the test failed. + testcases[tc].passed = writeTestCaseResult( + "failure on line" + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[0].passed = false; + + testcases[tc].reason = "test should have caused runtime error "; + + stopTest(); + return ( testcases ); +} + + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[0] = new TestCase( "7.2", "a", "error", ""); + + return ( array ); +} + diff --git a/tests/mozilla/ecma/LexicalConventions/7.2-4-n.js b/tests/mozilla/ecma/LexicalConventions/7.2-4-n.js new file mode 100644 index 0000000..0f98b9b --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.2-4-n.js @@ -0,0 +1,82 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + // this is line 33 + + a = "\nb"; + eval( a ); + + // if we get this far, the test failed. + testcases[tc].passed = writeTestCaseResult( + "failure on line" + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[0].passed = false; + + testcases[tc].reason = "test should have caused runtime error "; + + stopTest(); + + return ( testcases ); +} + + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[0] = new TestCase( "7.2", "a = \\nb", "error", ""); + + return ( array ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.2-5-n.js b/tests/mozilla/ecma/LexicalConventions/7.2-5-n.js new file mode 100644 index 0000000..b226a98 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.2-5-n.js @@ -0,0 +1,85 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function test() { + // this is line 27 + + a = "\rb"; + eval( a ); + + // if we get this far, the test failed. + testcases[tc].passed = writeTestCaseResult( + "failure on line" + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].passed = false; + + testcases[tc].reason = "test should have caused runtime error "; + + passed = false; + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} + + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[0] = new TestCase( "7.2", "a", "error", ""); + + return ( array ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.2-6.js b/tests/mozilla/ecma/LexicalConventions/7.2-6.js new file mode 100644 index 0000000..70cff7e --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.2-6.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.2-6.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.2-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Line Terminators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var a\u000Ab = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); + array[item++] = new TestCase( SECTION, "var a\u000Db = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-1.js b/tests/mozilla/ecma/LexicalConventions/7.3-1.js new file mode 100644 index 0000000..ff94a3c --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-1.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-1.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item] = new TestCase( SECTION, + "a comment with a line terminator string, and text following", + "pass", + "pass"); + + // "\u000A" array[item].actual = "fail"; + + item++; + + array[item] = new TestCase( SECTION, + "// test \\n array[item].actual = \"pass\"", + "pass", + "" ); + + var x = "// test \n array[item].actual = 'pass'" + + array[0].actual = eval(x); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-10.js b/tests/mozilla/ecma/LexicalConventions/7.3-10.js new file mode 100644 index 0000000..ed4a5b3 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-10.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-10.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); + return ( array ); +} +function test() { + + /*//*/testcases[tc].actual="pass"; + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-11.js b/tests/mozilla/ecma/LexicalConventions/7.3-11.js new file mode 100644 index 0000000..8b6773a --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-11.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-11.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "pass"); + return ( array ); +} +function test() { + + ////testcases[tc].actual="fail"; + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-12.js b/tests/mozilla/ecma/LexicalConventions/7.3-12.js new file mode 100644 index 0000000..fede098 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-12.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-12.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "pass"); + return ( array ); +} +function test() { + + /*testcases[tc].actual="fail";**/ + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-13-n.js b/tests/mozilla/ecma/LexicalConventions/7.3-13-n.js new file mode 100644 index 0000000..92394e6 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-13-n.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-13-n.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-13-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "nested comment", + "error", + "pass"); + return ( array ); +} +function test() { + + /*/*testcases[tc].actual="fail";*/*/ + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-2.js b/tests/mozilla/ecma/LexicalConventions/7.3-2.js new file mode 100644 index 0000000..8eca512 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-2.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-2.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "a comment with a carriage return, and text following", + "pass", + "pass"); + return ( array ); +} +function test() { + + // "\u000D" testcases[tc].actual = "fail"; + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-3.js b/tests/mozilla/ecma/LexicalConventions/7.3-3.js new file mode 100644 index 0000000..1bcd561 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-3.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-3.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "source text directly following a single-line comment", + "pass", + "fail"); + return ( array ); +} +function test() { + + // a comment string + testcases[tc].actual = "pass"; + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-4.js b/tests/mozilla/ecma/LexicalConventions/7.3-4.js new file mode 100644 index 0000000..7ac82c7 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-4.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-4.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "multiline comment ", + "pass", + "pass"); + return ( array ); +} +function test() { + + /*testcases[tc].actual = "fail";*/ + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-5.js b/tests/mozilla/ecma/LexicalConventions/7.3-5.js new file mode 100644 index 0000000..2ce6844 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-5.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-5.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "a comment with a carriage return, and text following", + "pass", + "pass"); + return ( array ); +} +function test() { + + // "\u000A" testcases[tc].actual = "fail"; + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-6.js b/tests/mozilla/ecma/LexicalConventions/7.3-6.js new file mode 100644 index 0000000..d010817 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-6.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-6.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "comment with multiple asterisks", + "pass", + "fail"); + return ( array ); +} +function test() { + + /* + ***/testcases[tc].actual="pass"; + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-7.js b/tests/mozilla/ecma/LexicalConventions/7.3-7.js new file mode 100644 index 0000000..8bdf623 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-7.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-7.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "single line comment following multiline comment", + "pass", + "pass"); + return ( array ); +} +function test() { + + /* + ***///testcases[tc].actual="fail"; + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-8.js b/tests/mozilla/ecma/LexicalConventions/7.3-8.js new file mode 100644 index 0000000..6d686cf --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-8.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-7.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); + return ( array ); +} +function test() { + + /**/testcases[tc].actual="pass"; + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.3-9.js b/tests/mozilla/ecma/LexicalConventions/7.3-9.js new file mode 100644 index 0000000..701e115 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.3-9.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.3-9.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.3-9"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Comments"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); + return ( array ); +} +function test() { + + /*/*/testcases[tc].actual="pass"; + + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.1-1-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.1-1-n.js new file mode 100644 index 0000000..37b1c4e --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.1-1-n.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.1-1-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var null = true", "error", "var null = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.1-2-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.1-2-n.js new file mode 100644 index 0000000..f85891b --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.1-2-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.1-2.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var true = false", "error", "var true = false" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.1-3-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.1-3-n.js new file mode 100644 index 0000000..a05480a --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.1-3-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.1-3-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var false = true", "error", "var false = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-1-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-1-n.js new file mode 100644 index 0000000..43d0425 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-1-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-1.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var break = true", "error", "var break = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-10-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-10-n.js new file mode 100644 index 0000000..0ad19db --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-10-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-10.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-10-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var if = true", "error", "var if = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-11-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-11-n.js new file mode 100644 index 0000000..e8a0f80 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-11-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-11-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-11-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var this = true", "error", "var this = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-12-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-12-n.js new file mode 100644 index 0000000..ffc3350 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-12-n.js @@ -0,0 +1,77 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-12-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-12-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var while = true", "error", "var while = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-13-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-13-n.js new file mode 100644 index 0000000..78320b2 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-13-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-13-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-13-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var else = true", "error", "var else = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-14-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-14-n.js new file mode 100644 index 0000000..4b8bb0f --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-14-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-14-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-14-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var in = true", "error", "var in = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-15-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-15-n.js new file mode 100644 index 0000000..d84f9d7 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-15-n.js @@ -0,0 +1,77 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-15-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-15-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var typeof = true", "error", "var typeof = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-16-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-16-n.js new file mode 100644 index 0000000..8293eee --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-16-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-16-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-16-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var with = true", "error", "var with = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-2-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-2-n.js new file mode 100644 index 0000000..2b799b1 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-2-n.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-2-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var for = true", "error", "var for = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-3-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-3-n.js new file mode 100644 index 0000000..3b5feb0 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-3-n.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-3-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var new = true", "error", "var new = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-4-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-4-n.js new file mode 100644 index 0000000..13faf32 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-4-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-4-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var var = true", "error", "var var = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-5-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-5-n.js new file mode 100644 index 0000000..004249b --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-5-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-5-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-5-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var continue = true", "error", "var continue = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-6-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-6-n.js new file mode 100644 index 0000000..3b830f8 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-6-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-6.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-6-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var function = true", "error", "var function = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-7-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-7-n.js new file mode 100644 index 0000000..c84ca9d --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-7-n.js @@ -0,0 +1,73 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-7-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-7"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + writeHeaderToLog( SECTION + " Keywords"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var return = true", "error", "var return = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-8-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-8-n.js new file mode 100644 index 0000000..f2397bb --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-8-n.js @@ -0,0 +1,73 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-8-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.2-8"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + writeHeaderToLog( SECTION + " Keywords"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var void = true", "error", "var void = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.2-9-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.2-9-n.js new file mode 100644 index 0000000..5b5a288 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.2-9-n.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.2-9-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "7.4.1-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Keywords"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var delete = true", "error", "var delete = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-1-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-1-n.js new file mode 100644 index 0000000..5a626a4 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-1-n.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-1-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var case = true", "error", "var case = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-10-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-10-n.js new file mode 100644 index 0000000..84d6cf3 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-10-n.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-10-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-10-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var do = true", "error", "var do = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-11-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-11-n.js new file mode 100644 index 0000000..b850584 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-11-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-11-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-11-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var finally = true", "error", "var finally = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-12-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-12-n.js new file mode 100644 index 0000000..7dfe3cc --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-12-n.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-12-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-12-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var throw = true", "error", "var throw = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-13-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-13-n.js new file mode 100644 index 0000000..ede44c1 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-13-n.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-13-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-13-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var const = true", "error", "var const = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-14-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-14-n.js new file mode 100644 index 0000000..31b6794 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-14-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-14-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-14-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var enum = true", "error", "var enum = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-15-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-15-n.js new file mode 100644 index 0000000..dfda054 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-15-n.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-15-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-15-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var import = true", "error", "var import = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-16-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-16-n.js new file mode 100644 index 0000000..cf61635 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-16-n.js @@ -0,0 +1,69 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: lexical-023.js + Corresponds To: 7.4.3-16-n.js + ECMA Section: 7.4.3 + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-023.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + try = true; + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "try = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-2-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-2-n.js new file mode 100644 index 0000000..46da571 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-2-n.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-2-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var debugger = true", "error", "var debugger = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-3-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-3-n.js new file mode 100644 index 0000000..bfdbe3b --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-3-n.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-3-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var export = true", "error", "var export = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-4-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-4-n.js new file mode 100644 index 0000000..11b97c9 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-4-n.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-4-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var super = true", "error", "var super = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-5-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-5-n.js new file mode 100644 index 0000000..8acbbcd --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-5-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-5-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-5-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var catch = true", "error", "var catch = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-6-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-6-n.js new file mode 100644 index 0000000..d5ea75e --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-6-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-6-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-6-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var default = true", "error", "var default = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-7-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-7-n.js new file mode 100644 index 0000000..93cf4cd --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-7-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-7-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-7-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var extends = true", "error", "var extends = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-8-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-8-n.js new file mode 100644 index 0000000..7d09f0c --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-8-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-8-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var switch = true", "error", "var switch = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.4.3-9-n.js b/tests/mozilla/ecma/LexicalConventions/7.4.3-9-n.js new file mode 100644 index 0000000..f0e71f9 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.4.3-9-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.4.3-9-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "7.4.3-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Future Reserved Words"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var class = true", "error", "var class = true" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-1.js b/tests/mozilla/ecma/LexicalConventions/7.5-1.js new file mode 100644 index 0000000..ef1b257 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-1.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-1.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var $123 = 5", 5, eval("var $123 = 5;$123") ); + array[item++] = new TestCase( SECTION, "var _123 = 5", 5, eval("var _123 = 5;_123") ); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-10-n.js b/tests/mozilla/ecma/LexicalConventions/7.5-10-n.js new file mode 100644 index 0000000..b1bb872 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-10-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item] = new TestCase( SECTION, "var 123=\"hi\"", "error", "" ); + + 123 = "hi"; + + array[item] = 123; + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-2-n.js b/tests/mozilla/ecma/LexicalConventions/7.5-2-n.js new file mode 100644 index 0000000..b8a161d --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-2-n.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-2-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 0abc" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-3-n.js b/tests/mozilla/ecma/LexicalConventions/7.5-3-n.js new file mode 100644 index 0000000..0d0aa84 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-3-n.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-2.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 1abc" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-4-n.js b/tests/mozilla/ecma/LexicalConventions/7.5-4-n.js new file mode 100644 index 0000000..8a21a77 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-4-n.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-4-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-4-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 2abc" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-5-n.js b/tests/mozilla/ecma/LexicalConventions/7.5-5-n.js new file mode 100644 index 0000000..7a17f16 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-5-n.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-5-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-5-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 3abc" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-6.js b/tests/mozilla/ecma/LexicalConventions/7.5-6.js new file mode 100644 index 0000000..8b19307 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-6.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-6.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var _0abc = 5", 5, "var _0abc = 5; _0abc" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-7.js b/tests/mozilla/ecma/LexicalConventions/7.5-7.js new file mode 100644 index 0000000..7ade939 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-7.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-7.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var $0abc = 5", 5, "var $0abc = 5; $0abc" ); + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-8-n.js b/tests/mozilla/ecma/LexicalConventions/7.5-8-n.js new file mode 100644 index 0000000..f17e071 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-8-n.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-8-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-8-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var @0abc = 5", "error", "var @0abc = 5; @0abc" ); + return ( array ); +} + +function test() {s + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.5-9-n.js b/tests/mozilla/ecma/LexicalConventions/7.5-9-n.js new file mode 100644 index 0000000..8ef78d6 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.5-9-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "7.5-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Identifiers"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item] = new TestCase( SECTION, "var 123=\"hi\"", "error", "" ); + + var 123 = "hi"; + + array[item] = 123; + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.6.js b/tests/mozilla/ecma/LexicalConventions/7.6.js new file mode 100644 index 0000000..68b66be --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.6.js @@ -0,0 +1,309 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.6.js + ECMA Section: Punctuators + Description: + + This tests verifies that all ECMA punctutors are recognized as a + token separator, but does not attempt to verify the functionality + of any punctuator. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "7.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Punctuators"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // == + testcases[tc++] = new TestCase( SECTION, + "var c,d;c==d", + true, + eval("var c,d;c==d") ); + + // = + + testcases[tc++] = new TestCase( SECTION, + "var a=true;a", + true, + eval("var a=true;a") ); + + // > + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;a>b", + true, + eval("var a=true,b=false;a>b") ); + + // < + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;a= + testcases[tc++] = new TestCase( SECTION, + "var a=0xFFFF,b=0XFFFE;a>=b", + true, + eval("var a=0xFFFF,b=0XFFFE;a>=b") ); + + // != + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;a!=b", + true, + eval("var a=true,b=false;a!=b") ); + + testcases[tc++] = new TestCase( SECTION, + "var a=false,b=false;a!=b", + false, + eval("var a=false,b=false;a!=b") ); + // , + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;a,b", + false, + eval("var a=true,b=false;a,b") ); + // ! + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false;!a", + false, + eval("var a=true,b=false;!a") ); + + // ~ + testcases[tc++] = new TestCase( SECTION, + "var a=true;~a", + -2, + eval("var a=true;~a") ); + // ? + testcases[tc++] = new TestCase( SECTION, + "var a=true; (a ? 'PASS' : '')", + "PASS", + eval("var a=true; (a ? 'PASS' : '')") ); + + // : + + testcases[tc++] = new TestCase( SECTION, + "var a=false; (a ? 'FAIL' : 'PASS')", + "PASS", + eval("var a=false; (a ? 'FAIL' : 'PASS')") ); + // . + + testcases[tc++] = new TestCase( SECTION, + "var a=Number;a.NaN", + NaN, + eval("var a=Number;a.NaN") ); + + // && + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;if(a&&b)'PASS';else'FAIL'", + "PASS", + eval("var a=true,b=true;if(a&&b)'PASS';else'FAIL'") ); + + // || + testcases[tc++] = new TestCase( SECTION, + "var a=false,b=false;if(a||b)'FAIL';else'PASS'", + "PASS", + eval("var a=false,b=false;if(a||b)'FAIL';else'PASS'") ); + // ++ + testcases[tc++] = new TestCase( SECTION, + "var a=false,b=false;++a", + 1, + eval("var a=false,b=false;++a") ); + // -- + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=false--a", + 0, + eval("var a=true,b=false;--a") ); + // + + + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;a+b", + 2, + eval("var a=true,b=true;a+b") ); + // - + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;a-b", + 0, + eval("var a=true,b=true;a-b") ); + // * + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;a*b", + 1, + eval("var a=true,b=true;a*b") ); + // / + testcases[tc++] = new TestCase( SECTION, + "var a=true,b=true;a/b", + 1, + eval("var a=true,b=true;a/b") ); + // & + testcases[tc++] = new TestCase( SECTION, + "var a=3,b=2;a&b", + 2, + eval("var a=3,b=2;a&b") ); + // | + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a|b", + 7, + eval("var a=4,b=3;a|b") ); + + // | + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a^b", + 7, + eval("var a=4,b=3;a^b") ); + + // % + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a|b", + 1, + eval("var a=4,b=3;a%b") ); + + // << + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a<> + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=1;a>>b", + 2, + eval("var a=4,b=1;a>>b") ); + + // >>> + testcases[tc++] = new TestCase( SECTION, + "var a=1,b=1;a>>>b", + 0, + eval("var a=1,b=1;a>>>b") ); + // += + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a+=b;a", + 7, + eval("var a=4,b=3;a+=b;a") ); + + // -= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a-=b;a", + 1, + eval("var a=4,b=3;a-=b;a") ); + // *= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a*=b;a", + 12, + eval("var a=4,b=3;a*=b;a") ); + // += + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a+=b;a", + 7, + eval("var a=4,b=3;a+=b;a") ); + // /= + testcases[tc++] = new TestCase( SECTION, + "var a=12,b=3;a/=b;a", + 4, + eval("var a=12,b=3;a/=b;a") ); + + // &= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=5;a&=b;a", + 4, + eval("var a=4,b=5;a&=b;a") ); + + // |= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=5;a&=b;a", + 5, + eval("var a=4,b=5;a|=b;a") ); + // ^= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=5;a^=b;a", + 1, + eval("var a=4,b=5;a^=b;a") ); + // %= + testcases[tc++] = new TestCase( SECTION, + "var a=12,b=5;a%=b;a", + 2, + eval("var a=12,b=5;a%=b;a") ); + // <<= + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;a<<=b;a", + 32, + eval("var a=4,b=3;a<<=b;a") ); + + // >> + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=1;a>>=b;a", + 2, + eval("var a=4,b=1;a>>=b;a") ); + + // >>> + testcases[tc++] = new TestCase( SECTION, + "var a=1,b=1;a>>>=b;a", + 0, + eval("var a=1,b=1;a>>>=b;a") ); + + // () + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;(a)", + 4, + eval("var a=4,b=3;(a)") ); + // {} + testcases[tc++] = new TestCase( SECTION, + "var a=4,b=3;{b}", + 3, + eval("var a=4,b=3;{b}") ); + + // [] + testcases[tc++] = new TestCase( SECTION, + "var a=new Array('hi');a[0]", + "hi", + eval("var a=new Array('hi');a[0]") ); + // [] + testcases[tc++] = new TestCase( SECTION, + ";", + void 0, + eval(";") ); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.7.1.js b/tests/mozilla/ecma/LexicalConventions/7.7.1.js new file mode 100644 index 0000000..a939e51 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.7.1.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.7.1.js + ECMA Section: 7.7.1 Null Literals + + Description: NullLiteral:: + null + + + The value of the null literal null is the sole value + of the Null type, namely null. + + Author: christine@netscape.com + Date: 21 october 1997 +*/ + var SECTION = "7.7.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Null Literals"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "null", null, null); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = testcases[tc].actual; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + + stopTest(); + + // all tests must return the test array + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.7.2.js b/tests/mozilla/ecma/LexicalConventions/7.7.2.js new file mode 100644 index 0000000..1202df3 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.7.2.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.7.2.js + ECMA Section: 7.7.2 Boolean Literals + + Description: BooleanLiteral:: + true + false + + The value of the Boolean literal true is a value of the + Boolean type, namely true. + + The value of the Boolean literal false is a value of the + Boolean type, namely false. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "7.7.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Boolean Literals"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // StringLiteral:: "" and '' + + array[item++] = new TestCase( SECTION, "true", Boolean(true), true ); + array[item++] = new TestCase( SECTION, "false", Boolean(false), false ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = testcases[tc].actual; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + stopTest(); + } + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.7.3-1.js b/tests/mozilla/ecma/LexicalConventions/7.7.3-1.js new file mode 100644 index 0000000..91becca --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.7.3-1.js @@ -0,0 +1,197 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.7.3-1.js + ECMA Section: 7.7.3 Numeric Literals + + Description: A numeric literal stands for a value of the Number type + This value is determined in two steps: first a + mathematical value (MV) is derived from the literal; + second, this mathematical value is rounded, ideally + using IEEE 754 round-to-nearest mode, to a reprentable + value of of the number type. + + These test cases came from Waldemar. + + Author: christine@netscape.com + Date: 12 June 1998 +*/ + +var SECTION = "7.7.3-1"; +var VERSION = "ECMA_1"; + startTest(); +var TITLE = "Numeric Literals"; +var BUGNUMBER="122877"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcases = new Array(); + + +testcases[tc++] = new TestCase( SECTION, + "0x12345678", + 305419896, + 0x12345678 ); + +testcases[tc++] = new TestCase( SECTION, + "0x80000000", + 2147483648, + 0x80000000 ); + +testcases[tc++] = new TestCase( SECTION, + "0xffffffff", + 4294967295, + 0xffffffff ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000", + 4294967296, + 0x100000000 ); + +testcases[tc++] = new TestCase( SECTION, + "077777777777777777", + 2251799813685247, + 077777777777777777 ); + +testcases[tc++] = new TestCase( SECTION, + "077777777777777776", + 2251799813685246, + 077777777777777776 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1fffffffffffff", + 9007199254740991, + 0x1fffffffffffff ); + +testcases[tc++] = new TestCase( SECTION, + "0x20000000000000", + 9007199254740992, + 0x20000000000000 ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abc", + 9027215253084860, + 0x20123456789abc ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abd", + 9027215253084860, + 0x20123456789abd ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abe", + 9027215253084862, + 0x20123456789abe ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abf", + 9027215253084864, + 0x20123456789abf ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000080", + 1152921504606847000, + 0x1000000000000080 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000081", + 1152921504606847200, + 0x1000000000000081 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000100", + 1152921504606847200, + 0x1000000000000100 ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000000017f", + 1152921504606847200, + 0x100000000000017f ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000180", + 1152921504606847500, + 0x1000000000000180 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000181", + 1152921504606847500, + 0x1000000000000181 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000001f0", + 1152921504606847500, + 0x10000000000001f0 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000200", + 1152921504606847500, + 0x1000000000000200 ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000000027f", + 1152921504606847500, + 0x100000000000027f ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000280", + 1152921504606847500, + 0x1000000000000280 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000281", + 1152921504606847700, + 0x1000000000000281 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000002ff", + 1152921504606847700, + 0x10000000000002ff ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000300", + 1152921504606847700, + 0x1000000000000300 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000000000", + 18446744073709552000, + 0x10000000000000000 ); + +test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = testcases[tc].actual; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + } + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.7.3-2.js b/tests/mozilla/ecma/LexicalConventions/7.7.3-2.js new file mode 100644 index 0000000..b6e750c --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.7.3-2.js @@ -0,0 +1,93 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.7.3-2.js + ECMA Section: 7.7.3 Numeric Literals + + Description: + + This is a regression test for + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122884 + + Waldemar's comments: + + A numeric literal that starts with either '08' or '09' is interpreted as a + decimal literal; it should be an error instead. (Strictly speaking, according + to ECMA v1 such literals should be interpreted as two integers -- a zero + followed by a decimal number whose first digit is 8 or 9, but this is a bug in + ECMA that will be fixed in v2. In any case, there is no place in the grammar + where two consecutive numbers would be legal.) + + Author: christine@netscape.com + Date: 15 june 1998 + +*/ + var SECTION = "7.7.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Numeric Literals"; + var BUGNUMBER="122884"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "9", + 9, + 9 ); + + testcases[tc++] = new TestCase( SECTION, + "09", + 9, + 09 ); + + testcases[tc++] = new TestCase( SECTION, + "099", + 99, + 099 ); + + + testcases[tc++] = new TestCase( SECTION, + "077", + 63, + 077 ); + + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = testcases[tc].actual; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + } + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.7.3.js b/tests/mozilla/ecma/LexicalConventions/7.7.3.js new file mode 100644 index 0000000..7d47a40 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.7.3.js @@ -0,0 +1,337 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.7.3.js + ECMA Section: 7.7.3 Numeric Literals + + Description: A numeric literal stands for a value of the Number type + This value is determined in two steps: first a + mathematical value (MV) is derived from the literal; + second, this mathematical value is rounded, ideally + using IEEE 754 round-to-nearest mode, to a reprentable + value of of the number type. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "7.7.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Numeric Literals"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "0", 0, 0 ); + array[item++] = new TestCase( SECTION, "1", 1, 1 ); + array[item++] = new TestCase( SECTION, "2", 2, 2 ); + array[item++] = new TestCase( SECTION, "3", 3, 3 ); + array[item++] = new TestCase( SECTION, "4", 4, 4 ); + array[item++] = new TestCase( SECTION, "5", 5, 5 ); + array[item++] = new TestCase( SECTION, "6", 6, 6 ); + array[item++] = new TestCase( SECTION, "7", 7, 7 ); + array[item++] = new TestCase( SECTION, "8", 8, 8 ); + array[item++] = new TestCase( SECTION, "9", 9, 9 ); + + array[item++] = new TestCase( SECTION, "0.", 0, 0. ); + array[item++] = new TestCase( SECTION, "1.", 1, 1. ); + array[item++] = new TestCase( SECTION, "2.", 2, 2. ); + array[item++] = new TestCase( SECTION, "3.", 3, 3. ); + array[item++] = new TestCase( SECTION, "4.", 4, 4. ); + + array[item++] = new TestCase( SECTION, "0.e0", 0, 0.e0 ); + array[item++] = new TestCase( SECTION, "1.e1", 10, 1.e1 ); + array[item++] = new TestCase( SECTION, "2.e2", 200, 2.e2 ); + array[item++] = new TestCase( SECTION, "3.e3", 3000, 3.e3 ); + array[item++] = new TestCase( SECTION, "4.e4", 40000, 4.e4 ); + + array[item++] = new TestCase( SECTION, "0.1e0", .1, 0.1e0 ); + array[item++] = new TestCase( SECTION, "1.1e1", 11, 1.1e1 ); + array[item++] = new TestCase( SECTION, "2.2e2", 220, 2.2e2 ); + array[item++] = new TestCase( SECTION, "3.3e3", 3300, 3.3e3 ); + array[item++] = new TestCase( SECTION, "4.4e4", 44000, 4.4e4 ); + + array[item++] = new TestCase( SECTION, ".1e0", .1, .1e0 ); + array[item++] = new TestCase( SECTION, ".1e1", 1, .1e1 ); + array[item++] = new TestCase( SECTION, ".2e2", 20, .2e2 ); + array[item++] = new TestCase( SECTION, ".3e3", 300, .3e3 ); + array[item++] = new TestCase( SECTION, ".4e4", 4000, .4e4 ); + + array[item++] = new TestCase( SECTION, "0e0", 0, 0e0 ); + array[item++] = new TestCase( SECTION, "1e1", 10, 1e1 ); + array[item++] = new TestCase( SECTION, "2e2", 200, 2e2 ); + array[item++] = new TestCase( SECTION, "3e3", 3000, 3e3 ); + array[item++] = new TestCase( SECTION, "4e4", 40000, 4e4 ); + + array[item++] = new TestCase( SECTION, "0e0", 0, 0e0 ); + array[item++] = new TestCase( SECTION, "1e1", 10, 1e1 ); + array[item++] = new TestCase( SECTION, "2e2", 200, 2e2 ); + array[item++] = new TestCase( SECTION, "3e3", 3000, 3e3 ); + array[item++] = new TestCase( SECTION, "4e4", 40000, 4e4 ); + + array[item++] = new TestCase( SECTION, "0E0", 0, 0E0 ); + array[item++] = new TestCase( SECTION, "1E1", 10, 1E1 ); + array[item++] = new TestCase( SECTION, "2E2", 200, 2E2 ); + array[item++] = new TestCase( SECTION, "3E3", 3000, 3E3 ); + array[item++] = new TestCase( SECTION, "4E4", 40000, 4E4 ); + + array[item++] = new TestCase( SECTION, "1.e-1", 0.1, 1.e-1 ); + array[item++] = new TestCase( SECTION, "2.e-2", 0.02, 2.e-2 ); + array[item++] = new TestCase( SECTION, "3.e-3", 0.003, 3.e-3 ); + array[item++] = new TestCase( SECTION, "4.e-4", 0.0004, 4.e-4 ); + + array[item++] = new TestCase( SECTION, "0.1e-0", .1, 0.1e-0 ); + array[item++] = new TestCase( SECTION, "1.1e-1", 0.11, 1.1e-1 ); + array[item++] = new TestCase( SECTION, "2.2e-2", .022, 2.2e-2 ); + array[item++] = new TestCase( SECTION, "3.3e-3", .0033, 3.3e-3 ); + array[item++] = new TestCase( SECTION, "4.4e-4", .00044, 4.4e-4 ); + + array[item++] = new TestCase( SECTION, ".1e-0", .1, .1e-0 ); + array[item++] = new TestCase( SECTION, ".1e-1", .01, .1e-1 ); + array[item++] = new TestCase( SECTION, ".2e-2", .002, .2e-2 ); + array[item++] = new TestCase( SECTION, ".3e-3", .0003, .3e-3 ); + array[item++] = new TestCase( SECTION, ".4e-4", .00004, .4e-4 ); + + array[item++] = new TestCase( SECTION, "1.e+1", 10, 1.e+1 ); + array[item++] = new TestCase( SECTION, "2.e+2", 200, 2.e+2 ); + array[item++] = new TestCase( SECTION, "3.e+3", 3000, 3.e+3 ); + array[item++] = new TestCase( SECTION, "4.e+4", 40000, 4.e+4 ); + + array[item++] = new TestCase( SECTION, "0.1e+0", .1, 0.1e+0 ); + array[item++] = new TestCase( SECTION, "1.1e+1", 11, 1.1e+1 ); + array[item++] = new TestCase( SECTION, "2.2e+2", 220, 2.2e+2 ); + array[item++] = new TestCase( SECTION, "3.3e+3", 3300, 3.3e+3 ); + array[item++] = new TestCase( SECTION, "4.4e+4", 44000, 4.4e+4 ); + + array[item++] = new TestCase( SECTION, ".1e+0", .1, .1e+0 ); + array[item++] = new TestCase( SECTION, ".1e+1", 1, .1e+1 ); + array[item++] = new TestCase( SECTION, ".2e+2", 20, .2e+2 ); + array[item++] = new TestCase( SECTION, ".3e+3", 300, .3e+3 ); + array[item++] = new TestCase( SECTION, ".4e+4", 4000, .4e+4 ); + + array[item++] = new TestCase( SECTION, "0x0", 0, 0x0 ); + array[item++] = new TestCase( SECTION, "0x1", 1, 0x1 ); + array[item++] = new TestCase( SECTION, "0x2", 2, 0x2 ); + array[item++] = new TestCase( SECTION, "0x3", 3, 0x3 ); + array[item++] = new TestCase( SECTION, "0x4", 4, 0x4 ); + array[item++] = new TestCase( SECTION, "0x5", 5, 0x5 ); + array[item++] = new TestCase( SECTION, "0x6", 6, 0x6 ); + array[item++] = new TestCase( SECTION, "0x7", 7, 0x7 ); + array[item++] = new TestCase( SECTION, "0x8", 8, 0x8 ); + array[item++] = new TestCase( SECTION, "0x9", 9, 0x9 ); + array[item++] = new TestCase( SECTION, "0xa", 10, 0xa ); + array[item++] = new TestCase( SECTION, "0xb", 11, 0xb ); + array[item++] = new TestCase( SECTION, "0xc", 12, 0xc ); + array[item++] = new TestCase( SECTION, "0xd", 13, 0xd ); + array[item++] = new TestCase( SECTION, "0xe", 14, 0xe ); + array[item++] = new TestCase( SECTION, "0xf", 15, 0xf ); + + array[item++] = new TestCase( SECTION, "0X0", 0, 0X0 ); + array[item++] = new TestCase( SECTION, "0X1", 1, 0X1 ); + array[item++] = new TestCase( SECTION, "0X2", 2, 0X2 ); + array[item++] = new TestCase( SECTION, "0X3", 3, 0X3 ); + array[item++] = new TestCase( SECTION, "0X4", 4, 0X4 ); + array[item++] = new TestCase( SECTION, "0X5", 5, 0X5 ); + array[item++] = new TestCase( SECTION, "0X6", 6, 0X6 ); + array[item++] = new TestCase( SECTION, "0X7", 7, 0X7 ); + array[item++] = new TestCase( SECTION, "0X8", 8, 0X8 ); + array[item++] = new TestCase( SECTION, "0X9", 9, 0X9 ); + array[item++] = new TestCase( SECTION, "0Xa", 10, 0Xa ); + array[item++] = new TestCase( SECTION, "0Xb", 11, 0Xb ); + array[item++] = new TestCase( SECTION, "0Xc", 12, 0Xc ); + array[item++] = new TestCase( SECTION, "0Xd", 13, 0Xd ); + array[item++] = new TestCase( SECTION, "0Xe", 14, 0Xe ); + array[item++] = new TestCase( SECTION, "0Xf", 15, 0Xf ); + + array[item++] = new TestCase( SECTION, "0x0", 0, 0x0 ); + array[item++] = new TestCase( SECTION, "0x1", 1, 0x1 ); + array[item++] = new TestCase( SECTION, "0x2", 2, 0x2 ); + array[item++] = new TestCase( SECTION, "0x3", 3, 0x3 ); + array[item++] = new TestCase( SECTION, "0x4", 4, 0x4 ); + array[item++] = new TestCase( SECTION, "0x5", 5, 0x5 ); + array[item++] = new TestCase( SECTION, "0x6", 6, 0x6 ); + array[item++] = new TestCase( SECTION, "0x7", 7, 0x7 ); + array[item++] = new TestCase( SECTION, "0x8", 8, 0x8 ); + array[item++] = new TestCase( SECTION, "0x9", 9, 0x9 ); + array[item++] = new TestCase( SECTION, "0xA", 10, 0xA ); + array[item++] = new TestCase( SECTION, "0xB", 11, 0xB ); + array[item++] = new TestCase( SECTION, "0xC", 12, 0xC ); + array[item++] = new TestCase( SECTION, "0xD", 13, 0xD ); + array[item++] = new TestCase( SECTION, "0xE", 14, 0xE ); + array[item++] = new TestCase( SECTION, "0xF", 15, 0xF ); + + array[item++] = new TestCase( SECTION, "0X0", 0, 0X0 ); + array[item++] = new TestCase( SECTION, "0X1", 1, 0X1 ); + array[item++] = new TestCase( SECTION, "0X2", 2, 0X2 ); + array[item++] = new TestCase( SECTION, "0X3", 3, 0X3 ); + array[item++] = new TestCase( SECTION, "0X4", 4, 0X4 ); + array[item++] = new TestCase( SECTION, "0X5", 5, 0X5 ); + array[item++] = new TestCase( SECTION, "0X6", 6, 0X6 ); + array[item++] = new TestCase( SECTION, "0X7", 7, 0X7 ); + array[item++] = new TestCase( SECTION, "0X8", 8, 0X8 ); + array[item++] = new TestCase( SECTION, "0X9", 9, 0X9 ); + array[item++] = new TestCase( SECTION, "0XA", 10, 0XA ); + array[item++] = new TestCase( SECTION, "0XB", 11, 0XB ); + array[item++] = new TestCase( SECTION, "0XC", 12, 0XC ); + array[item++] = new TestCase( SECTION, "0XD", 13, 0XD ); + array[item++] = new TestCase( SECTION, "0XE", 14, 0XE ); + array[item++] = new TestCase( SECTION, "0XF", 15, 0XF ); + + + array[item++] = new TestCase( SECTION, "00", 0, 00 ); + array[item++] = new TestCase( SECTION, "01", 1, 01 ); + array[item++] = new TestCase( SECTION, "02", 2, 02 ); + array[item++] = new TestCase( SECTION, "03", 3, 03 ); + array[item++] = new TestCase( SECTION, "04", 4, 04 ); + array[item++] = new TestCase( SECTION, "05", 5, 05 ); + array[item++] = new TestCase( SECTION, "06", 6, 06 ); + array[item++] = new TestCase( SECTION, "07", 7, 07 ); + + array[item++] = new TestCase( SECTION, "000", 0, 000 ); + array[item++] = new TestCase( SECTION, "011", 9, 011 ); + array[item++] = new TestCase( SECTION, "022", 18, 022 ); + array[item++] = new TestCase( SECTION, "033", 27, 033 ); + array[item++] = new TestCase( SECTION, "044", 36, 044 ); + array[item++] = new TestCase( SECTION, "055", 45, 055 ); + array[item++] = new TestCase( SECTION, "066", 54, 066 ); + array[item++] = new TestCase( SECTION, "077", 63, 077 ); + + array[item++] = new TestCase( SECTION, "0.00000000001", 0.00000000001, 0.00000000001 ); + array[item++] = new TestCase( SECTION, "0.00000000001e-2", 0.0000000000001, 0.00000000001e-2 ); + + + array[item++] = new TestCase( SECTION, + "123456789012345671.9999", + "123456789012345660", + 123456789012345671.9999 +""); + array[item++] = new TestCase( SECTION, + "123456789012345672", + "123456789012345660", + 123456789012345672 +""); + + array[item++] = new TestCase( SECTION, + "123456789012345672.000000000000000000000000000", + "123456789012345660", + 123456789012345672.000000000000000000000000000 +""); + + array[item++] = new TestCase( SECTION, + "123456789012345672.01", + "123456789012345680", + 123456789012345672.01 +""); + + array[item++] = new TestCase( SECTION, + "123456789012345672.000000000000000000000000001+'' == 123456789012345680 || 123456789012345660", + true, + ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345680 ) + || + ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345660) ); + + array[item++] = new TestCase( SECTION, + "123456789012345673", + "123456789012345680", + 123456789012345673 +"" ); + + array[item++] = new TestCase( SECTION, + "-123456789012345671.9999", + "-123456789012345660", + -123456789012345671.9999 +"" ); + + array[item++] = new TestCase( SECTION, + "-123456789012345672", + "-123456789012345660", + -123456789012345672+""); + + array[item++] = new TestCase( SECTION, + "-123456789012345672.000000000000000000000000000", + "-123456789012345660", + -123456789012345672.000000000000000000000000000 +""); + + array[item++] = new TestCase( SECTION, + "-123456789012345672.01", + "-123456789012345680", + -123456789012345672.01 +"" ); + + array[item++] = new TestCase( SECTION, + "-123456789012345672.000000000000000000000000001 == -123456789012345680 or -123456789012345660", + true, + (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345680) + || + (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345660)); + + array[item++] = new TestCase( SECTION, + -123456789012345673, + "-123456789012345680", + -123456789012345673 +""); + + array[item++] = new TestCase( SECTION, + "12345678901234567890", + "12345678901234567000", + 12345678901234567890 +"" ); + + +/* + array[item++] = new TestCase( SECTION, "12345678901234567", "12345678901234567", 12345678901234567+"" ); + array[item++] = new TestCase( SECTION, "123456789012345678", "123456789012345678", 123456789012345678+"" ); + array[item++] = new TestCase( SECTION, "1234567890123456789", "1234567890123456789", 1234567890123456789+"" ); + array[item++] = new TestCase( SECTION, "12345678901234567890", "12345678901234567890", 12345678901234567890+"" ); + array[item++] = new TestCase( SECTION, "123456789012345678900", "123456789012345678900", 123456789012345678900+"" ); + array[item++] = new TestCase( SECTION, "1234567890123456789000", "1234567890123456789000", 1234567890123456789000+"" ); +*/ + array[item++] = new TestCase( SECTION, "0x1", 1, 0x1 ); + array[item++] = new TestCase( SECTION, "0x10", 16, 0x10 ); + array[item++] = new TestCase( SECTION, "0x100", 256, 0x100 ); + array[item++] = new TestCase( SECTION, "0x1000", 4096, 0x1000 ); + array[item++] = new TestCase( SECTION, "0x10000", 65536, 0x10000 ); + array[item++] = new TestCase( SECTION, "0x100000", 1048576, 0x100000 ); + array[item++] = new TestCase( SECTION, "0x1000000", 16777216, 0x1000000 ); + array[item++] = new TestCase( SECTION, "0x10000000", 268435456, 0x10000000 ); +/* + array[item++] = new TestCase( SECTION, "0x100000000", 4294967296, 0x100000000 ); + array[item++] = new TestCase( SECTION, "0x1000000000", 68719476736, 0x1000000000 ); + array[item++] = new TestCase( SECTION, "0x10000000000", 1099511627776, 0x10000000000 ); +*/ + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = testcases[tc].actual; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + } + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.7.4.js b/tests/mozilla/ecma/LexicalConventions/7.7.4.js new file mode 100644 index 0000000..769b819 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.7.4.js @@ -0,0 +1,275 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.7.4.js + ECMA Section: 7.7.4 String Literals + + Description: A string literal is zero or more characters enclosed in + single or double quotes. Each character may be + represented by an escape sequence. + + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "7.7.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String Literals"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // StringLiteral:: "" and '' + + array[item++] = new TestCase( SECTION, "\"\"", "", "" ); + array[item++] = new TestCase( SECTION, "\'\'", "", '' ); + + // DoubleStringCharacters:: DoubleStringCharacter :: EscapeSequence :: CharacterEscapeSequence + array[item++] = new TestCase( SECTION, "\\\"", String.fromCharCode(0x0022), "\"" ); + array[item++] = new TestCase( SECTION, "\\\'", String.fromCharCode(0x0027), "\'" ); + array[item++] = new TestCase( SECTION, "\\", String.fromCharCode(0x005C), "\\" ); + array[item++] = new TestCase( SECTION, "\\b", String.fromCharCode(0x0008), "\b" ); + array[item++] = new TestCase( SECTION, "\\f", String.fromCharCode(0x000C), "\f" ); + array[item++] = new TestCase( SECTION, "\\n", String.fromCharCode(0x000A), "\n" ); + array[item++] = new TestCase( SECTION, "\\r", String.fromCharCode(0x000D), "\r" ); + array[item++] = new TestCase( SECTION, "\\t", String.fromCharCode(0x0009), "\t" ); + array[item++] = new TestCase( SECTION, "\\v", String.fromCharCode(0x000B), "\v" ); + + // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::OctalEscapeSequence + + array[item++] = new TestCase( SECTION, "\\00", String.fromCharCode(0x0000), "\00" ); + array[item++] = new TestCase( SECTION, "\\01", String.fromCharCode(0x0001), "\01" ); + array[item++] = new TestCase( SECTION, "\\02", String.fromCharCode(0x0002), "\02" ); + array[item++] = new TestCase( SECTION, "\\03", String.fromCharCode(0x0003), "\03" ); + array[item++] = new TestCase( SECTION, "\\04", String.fromCharCode(0x0004), "\04" ); + array[item++] = new TestCase( SECTION, "\\05", String.fromCharCode(0x0005), "\05" ); + array[item++] = new TestCase( SECTION, "\\06", String.fromCharCode(0x0006), "\06" ); + array[item++] = new TestCase( SECTION, "\\07", String.fromCharCode(0x0007), "\07" ); + + array[item++] = new TestCase( SECTION, "\\010", String.fromCharCode(0x0008), "\010" ); + array[item++] = new TestCase( SECTION, "\\011", String.fromCharCode(0x0009), "\011" ); + array[item++] = new TestCase( SECTION, "\\012", String.fromCharCode(0x000A), "\012" ); + array[item++] = new TestCase( SECTION, "\\013", String.fromCharCode(0x000B), "\013" ); + array[item++] = new TestCase( SECTION, "\\014", String.fromCharCode(0x000C), "\014" ); + array[item++] = new TestCase( SECTION, "\\015", String.fromCharCode(0x000D), "\015" ); + array[item++] = new TestCase( SECTION, "\\016", String.fromCharCode(0x000E), "\016" ); + array[item++] = new TestCase( SECTION, "\\017", String.fromCharCode(0x000F), "\017" ); + array[item++] = new TestCase( SECTION, "\\020", String.fromCharCode(0x0010), "\020" ); + array[item++] = new TestCase( SECTION, "\\042", String.fromCharCode(0x0022), "\042" ); + + array[item++] = new TestCase( SECTION, "\\0", String.fromCharCode(0x0000), "\0" ); + array[item++] = new TestCase( SECTION, "\\1", String.fromCharCode(0x0001), "\1" ); + array[item++] = new TestCase( SECTION, "\\2", String.fromCharCode(0x0002), "\2" ); + array[item++] = new TestCase( SECTION, "\\3", String.fromCharCode(0x0003), "\3" ); + array[item++] = new TestCase( SECTION, "\\4", String.fromCharCode(0x0004), "\4" ); + array[item++] = new TestCase( SECTION, "\\5", String.fromCharCode(0x0005), "\5" ); + array[item++] = new TestCase( SECTION, "\\6", String.fromCharCode(0x0006), "\6" ); + array[item++] = new TestCase( SECTION, "\\7", String.fromCharCode(0x0007), "\7" ); + + array[item++] = new TestCase( SECTION, "\\10", String.fromCharCode(0x0008), "\10" ); + array[item++] = new TestCase( SECTION, "\\11", String.fromCharCode(0x0009), "\11" ); + array[item++] = new TestCase( SECTION, "\\12", String.fromCharCode(0x000A), "\12" ); + array[item++] = new TestCase( SECTION, "\\13", String.fromCharCode(0x000B), "\13" ); + array[item++] = new TestCase( SECTION, "\\14", String.fromCharCode(0x000C), "\14" ); + array[item++] = new TestCase( SECTION, "\\15", String.fromCharCode(0x000D), "\15" ); + array[item++] = new TestCase( SECTION, "\\16", String.fromCharCode(0x000E), "\16" ); + array[item++] = new TestCase( SECTION, "\\17", String.fromCharCode(0x000F), "\17" ); + array[item++] = new TestCase( SECTION, "\\20", String.fromCharCode(0x0010), "\20" ); + array[item++] = new TestCase( SECTION, "\\42", String.fromCharCode(0x0022), "\42" ); + + array[item++] = new TestCase( SECTION, "\\000", String.fromCharCode(0), "\000" ); + array[item++] = new TestCase( SECTION, "\\111", String.fromCharCode(73), "\111" ); + array[item++] = new TestCase( SECTION, "\\222", String.fromCharCode(146), "\222" ); + array[item++] = new TestCase( SECTION, "\\333", String.fromCharCode(219), "\333" ); + +// following line commented out as it causes a compile time error +// array[item++] = new TestCase( SECTION, "\\444", "444", "\444" ); + + // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::HexEscapeSequence +/* + array[item++] = new TestCase( SECTION, "\\x0", String.fromCharCode(0), "\x0" ); + array[item++] = new TestCase( SECTION, "\\x1", String.fromCharCode(1), "\x1" ); + array[item++] = new TestCase( SECTION, "\\x2", String.fromCharCode(2), "\x2" ); + array[item++] = new TestCase( SECTION, "\\x3", String.fromCharCode(3), "\x3" ); + array[item++] = new TestCase( SECTION, "\\x4", String.fromCharCode(4), "\x4" ); + array[item++] = new TestCase( SECTION, "\\x5", String.fromCharCode(5), "\x5" ); + array[item++] = new TestCase( SECTION, "\\x6", String.fromCharCode(6), "\x6" ); + array[item++] = new TestCase( SECTION, "\\x7", String.fromCharCode(7), "\x7" ); + array[item++] = new TestCase( SECTION, "\\x8", String.fromCharCode(8), "\x8" ); + array[item++] = new TestCase( SECTION, "\\x9", String.fromCharCode(9), "\x9" ); + array[item++] = new TestCase( SECTION, "\\xA", String.fromCharCode(10), "\xA" ); + array[item++] = new TestCase( SECTION, "\\xB", String.fromCharCode(11), "\xB" ); + array[item++] = new TestCase( SECTION, "\\xC", String.fromCharCode(12), "\xC" ); + array[item++] = new TestCase( SECTION, "\\xD", String.fromCharCode(13), "\xD" ); + array[item++] = new TestCase( SECTION, "\\xE", String.fromCharCode(14), "\xE" ); + array[item++] = new TestCase( SECTION, "\\xF", String.fromCharCode(15), "\xF" ); + +*/ + array[item++] = new TestCase( SECTION, "\\xF0", String.fromCharCode(240), "\xF0" ); + array[item++] = new TestCase( SECTION, "\\xE1", String.fromCharCode(225), "\xE1" ); + array[item++] = new TestCase( SECTION, "\\xD2", String.fromCharCode(210), "\xD2" ); + array[item++] = new TestCase( SECTION, "\\xC3", String.fromCharCode(195), "\xC3" ); + array[item++] = new TestCase( SECTION, "\\xB4", String.fromCharCode(180), "\xB4" ); + array[item++] = new TestCase( SECTION, "\\xA5", String.fromCharCode(165), "\xA5" ); + array[item++] = new TestCase( SECTION, "\\x96", String.fromCharCode(150), "\x96" ); + array[item++] = new TestCase( SECTION, "\\x87", String.fromCharCode(135), "\x87" ); + array[item++] = new TestCase( SECTION, "\\x78", String.fromCharCode(120), "\x78" ); + array[item++] = new TestCase( SECTION, "\\x69", String.fromCharCode(105), "\x69" ); + array[item++] = new TestCase( SECTION, "\\x5A", String.fromCharCode(90), "\x5A" ); + array[item++] = new TestCase( SECTION, "\\x4B", String.fromCharCode(75), "\x4B" ); + array[item++] = new TestCase( SECTION, "\\x3C", String.fromCharCode(60), "\x3C" ); + array[item++] = new TestCase( SECTION, "\\x2D", String.fromCharCode(45), "\x2D" ); + array[item++] = new TestCase( SECTION, "\\x1E", String.fromCharCode(30), "\x1E" ); + array[item++] = new TestCase( SECTION, "\\x0F", String.fromCharCode(15), "\x0F" ); + + // string literals only take up to two hext digits. therefore, the third character in this string + // should be interpreted as a StringCharacter and not part of the HextEscapeSequence + + array[item++] = new TestCase( SECTION, "\\xF0F", String.fromCharCode(240)+"F", "\xF0F" ); + array[item++] = new TestCase( SECTION, "\\xE1E", String.fromCharCode(225)+"E", "\xE1E" ); + array[item++] = new TestCase( SECTION, "\\xD2D", String.fromCharCode(210)+"D", "\xD2D" ); + array[item++] = new TestCase( SECTION, "\\xC3C", String.fromCharCode(195)+"C", "\xC3C" ); + array[item++] = new TestCase( SECTION, "\\xB4B", String.fromCharCode(180)+"B", "\xB4B" ); + array[item++] = new TestCase( SECTION, "\\xA5A", String.fromCharCode(165)+"A", "\xA5A" ); + array[item++] = new TestCase( SECTION, "\\x969", String.fromCharCode(150)+"9", "\x969" ); + array[item++] = new TestCase( SECTION, "\\x878", String.fromCharCode(135)+"8", "\x878" ); + array[item++] = new TestCase( SECTION, "\\x787", String.fromCharCode(120)+"7", "\x787" ); + array[item++] = new TestCase( SECTION, "\\x696", String.fromCharCode(105)+"6", "\x696" ); + array[item++] = new TestCase( SECTION, "\\x5A5", String.fromCharCode(90)+"5", "\x5A5" ); + array[item++] = new TestCase( SECTION, "\\x4B4", String.fromCharCode(75)+"4", "\x4B4" ); + array[item++] = new TestCase( SECTION, "\\x3C3", String.fromCharCode(60)+"3", "\x3C3" ); + array[item++] = new TestCase( SECTION, "\\x2D2", String.fromCharCode(45)+"2", "\x2D2" ); + array[item++] = new TestCase( SECTION, "\\x1E1", String.fromCharCode(30)+"1", "\x1E1" ); + array[item++] = new TestCase( SECTION, "\\x0F0", String.fromCharCode(15)+"0", "\x0F0" ); + + // G is out of hex range + + array[item++] = new TestCase( SECTION, "\\xG", "xG", "\xG" ); + array[item++] = new TestCase( SECTION, "\\xCG", "xCG", "\xCG" ); + + // DoubleStringCharacter::EscapeSequence::CharacterEscapeSequence::\ NonEscapeCharacter + array[item++] = new TestCase( SECTION, "\\a", "a", "\a" ); + array[item++] = new TestCase( SECTION, "\\c", "c", "\c" ); + array[item++] = new TestCase( SECTION, "\\d", "d", "\d" ); + array[item++] = new TestCase( SECTION, "\\e", "e", "\e" ); + array[item++] = new TestCase( SECTION, "\\g", "g", "\g" ); + array[item++] = new TestCase( SECTION, "\\h", "h", "\h" ); + array[item++] = new TestCase( SECTION, "\\i", "i", "\i" ); + array[item++] = new TestCase( SECTION, "\\j", "j", "\j" ); + array[item++] = new TestCase( SECTION, "\\k", "k", "\k" ); + array[item++] = new TestCase( SECTION, "\\l", "l", "\l" ); + array[item++] = new TestCase( SECTION, "\\m", "m", "\m" ); + array[item++] = new TestCase( SECTION, "\\o", "o", "\o" ); + array[item++] = new TestCase( SECTION, "\\p", "p", "\p" ); + array[item++] = new TestCase( SECTION, "\\q", "q", "\q" ); + array[item++] = new TestCase( SECTION, "\\s", "s", "\s" ); + array[item++] = new TestCase( SECTION, "\\u", "u", "\u" ); + + array[item++] = new TestCase( SECTION, "\\w", "w", "\w" ); + array[item++] = new TestCase( SECTION, "\\x", "x", "\x" ); + array[item++] = new TestCase( SECTION, "\\y", "y", "\y" ); + array[item++] = new TestCase( SECTION, "\\z", "z", "\z" ); + array[item++] = new TestCase( SECTION, "\\9", "9", "\9" ); + + array[item++] = new TestCase( SECTION, "\\A", "A", "\A" ); + array[item++] = new TestCase( SECTION, "\\B", "B", "\B" ); + array[item++] = new TestCase( SECTION, "\\C", "C", "\C" ); + array[item++] = new TestCase( SECTION, "\\D", "D", "\D" ); + array[item++] = new TestCase( SECTION, "\\E", "E", "\E" ); + array[item++] = new TestCase( SECTION, "\\F", "F", "\F" ); + array[item++] = new TestCase( SECTION, "\\G", "G", "\G" ); + array[item++] = new TestCase( SECTION, "\\H", "H", "\H" ); + array[item++] = new TestCase( SECTION, "\\I", "I", "\I" ); + array[item++] = new TestCase( SECTION, "\\J", "J", "\J" ); + array[item++] = new TestCase( SECTION, "\\K", "K", "\K" ); + array[item++] = new TestCase( SECTION, "\\L", "L", "\L" ); + array[item++] = new TestCase( SECTION, "\\M", "M", "\M" ); + array[item++] = new TestCase( SECTION, "\\N", "N", "\N" ); + array[item++] = new TestCase( SECTION, "\\O", "O", "\O" ); + array[item++] = new TestCase( SECTION, "\\P", "P", "\P" ); + array[item++] = new TestCase( SECTION, "\\Q", "Q", "\Q" ); + array[item++] = new TestCase( SECTION, "\\R", "R", "\R" ); + array[item++] = new TestCase( SECTION, "\\S", "S", "\S" ); + array[item++] = new TestCase( SECTION, "\\T", "T", "\T" ); + array[item++] = new TestCase( SECTION, "\\U", "U", "\U" ); + array[item++] = new TestCase( SECTION, "\\V", "V", "\V" ); + array[item++] = new TestCase( SECTION, "\\W", "W", "\W" ); + array[item++] = new TestCase( SECTION, "\\X", "X", "\X" ); + array[item++] = new TestCase( SECTION, "\\Y", "Y", "\Y" ); + array[item++] = new TestCase( SECTION, "\\Z", "Z", "\Z" ); + + // DoubleStringCharacter::EscapeSequence::UnicodeEscapeSequence + + array[item++] = new TestCase( SECTION, "\\u0020", " ", "\u0020" ); + array[item++] = new TestCase( SECTION, "\\u0021", "!", "\u0021" ); + array[item++] = new TestCase( SECTION, "\\u0022", "\"", "\u0022" ); + array[item++] = new TestCase( SECTION, "\\u0023", "#", "\u0023" ); + array[item++] = new TestCase( SECTION, "\\u0024", "$", "\u0024" ); + array[item++] = new TestCase( SECTION, "\\u0025", "%", "\u0025" ); + array[item++] = new TestCase( SECTION, "\\u0026", "&", "\u0026" ); + array[item++] = new TestCase( SECTION, "\\u0027", "'", "\u0027" ); + array[item++] = new TestCase( SECTION, "\\u0028", "(", "\u0028" ); + array[item++] = new TestCase( SECTION, "\\u0029", ")", "\u0029" ); + array[item++] = new TestCase( SECTION, "\\u002A", "*", "\u002A" ); + array[item++] = new TestCase( SECTION, "\\u002B", "+", "\u002B" ); + array[item++] = new TestCase( SECTION, "\\u002C", ",", "\u002C" ); + array[item++] = new TestCase( SECTION, "\\u002D", "-", "\u002D" ); + array[item++] = new TestCase( SECTION, "\\u002E", ".", "\u002E" ); + array[item++] = new TestCase( SECTION, "\\u002F", "/", "\u002F" ); + array[item++] = new TestCase( SECTION, "\\u0030", "0", "\u0030" ); + array[item++] = new TestCase( SECTION, "\\u0031", "1", "\u0031" ); + array[item++] = new TestCase( SECTION, "\\u0032", "2", "\u0032" ); + array[item++] = new TestCase( SECTION, "\\u0033", "3", "\u0033" ); + array[item++] = new TestCase( SECTION, "\\u0034", "4", "\u0034" ); + array[item++] = new TestCase( SECTION, "\\u0035", "5", "\u0035" ); + array[item++] = new TestCase( SECTION, "\\u0036", "6", "\u0036" ); + array[item++] = new TestCase( SECTION, "\\u0037", "7", "\u0037" ); + array[item++] = new TestCase( SECTION, "\\u0038", "8", "\u0038" ); + array[item++] = new TestCase( SECTION, "\\u0039", "9", "\u0039" ); + + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = testcases[tc].actual; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/LexicalConventions/7.8.2-n.js b/tests/mozilla/ecma/LexicalConventions/7.8.2-n.js new file mode 100644 index 0000000..82bd7c4 --- /dev/null +++ b/tests/mozilla/ecma/LexicalConventions/7.8.2-n.js @@ -0,0 +1,48 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 7.8.2.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION="7.8.2"; + var VERSION="ECMA_1" + startTest(); + writeHeaderToLog(SECTION+" "+"Examples of Semicolon Insertion"); + + testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// array[item++] = new TestCase( "7.8.2", "{ 1 \n 2 } 3", 3, "{ 1 \n 2 } 3" ); + array[item++] = new TestCase( "7.8.2", "{ 1 2 } 3", "error", eval("{1 2 } 3") ); + + return ( array ); +} + diff --git a/tests/mozilla/ecma/Math/15.8-1.js b/tests/mozilla/ecma/Math/15.8-1.js new file mode 100644 index 0000000..8b08eb6 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8-1.js @@ -0,0 +1,84 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8-1.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + + var SECTION = "15.8-1"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "The Math Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "Math.__proto__ == Object.prototype", + true, + Math.__proto__ == Object.prototype ); + + array[item++] = new TestCase( SECTION, + "Math.__proto__", + Object.prototype, + Math.__proto__ ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8-2-n.js b/tests/mozilla/ecma/Math/15.8-2-n.js new file mode 100644 index 0000000..2bf41c0 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8-2-n.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8-2.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + + var SECTION = "15.8-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Math Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "MYMATH = new Math()", + "error", + "MYMATH = new Math()" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += "Math does not have the [Construct] property"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8-3-n.js b/tests/mozilla/ecma/Math/15.8-3-n.js new file mode 100644 index 0000000..4896f48 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8-3-n.js @@ -0,0 +1,81 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8-3.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "15.8-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Math Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "MYMATH = Math()", + "error", + "MYMATH = Math()" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += "Math does not have the [Call] property"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.1-1.js b/tests/mozilla/ecma/Math/15.8.1.1-1.js new file mode 100644 index 0000000..f22fdca --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.1-1.js @@ -0,0 +1,62 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.1-1.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.E = 0; Math.E", 2.7182818284590452354, ("Math.E=0;Math.E") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "Math.E should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.1-2.js b/tests/mozilla/ecma/Math/15.8.1.1-2.js new file mode 100644 index 0000000..2aea4ff --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.1-2.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.1-2.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MATH_E = 2.7182818284590452354 + array[item++] = new TestCase( SECTION, "delete(Math.E)", false, "delete Math.E" ); + array[item++] = new TestCase( SECTION, "delete(Math.E); Math.E", MATH_E, "delete Math.E; Math.E" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "should not be able to delete property"; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.2-1.js b/tests/mozilla/ecma/Math/15.8.1.2-1.js new file mode 100644 index 0000000..a9d8c0d --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.2-1.js @@ -0,0 +1,62 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN10 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LN10"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.LN10=0; Math.LN10", 2.302585092994046, "Math.LN10=0; Math.LN10" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.2-2.js b/tests/mozilla/ecma/Math/15.8.1.2-2.js new file mode 100644 index 0000000..2774177 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.2-2.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LN10 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LN10"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete( Math.LN10 ); Math.LN10", 2.302585092994046, "delete(Math.LN10); Math.LN10" ); + array[item++] = new TestCase( SECTION, "delete( Math.LN10 ); ", false, "delete(Math.LN10)" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.3-1.js b/tests/mozilla/ecma/Math/15.8.1.3-1.js new file mode 100644 index 0000000..d8354ad --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.3-1.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.3-1.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LN2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.LN2=0; Math.LN2", 0.6931471805599453, ("Math.LN2=0; Math.LN2") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.3-2.js b/tests/mozilla/ecma/Math/15.8.1.3-2.js new file mode 100644 index 0000000..a26ef79 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.3-2.js @@ -0,0 +1,69 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.3-3.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LN2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MATH_LN2 = 0.6931471805599453; + + array[item++] = new TestCase( SECTION, "delete(Math.LN2)", false, "delete(Math.LN2)" ); + array[item++] = new TestCase( SECTION, "delete(Math.LN2); Math.LN2", MATH_LN2, "delete(Math.LN2); Math.LN2" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.4-1.js b/tests/mozilla/ecma/Math/15.8.1.4-1.js new file mode 100644 index 0000000..82e2fea --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.4-1.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.4-1.js + ECMA Section: 15.8.1.4.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LOG2E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LOG2E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.L0G2E=0; Math.LOG2E", 1.4426950408889634, ("Math.LOG2E=0; Math.LOG2E") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Math/15.8.1.4-2.js b/tests/mozilla/ecma/Math/15.8.1.4-2.js new file mode 100644 index 0000000..9208b46 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.4-2.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.4-2.js + ECMA Section: 15.8.1.4.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LOG2E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.4-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LOG2E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete(Math.L0G2E);Math.LOG2E", 1.4426950408889634, "delete(Math.LOG2E);Math.LOG2E" ); + array[item++] = new TestCase( SECTION, "delete(Math.L0G2E)", false, "delete(Math.LOG2E)" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Math/15.8.1.5-1.js b/tests/mozilla/ecma/Math/15.8.1.5-1.js new file mode 100644 index 0000000..1ad5000 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.5-1.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.5-1.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LOG10E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.8.1.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LOG10E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.LOG10E=0; Math.LOG10E", 0.4342944819032518, ("Math.LOG10E=0; Math.LOG10E") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Math/15.8.1.5-2.js b/tests/mozilla/ecma/Math/15.8.1.5-2.js new file mode 100644 index 0000000..7b204e7 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.5-2.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.5-2.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LOG10E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.LOG10E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.LOG10E; Math.LOG10E", 0.4342944819032518, "delete Math.LOG10E; Math.LOG10E" ); + array[item++] = new TestCase( SECTION, "delete Math.LOG10E", false, "delete Math.LOG10E" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Math/15.8.1.6-1.js b/tests/mozilla/ecma/Math/15.8.1.6-1.js new file mode 100644 index 0000000..4a998cc --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.6-1.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.6-1.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.PI + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.PI"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.PI=0; Math.PI", 3.1415926535897923846, "Math.PI=0; Math.PI" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.6-2.js b/tests/mozilla/ecma/Math/15.8.1.6-2.js new file mode 100644 index 0000000..3a0fb1f --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.6-2.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.6-2.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.PI + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.6-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.PI"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.PI; Math.PI", 3.1415926535897923846, "delete Math.PI; Math.PI" ); + array[item++] = new TestCase( SECTION, "delete Math.PI; Math.PI", false, "delete Math.PI" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.7-1.js b/tests/mozilla/ecma/Math/15.8.1.7-1.js new file mode 100644 index 0000000..9eeb6d7 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.7-1.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.7-1.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.7-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.SQRT1_2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.SQRT1_2=0; Math.SQRT1_2", 0.7071067811865476, "Math.SQRT1_2=0; Math.SQRT1_2" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Math/15.8.1.7-2.js b/tests/mozilla/ecma/Math/15.8.1.7-2.js new file mode 100644 index 0000000..85dd054 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.7-2.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.7-2.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.7-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.SQRT1_2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.SQRT1_2; Math.SQRT1_2", 0.7071067811865476, "delete Math.SQRT1_2; Math.SQRT1_2" ); + array[item++] = new TestCase( SECTION, "delete Math.SQRT1_2", false, "delete Math.SQRT1_2" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.8-1.js b/tests/mozilla/ecma/Math/15.8.1.8-1.js new file mode 100644 index 0000000..1b3615d --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.8-1.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.8-1.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.8-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.SQRT2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Math.SQRT2=0; Math.SQRT2", 1.4142135623730951, ("Math.SQRT2=0; Math.SQRT2") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Math/15.8.1.8-2.js b/tests/mozilla/ecma/Math/15.8.1.8-2.js new file mode 100644 index 0000000..25634dd --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.8-2.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.8-2.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.8-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.SQRT2"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.SQRT2; Math.SQRT2", 1.4142135623730951, "delete Math.SQRT2; Math.SQRT2" ); + array[item++] = new TestCase( SECTION, "delete Math.SQRT2", false, "delete Math.SQRT2" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.1.8-3.js b/tests/mozilla/ecma/Math/15.8.1.8-3.js new file mode 100644 index 0000000..d1df188 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.8-3.js @@ -0,0 +1,61 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.8-3.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.8.1.8-3"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Math.SQRT2: DontDelete"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete Math.SQRT2", false, ("delete Math.SQRT2") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Math/15.8.1.js b/tests/mozilla/ecma/Math/15.8.1.js new file mode 100644 index 0000000..a0fdf26 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.1.js @@ -0,0 +1,86 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.1.js + ECMA Section: 15.8.1.js Value Properties of the Math Object + 15.8.1.1 E + 15.8.1.2 LN10 + 15.8.1.3 LN2 + 15.8.1.4 LOG2E + 15.8.1.5 LOG10E + 15.8.1.6 PI + 15.8.1.7 SQRT1_2 + 15.8.1.8 SQRT2 + Description: verify the values of some math constants + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "15.8.1" + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Value Properties of the Math Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "15.8.1.1", "Math.E", 2.7182818284590452354, Math.E ); + array[item++] = new TestCase( "15.8.1.1", "typeof Math.E", "number", typeof Math.E ); + array[item++] = new TestCase( "15.8.1.2", "Math.LN10", 2.302585092994046, Math.LN10 ); + array[item++] = new TestCase( "15.8.1.2", "typeof Math.LN10", "number", typeof Math.LN10 ); + array[item++] = new TestCase( "15.8.1.3", "Math.LN2", 0.6931471805599453, Math.LN2 ); + array[item++] = new TestCase( "15.8.1.3", "typeof Math.LN2", "number", typeof Math.LN2 ); + array[item++] = new TestCase( "15.8.1.4", "Math.LOG2E", 1.4426950408889634, Math.LOG2E ); + array[item++] = new TestCase( "15.8.1.4", "typeof Math.LOG2E", "number", typeof Math.LOG2E ); + array[item++] = new TestCase( "15.8.1.5", "Math.LOG10E", 0.4342944819032518, Math.LOG10E); + array[item++] = new TestCase( "15.8.1.5", "typeof Math.LOG10E", "number", typeof Math.LOG10E); + array[item++] = new TestCase( "15.8.1.6", "Math.PI", 3.14159265358979323846, Math.PI ); + array[item++] = new TestCase( "15.8.1.6", "typeof Math.PI", "number", typeof Math.PI ); + array[item++] = new TestCase( "15.8.1.7", "Math.SQRT1_2", 0.7071067811865476, Math.SQRT1_2); + array[item++] = new TestCase( "15.8.1.7", "typeof Math.SQRT1_2", "number", typeof Math.SQRT1_2); + array[item++] = new TestCase( "15.8.1.8", "Math.SQRT2", 1.4142135623730951, Math.SQRT2 ); + array[item++] = new TestCase( "15.8.1.8", "typeof Math.SQRT2", "number", typeof Math.SQRT2 ); + + array[item++] = new TestCase( SECTION, "var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS", + "", + eval("var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS") ); + + return ( array ); +} + +function test() { + for ( i = 0; i < testcases.length; i++ ) { + testcases[i].passed = writeTestCaseResult( + testcases[i].expect, + testcases[i].actual, + testcases[i].description +" = "+ testcases[i].actual ); + testcases[i].reason += ( testcases[i].passed ) ? "" : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.1.js b/tests/mozilla/ecma/Math/15.8.2.1.js new file mode 100644 index 0000000..4f0ba21 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.1.js @@ -0,0 +1,103 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.1.js + ECMA Section: 15.8.2.1 abs( x ) + Description: return the absolute value of the argument, + which should be the magnitude of the argument + with a positive sign. + - if x is NaN, return NaN + - if x is -0, result is +0 + - if x is -Infinity, result is +Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + var SECTION = "15.8.2.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.abs()"; + var BUGNUMBER = "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.abs.length", 1, Math.abs.length ); + + array[item++] = new TestCase( SECTION, "Math.abs()", Number.NaN, Math.abs() ); + array[item++] = new TestCase( SECTION, "Math.abs( void 0 )", Number.NaN, Math.abs(void 0) ); + array[item++] = new TestCase( SECTION, "Math.abs( null )", 0, Math.abs(null) ); + array[item++] = new TestCase( SECTION, "Math.abs( true )", 1, Math.abs(true) ); + array[item++] = new TestCase( SECTION, "Math.abs( false )", 0, Math.abs(false) ); + array[item++] = new TestCase( SECTION, "Math.abs( string primitive)", Number.NaN, Math.abs("a string primitive") ); + array[item++] = new TestCase( SECTION, "Math.abs( string object )", Number.NaN, Math.abs(new String( 'a String object' )) ); + array[item++] = new TestCase( SECTION, "Math.abs( Number.NaN )", Number.NaN, Math.abs(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.abs(0)", 0, Math.abs( 0 ) ); + array[item++] = new TestCase( SECTION, "Math.abs( -0 )", 0, Math.abs(-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.abs(-0)", Infinity, Infinity/Math.abs(-0) ); + + array[item++] = new TestCase( SECTION, "Math.abs( -Infinity )", Number.POSITIVE_INFINITY, Math.abs( Number.NEGATIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "Math.abs( Infinity )", Number.POSITIVE_INFINITY, Math.abs( Number.POSITIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "Math.abs( - MAX_VALUE )", Number.MAX_VALUE, Math.abs( - Number.MAX_VALUE ) ); + array[item++] = new TestCase( SECTION, "Math.abs( - MIN_VALUE )", Number.MIN_VALUE, Math.abs( -Number.MIN_VALUE ) ); + array[item++] = new TestCase( SECTION, "Math.abs( MAX_VALUE )", Number.MAX_VALUE, Math.abs( Number.MAX_VALUE ) ); + array[item++] = new TestCase( SECTION, "Math.abs( MIN_VALUE )", Number.MIN_VALUE, Math.abs( Number.MIN_VALUE ) ); + + array[item++] = new TestCase( SECTION, "Math.abs( -1 )", 1, Math.abs( -1 ) ); + array[item++] = new TestCase( SECTION, "Math.abs( new Number( -1 ) )", 1, Math.abs( new Number(-1) ) ); + array[item++] = new TestCase( SECTION, "Math.abs( 1 )", 1, Math.abs( 1 ) ); + array[item++] = new TestCase( SECTION, "Math.abs( Math.PI )", Math.PI, Math.abs( Math.PI ) ); + array[item++] = new TestCase( SECTION, "Math.abs( -Math.PI )", Math.PI, Math.abs( -Math.PI ) ); + array[item++] = new TestCase( SECTION, "Math.abs(-1/100000000)", 1/100000000, Math.abs(-1/100000000) ); + array[item++] = new TestCase( SECTION, "Math.abs(-Math.pow(2,32))", Math.pow(2,32), Math.abs(-Math.pow(2,32)) ); + array[item++] = new TestCase( SECTION, "Math.abs(Math.pow(2,32))", Math.pow(2,32), Math.abs(Math.pow(2,32)) ); + array[item++] = new TestCase( SECTION, "Math.abs( -0xfff )", 4095, Math.abs( -0xfff ) ); + array[item++] = new TestCase( SECTION, "Math.abs( -0777 )", 511, Math.abs(-0777 ) ); + + array[item++] = new TestCase( SECTION, "Math.abs('-1e-1')", 0.1, Math.abs('-1e-1') ); + array[item++] = new TestCase( SECTION, "Math.abs('0xff')", 255, Math.abs('0xff') ); + array[item++] = new TestCase( SECTION, "Math.abs('077')", 77, Math.abs('077') ); + array[item++] = new TestCase( SECTION, "Math.abs( 'Infinity' )", Infinity, Math.abs('Infinity') ); + array[item++] = new TestCase( SECTION, "Math.abs( '-Infinity' )", Infinity, Math.abs('-Infinity') ); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.10.js b/tests/mozilla/ecma/Math/15.8.2.10.js new file mode 100644 index 0000000..24b6cb8 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.10.js @@ -0,0 +1,86 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.10.js + ECMA Section: 15.8.2.10 Math.log(x) + Description: return an approximiation to the natural logarithm of + the argument. + special cases: + - if arg is NaN result is NaN + - if arg is <0 result is NaN + - if arg is 0 or -0 result is -Infinity + - if arg is 1 result is 0 + - if arg is Infinity result is Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.log(x)"; + var BUGNUMBER = "77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.log.length", 1, Math.log.length ); + + array[item++] = new TestCase( SECTION, "Math.log()", Number.NaN, Math.log() ); + array[item++] = new TestCase( SECTION, "Math.log(void 0)", Number.NaN, Math.log(void 0) ); + array[item++] = new TestCase( SECTION, "Math.log(null)", Number.NEGATIVE_INFINITY, Math.log(null) ); + array[item++] = new TestCase( SECTION, "Math.log(true)", 0, Math.log(true) ); + array[item++] = new TestCase( SECTION, "Math.log(false)", -Infinity, Math.log(false) ); + array[item++] = new TestCase( SECTION, "Math.log('0')", -Infinity, Math.log('0') ); + array[item++] = new TestCase( SECTION, "Math.log('1')", 0, Math.log('1') ); + array[item++] = new TestCase( SECTION, "Math.log('Infinity')", Infinity, Math.log("Infinity") ); + + array[item++] = new TestCase( SECTION, "Math.log(NaN)", Number.NaN, Math.log(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.log(-0.0000001)", Number.NaN, Math.log(-0.000001) ); + array[item++] = new TestCase( SECTION, "Math.log(-1)", Number.NaN, Math.log(-1) ); + array[item++] = new TestCase( SECTION, "Math.log(0)", Number.NEGATIVE_INFINITY, Math.log(0) ); + array[item++] = new TestCase( SECTION, "Math.log(-0)", Number.NEGATIVE_INFINITY, Math.log(-0)); + array[item++] = new TestCase( SECTION, "Math.log(1)", 0, Math.log(1) ); + array[item++] = new TestCase( SECTION, "Math.log(Infinity)", Number.POSITIVE_INFINITY, Math.log(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.log(-Infinity)", Number.NaN, Math.log(Number.NEGATIVE_INFINITY) ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Math/15.8.2.11.js b/tests/mozilla/ecma/Math/15.8.2.11.js new file mode 100644 index 0000000..4be499c --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.11.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.11.js + ECMA Section: 15.8.2.11 Math.max(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.max(x, y)"; + var BUGNUMBER="76439"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.max.length", 2, Math.max.length ); + + array[item++] = new TestCase( SECTION, "Math.max()", -Infinity, Math.max() ); + array[item++] = new TestCase( SECTION, "Math.max(void 0, 1)", Number.NaN, Math.max( void 0, 1 ) ); + array[item++] = new TestCase( SECTION, "Math.max(void 0, void 0)", Number.NaN, Math.max( void 0, void 0 ) ); + array[item++] = new TestCase( SECTION, "Math.max(null, 1)", 1, Math.max( null, 1 ) ); + array[item++] = new TestCase( SECTION, "Math.max(-1, null)", 0, Math.max( -1, null ) ); + array[item++] = new TestCase( SECTION, "Math.max(true, false)", 1, Math.max(true,false) ); + + array[item++] = new TestCase( SECTION, "Math.max('-99','99')", 99, Math.max( "-99","99") ); + + array[item++] = new TestCase( SECTION, "Math.max(NaN, Infinity)", Number.NaN, Math.max(Number.NaN,Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.max(NaN, 0)", Number.NaN, Math.max(Number.NaN, 0) ); + array[item++] = new TestCase( SECTION, "Math.max('a string', 0)", Number.NaN, Math.max("a string", 0) ); + array[item++] = new TestCase( SECTION, "Math.max(NaN, 1)", Number.NaN, Math.max(Number.NaN,1) ); + array[item++] = new TestCase( SECTION, "Math.max('a string',Infinity)", Number.NaN, Math.max("a string", Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.max(Infinity, NaN)", Number.NaN, Math.max( Number.POSITIVE_INFINITY, Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.max(NaN, NaN)", Number.NaN, Math.max(Number.NaN, Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.max(0,NaN)", Number.NaN, Math.max(0,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.max(1, NaN)", Number.NaN, Math.max(1, Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.max(0,0)", 0, Math.max(0,0) ); + array[item++] = new TestCase( SECTION, "Math.max(0,-0)", 0, Math.max(0,-0) ); + array[item++] = new TestCase( SECTION, "Math.max(-0,0)", 0, Math.max(-0,0) ); + array[item++] = new TestCase( SECTION, "Math.max(-0,-0)", -0, Math.max(-0,-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.max(-0,-0)", -Infinity, Infinity/Math.max(-0,-0) ); + array[item++] = new TestCase( SECTION, "Math.max(Infinity, Number.MAX_VALUE)", Number.POSITIVE_INFINITY, Math.max(Number.POSITIVE_INFINITY, Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "Math.max(Infinity, Infinity)", Number.POSITIVE_INFINITY, Math.max(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.max(-Infinity,-Infinity)", Number.NEGATIVE_INFINITY, Math.max(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.max(1,.99999999999999)", 1, Math.max(1,.99999999999999) ); + array[item++] = new TestCase( SECTION, "Math.max(-1,-.99999999999999)", -.99999999999999, Math.max(-1,-.99999999999999) ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.12.js b/tests/mozilla/ecma/Math/15.8.2.12.js new file mode 100644 index 0000000..0706e0b --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.12.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.12.js + ECMA Section: 15.8.2.12 Math.min(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + + var SECTION = "15.8.2.12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.min(x, y)"; + var BUGNUMBER="76439"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.min.length", 2, Math.min.length ); + + array[item++] = new TestCase( SECTION, "Math.min()", Infinity, Math.min() ); + array[item++] = new TestCase( SECTION, "Math.min(void 0, 1)", Number.NaN, Math.min( void 0, 1 ) ); + array[item++] = new TestCase( SECTION, "Math.min(void 0, void 0)", Number.NaN, Math.min( void 0, void 0 ) ); + array[item++] = new TestCase( SECTION, "Math.min(null, 1)", 0, Math.min( null, 1 ) ); + array[item++] = new TestCase( SECTION, "Math.min(-1, null)", -1, Math.min( -1, null ) ); + array[item++] = new TestCase( SECTION, "Math.min(true, false)", 0, Math.min(true,false) ); + + array[item++] = new TestCase( SECTION, "Math.min('-99','99')", -99, Math.min( "-99","99") ); + + array[item++] = new TestCase( SECTION, "Math.min(NaN,0)", Number.NaN, Math.min(Number.NaN,0) ); + array[item++] = new TestCase( SECTION, "Math.min(NaN,1)", Number.NaN, Math.min(Number.NaN,1) ); + array[item++] = new TestCase( SECTION, "Math.min(NaN,-1)", Number.NaN, Math.min(Number.NaN,-1) ); + array[item++] = new TestCase( SECTION, "Math.min(0,NaN)", Number.NaN, Math.min(0,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.min(1,NaN)", Number.NaN, Math.min(1,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.min(-1,NaN)", Number.NaN, Math.min(-1,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.min(NaN,NaN)", Number.NaN, Math.min(Number.NaN,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.min(1,1.0000000001)", 1, Math.min(1,1.0000000001) ); + array[item++] = new TestCase( SECTION, "Math.min(1.0000000001,1)", 1, Math.min(1.0000000001,1) ); + array[item++] = new TestCase( SECTION, "Math.min(0,0)", 0, Math.min(0,0) ); + array[item++] = new TestCase( SECTION, "Math.min(0,-0)", -0, Math.min(0,-0) ); + array[item++] = new TestCase( SECTION, "Math.min(-0,-0)", -0, Math.min(-0,-0) ); + + array[item++] = new TestCase( SECTION, "Infinity/Math.min(0,-0)", -Infinity, Infinity/Math.min(0,-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.min(-0,-0)", -Infinity, Infinity/Math.min(-0,-0) ); + + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.13.js b/tests/mozilla/ecma/Math/15.8.2.13.js new file mode 100644 index 0000000..4744eb0 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.13.js @@ -0,0 +1,132 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.13.js + ECMA Section: 15.8.2.13 Math.pow(x, y) + Description: return an approximation to the result of x + to the power of y. there are many special cases; + refer to the spec. + Author: christine@netscape.com + Date: 9 july 1997 +*/ + + var SECTION = "15.8.2.13"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.pow(x, y)"; + var BUGNUMBER="77141"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.pow.length", 2, Math.pow.length ); + + array[item++] = new TestCase( SECTION, "Math.pow()", Number.NaN, Math.pow() ); + array[item++] = new TestCase( SECTION, "Math.pow(null, null)", 1, Math.pow(null,null) ); + array[item++] = new TestCase( SECTION, "Math.pow(void 0, void 0)", Number.NaN, Math.pow(void 0, void 0)); + array[item++] = new TestCase( SECTION, "Math.pow(true, false)", 1, Math.pow(true, false) ); + array[item++] = new TestCase( SECTION, "Math.pow(false,true)", 0, Math.pow(false,true) ); + array[item++] = new TestCase( SECTION, "Math.pow('2','32')", 4294967296, Math.pow('2','32') ); + + array[item++] = new TestCase( SECTION, "Math.pow(1,NaN)", Number.NaN, Math.pow(1,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.pow(0,NaN)", Number.NaN, Math.pow(0,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.pow(NaN,0)", 1, Math.pow(Number.NaN,0) ); + array[item++] = new TestCase( SECTION, "Math.pow(NaN,-0)", 1, Math.pow(Number.NaN,-0) ); + array[item++] = new TestCase( SECTION, "Math.pow(NaN,1)", Number.NaN, Math.pow(Number.NaN, 1) ); + array[item++] = new TestCase( SECTION, "Math.pow(NaN,.5)", Number.NaN, Math.pow(Number.NaN, .5) ); + array[item++] = new TestCase( SECTION, "Math.pow(1.00000001, Infinity)", Number.POSITIVE_INFINITY, Math.pow(1.00000001, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(1.00000001, -Infinity)", 0, Math.pow(1.00000001, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1.00000001, Infinity)", Number.POSITIVE_INFINITY, Math.pow(-1.00000001,Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1.00000001, -Infinity)", 0, Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(1, Infinity)", Number.NaN, Math.pow(1, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(1, -Infinity)", Number.NaN, Math.pow(1, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, Infinity)", Number.NaN, Math.pow(-1, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, -Infinity)", Number.NaN, Math.pow(-1, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(.0000000009, Infinity)", 0, Math.pow(.0000000009, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-.0000000009, Infinity)", 0, Math.pow(-.0000000009, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(.0000000009, -Infinity)", Number.POSITIVE_INFINITY, Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, .00000000001)", Number.POSITIVE_INFINITY, Math.pow(Number.POSITIVE_INFINITY,.00000000001) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, 1)", Number.POSITIVE_INFINITY, Math.pow(Number.POSITIVE_INFINITY, 1) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, -.00000000001)",0, Math.pow(Number.POSITIVE_INFINITY, -.00000000001) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, -1)", 0, Math.pow(Number.POSITIVE_INFINITY, -1) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 1)", Number.NEGATIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 1) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 333)", Number.NEGATIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 333) ); + array[item++] = new TestCase( SECTION, "Math.pow(Infinity, 2)", Number.POSITIVE_INFINITY, Math.pow(Number.POSITIVE_INFINITY, 2) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 666)", Number.POSITIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 666) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 0.5)", Number.POSITIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, Infinity)", Number.POSITIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -1)", -0, Math.pow(Number.NEGATIVE_INFINITY, -1) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.pow(-Infinity, -1)", -Infinity, Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) ); + + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -3)", -0, Math.pow(Number.NEGATIVE_INFINITY, -3) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -2)", 0, Math.pow(Number.NEGATIVE_INFINITY, -2) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -0.5)", 0, Math.pow(Number.NEGATIVE_INFINITY,-0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -Infinity)", 0, Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, 1)", 0, Math.pow(0,1) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, 0)", 1, Math.pow(0,0) ); + array[item++] = new TestCase( SECTION, "Math.pow(1, 0)", 1, Math.pow(1,0) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, 0)", 1, Math.pow(-1,0) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, 0.5)", 0, Math.pow(0,0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, 1000)", 0, Math.pow(0,1000) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, Infinity)", 0, Math.pow(0, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, -1)", Number.POSITIVE_INFINITY, Math.pow(0, -1) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, -0.5)", Number.POSITIVE_INFINITY, Math.pow(0, -0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, -1000)", Number.POSITIVE_INFINITY, Math.pow(0, -1000) ); + array[item++] = new TestCase( SECTION, "Math.pow(0, -Infinity)", Number.POSITIVE_INFINITY, Math.pow(0, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, 1)", -0, Math.pow(-0, 1) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, 3)", -0, Math.pow(-0,3) ); + + array[item++] = new TestCase( SECTION, "Infinity/Math.pow(-0, 1)", -Infinity, Infinity/Math.pow(-0, 1) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.pow(-0, 3)", -Infinity, Infinity/Math.pow(-0,3) ); + + array[item++] = new TestCase( SECTION, "Math.pow(-0, 2)", 0, Math.pow(-0,2) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, Infinity)", 0, Math.pow(-0, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, -1)", Number.NEGATIVE_INFINITY, Math.pow(-0, -1) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, -10001)", Number.NEGATIVE_INFINITY, Math.pow(-0, -10001) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, -2)", Number.POSITIVE_INFINITY, Math.pow(-0, -2) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, 0.5)", 0, Math.pow(-0, 0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(-0, Infinity)", 0, Math.pow(-0, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, 0.5)", Number.NaN, Math.pow(-1, 0.5) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, NaN)", Number.NaN, Math.pow(-1, Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.pow(-1, -0.5)", Number.NaN, Math.pow(-1, -0.5) ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.14.js b/tests/mozilla/ecma/Math/15.8.2.14.js new file mode 100644 index 0000000..e5ed1fb --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.14.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.14.js + ECMA Section: 15.8.2.14 Math.random() + returns a number value x with a positive sign + with 1 > x >= 0 with approximately uniform + distribution over that range, using an + implementation-dependent algorithm or strategy. + This function takes no arguments. + + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.2.14"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.random()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( item = 0; item < 100; item++ ) { + array[item] = new TestCase( SECTION, "Math.random()", "pass", null ); + } + + return ( array ); +} +function getRandom( caseno ) { + testcases[caseno].reason = Math.random(); + testcases[caseno].actual = "pass"; + + if ( ! ( testcases[caseno].reason >= 0) ) { + testcases[caseno].actual = "fail"; + } + + if ( ! (testcases[caseno].reason < 1) ) { + testcases[caseno].actual = "fail"; + } +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + getRandom( tc ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.15.js b/tests/mozilla/ecma/Math/15.8.2.15.js new file mode 100644 index 0000000..ca8cc94 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.15.js @@ -0,0 +1,113 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.15.js + ECMA Section: 15.8.2.15 Math.round(x) + Description: return the greatest number value that is closest to the + argument and is an integer. if two integers are equally + close to the argument. then the result is the number value + that is closer to Infinity. if the argument is an integer, + return the argument. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if 0 < x < 0.5 return 0 + - if -0.5 <= x < 0 return -0 + example: + Math.round( 3.5 ) == 4 + Math.round( -3.5 ) == 3 + also: + - Math.round(x) == Math.floor( x + 0.5 ) + except if x = -0. in that case, Math.round(x) = -0 + + and Math.floor( x+0.5 ) = +0 + + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.15"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.round(x)"; + var BUGNUMBER="331411"; + + var EXCLUDE = "true"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.round.length", 1, Math.round.length ); + + array[item++] = new TestCase( SECTION, "Math.round()", Number.NaN, Math.round() ); + array[item++] = new TestCase( SECTION, "Math.round(null)", 0, Math.round(0) ); + array[item++] = new TestCase( SECTION, "Math.round(void 0)", Number.NaN, Math.round(void 0) ); + array[item++] = new TestCase( SECTION, "Math.round(true)", 1, Math.round(true) ); + array[item++] = new TestCase( SECTION, "Math.round(false)", 0, Math.round(false) ); + array[item++] = new TestCase( SECTION, "Math.round('.99999')", 1, Math.round('.99999') ); + array[item++] = new TestCase( SECTION, "Math.round('12345e-2')", 123, Math.round('12345e-2') ); + + array[item++] = new TestCase( SECTION, "Math.round(NaN)", Number.NaN, Math.round(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.round(0)", 0, Math.round(0) ); + array[item++] = new TestCase( SECTION, "Math.round(-0)", -0, Math.round(-0)); + array[item++] = new TestCase( SECTION, "Infinity/Math.round(-0)", -Infinity, Infinity/Math.round(-0) ); + + array[item++] = new TestCase( SECTION, "Math.round(Infinity)", Number.POSITIVE_INFINITY, Math.round(Number.POSITIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.round(-Infinity)",Number.NEGATIVE_INFINITY, Math.round(Number.NEGATIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.round(0.49)", 0, Math.round(0.49)); + array[item++] = new TestCase( SECTION, "Math.round(0.5)", 1, Math.round(0.5)); + array[item++] = new TestCase( SECTION, "Math.round(0.51)", 1, Math.round(0.51)); + + array[item++] = new TestCase( SECTION, "Math.round(-0.49)", -0, Math.round(-0.49)); + array[item++] = new TestCase( SECTION, "Math.round(-0.5)", -0, Math.round(-0.5)); + array[item++] = new TestCase( SECTION, "Infinity/Math.round(-0.49)", -Infinity, Infinity/Math.round(-0.49)); + array[item++] = new TestCase( SECTION, "Infinity/Math.round(-0.5)", -Infinity, Infinity/Math.round(-0.5)); + + array[item++] = new TestCase( SECTION, "Math.round(-0.51)", -1, Math.round(-0.51)); + array[item++] = new TestCase( SECTION, "Math.round(3.5)", 4, Math.round(3.5)); + array[item++] = new TestCase( SECTION, "Math.round(-3.5)", -3, Math.round(-3)); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Math/15.8.2.16.js b/tests/mozilla/ecma/Math/15.8.2.16.js new file mode 100644 index 0000000..b144d9b --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.16.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.16.js + ECMA Section: 15.8.2.16 sin( x ) + Description: return an approximation to the sine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "15.8.2.16"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.sin(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.sin.length", 1, Math.sin.length ); + + array[item++] = new TestCase( SECTION, "Math.sin()", Number.NaN, Math.sin() ); + array[item++] = new TestCase( SECTION, "Math.sin(null)", 0, Math.sin(null) ); + array[item++] = new TestCase( SECTION, "Math.sin(void 0)", Number.NaN, Math.sin(void 0) ); + array[item++] = new TestCase( SECTION, "Math.sin(false)", 0, Math.sin(false) ); + array[item++] = new TestCase( SECTION, "Math.sin('2.356194490192')", 0.7071067811865, Math.sin('2.356194490192') ); + + array[item++] = new TestCase( SECTION, "Math.sin(NaN)", Number.NaN, Math.sin(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.sin(0)", 0, Math.sin(0) ); + array[item++] = new TestCase( SECTION, "Math.sin(-0)", -0, Math.sin(-0)); + array[item++] = new TestCase( SECTION, "Math.sin(Infinity)", Number.NaN, Math.sin(Number.POSITIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.sin(-Infinity)", Number.NaN, Math.sin(Number.NEGATIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.sin(0.7853981633974)", 0.7071067811865, Math.sin(0.7853981633974)); + array[item++] = new TestCase( SECTION, "Math.sin(1.570796326795)", 1, Math.sin(1.570796326795)); + array[item++] = new TestCase( SECTION, "Math.sin(2.356194490192)", 0.7071067811865, Math.sin(2.356194490192)); + array[item++] = new TestCase( SECTION, "Math.sin(3.14159265359)", 0, Math.sin(3.14159265359)); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Math/15.8.2.17.js b/tests/mozilla/ecma/Math/15.8.2.17.js new file mode 100644 index 0000000..16859ed --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.17.js @@ -0,0 +1,99 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.17.js + ECMA Section: 15.8.2.17 Math.sqrt(x) + Description: return an approximation to the squareroot of the argument. + special cases: + - if x is NaN return NaN + - if x < 0 return NaN + - if x == 0 return 0 + - if x == -0 return -0 + - if x == Infinity return Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.17"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.sqrt(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.sqrt.length", 1, Math.sqrt.length ); + + array[item++] = new TestCase( SECTION, "Math.sqrt()", Number.NaN, Math.sqrt() ); + array[item++] = new TestCase( SECTION, "Math.sqrt(void 0)", Number.NaN, Math.sqrt(void 0) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(null)", 0, Math.sqrt(null) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(true)", 1, Math.sqrt(1) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(false)", 0, Math.sqrt(false) ); + array[item++] = new TestCase( SECTION, "Math.sqrt('225')", 15, Math.sqrt('225') ); + + array[item++] = new TestCase( SECTION, "Math.sqrt(NaN)", Number.NaN, Math.sqrt(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(-Infinity)", Number.NaN, Math.sqrt(Number.NEGATIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.sqrt(-1)", Number.NaN, Math.sqrt(-1)); + array[item++] = new TestCase( SECTION, "Math.sqrt(-0.5)", Number.NaN, Math.sqrt(-0.5)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0)", 0, Math.sqrt(0)); + array[item++] = new TestCase( SECTION, "Math.sqrt(-0)", -0, Math.sqrt(-0)); + array[item++] = new TestCase( SECTION, "Infinity/Math.sqrt(-0)", -Infinity, Infinity/Math.sqrt(-0) ); + array[item++] = new TestCase( SECTION, "Math.sqrt(Infinity)", Number.POSITIVE_INFINITY, Math.sqrt(Number.POSITIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.sqrt(1)", 1, Math.sqrt(1)); + array[item++] = new TestCase( SECTION, "Math.sqrt(2)", Math.SQRT2, Math.sqrt(2)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0.5)", Math.SQRT1_2, Math.sqrt(0.5)); + array[item++] = new TestCase( SECTION, "Math.sqrt(4)", 2, Math.sqrt(4)); + array[item++] = new TestCase( SECTION, "Math.sqrt(9)", 3, Math.sqrt(9)); + array[item++] = new TestCase( SECTION, "Math.sqrt(16)", 4, Math.sqrt(16)); + array[item++] = new TestCase( SECTION, "Math.sqrt(25)", 5, Math.sqrt(25)); + array[item++] = new TestCase( SECTION, "Math.sqrt(36)", 6, Math.sqrt(36)); + array[item++] = new TestCase( SECTION, "Math.sqrt(49)", 7, Math.sqrt(49)); + array[item++] = new TestCase( SECTION, "Math.sqrt(64)", 8, Math.sqrt(64)); + array[item++] = new TestCase( SECTION, "Math.sqrt(256)", 16, Math.sqrt(256)); + array[item++] = new TestCase( SECTION, "Math.sqrt(10000)", 100, Math.sqrt(10000)); + array[item++] = new TestCase( SECTION, "Math.sqrt(65536)", 256, Math.sqrt(65536)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0.09)", 0.3, Math.sqrt(0.09)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0.01)", 0.1, Math.sqrt(0.01)); + array[item++] = new TestCase( SECTION, "Math.sqrt(0.00000001)",0.0001, Math.sqrt(0.00000001)); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Math/15.8.2.18.js b/tests/mozilla/ecma/Math/15.8.2.18.js new file mode 100644 index 0000000..f745dd7 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.18.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.18.js + ECMA Section: 15.8.2.18 tan( x ) + Description: return an approximation to the tan of the + argument. argument is expressed in radians + special cases: + - if x is NaN result is NaN + - if x is 0 result is 0 + - if x is -0 result is -0 + - if x is Infinity or -Infinity result is NaN + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.18"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.tan(x)"; + var EXCLUDE = "true"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.tan.length", 1, Math.tan.length ); + + array[item++] = new TestCase( SECTION, "Math.tan()", Number.NaN, Math.tan() ); + array[item++] = new TestCase( SECTION, "Math.tan(void 0)", Number.NaN, Math.tan(void 0)); + array[item++] = new TestCase( SECTION, "Math.tan(null)", 0, Math.tan(null) ); + array[item++] = new TestCase( SECTION, "Math.tan(false)", 0, Math.tan(false) ); + + array[item++] = new TestCase( SECTION, "Math.tan(NaN)", Number.NaN, Math.tan(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.tan(0)", 0, Math.tan(0)); + array[item++] = new TestCase( SECTION, "Math.tan(-0)", -0, Math.tan(-0)); + array[item++] = new TestCase( SECTION, "Math.tan(Infinity)", Number.NaN, Math.tan(Number.POSITIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.tan(-Infinity)", Number.NaN, Math.tan(Number.NEGATIVE_INFINITY)); + array[item++] = new TestCase( SECTION, "Math.tan(Math.PI/4)", 1, Math.tan(Math.PI/4)); + array[item++] = new TestCase( SECTION, "Math.tan(3*Math.PI/4)", -1, Math.tan(3*Math.PI/4)); + array[item++] = new TestCase( SECTION, "Math.tan(Math.PI)", -0, Math.tan(Math.PI)); + array[item++] = new TestCase( SECTION, "Math.tan(5*Math.PI/4)", 1, Math.tan(5*Math.PI/4)); + array[item++] = new TestCase( SECTION, "Math.tan(7*Math.PI/4)", -1, Math.tan(7*Math.PI/4)); + array[item++] = new TestCase( SECTION, "Infinity/Math.tan(-0)", -Infinity, Infinity/Math.tan(-0) ); + +/* + Arctan (x) ~ PI/2 - 1/x for large x. For x = 1.6x10^16, 1/x is about the last binary digit of double precision PI/2. + That is to say, perturbing PI/2 by this much is about the smallest rounding error possible. + + This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I + suspect that tan (PI/2 + one ulp) is a negative result about the same size as tan (PI/2) and that this pair are the closest + results to infinity that the algorithm can deliver. + + In any case, my call is that the answer we're seeing is "right". I suggest the test pass on any result this size or larger. + = C = +*/ + array[item++] = new TestCase( SECTION, "Math.tan(3*Math.PI/2) >= 5443000000000000", true, Math.tan(3*Math.PI/2) >= 5443000000000000 ); + array[item++] = new TestCase( SECTION, "Math.tan(Math.PI/2) >= 5443000000000000", true, Math.tan(Math.PI/2) >= 5443000000000000 ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.2.js b/tests/mozilla/ecma/Math/15.8.2.2.js new file mode 100644 index 0000000..4a6f11e --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.2.js @@ -0,0 +1,86 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.2.js + ECMA Section: 15.8.2.2 acos( x ) + Description: return an approximation to the arc cosine of the + argument. the result is expressed in radians and + range is from +0 to +PI. special cases: + - if x is NaN, return NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == 1, the result is +0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + var SECTION = "15.8.2.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.acos()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.acos.length", 1, Math.acos.length ); + + array[item++] = new TestCase( SECTION, "Math.acos(void 0)", Number.NaN, Math.acos(void 0) ); + array[item++] = new TestCase( SECTION, "Math.acos()", Number.NaN, Math.acos() ); + array[item++] = new TestCase( SECTION, "Math.acos(null)", Math.PI/2, Math.acos(null) ); + array[item++] = new TestCase( SECTION, "Math.acos(NaN)", Number.NaN, Math.acos(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.acos(a string)", Number.NaN, Math.acos("a string") ); + array[item++] = new TestCase( SECTION, "Math.acos('0')", Math.PI/2, Math.acos('0') ); + array[item++] = new TestCase( SECTION, "Math.acos('1')", 0, Math.acos('1') ); + array[item++] = new TestCase( SECTION, "Math.acos('-1')", Math.PI, Math.acos('-1') ); + + array[item++] = new TestCase( SECTION, "Math.acos(1.00000001)", Number.NaN, Math.acos(1.00000001) ); + array[item++] = new TestCase( SECTION, "Math.acos(11.00000001)", Number.NaN, Math.acos(-1.00000001) ); + array[item++] = new TestCase( SECTION, "Math.acos(1)", 0, Math.acos(1) ); + array[item++] = new TestCase( SECTION, "Math.acos(-1)", Math.PI, Math.acos(-1) ); + array[item++] = new TestCase( SECTION, "Math.acos(0)", Math.PI/2, Math.acos(0) ); + array[item++] = new TestCase( SECTION, "Math.acos(-0)", Math.PI/2, Math.acos(-0) ); + array[item++] = new TestCase( SECTION, "Math.acos(Math.SQRT1_2)", Math.PI/4, Math.acos(Math.SQRT1_2)); + array[item++] = new TestCase( SECTION, "Math.acos(-Math.SQRT1_2)", Math.PI/4*3, Math.acos(-Math.SQRT1_2)); + array[item++] = new TestCase( SECTION, "Math.acos(0.9999619230642)", Math.PI/360, Math.acos(0.9999619230642)); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.3.js b/tests/mozilla/ecma/Math/15.8.2.3.js new file mode 100644 index 0000000..2a00e93 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.3.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.3.js + ECMA Section: 15.8.2.3 asin( x ) + Description: return an approximation to the arc sine of the + argument. the result is expressed in radians and + range is from -PI/2 to +PI/2. special cases: + - if x is NaN, the result is NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == +0, the result is +0 + - if x == -0, the result is -0 + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "15.8.2.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.asin()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.asin()", Number.NaN, Math.asin() ); + array[item++] = new TestCase( SECTION, "Math.asin(void 0)", Number.NaN, Math.asin(void 0) ); + array[item++] = new TestCase( SECTION, "Math.asin(null)", 0, Math.asin(null) ); + array[item++] = new TestCase( SECTION, "Math.asin(NaN)", Number.NaN, Math.asin(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.asin('string')", Number.NaN, Math.asin("string") ); + array[item++] = new TestCase( SECTION, "Math.asin('0')", 0, Math.asin("0") ); + array[item++] = new TestCase( SECTION, "Math.asin('1')", Math.PI/2, Math.asin("1") ); + array[item++] = new TestCase( SECTION, "Math.asin('-1')", -Math.PI/2, Math.asin("-1") ); + array[item++] = new TestCase( SECTION, "Math.asin(Math.SQRT1_2+'')", Math.PI/4, Math.asin(Math.SQRT1_2+'') ); + array[item++] = new TestCase( SECTION, "Math.asin(-Math.SQRT1_2+'')", -Math.PI/4, Math.asin(-Math.SQRT1_2+'') ); + + array[item++] = new TestCase( SECTION, "Math.asin(1.000001)", Number.NaN, Math.asin(1.000001) ); + array[item++] = new TestCase( SECTION, "Math.asin(-1.000001)", Number.NaN, Math.asin(-1.000001) ); + array[item++] = new TestCase( SECTION, "Math.asin(0)", 0, Math.asin(0) ); + array[item++] = new TestCase( SECTION, "Math.asin(-0)", -0, Math.asin(-0) ); + + array[item++] = new TestCase( SECTION, "Infinity/Math.asin(-0)", -Infinity, Infinity/Math.asin(-0) ); + + array[item++] = new TestCase( SECTION, "Math.asin(1)", Math.PI/2, Math.asin(1) ); + array[item++] = new TestCase( SECTION, "Math.asin(-1)", -Math.PI/2, Math.asin(-1) ); + array[item++] = new TestCase( SECTION, "Math.asin(Math.SQRT1_2))", Math.PI/4, Math.asin(Math.SQRT1_2) ); + array[item++] = new TestCase( SECTION, "Math.asin(-Math.SQRT1_2))", -Math.PI/4, Math.asin(-Math.SQRT1_2)); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Math/15.8.2.4.js b/tests/mozilla/ecma/Math/15.8.2.4.js new file mode 100644 index 0000000..3711331 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.4.js @@ -0,0 +1,88 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + /** + File Name: 15.8.2.4.js + ECMA Section: 15.8.2.4 atan( x ) + Description: return an approximation to the arc tangent of the + argument. the result is expressed in radians and + range is from -PI/2 to +PI/2. special cases: + - if x is NaN, the result is NaN + - if x == +0, the result is +0 + - if x == -0, the result is -0 + - if x == +Infinity, the result is approximately +PI/2 + - if x == -Infinity, the result is approximately -PI/2 + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + + var SECTION = "15.8.2.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.atan()"; + var BUGNUMBER="77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.atan.length", 1, Math.atan.length ); + + array[item++] = new TestCase( SECTION, "Math.atan()", Number.NaN, Math.atan() ); + array[item++] = new TestCase( SECTION, "Math.atan(void 0)", Number.NaN, Math.atan(void 0) ); + array[item++] = new TestCase( SECTION, "Math.atan(null)", 0, Math.atan(null) ); + array[item++] = new TestCase( SECTION, "Math.atan(NaN)", Number.NaN, Math.atan(Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.atan('a string')", Number.NaN, Math.atan("a string") ); + array[item++] = new TestCase( SECTION, "Math.atan('0')", 0, Math.atan('0') ); + array[item++] = new TestCase( SECTION, "Math.atan('1')", Math.PI/4, Math.atan('1') ); + array[item++] = new TestCase( SECTION, "Math.atan('-1')", -Math.PI/4, Math.atan('-1') ); + array[item++] = new TestCase( SECTION, "Math.atan('Infinity)", Math.PI/2, Math.atan('Infinity') ); + array[item++] = new TestCase( SECTION, "Math.atan('-Infinity)", -Math.PI/2, Math.atan('-Infinity') ); + + array[item++] = new TestCase( SECTION, "Math.atan(0)", 0, Math.atan(0) ); + array[item++] = new TestCase( SECTION, "Math.atan(-0)", -0, Math.atan(-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.atan(-0)", -Infinity, Infinity/Math.atan(-0) ); + array[item++] = new TestCase( SECTION, "Math.atan(Infinity)", Math.PI/2, Math.atan(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan(-Infinity)", -Math.PI/2, Math.atan(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan(1)", Math.PI/4, Math.atan(1) ); + array[item++] = new TestCase( SECTION, "Math.atan(-1)", -Math.PI/4, Math.atan(-1) ); + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Math/15.8.2.5.js b/tests/mozilla/ecma/Math/15.8.2.5.js new file mode 100644 index 0000000..d1eeead --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.5.js @@ -0,0 +1,105 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.5.js + ECMA Section: 15.8.2.5 atan2( y, x ) + Description: + + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + var SECTION = "15.8.2.5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.atan2(x,y)"; + var BUGNUMBER="76111"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.atan2.length", 2, Math.atan2.length ); + + array[item++] = new TestCase( SECTION, "Math.atan2(NaN, 0)", Number.NaN, Math.atan2(Number.NaN,0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(null, null)", 0, Math.atan2(null, null) ); + array[item++] = new TestCase( SECTION, "Math.atan2(void 0, void 0)", Number.NaN, Math.atan2(void 0, void 0) ); + array[item++] = new TestCase( SECTION, "Math.atan2()", Number.NaN, Math.atan2() ); + + array[item++] = new TestCase( SECTION, "Math.atan2(0, NaN)", Number.NaN, Math.atan2(0,Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.atan2(1, 0)", Math.PI/2, Math.atan2(1,0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(1,-0)", Math.PI/2, Math.atan2(1,-0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(0,0.001)", 0, Math.atan2(0,0.001) ); + array[item++] = new TestCase( SECTION, "Math.atan2(0,0)", 0, Math.atan2(0,0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(0, -0)", Math.PI, Math.atan2(0,-0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(0, -1)", Math.PI, Math.atan2(0, -1) ); + + array[item++] = new TestCase( SECTION, "Math.atan2(-0, 1)", -0, Math.atan2(-0, 1) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.atan2(-0, 1)", -Infinity, Infinity/Math.atan2(-0,1) ); + + array[item++] = new TestCase( SECTION, "Math.atan2(-0, 0)", -0, Math.atan2(-0,0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-0, -0)", -Math.PI, Math.atan2(-0, -0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-0, -1)", -Math.PI, Math.atan2(-0, -1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-1, 0)", -Math.PI/2, Math.atan2(-1, 0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-1, -0)", -Math.PI/2, Math.atan2(-1, -0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(1, Infinity)", 0, Math.atan2(1, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(1,-Infinity)", Math.PI, Math.atan2(1, Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "Math.atan2(-1, Infinity)", -0, Math.atan2(-1,Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.atan2(-1, Infinity)", -Infinity, Infinity/Math.atan2(-1,Infinity) ); + + array[item++] = new TestCase( SECTION, "Math.atan2(-1,-Infinity)", -Math.PI, Math.atan2(-1,Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, 0)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY, 0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, 1)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY, 1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity,-1)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY,-1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity,-0)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY,-0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, 0)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY, 0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity,-0)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY,-0) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, 1)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY, 1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, -1)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY,-1) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, Infinity)", Math.PI/4, Math.atan2(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, -Infinity)", 3*Math.PI/4, Math.atan2(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, Infinity)", -Math.PI/4, Math.atan2(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, -Infinity)", -3*Math.PI/4, Math.atan2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.atan2(-1, 1)", -Math.PI/4, Math.atan2( -1, 1) ); + + return array; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.6.js b/tests/mozilla/ecma/Math/15.8.2.6.js new file mode 100644 index 0000000..738bfe4 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.6.js @@ -0,0 +1,108 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.6.js + ECMA Section: 15.8.2.6 Math.ceil(x) + Description: return the smallest number value that is not less than the + argument and is equal to a mathematical integer. if the + number is already an integer, return the number itself. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = 0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.ceil(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 +*/ + var SECTION = "15.8.2.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.ceil(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.ceil.length", 1, Math.ceil.length ); + + array[item++] = new TestCase( SECTION, "Math.ceil(NaN)", Number.NaN, Math.ceil(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.ceil(null)", 0, Math.ceil(null) ); + array[item++] = new TestCase( SECTION, "Math.ceil()", Number.NaN, Math.ceil() ); + array[item++] = new TestCase( SECTION, "Math.ceil(void 0)", Number.NaN, Math.ceil(void 0) ); + + array[item++] = new TestCase( SECTION, "Math.ceil('0')", 0, Math.ceil('0') ); + array[item++] = new TestCase( SECTION, "Math.ceil('-0')", -0, Math.ceil('-0') ); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil('0')", Infinity, Infinity/Math.ceil('0')); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil('-0')", -Infinity, Infinity/Math.ceil('-0')); + + array[item++] = new TestCase( SECTION, "Math.ceil(0)", 0, Math.ceil(0) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-0)", -0, Math.ceil(-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(0)", Infinity, Infinity/Math.ceil(0)); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(-0)", -Infinity, Infinity/Math.ceil(-0)); + + array[item++] = new TestCase( SECTION, "Math.ceil(Infinity)", Number.POSITIVE_INFINITY, Math.ceil(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-Infinity)", Number.NEGATIVE_INFINITY, Math.ceil(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-Number.MIN_VALUE)", -0, Math.ceil(-Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(-Number.MIN_VALUE)", -Infinity, Infinity/Math.ceil(-Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "Math.ceil(1)", 1, Math.ceil(1) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-1)", -1, Math.ceil(-1) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-0.9)", -0, Math.ceil(-0.9) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(-0.9)", -Infinity, Infinity/Math.ceil(-0.9) ); + array[item++] = new TestCase( SECTION, "Math.ceil(0.9 )", 1, Math.ceil( 0.9) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-1.1)", -1, Math.ceil( -1.1)); + array[item++] = new TestCase( SECTION, "Math.ceil( 1.1)", 2, Math.ceil( 1.1)); + + array[item++] = new TestCase( SECTION, "Math.ceil(Infinity)", -Math.floor(-Infinity), Math.ceil(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-Infinity)", -Math.floor(Infinity), Math.ceil(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-Number.MIN_VALUE)", -Math.floor(Number.MIN_VALUE), Math.ceil(-Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "Math.ceil(1)", -Math.floor(-1), Math.ceil(1) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-1)", -Math.floor(1), Math.ceil(-1) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-0.9)", -Math.floor(0.9), Math.ceil(-0.9) ); + array[item++] = new TestCase( SECTION, "Math.ceil(0.9 )", -Math.floor(-0.9), Math.ceil( 0.9) ); + array[item++] = new TestCase( SECTION, "Math.ceil(-1.1)", -Math.floor(1.1), Math.ceil( -1.1)); + array[item++] = new TestCase( SECTION, "Math.ceil( 1.1)", -Math.floor(-1.1), Math.ceil( 1.1)); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.7.js b/tests/mozilla/ecma/Math/15.8.2.7.js new file mode 100644 index 0000000..6b7dcfe --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.7.js @@ -0,0 +1,111 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.7.js + ECMA Section: 15.8.2.7 cos( x ) + Description: return an approximation to the cosine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + + var SECTION = "15.8.2.7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.cos(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.cos.length", 1, Math.cos.length ); + + array[item++] = new TestCase( SECTION, "Math.cos()", Number.NaN, Math.cos() ); + array[item++] = new TestCase( SECTION, "Math.cos(void 0)", Number.NaN, Math.cos(void 0) ); + array[item++] = new TestCase( SECTION, "Math.cos(false)", 1, Math.cos(false) ); + array[item++] = new TestCase( SECTION, "Math.cos(null)", 1, Math.cos(null) ); + + array[item++] = new TestCase( SECTION, "Math.cos('0')", 1, Math.cos('0') ); + array[item++] = new TestCase( SECTION, "Math.cos('Infinity')", Number.NaN, Math.cos("Infinity") ); + array[item++] = new TestCase( SECTION, "Math.cos('3.14159265359')", -1, Math.cos('3.14159265359') ); + + array[item++] = new TestCase( SECTION, "Math.cos(NaN)", Number.NaN, Math.cos(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.cos(0)", 1, Math.cos(0) ); + array[item++] = new TestCase( SECTION, "Math.cos(-0)", 1, Math.cos(-0) ); + array[item++] = new TestCase( SECTION, "Math.cos(Infinity)", Number.NaN, Math.cos(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Infinity)", Number.NaN, Math.cos(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.cos(0.7853981633974)", 0.7071067811865, Math.cos(0.7853981633974) ); + array[item++] = new TestCase( SECTION, "Math.cos(1.570796326795)", 0, Math.cos(1.570796326795) ); + array[item++] = new TestCase( SECTION, "Math.cos(2.356194490192)", -0.7071067811865, Math.cos(2.356194490192) ); + array[item++] = new TestCase( SECTION, "Math.cos(3.14159265359)", -1, Math.cos(3.14159265359) ); + array[item++] = new TestCase( SECTION, "Math.cos(3.926990816987)", -0.7071067811865, Math.cos(3.926990816987) ); + array[item++] = new TestCase( SECTION, "Math.cos(4.712388980385)", 0, Math.cos(4.712388980385) ); + array[item++] = new TestCase( SECTION, "Math.cos(5.497787143782)", 0.7071067811865, Math.cos(5.497787143782) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI*2)", 1, Math.cos(Math.PI*2) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI/4)", Math.SQRT2/2, Math.cos(Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI/2)", 0, Math.cos(Math.PI/2) ); + array[item++] = new TestCase( SECTION, "Math.cos(3*Math.PI/4)", -Math.SQRT2/2, Math.cos(3*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI)", -1, Math.cos(Math.PI) ); + array[item++] = new TestCase( SECTION, "Math.cos(5*Math.PI/4)", -Math.SQRT2/2, Math.cos(5*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(3*Math.PI/2)", 0, Math.cos(3*Math.PI/2) ); + array[item++] = new TestCase( SECTION, "Math.cos(7*Math.PI/4)", Math.SQRT2/2, Math.cos(7*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(Math.PI*2)", 1, Math.cos(2*Math.PI) ); + array[item++] = new TestCase( SECTION, "Math.cos(-0.7853981633974)", 0.7071067811865, Math.cos(-0.7853981633974) ); + array[item++] = new TestCase( SECTION, "Math.cos(-1.570796326795)", 0, Math.cos(-1.570796326795) ); + array[item++] = new TestCase( SECTION, "Math.cos(-2.3561944901920)", -.7071067811865, Math.cos(2.3561944901920) ); + array[item++] = new TestCase( SECTION, "Math.cos(-3.14159265359)", -1, Math.cos(3.14159265359) ); + array[item++] = new TestCase( SECTION, "Math.cos(-3.926990816987)", -0.7071067811865, Math.cos(3.926990816987) ); + array[item++] = new TestCase( SECTION, "Math.cos(-4.712388980385)", 0, Math.cos(4.712388980385) ); + array[item++] = new TestCase( SECTION, "Math.cos(-5.497787143782)", 0.7071067811865, Math.cos(5.497787143782) ); + array[item++] = new TestCase( SECTION, "Math.cos(-6.28318530718)", 1, Math.cos(6.28318530718) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI/4)", Math.SQRT2/2, Math.cos(-Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI/2)", 0, Math.cos(-Math.PI/2) ); + array[item++] = new TestCase( SECTION, "Math.cos(-3*Math.PI/4)", -Math.SQRT2/2, Math.cos(-3*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI)", -1, Math.cos(-Math.PI) ); + array[item++] = new TestCase( SECTION, "Math.cos(-5*Math.PI/4)", -Math.SQRT2/2, Math.cos(-5*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(-3*Math.PI/2)", 0, Math.cos(-3*Math.PI/2) ); + array[item++] = new TestCase( SECTION, "Math.cos(-7*Math.PI/4)", Math.SQRT2/2, Math.cos(-7*Math.PI/4) ); + array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI*2)", 1, Math.cos(-Math.PI*2) ); + + return ( array ); +} + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.8.js b/tests/mozilla/ecma/Math/15.8.2.8.js new file mode 100644 index 0000000..c0a4924 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.8.js @@ -0,0 +1,84 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.8.js + ECMA Section: 15.8.2.8 Math.exp(x) + Description: return an approximation to the exponential function of + the argument (e raised to the power of the argument) + special cases: + - if x is NaN return NaN + - if x is 0 return 1 + - if x is -0 return 1 + - if x is Infinity return Infinity + - if x is -Infinity return 0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + + var SECTION = "15.8.2.8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.exp(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.exp.length", 1, Math.exp.length ); + + array[item++] = new TestCase( SECTION, "Math.exp()", Number.NaN, Math.exp() ); + array[item++] = new TestCase( SECTION, "Math.exp(null)", 1, Math.exp(null) ); + array[item++] = new TestCase( SECTION, "Math.exp(void 0)", Number.NaN, Math.exp(void 0) ); + array[item++] = new TestCase( SECTION, "Math.exp(1)", Math.E, Math.exp(1) ); + array[item++] = new TestCase( SECTION, "Math.exp(true)", Math.E, Math.exp(true) ); + array[item++] = new TestCase( SECTION, "Math.exp(false)", 1, Math.exp(false) ); + + array[item++] = new TestCase( SECTION, "Math.exp('1')", Math.E, Math.exp('1') ); + array[item++] = new TestCase( SECTION, "Math.exp('0')", 1, Math.exp('0') ); + + array[item++] = new TestCase( SECTION, "Math.exp(NaN)", Number.NaN, Math.exp(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.exp(0)", 1, Math.exp(0) ); + array[item++] = new TestCase( SECTION, "Math.exp(-0)", 1, Math.exp(-0) ); + array[item++] = new TestCase( SECTION, "Math.exp(Infinity)", Number.POSITIVE_INFINITY, Math.exp(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.exp(-Infinity)", 0, Math.exp(Number.NEGATIVE_INFINITY) ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Math/15.8.2.9.js b/tests/mozilla/ecma/Math/15.8.2.9.js new file mode 100644 index 0000000..c1ea987 --- /dev/null +++ b/tests/mozilla/ecma/Math/15.8.2.9.js @@ -0,0 +1,105 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.8.2.9.js + ECMA Section: 15.8.2.9 Math.floor(x) + Description: return the greatest number value that is not greater + than the argument and is equal to a mathematical integer. + if the number is already an integer, return the number + itself. special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.floor(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + var SECTION = "15.8.2.9"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Math.floor(x)"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Math.floor.length", 1, Math.floor.length ); + + array[item++] = new TestCase( SECTION, "Math.floor()", Number.NaN, Math.floor() ); + array[item++] = new TestCase( SECTION, "Math.floor(void 0)", Number.NaN, Math.floor(void 0) ); + array[item++] = new TestCase( SECTION, "Math.floor(null)", 0, Math.floor(null) ); + array[item++] = new TestCase( SECTION, "Math.floor(true)", 1, Math.floor(true) ); + array[item++] = new TestCase( SECTION, "Math.floor(false)", 0, Math.floor(false) ); + + array[item++] = new TestCase( SECTION, "Math.floor('1.1')", 1, Math.floor("1.1") ); + array[item++] = new TestCase( SECTION, "Math.floor('-1.1')", -2, Math.floor("-1.1") ); + array[item++] = new TestCase( SECTION, "Math.floor('0.1')", 0, Math.floor("0.1") ); + array[item++] = new TestCase( SECTION, "Math.floor('-0.1')", -1, Math.floor("-0.1") ); + + array[item++] = new TestCase( SECTION, "Math.floor(NaN)", Number.NaN, Math.floor(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Math.floor(NaN)==-Math.ceil(-NaN)", false, Math.floor(Number.NaN) == -Math.ceil(-Number.NaN) ); + + array[item++] = new TestCase( SECTION, "Math.floor(0)", 0, Math.floor(0) ); + array[item++] = new TestCase( SECTION, "Math.floor(0)==-Math.ceil(-0)", true, Math.floor(0) == -Math.ceil(-0) ); + + array[item++] = new TestCase( SECTION, "Math.floor(-0)", -0, Math.floor(-0) ); + array[item++] = new TestCase( SECTION, "Infinity/Math.floor(-0)", -Infinity, Infinity/Math.floor(-0) ); + array[item++] = new TestCase( SECTION, "Math.floor(-0)==-Math.ceil(0)", true, Math.floor(-0)== -Math.ceil(0) ); + + array[item++] = new TestCase( SECTION, "Math.floor(Infinity)", Number.POSITIVE_INFINITY, Math.floor(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.floor(Infinity)==-Math.ceil(-Infinity)", true, Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil(Number.NEGATIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "Math.floor(-Infinity)", Number.NEGATIVE_INFINITY, Math.floor(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Math.floor(-Infinity)==-Math.ceil(Infinity)", true, Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil(Number.POSITIVE_INFINITY) ); + + array[item++] = new TestCase( SECTION, "Math.floor(0.0000001)", 0, Math.floor(0.0000001) ); + array[item++] = new TestCase( SECTION, "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true, Math.floor(0.0000001)==-Math.ceil(-0.0000001) ); + + array[item++] = new TestCase( SECTION, "Math.floor(-0.0000001)", -1, Math.floor(-0.0000001) ); + array[item++] = new TestCase( SECTION, "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true, Math.floor(-0.0000001)==-Math.ceil(0.0000001) ); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/NativeObjects/15-1.js b/tests/mozilla/ecma/NativeObjects/15-1.js new file mode 100644 index 0000000..cecdd90 --- /dev/null +++ b/tests/mozilla/ecma/NativeObjects/15-1.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.js + ECMA Section: 15 Native ECMAScript Objects + Description: Every built-in prototype object has the Object prototype + object, which is the value of the expression + Object.prototype (15.2.3.1) as the value of its internal + [[Prototype]] property, except the Object prototype + object itself. + + Every native object associated with a program-created + function also has the Object prototype object as the + value of its internal [[Prototype]] property. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Native ECMAScript Objects"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; +/* + array[item++] = new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); +// array[item++] = new TestCase( SECTION, "Math.prototype.__proto__", Object.prototype, Math.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "Date.prototype.__proto__", Object.prototype, Date.prototype.__proto__ ); + array[item++] = new TestCase( SECTION, "TestCase.prototype.__proto__", Object.prototype, TestCase.prototype.__proto__ ); + + array[item++] = new TestCase( SECTION, "MyObject.prototype.__proto__", Object.prototype, MyObject.prototype.__proto__ ); +*/ + array[item++] = new TestCase( SECTION, "Function.prototype.__proto__ == Object.prototype", true, Function.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "Array.prototype.__proto__ == Object.prototype", true, Array.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "String.prototype.__proto__ == Object.prototype", true, String.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__ == Object.prototype", true, Boolean.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); +// array[item++] = new TestCase( SECTION, "Math.prototype.__proto__ == Object.prototype", true, Math.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "Date.prototype.__proto__ == Object.prototype", true, Date.prototype.__proto__ == Object.prototype ); + array[item++] = new TestCase( SECTION, "TestCase.prototype.__proto__ == Object.prototype", true, TestCase.prototype.__proto__ == Object.prototype ); + + array[item++] = new TestCase( SECTION, "MyObject.prototype.__proto__ == Object.prototype", true, MyObject.prototype.__proto__ == Object.prototype ); + + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + + stopTest(); + return ( testcases ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/tests/mozilla/ecma/NativeObjects/15-2.js b/tests/mozilla/ecma/NativeObjects/15-2.js new file mode 100644 index 0000000..612e1b4 --- /dev/null +++ b/tests/mozilla/ecma/NativeObjects/15-2.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15-2.js + ECMA Section: 15 Native ECMAScript Objects + + Description: Every built-in function and every built-in constructor + has the Function prototype object, which is the value of + the expression Function.prototype as the value of its + internal [[Prototype]] property, except the Function + prototype object itself. + + That is, the __proto__ property of builtin functions and + constructors should be the Function.prototype object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Native ECMAScript Objects"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); + array[item++] = new TestCase( SECTION, "Array.__proto__", Function.prototype, Array.__proto__ ); + array[item++] = new TestCase( SECTION, "String.__proto__", Function.prototype, String.__proto__ ); + array[item++] = new TestCase( SECTION, "Boolean.__proto__", Function.prototype, Boolean.__proto__ ); + array[item++] = new TestCase( SECTION, "Number.__proto__", Function.prototype, Number.__proto__ ); + array[item++] = new TestCase( SECTION, "Date.__proto__", Function.prototype, Date.__proto__ ); + array[item++] = new TestCase( SECTION, "TestCase.__proto__", Function.prototype, TestCase.__proto__ ); + + array[item++] = new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); + array[item++] = new TestCase( SECTION, "Math.pow.__proto__", Function.prototype, Math.pow.__proto__ ); + array[item++] = new TestCase( SECTION, "String.prototype.indexOf.__proto__", Function.prototype, String.prototype.indexOf.__proto__ ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.1.js b/tests/mozilla/ecma/Number/15.7.1.js new file mode 100644 index 0000000..102912d --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.1.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.1.js + ECMA Section: 15.7.1 The Number Constructor Called as a Function + 15.7.1.1 + 15.7.1.2 + + Description: When Number is called as a function rather than as a + constructor, it performs a type conversion. + 15.7.1.1 Return a number value (not a Number object) + computed by ToNumber( value ) + 15.7.1.2 Number() returns 0. + + need to add more test cases. see the testcases for + TypeConversion ToNumber. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + + var SECTION = "15.7.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Number Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "Number()", 0, Number() ); + array[item++] = new TestCase(SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); + array[item++] = new TestCase(SECTION, "Number(null)", 0, Number(null) ); + array[item++] = new TestCase(SECTION, "Number()", 0, Number() ); + array[item++] = new TestCase(SECTION, "Number(new Number())", 0, Number( new Number() ) ); + array[item++] = new TestCase(SECTION, "Number(0)", 0, Number(0) ); + array[item++] = new TestCase(SECTION, "Number(1)", 1, Number(1) ); + array[item++] = new TestCase(SECTION, "Number(-1)", -1, Number(-1) ); + array[item++] = new TestCase(SECTION, "Number(NaN)", Number.NaN, Number( Number.NaN ) ); + array[item++] = new TestCase(SECTION, "Number('string')", Number.NaN, Number( "string") ); + array[item++] = new TestCase(SECTION, "Number(new String())", 0, Number( new String() ) ); + array[item++] = new TestCase(SECTION, "Number('')", 0, Number( "" ) ); + array[item++] = new TestCase(SECTION, "Number(Infinity)", Number.POSITIVE_INFINITY, Number("Infinity") ); + + array[item++] = new TestCase(SECTION, "Number(new MyObject(100))", 100, Number(new MyObject(100)) ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Number/15.7.2.js b/tests/mozilla/ecma/Number/15.7.2.js new file mode 100644 index 0000000..6e3982b --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.2.js @@ -0,0 +1,173 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.2.js + ECMA Section: 15.7.2 The Number Constructor + 15.7.2.1 + 15.7.2.2 + + Description: 15.7.2 When Number is called as part of a new + expression, it is a constructor: it initializes + the newly created object. + + 15.7.2.1 The [[Prototype]] property of the newly + constructed object is set to othe original Number + prototype object, the one that is the initial value + of Number.prototype(0). The [[Class]] property is + set to "Number". The [[Value]] property of the + newly constructed object is set to ToNumber(value) + + 15.7.2.2 new Number(). same as in 15.7.2.1, except + the [[Value]] property is set to +0. + + need to add more test cases. see the testcases for + TypeConversion ToNumber. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + + var SECTION = "15.7.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The Number Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // To verify that the object's prototype is the Number.prototype, check to see if the object's + // constructor property is the same as Number.prototype.constructor. + + array[item++] = new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); + + array[item++] = new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); + array[item++] = new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(0)).constructor", Number.prototype.constructor, (new Number(0)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(0))", "object", typeof (new Number(0)) ); + array[item++] = new TestCase(SECTION, "(new Number(0)).valueOf()", 0, (new Number(0)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(1)).constructor", Number.prototype.constructor, (new Number(1)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(1))", "object", typeof (new Number(1)) ); + array[item++] = new TestCase(SECTION, "(new Number(1)).valueOf()", 1, (new Number(1)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(-1)).constructor", Number.prototype.constructor, (new Number(-1)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(-1))", "object", typeof (new Number(-1)) ); + array[item++] = new TestCase(SECTION, "(new Number(-1)).valueOf()", -1, (new Number(-1)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(Number.NaN)).constructor", Number.prototype.constructor, (new Number(Number.NaN)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(Number.NaN))", "object", typeof (new Number(Number.NaN)) ); + array[item++] = new TestCase(SECTION, "(new Number(Number.NaN)).valueOf()", Number.NaN, (new Number(Number.NaN)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number('string')).constructor", Number.prototype.constructor, (new Number('string')).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number('string'))", "object", typeof (new Number('string')) ); + array[item++] = new TestCase(SECTION, "(new Number('string')).valueOf()", Number.NaN, (new Number('string')).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(new String())).constructor", Number.prototype.constructor, (new Number(new String())).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(new String()))", "object", typeof (new Number(new String())) ); + array[item++] = new TestCase(SECTION, "(new Number(new String())).valueOf()", 0, (new Number(new String())).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number('')).constructor", Number.prototype.constructor, (new Number('')).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(''))", "object", typeof (new Number('')) ); + array[item++] = new TestCase(SECTION, "(new Number('')).valueOf()", 0, (new Number('')).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.POSITIVE_INFINITY)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(Number.POSITIVE_INFINITY))", "object", typeof (new Number(Number.POSITIVE_INFINITY)) ); + array[item++] = new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).valueOf()", Number.POSITIVE_INFINITY, (new Number(Number.POSITIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + array[item++] = new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.NEGATIVE_INFINITY)).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number(Number.NEGATIVE_INFINITY))", "object", typeof (new Number(Number.NEGATIVE_INFINITY)) ); + array[item++] = new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).valueOf()", Number.NEGATIVE_INFINITY, (new Number(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + + array[item++] = new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); + array[item++] = new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); + array[item++] = new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); + array[item++] = new TestCase(SECTION, + "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + return ( array ); +} + + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Number/15.7.3.1-1.js b/tests/mozilla/ecma/Number/15.7.3.1-1.js new file mode 100644 index 0000000..71aea75 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.1-1.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.1-2.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.prototype + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.3.1-1"; +var VERSION = "ECMA_1"; + startTest(); +var TITLE = "Number.prototype"; + +writeHeaderToLog( SECTION +" "+ TITLE); + +var testcases = getTestCases(); +test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype", true, "var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype" ); + array[item++] = new TestCase(SECTION, "delete( Number.prototype )", false, "delete( Number.prototype )" ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Number/15.7.3.1-2.js b/tests/mozilla/ecma/Number/15.7.3.1-2.js new file mode 100644 index 0000000..dbce0e1 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.1-2.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.1-2.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.prototype + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT", + true, + eval("var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT") ); + + array[item++] = new TestCase( SECTION, + "Number.prototype=0; Number.prototype", + Number.prototype, + eval("Number.prototype=0; Number.prototype") ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Number/15.7.3.1-3.js b/tests/mozilla/ecma/Number/15.7.3.1-3.js new file mode 100644 index 0000000..34bd2ff --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.1-3.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.1-4.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.prototype + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "15.7.3.1-3"; + var TITLE = "Number.prototype"; + + writeHeaderToLog( SECTION + " Number.prototype: DontEnum Attribute"); + + var testcases = getTestCases(); + + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop: '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop : '' } string;") + ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += "property should not be enumerated "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.2-1.js b/tests/mozilla/ecma/Number/15.7.3.2-1.js new file mode 100644 index 0000000..51d679a --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.2-1.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.2-1.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MAX_VALUE"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Number.MAX_VALUE", 1.7976931348623157e308, Number.MAX_VALUE ); + + + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.2-2.js b/tests/mozilla/ecma/Number/15.7.3.2-2.js new file mode 100644 index 0000000..b5f57c9 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.2-2.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.2-2.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MAX_VALUE: DontDelete Attribute"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "delete( Number.MAX_VALUE ); Number.MAX_VALUE", 1.7976931348623157e308, "delete( Number.MAX_VALUE );Number.MAX_VALUE" ); + array[item++] = new TestCase( SECTION, "delete( Number.MAX_VALUE )", false, "delete( Number.MAX_VALUE )" ); + + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.2-3.js b/tests/mozilla/ecma/Number/15.7.3.2-3.js new file mode 100644 index 0000000..c8040cd --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.2-3.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.2-3.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MAX_VALUE"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MAX_VAL = 1.7976931348623157e308; + + array[item++] = new TestCase( SECTION, + "Number.MAX_VALUE=0; Number.MAX_VALUE", + MAX_VAL, + eval("Number.MAX_VALUE=0; Number.MAX_VALUE") ); + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.2-4.js b/tests/mozilla/ecma/Number/15.7.3.2-4.js new file mode 100644 index 0000000..846a3c1 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.2-4.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.2-4.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.2-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MAX_VALUE: DontEnum Attribute"; + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;") + ); + + return ( array ); +} +function test( testcases ) { + for ( tc = 0; tc < testcases.length; tc++ ) { + writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += "property should not be enumerated "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.3-1.js b/tests/mozilla/ecma/Number/15.7.3.3-1.js new file mode 100644 index 0000000..f912583 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.3-1.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.3-1.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MIN_VALUE"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MIN_VAL = 5e-324; + + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE", MIN_VAL, Number.MIN_VALUE ); + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.3-2.js b/tests/mozilla/ecma/Number/15.7.3.3-2.js new file mode 100644 index 0000000..fdcfb0a --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.3-2.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.3-2.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MIN_VALUE"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MIN_VAL = 5e-324; + + array[item++] = new TestCase( SECTION, "delete( Number.MIN_VALUE )", false, "delete( Number.MIN_VALUE )" ); + array[item++] = new TestCase( SECTION, "delete( Number.MIN_VALUE ); Number.MIN_VALUE", MIN_VAL, "delete( Number.MIN_VALUE );Number.MIN_VALUE" ); + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.3-3.js b/tests/mozilla/ecma/Number/15.7.3.3-3.js new file mode 100644 index 0000000..f1c4380 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.3-3.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.3-3.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.3-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.MIN_VALUE: ReadOnly Attribute"; + + writeHeaderToLog( SECTION + " "+TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "Number.MIN_VALUE=0; Number.MIN_VALUE", + Number.MIN_VALUE, + "Number.MIN_VALUE=0; Number.MIN_VALUE" ); + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += "property should be readonly "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.3-4.js b/tests/mozilla/ecma/Number/15.7.3.3-4.js new file mode 100644 index 0000000..7b3fa19 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.3-4.js @@ -0,0 +1,69 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.3-4.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.3-4"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Number.MIN_VALUE: DontEnum Attribute"); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;") + ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += "property should not be enumerated "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.4-1.js b/tests/mozilla/ecma/Number/15.7.3.4-1.js new file mode 100644 index 0000000..2ff39f6 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.4-1.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.4-1.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NaN"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase(SECTION, "NaN", NaN, Number.NaN ); + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.4-2.js b/tests/mozilla/ecma/Number/15.7.3.4-2.js new file mode 100644 index 0000000..96535f1 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.4-2.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.4-2.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.3.4-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NaN"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "delete( Number.NaN ); Number.NaN", NaN, "delete( Number.NaN );Number.NaN" ); + array[item++] = new TestCase( SECTION, "delete( Number.NaN )", false, "delete( Number.NaN )" ); + + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.4-3.js b/tests/mozilla/ecma/Number/15.7.3.4-3.js new file mode 100644 index 0000000..3f13a2f --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.4-3.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.4-3.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.4-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NaN"; + + writeHeaderToLog( SECTION + " "+ TITLE ); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( + SECTION, + "Number.NaN=0; Number.NaN", + Number.NaN, + "Number.NaN=0; Number.NaN" ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += "property should be readonly "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.4-4.js b/tests/mozilla/ecma/Number/15.7.3.4-4.js new file mode 100644 index 0000000..33b1667 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.4-4.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.4-4.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.4-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NaN"; + + writeHeaderToLog( SECTION + " " + TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;") + ); + + return ( array ); +} + +function test( testcases ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += "property should not be enumerated "; + passed = false; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.5-1.js b/tests/mozilla/ecma/Number/15.7.3.5-1.js new file mode 100644 index 0000000..1ca04eb --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.5-1.js @@ -0,0 +1,61 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.5-1.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NEGATIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase(SECTION, "Number.NEGATIVE_INFINITY", -Infinity, Number.NEGATIVE_INFINITY ); + + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.5-2.js b/tests/mozilla/ecma/Number/15.7.3.5-2.js new file mode 100644 index 0000000..2291552 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.5-2.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.5-2.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NEGATIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "delete( Number.NEGATIVE_INFINITY )", + false, + "delete( Number.NEGATIVE_INFINITY )" ); + + array[item++] = new TestCase( SECTION, + "delete( Number.NEGATIVE_INFINITY ); Number.NEGATIVE_INFINITY", + -Infinity, + "delete( Number.NEGATIVE_INFINITY );Number.NEGATIVE_INFINITY" ); + return ( array ); +} +function test( testcases ) { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.5-3.js b/tests/mozilla/ecma/Number/15.7.3.5-3.js new file mode 100644 index 0000000..c14fcf8 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.5-3.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.5-3.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.5-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NEGATIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY", + -Infinity, + "Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += "property should be readonly "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.5-4.js b/tests/mozilla/ecma/Number/15.7.3.5-4.js new file mode 100644 index 0000000..fd3fd4e --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.5-4.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.5-4.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.5-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.NEGATIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;") + ); + return ( array ); +} + +function test( testcases ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += "property should not be enumerated "; + + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Number/15.7.3.6-1.js b/tests/mozilla/ecma/Number/15.7.3.6-1.js new file mode 100644 index 0000000..a14b35e --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.6-1.js @@ -0,0 +1,60 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.6-1.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.POSITIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY", Infinity, Number.POSITIVE_INFINITY ); + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.6-2.js b/tests/mozilla/ecma/Number/15.7.3.6-2.js new file mode 100644 index 0000000..573648b --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.6-2.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.6-2.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.6-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.POSITIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "delete( Number.POSITIVE_INFINITY )", false, "delete( Number.POSITIVE_INFINITY )" ); + array[item++] = new TestCase(SECTION, "delete( Number.POSITIVE_INFINITY ); Number.POSITIVE_INFINITY", Infinity, "delete( Number.POSITIVE_INFINITY );Number.POSITIVE_INFINITY" ); + return ( array ); +} + +function test( testcases ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.6-3.js b/tests/mozilla/ecma/Number/15.7.3.6-3.js new file mode 100644 index 0000000..c4c5973 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.6-3.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.6-3.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.7.3.6-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.POSITIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( + SECTION, + "Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY", + Number.POSITIVE_INFINITY, + "Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY" ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += "property should be readonly "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.6-4.js b/tests/mozilla/ecma/Number/15.7.3.6-4.js new file mode 100644 index 0000000..25b2b4f --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.6-4.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.6-4.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.3.6-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.POSITIVE_INFINITY"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;") + ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += "property should not be enumerated "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.3.js b/tests/mozilla/ecma/Number/15.7.3.js new file mode 100644 index 0000000..c832cfc --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.3.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.3.js + 15.7.3 Properties of the Number Constructor + + Description: The value of the internal [[Prototype]] property + of the Number constructor is the Function prototype + object. The Number constructor also has the internal + [[Call]] and [[Construct]] properties, and the length + property. + + Other properties are in subsequent tests. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + + var SECTION = "15.7.3"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Properties of the Number Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase(SECTION, "Number.__proto__", Function.prototype, Number.__proto__ ); + array[item++] = new TestCase(SECTION, "Number.length", 1, Number.length ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.4-1.js b/tests/mozilla/ecma/Number/15.7.4-1.js new file mode 100644 index 0000000..8d7c79d --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4-1.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4-1.js + ECMA Section: 15.7.4.1 Properties of the Number Prototype Object + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + + var SECTION = "15.7.4-1"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + "Properties of the Number prototype object"); + + var testcases = getTestCases(); + + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "Number.prototype.valueOf()", 0, Number.prototype.valueOf() ); + array[item++] = new TestCase(SECTION, "typeof(Number.prototype)", "object", typeof(Number.prototype) ); + array[item++] = new TestCase(SECTION, "Number.prototype.constructor == Number", true, Number.prototype.constructor == Number ); +// array[item++] = new TestCase(SECTION, "Number.prototype == Number.__proto__", true, Number.prototype == Number.__proto__ ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Number/15.7.4.1.js b/tests/mozilla/ecma/Number/15.7.4.1.js new file mode 100644 index 0000000..789e71c --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4.1.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4.1.js + ECMA Section: 15.7.4.1.1 Number.prototype.constructor + + Number.prototype.constructor is the built-in Number constructor. + + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Number.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "Number.prototype.constructor", + Number, + Number.prototype.constructor ); + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.4.2-1.js b/tests/mozilla/ecma/Number/15.7.4.2-1.js new file mode 100644 index 0000000..f41b698 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4.2-1.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4.2.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// the following two lines cause navigator to crash -- cmb 9/16/97 + array[item++] = new TestCase(SECTION, "Number.prototype.toString()", "0", "Number.prototype.toString()" ); + array[item++] = new TestCase(SECTION, "typeof(Number.prototype.toString())", "string", "typeof(Number.prototype.toString())" ); + + array[item++] = new TestCase(SECTION, "s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()", "0", "s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()" ); + array[item++] = new TestCase(SECTION, "s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()", "1", "s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()" ); + array[item++] = new TestCase(SECTION, "s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()", "-1", "s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()" ); + + array[item++] = new TestCase(SECTION, "var MYNUM = new Number(255); MYNUM.toString(10)", "255", "var MYNUM = new Number(255); MYNUM.toString(10)" ); + array[item++] = new TestCase(SECTION, "var MYNUM = new Number(Number.NaN); MYNUM.toString(10)", "NaN", "var MYNUM = new Number(Number.NaN); MYNUM.toString(10)" ); + array[item++] = new TestCase(SECTION, "var MYNUM = new Number(Infinity); MYNUM.toString(10)", "Infinity", "var MYNUM = new Number(Infinity); MYNUM.toString(10)" ); + array[item++] = new TestCase(SECTION, "var MYNUM = new Number(-Infinity); MYNUM.toString(10)", "-Infinity", "var MYNUM = new Number(-Infinity); MYNUM.toString(10)" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual= eval(testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.4.2-2-n.js b/tests/mozilla/ecma/Number/15.7.4.2-2-n.js new file mode 100644 index 0000000..2aa035a --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4.2-2-n.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4.2-2-n.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.2-2-n"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "o = new Object(); o.toString = Number.prototype.toString; o.toString()", "error", "o = new Object(); o.toString = Number.prototype.toString; o.toString()" ); +// array[item++] = new TestCase(SECTION, "o = new String(); o.toString = Number.prototype.toString; o.toString()", "error", "o = new String(); o.toString = Number.prototype.toString; o.toString()" ); +// array[item++] = new TestCase(SECTION, "o = 3; o.toString = Number.prototype.toString; o.toString()", "error", "o = 3; o.toString = Number.prototype.toString; o.toString()" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.4.2-3-n.js b/tests/mozilla/ecma/Number/15.7.4.2-3-n.js new file mode 100644 index 0000000..8e73acb --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4.2-3-n.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4.2-3-n.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.2-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "o = new String(); o.toString = Number.prototype.toString; o.toString()", "error", "o = new String(); o.toString = Number.prototype.toString; o.toString()" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.4.2-4.js b/tests/mozilla/ecma/Number/15.7.4.2-4.js new file mode 100644 index 0000000..4896ba9 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4.2-4.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4.2-4.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.2-4"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "o = 3; o.toString = Number.prototype.toString; o.toString()", "3", "o = 3; o.toString = Number.prototype.toString; o.toString()" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.4.3-1.js b/tests/mozilla/ecma/Number/15.7.4.3-1.js new file mode 100644 index 0000000..341b347 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4.3-1.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4.3-1.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + +// the following two line causes navigator to crash -- cmb 9/16/97 + array[item++] = new TestCase("15.7.4.1", "Number.prototype.valueOf()", 0, "Number.prototype.valueOf()" ); + + array[item++] = new TestCase("15.7.4.1", "(new Number(1)).valueOf()", 1, "(new Number(1)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number(-1)).valueOf()", -1, "(new Number(-1)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number(0)).valueOf()", 0, "(new Number(0)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number(Number.POSITIVE_INFINITY)).valueOf()", Number.POSITIVE_INFINITY, "(new Number(Number.POSITIVE_INFINITY)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number(Number.NaN)).valueOf()", Number.NaN, "(new Number(Number.NaN)).valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "(new Number()).valueOf()", 0, "(new Number()).valueOf()" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.4.3-2.js b/tests/mozilla/ecma/Number/15.7.4.3-2.js new file mode 100644 index 0000000..6b81da6 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4.3-2.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4.3-2.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase(SECTION, "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", 3, "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.4.3-3-n.js b/tests/mozilla/ecma/Number/15.7.4.3-3-n.js new file mode 100644 index 0000000..8905f25 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4.3-3-n.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4.3-3.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "15.7.4.3-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + +// array[item++] = new TestCase("15.7.4.1", "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", "error", "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()" ); + array[item++] = new TestCase("15.7.4.1", "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()", "error", "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()" ); +// array[item++] = new TestCase("15.7.4.1", "v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()", "error", "v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()" ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Number/15.7.4.js b/tests/mozilla/ecma/Number/15.7.4.js new file mode 100644 index 0000000..fd62ad5 --- /dev/null +++ b/tests/mozilla/ecma/Number/15.7.4.js @@ -0,0 +1,86 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.7.4.js + ECMA Section: 15.7.4 + + Description: + + The Number prototype object is itself a Number object (its [[Class]] is + "Number") whose value is +0. + + The value of the internal [[Prototype]] property of the Number prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Number + prototype object, the phrase "this Number object" refers to the object + that is the this value for the invocation of the function; it is an error + if this does not refer to an object for which the value of the internal + [[Class]] property is "Number". Also, the phrase "this number value" refers + to the number value represented by this Number object, that is, the value + of the internal [[Value]] property of this Number object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "15.7.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Number Prototype Object"; + + writeHeaderToLog( SECTION + " "+TITLE); + + var testcases = getTestCases(); + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, + "Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()", + "[object Number]", + eval("Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()") ); + array[item++] = new TestCase( SECTION, "typeof Number.prototype", "object", typeof Number.prototype ); + array[item++] = new TestCase( SECTION, "Number.prototype.valueOf()", 0, Number.prototype.valueOf() ); + + +// The __proto__ property cannot be used in ECMA_1 tests. +// array[item++] = new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); +// array[item++] = new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); + + + return ( array ); +} +function test( ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + } + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.1.1.js b/tests/mozilla/ecma/ObjectObjects/15.2.1.1.js new file mode 100644 index 0000000..cbc1783 --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.1.1.js @@ -0,0 +1,151 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.1.1.js + ECMA Section: 15.2.1.1 The Object Constructor Called as a Function: + Object(value) + Description: When Object is called as a function rather than as a + constructor, the following steps are taken: + + 1. If value is null or undefined, create and return a + new object with no properties other than internal + properties exactly as if the object constructor + had been called on that same value (15.2.2.1). + 2. Return ToObject (value), whose rules are: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + + var SECTION = "15.2.1.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Object( value )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var NULL_OBJECT = Object(null); + + array[item++] = new TestCase( SECTION, "Object(null).valueOf()", NULL_OBJECT, (NULL_OBJECT).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(null)", "object", typeof (Object(null)) ); + array[item++] = new TestCase( SECTION, "Object(null).__proto__", Object.prototype, (Object(null)).__proto__ ); + + var UNDEFINED_OBJECT = Object( void 0 ); + + array[item++] = new TestCase( SECTION, "Object(void 0).valueOf()", UNDEFINED_OBJECT, (UNDEFINED_OBJECT).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(void 0)", "object", typeof (Object(void 0)) ); + array[item++] = new TestCase( SECTION, "Object(void 0).__proto__", Object.prototype, (Object(void 0)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); +// array[item++] = new TestCase( SECTION, "var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += + ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.1.2.js b/tests/mozilla/ecma/ObjectObjects/15.2.1.2.js new file mode 100644 index 0000000..6a619b6 --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.1.2.js @@ -0,0 +1,85 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.1.2.js + ECMA Section: 15.2.1.2 The Object Constructor Called as a Function: + Object(value) + Description: When Object is called as a function rather than as a + constructor, the following steps are taken: + + 1. If value is null or undefined, create and return a + new object with no proerties other than internal + properties exactly as if the object constructor + had been called on that same value (15.2.2.1). + 2. Return ToObject (value), whose rules are: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + + var SECTION = "15.2.1.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Object()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var MYOB = Object(); + + array[item++] = new TestCase( SECTION, "var MYOB = Object(); MYOB.valueOf()", MYOB, MYOB.valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object()", "object", typeof (Object(null)) ); + array[item++] = new TestCase( SECTION, "var MYOB = Object(); MYOB.toString()", "[object Object]", eval("var MYOB = Object(); MYOB.toString()") ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += + ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.2.1.js b/tests/mozilla/ecma/ObjectObjects/15.2.2.1.js new file mode 100644 index 0000000..cf04ce4 --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.2.1.js @@ -0,0 +1,139 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.2.1.js + ECMA Section: 15.2.2.1 The Object Constructor: new Object( value ) + + 1.If the type of the value is not Object, go to step 4. + 2.If the value is a native ECMAScript object, do not create a new object; simply return value. + 3.If the value is a host object, then actions are taken and a result is returned in an + implementation-dependent manner that may depend on the host object. + 4.If the type of the value is String, return ToObject(value). + 5.If the type of the value is Boolean, return ToObject(value). + 6.If the type of the value is Number, return ToObject(value). + 7.(The type of the value must be Null or Undefined.) Create a new native ECMAScript object. + The [[Prototype]] property of the newly constructed object is set to the Object prototype object. + The [[Class]] property of the newly constructed object is set to "Object". + The newly constructed object has no [[Value]] property. + Return the newly created native object. + + Description: This does not test cases where the object is a host object. + Author: christine@netscape.com + Date: 7 october 1997 +*/ + + var SECTION = "15.2.2.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Object( value )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof new Object(null)", "object", typeof new Object(null) ); + array[item++] = new TestCase( SECTION, "MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "typeof new Object(void 0)", "object", typeof new Object(void 0) ); + array[item++] = new TestCase( SECTION, "MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + + array[item++] = new TestCase( SECTION, "typeof new Object('string')", "object", typeof new Object('string') ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object('string').valueOf()", "string", (new Object('string')).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object('')", "object", typeof new Object('') ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object('').valueOf()", "", (new Object('')).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(Number.NaN)", "object", typeof new Object(Number.NaN) ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object(Number.NaN).valueOf()", Number.NaN, (new Object(Number.NaN)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(0)", "object", typeof new Object(0) ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object(0).valueOf()", 0, (new Object(0)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(-0)", "object", typeof new Object(-0) ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object(-0).valueOf()", -0, (new Object(-0)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(1)", "object", typeof new Object(1) ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object(1).valueOf()", 1, (new Object(1)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(-1)", "object", typeof new Object(-1) ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object(-1).valueOf()", -1, (new Object(-1)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(true)", "object", typeof new Object(true) ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object(true).valueOf()", true, (new Object(true)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(false)", "object", typeof new Object(false) ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object(false).valueOf()", false, (new Object(false)).valueOf() ); + + array[item++] = new TestCase( SECTION, "typeof new Object(Boolean())", "object", typeof new Object(Boolean()) ); + array[item++] = new TestCase( SECTION, "MYOB = (new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + array[item++] = new TestCase( SECTION, "(new Object(Boolean()).valueOf()", Boolean(), (new Object(Boolean())).valueOf() ); + + + var myglobal = this; + var myobject = new Object( "my new object" ); + var myarray = new Array(); + var myboolean = new Boolean(); + var mynumber = new Number(); + var mystring = new String(); + var myobject = new Object(); + var myfunction = new Function( "x", "return x"); + var mymath = Math; + + array[item++] = new TestCase( SECTION, "myglobal = new Object( this )", myglobal, new Object(this) ); + array[item++] = new TestCase( SECTION, "myobject = new Object('my new object'); new Object(myobject)", myobject, new Object(myobject) ); + array[item++] = new TestCase( SECTION, "myarray = new Array(); new Object(myarray)", myarray, new Object(myarray) ); + array[item++] = new TestCase( SECTION, "myboolean = new Boolean(); new Object(myboolean)", myboolean, new Object(myboolean) ); + array[item++] = new TestCase( SECTION, "mynumber = new Number(); new Object(mynumber)", mynumber, new Object(mynumber) ); + array[item++] = new TestCase( SECTION, "mystring = new String9); new Object(mystring)", mystring, new Object(mystring) ); + array[item++] = new TestCase( SECTION, "myobject = new Object(); new Object(mynobject)", myobject, new Object(myobject) ); + array[item++] = new TestCase( SECTION, "myfunction = new Function(); new Object(myfunction)", myfunction, new Object(myfunction) ); + array[item++] = new TestCase( SECTION, "mymath = Math; new Object(mymath)", mymath, new Object(mymath) ); + + return ( array ); +} +function test() { + for (tc = 0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + } + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.2.2.js b/tests/mozilla/ecma/ObjectObjects/15.2.2.2.js new file mode 100644 index 0000000..eddedfa --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.2.2.js @@ -0,0 +1,81 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.2.2.js + ECMA Section: 15.2.2.2 new Object() + Description: + + When the Object constructor is called with no argument, the following + step is taken: + + 1. Create a new native ECMAScript object. + The [[Prototype]] property of the newly constructed object is set to + the Object prototype object. + + The [[Class]] property of the newly constructed object is set + to "Object". + + The newly constructed object has no [[Value]] property. + + Return the newly created native object. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + var SECTION = "15.2.2.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "new Object()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof new Object()", "object", typeof new Object() ); + array[item++] = new TestCase( SECTION, "Object.prototype.toString()", "[object Object]", Object.prototype.toString() ); + array[item++] = new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); + + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value+''" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.3-1.js b/tests/mozilla/ecma/ObjectObjects/15.2.3-1.js new file mode 100644 index 0000000..06f50ce --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.3-1.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.3-1.js + ECMA Section: 15.2.3 Properties of the Object Constructor + + Description: The value of the internal [[Prototype]] property of the + Object constructor is the Function prototype object. + + Besides the call and construct propreties and the length + property, the Object constructor has properties described + in 15.2.3.1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.2.3"; + var VERSION = "ECMA_2"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Properties of the Object Constructor"); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); + array[item++] = new TestCase( SECTION, "Object.length", 1, Object.length ); + + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.3.1-1.js b/tests/mozilla/ecma/ObjectObjects/15.2.3.1-1.js new file mode 100644 index 0000000..ee0539a --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.3.1-1.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.3.1-1.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [DontEnum] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.2.3.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Object.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "var str = '';for ( p in Object ) { str += p; }; str", + "", + eval( "var str = ''; for ( p in Object ) { str += p; }; str" ) + ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.3.1-2.js b/tests/mozilla/ecma/ObjectObjects/15.2.3.1-2.js new file mode 100644 index 0000000..fc2c735 --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.3.1-2.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.3.1-2.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [DontDelete] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.2.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Object.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete( Object.prototype )", + false, + "delete( Object.prototype )" + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.3.1-3.js b/tests/mozilla/ecma/ObjectObjects/15.2.3.1-3.js new file mode 100644 index 0000000..eb3a79d --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.3.1-3.js @@ -0,0 +1,69 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.3.1-3.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [ReadOnly] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.2.3.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Object.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Object.prototype = null; Object.prototype", + Object.prototype, + "Object.prototype = null; Object.prototype" + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.3.1-4.js b/tests/mozilla/ecma/ObjectObjects/15.2.3.1-4.js new file mode 100644 index 0000000..8a39d7e --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.3.1-4.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.3.1-4.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [DontDelete] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.2.3.1-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Object.prototype"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "delete( Object.prototype ); Object.prototype", + Object.prototype, + "delete(Object.prototype); Object.prototype" + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval(testcases[tc].actual); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.3.js b/tests/mozilla/ecma/ObjectObjects/15.2.3.js new file mode 100644 index 0000000..152add9 --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.3.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.3.js + ECMA Section: 15.2.3 Properties of the Object Constructor + + Description: The value of the internal [[Prototype]] property of the + Object constructor is the Function prototype object. + + Besides the call and construct propreties and the length + property, the Object constructor has properties described + in 15.2.3.1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.2.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the Object Constructor"; + + writeHeaderToLog( SECTION + " " + TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + +// array[item++] = new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); + array[item++] = new TestCase( SECTION, "Object.length", 1, Object.length ); + + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.4.1.js b/tests/mozilla/ecma/ObjectObjects/15.2.4.1.js new file mode 100644 index 0000000..61f2898 --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.4.1.js @@ -0,0 +1,63 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.4.1.js + ECMA Section: 15.2.4 Object.prototype.constructor + + Description: The initial value of the Object.prototype.constructor + is the built-in Object constructor. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.2.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Object.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "Object.prototype.constructor", + Object, + Object.prototype.constructor + ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.4.2.js b/tests/mozilla/ecma/ObjectObjects/15.2.4.2.js new file mode 100644 index 0000000..40eca1b --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.4.2.js @@ -0,0 +1,128 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.4.2.js + ECMA Section: 15.2.4.2 Object.prototype.toString() + + Description: When the toString method is called, the following + steps are taken: + 1. Get the [[Class]] property of this object + 2. Call ToString( Result(1) ) + 3. Compute a string value by concatenating the three + strings "[object " + Result(2) + "]" + 4. Return Result(3). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.2.4.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Object.prototype.toString()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); + + array[item++] = new TestCase( SECTION, "myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()", + GLOBAL, + eval("myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Function]", + eval("myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()", + '[object Object]', + eval("myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Number]", + eval("myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object String]", + eval("myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Math]", + eval("myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Function]", + eval("myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Array]", + eval("myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Boolean]", + eval("myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Date]", + eval("myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + + array[item++] = new TestCase( SECTION, "var MYVAR = new Object( this ); MYVAR.toString()", + GLOBAL, + eval("var MYVAR = new Object( this ); MYVAR.toString()") ); + + array[item++] = new TestCase( SECTION, "var MYVAR = new Object(); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(); MYVAR.toString()") ); + + array[item++] = new TestCase( SECTION, "var MYVAR = new Object(void 0); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(void 0); MYVAR.toString()") ); + + array[item++] = new TestCase( SECTION, "var MYVAR = new Object(null); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(null); MYVAR.toString()") ); + + return ( array ); +} +function test( array ) { + for ( tc=0 ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function MyObject( value ) { + this.value = new Function( "return this.value" ); + this.toString = new Function ( "return this.value+''"); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.4.3.js b/tests/mozilla/ecma/ObjectObjects/15.2.4.3.js new file mode 100644 index 0000000..1daf04a --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.4.3.js @@ -0,0 +1,115 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.4.3.js + ECMA Section: 15.2.4.3 Object.prototype.valueOf() + + Description: As a rule, the valueOf method for an object simply + returns the object; but if the object is a "wrapper" + for a host object, as may perhaps be created by the + Object constructor, then the contained host object + should be returned. + + This only covers native objects. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.2.4.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Object.prototype.valueOf()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var myarray = new Array(); + myarray.valueOf = Object.prototype.valueOf; + var myboolean = new Boolean(); + myboolean.valueOf = Object.prototype.valueOf; + var myfunction = new Function(); + myfunction.valueOf = Object.prototype.valueOf; + var myobject = new Object(); + myobject.valueOf = Object.prototype.valueOf; + var mymath = Math; + mymath.valueOf = Object.prototype.valueOf; + var mydate = new Date(); + mydate.valueOf = Object.prototype.valueOf; + var mynumber = new Number(); + mynumber.valueOf = Object.prototype.valueOf; + var mystring = new String(); + mystring.valueOf = Object.prototype.valueOf; + + array[item++] = new TestCase( SECTION, "Object.prototype.valueOf.length", 0, Object.prototype.valueOf.length ); + + array[item++] = new TestCase( SECTION, + "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()", + myarray, + myarray.valueOf() ); + array[item++] = new TestCase( SECTION, + "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()", + myboolean, + myboolean.valueOf() ); + array[item++] = new TestCase( SECTION, + "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()", + myfunction, + myfunction.valueOf() ); + array[item++] = new TestCase( SECTION, + "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()", + myobject, + myobject.valueOf() ); + array[item++] = new TestCase( SECTION, + "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()", + mymath, + mymath.valueOf() ); + array[item++] = new TestCase( SECTION, + "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()", + mynumber, + mynumber.valueOf() ); + array[item++] = new TestCase( SECTION, + "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()", + mystring, + mystring.valueOf() ); + array[item++] = new TestCase( SECTION, + "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()", + mydate, + mydate.valueOf() ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/ObjectObjects/15.2.4.js b/tests/mozilla/ecma/ObjectObjects/15.2.4.js new file mode 100644 index 0000000..5a018c0 --- /dev/null +++ b/tests/mozilla/ecma/ObjectObjects/15.2.4.js @@ -0,0 +1,60 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.2.4.js + ECMA Section: 15.2.4 Properties of the Object prototype object + + Description: The value of the internal [[Prototype]] property of + the Object prototype object is null + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + + var SECTION = "15.2.4"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "Properties of the Object.prototype object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + testcases[tc++] = new TestCase( SECTION, "Object.prototype.__proto__", + null, + Object.prototype.__proto__ + ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/SourceText/6-1.js b/tests/mozilla/ecma/SourceText/6-1.js new file mode 100644 index 0000000..759402b --- /dev/null +++ b/tests/mozilla/ecma/SourceText/6-1.js @@ -0,0 +1,124 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 6-1.js + ECMA Section: Source Text + Description: + + ECMAScript source text is represented as a sequence of characters + representable using the Unicode version 2.0 character encoding. + + SourceCharacter :: + any Unicode character + + However, it is possible to represent every ECMAScript program using + only ASCII characters (which are equivalent to the first 128 Unicode + characters). Non-ASCII Unicode characters may appear only within comments + and string literals. In string literals, any Unicode character may also be + expressed as a Unicode escape sequence consisting of six ASCII characters, + namely \u plus four hexadecimal digits. Within a comment, such an escape + sequence is effectively ignored as part of the comment. Within a string + literal, the Unicode escape sequence contributes one character to the string + value of the literal. + + Note that ECMAScript differs from the Java programming language in the + behavior of Unicode escape sequences. In a Java program, if the Unicode escape + sequence \u000A, for example, occurs within a single-line comment, it is + interpreted as a line terminator (Unicode character 000A is line feed) and + therefore the next character is not part of the comment. Similarly, if the + Unicode escape sequence \u000A occurs within a string literal in a Java + program, it is likewise interpreted as a line terminator, which is not + allowed within a string literal-one must write \n instead of \u000A to + cause a line feed to be part of the string value of a string literal. In + an ECMAScript program, a Unicode escape sequence occurring within a comment + is never interpreted and therefore cannot contribute to termination of the + comment. Similarly, a Unicode escape sequence occurring within a string literal + in an ECMAScript program always contributes a character to the string value of + the literal and is never interpreted as a line terminator or as a quote mark + that might terminate the string literal. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Source Text"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \u000A", + 'PASSED', + "PASSED" ); + + // \u000A testcases[tc].actual = "FAILED!"; + + tc++; + + testcases[tc] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'", + 'PASSED', + 'PASSED' ); + + // the following character should noy be interpreted as a line terminator: \\n testcases[tc].actual = "FAILED" + + tc++; + + testcases[tc] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'", + 'PASSED', + 'PASSED' ) + + // the following character should not be interpreted as a line terminator: \u000A testcases[tc].actual = "FAILED" + + testcases[tc++] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'", + 'PASSED', + 'PASSED' ) + // the following character should not be interpreted as a line terminator: \n testcases[tc].actual = 'FAILED' + + testcases[tc] = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: u000D", + 'PASSED', + 'PASSED' ) + + // the following character should not be interpreted as a line terminator: \u000D testcases[tc].actual = "FAILED" + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/SourceText/6-2.js b/tests/mozilla/ecma/SourceText/6-2.js new file mode 100644 index 0000000..9e7c7f9 --- /dev/null +++ b/tests/mozilla/ecma/SourceText/6-2.js @@ -0,0 +1,129 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 6-1.js + ECMA Section: Source Text + Description: + + ECMAScript source text is represented as a sequence of characters + representable using the Unicode version 2.0 character encoding. + + SourceCharacter :: + any Unicode character + + However, it is possible to represent every ECMAScript program using + only ASCII characters (which are equivalent to the first 128 Unicode + characters). Non-ASCII Unicode characters may appear only within comments + and string literals. In string literals, any Unicode character may also be + expressed as a Unicode escape sequence consisting of six ASCII characters, + namely \u plus four hexadecimal digits. Within a comment, such an escape + sequence is effectively ignored as part of the comment. Within a string + literal, the Unicode escape sequence contributes one character to the string + value of the literal. + + Note that ECMAScript differs from the Java programming language in the + behavior of Unicode escape sequences. In a Java program, if the Unicode escape + sequence \u000A, for example, occurs within a single-line comment, it is + interpreted as a line terminator (Unicode character 000A is line feed) and + therefore the next character is not part of the comment. Similarly, if the + Unicode escape sequence \u000A occurs within a string literal in a Java + program, it is likewise interpreted as a line terminator, which is not + allowed within a string literal-one must write \n instead of \u000A to + cause a line feed to be part of the string value of a string literal. In + an ECMAScript program, a Unicode escape sequence occurring within a comment + is never interpreted and therefore cannot contribute to termination of the + comment. Similarly, a Unicode escape sequence occurring within a string literal + in an ECMAScript program always contributes a character to the string value of + the literal and is never interpreted as a line terminator or as a quote mark + that might terminate the string literal. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Source Text"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // encoded quotes should not end a quote + + testcases[tc++]= new TestCase( SECTION, + "var s = 'PAS\\u0022SED'; s", + "PAS\"SED", + eval("var s = 'PAS\\u0022SED'; s") ); + + testcases[tc++]= new TestCase( SECTION, + 'var s = "PAS\\u0022SED"; s', + "PAS\"SED", + eval('var s = "PAS\\u0022SED"; s') ); + + + testcases[tc++]= new TestCase( SECTION, + "var s = 'PAS\\u0027SED'; s", + "PAS\'SED", + eval("var s = 'PAS\\u0027SED'; s") ); + + + testcases[tc++]= new TestCase( SECTION, + 'var s = "PAS\\u0027SED"; s', + "PAS\'SED", + eval('var s = "PAS\\u0027SED"; s') ); + + testcases[tc] = new TestCase( SECTION, + 'var s="PAS\\u0027SED"; s', + "PAS\'SED", + "" ) + var s = "PAS\u0027SED"; + + testcases[tc].actual = s; + + tc++; + + testcases[tc]= new TestCase( SECTION, + 'var s = "PAS\\u0027SED"; s', + "PAS\"SED", + "" ); + var s = "PAS\u0022SED"; + + testcases[tc].actual = s; + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.10-1.js b/tests/mozilla/ecma/Statements/12.10-1.js new file mode 100644 index 0000000..cf33b0a --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.10-1.js @@ -0,0 +1,151 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: + WithStatement : + with ( Expression ) Statement + + The with statement adds a computed object to the front of the scope chain + of the current execution context, then executes a statement with this + augmented scope chain, then restores the scope chain. + + Semantics + + The production WithStatement : with ( Expression ) Statement is evaluated + as follows: + 1. Evaluate Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Add Result(3) to the front of the scope chain. + 5. Evaluate Statement using the augmented scope chain from step 4. + 6. Remove Result(3) from the front of the scope chain. + 7. Return Result(5). + + Discussion + Note that no matter how control leaves the embedded Statement, whether + normally or by some form of abrupt completion, the scope chain is always + restored to its former state. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.10-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The with statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // although the scope chain changes, the this value is immutable for a given + // execution context. + + array[item++] = new TestCase( SECTION, + "with( new Number() ) { this +'' }", + "[object global]", + eval("with( new Number() ) { this +'' }") ); + + // the object's functions and properties should override those of the + // global object. + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(true); with (MYOB) { parseInt() }", + true, + eval("var MYOB = new WithObject(true); with (MYOB) { parseInt() }") ); + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { NaN }", + false, + eval("var MYOB = new WithObject(false); with (MYOB) { NaN }") ); + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(NaN); with (MYOB) { Infinity }", + Number.NaN, + eval("var MYOB = new WithObject(NaN); with (MYOB) { Infinity }") ); + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { }; Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(false); with (MYOB) { }; Infinity") ); + + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }") ); + + // let us leave the with block via a break. + + array[item++] = new TestCase( + SECTION, + "var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity") ); + + return ( array ); +} +function WithObject( value ) { + this.prop1 = 1; + this.prop2 = new Boolean(true); + this.prop3 = "a string"; + this.value = value; + + // now we will override global functions + + this.parseInt = new Function( "return this.value" ); + this.NaN = value; + this.Infinity = value; + this.unescape = new Function( "return this.value" ); + this.escape = new Function( "return this.value" ); + this.eval = new Function( "return this.value" ); + this.parseFloat = new Function( "return this.value" ); + this.isNaN = new Function( "return this.value" ); + this.isFinite = new Function( "return this.value" ); +} diff --git a/tests/mozilla/ecma/Statements/12.10.js b/tests/mozilla/ecma/Statements/12.10.js new file mode 100644 index 0000000..08e8ebc --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.10.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.10-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The with statement"; + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION +" "+ TITLE); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var x; with (7) x = valueOf(); typeof x;", + "number", + eval("var x; with(7) x = valueOf(); typeof x;") ); + return ( array ); +} + diff --git a/tests/mozilla/ecma/Statements/12.2-1.js b/tests/mozilla/ecma/Statements/12.2-1.js new file mode 100644 index 0000000..44f64b8 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.2-1.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.2-1.js + ECMA Section: The variable statement + Description: + + If the variable statement occurs inside a FunctionDeclaration, the + variables are defined with function-local scope in that function, as + described in section 10.1.3. Otherwise, they are defined with global + scope, that is, they are created as members of the global object, as + described in section 0. Variables are created when the execution scope + is entered. A Block does not define a new execution scope. Only Program and + FunctionDeclaration produce a new scope. Variables are initialized to the + undefined value when created. A variable with an Initializer is assigned + the value of its AssignmentExpression when the VariableStatement is executed, + not when the variable is created. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The variable statement"; + + writeHeaderToLog( SECTION +" "+ TITLE); + + var testcases = new Array(); + + testcases[tc] = new TestCase( "SECTION", + "var x = 3; function f() { var a = x; var x = 23; return a; }; f()", + void 0, + eval("var x = 3; function f() { var a = x; var x = 23; return a; }; f()") ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.5-1.js b/tests/mozilla/ecma/Statements/12.5-1.js new file mode 100644 index 0000000..b0fe400 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.5-1.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.5-1.js + ECMA Section: The if statement + Description: + + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: + + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + + var SECTION = "12.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The if statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.5-2.js b/tests/mozilla/ecma/Statements/12.5-2.js new file mode 100644 index 0000000..9b30bfd --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.5-2.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.5-2.js + ECMA Section: The if statement + Description: + + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: + + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The if statement" ; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( false ) MYVAR='FAILED'; MYVAR;") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR") ); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( 0 ) MYVAR='FAILED'; MYVAR;") ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.1-1.js b/tests/mozilla/ecma/Statements/12.6.1-1.js new file mode 100644 index 0000000..0b43603 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.1-1.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.1-1.js + ECMA Section: The while statement + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.6.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The While statement"; + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ", + 1, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ")); + + testcases[tc++] = new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ", + 100, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ")); + + testcases[tc++] = new TestCase( SECTION, + "function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)", + 2, + eval("function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)")); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.2-1.js b/tests/mozilla/ecma/Statements/12.6.2-1.js new file mode 100644 index 0000000..387cf14 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.2-1.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.2-1.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "12.6.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( "12.6.2-1", "for statement", 99, "" ); + return ( array ); +} + +function testprogram() { + myVar = 0; + + for ( ; ; ) { + if ( ++myVar == 99 ) + break; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + + stopTest(); + + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.2-2.js b/tests/mozilla/ecma/Statements/12.6.2-2.js new file mode 100644 index 0000000..788a5d0 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.2-2.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.2-2.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( SECTION, "for statement", 99, "" ); + return ( array ); +} + +function testprogram() { + myVar = 0; + + for ( ; ; myVar++ ) { + if ( myVar < 99 ) { + continue; + } else { + break; + } + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.2-3.js b/tests/mozilla/ecma/Statements/12.6.2-3.js new file mode 100644 index 0000000..706f224 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.2-3.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.2-3.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + testcases[0] = new TestCase( SECTION, "for statement", 100, "" ); + + test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + continue; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.2-4.js b/tests/mozilla/ecma/Statements/12.6.2-4.js new file mode 100644 index 0000000..887dea4 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.2-4.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.2-4.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "12.6.2-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[testcases.length] = new TestCase( SECTION, + "for statement", 100, testprogram() ); + + test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + } + + return myVar; +} +function test() { + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.2-5.js b/tests/mozilla/ecma/Statements/12.6.2-5.js new file mode 100644 index 0000000..3404ecf --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.2-5.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.2-5.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( SECTION, "for statement", 99, "" ); + return ( array ); +} + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + if (myVar == 99) + break; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.2-6.js b/tests/mozilla/ecma/Statements/12.6.2-6.js new file mode 100644 index 0000000..1ed50d8 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.2-6.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.2-6.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( "12.6.2-6", "for statement", 256, "" ); + return ( array ); +} + +function testprogram() { + var myVar; + + for ( myVar=2; ; myVar *= myVar ) { + + if (myVar > 100) + break; + continue; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.2-7.js b/tests/mozilla/ecma/Statements/12.6.2-7.js new file mode 100644 index 0000000..ec9f246 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.2-7.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.2-7.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-7"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( SECTION, "for statement", 256, "" ); + return ( array ); +} + +function testprogram() { + var myVar; + + for ( myVar=2; myVar < 100 ; myVar *= myVar ) { + + continue; + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.2-8.js b/tests/mozilla/ecma/Statements/12.6.2-8.js new file mode 100644 index 0000000..ecabc06 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.2-8.js @@ -0,0 +1,69 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.2-8.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "12.6.2-8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + array[0] = new TestCase( SECTION, "for statement", 256, "" ); + return ( array ); +} +function testprogram() { + var myVar; + + for ( myVar=2; myVar < 256; myVar *= myVar ) { + } + + return myVar; +} +function test() { + testcases[0].actual = testprogram(); + + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.2-9-n.js b/tests/mozilla/ecma/Statements/12.6.2-9-n.js new file mode 100644 index 0000000..ef7c12e --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.2-9-n.js @@ -0,0 +1,65 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.2-9-n.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + + var SECTION = "12.6.2-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[testcases.length] = new TestCase( SECTION, + "for (i)", + "error", + "" ); + + for (i) { + } + + test(); + +function test() { + testcases[0].passed = writeTestCaseResult( + testcases[0].expect, + testcases[0].actual, + testcases[0].description +" = "+ testcases[0].actual ); + + testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; + + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.3-1.js b/tests/mozilla/ecma/Statements/12.6.3-1.js new file mode 100644 index 0000000..9b2aa2b --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-1.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "12.6.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var x; Number.prototype.foo = 34; for ( j in 7 ) x = j; x", + "foo", + eval("var x; Number.prototype.foo = 34; for ( j in 7 ){x = j;} x") ); + + return ( array ); +} + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject(a, b, c, d, e) { + + +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Statements/12.6.3-10.js b/tests/mozilla/ecma/Statements/12.6.3-10.js new file mode 100644 index 0000000..f2f042b --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-10.js @@ -0,0 +1,112 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-10.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-10"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + var count = 0; + function f() { count++; return new Array("h","e","l","l","o"); } + + var result = ""; + for ( p in f() ) { result += f()[p] }; + + testcases[testcases.length] = new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); + + testcases[testcases.length] = new TestCase( SECTION, + "result", + "hello", + result ); + + // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] + // LeftHandSideExpression:NewExpression:MemberExpression . Identifier + // LeftHandSideExpression:NewExpression:new MemberExpression Arguments + // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) + // LeftHandSideExpression:CallExpression:MemberExpression Arguments + // LeftHandSideExpression:CallExpression Arguments + // LeftHandSideExpression:CallExpression [ Expression ] + // LeftHandSideExpression:CallExpression . Identifier + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Statements/12.6.3-11.js b/tests/mozilla/ecma/Statements/12.6.3-11.js new file mode 100644 index 0000000..579845a --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-11.js @@ -0,0 +1,93 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-11.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-11"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +// 5. Get the name of the next property of Result(3) that doesn't have the +// DontEnum attribute. If there is no such property, go to step 14. + + var result = ""; + + for ( p in Number ) { result += String(p) }; + + testcases[testcases.length] = new TestCase( SECTION, + "result = \"\"; for ( p in Number ) { result += String(p) };", + "", + result ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.3-12.js b/tests/mozilla/ecma/Statements/12.6.3-12.js new file mode 100644 index 0000000..b5c4b18 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-12.js @@ -0,0 +1,100 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-12.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + This is a regression test for http://bugzilla.mozilla.org/show_bug.cgi?id=9802. + + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-12"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var result = "PASSED"; + + for ( aVar in this ) { + if (aVar == "aVar") { + result = "FAILED" + } + }; + + testcases[testcases.length] = new TestCase( + SECTION, + "var result=''; for ( aVar in this ) { " + + "if (aVar == 'aVar') {return a failure}; result", + "PASSED", + result ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Statements/12.6.3-19.js b/tests/mozilla/ecma/Statements/12.6.3-19.js new file mode 100644 index 0000000..4f386d8 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-19.js @@ -0,0 +1,114 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + var count = 0; + function f() { count++; return new Array("h","e","l","l","o"); } + + var result = ""; + for ( p in f() ) { result += f()[p] }; + + testcases[testcases.length] = new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); + + testcases[testcases.length] = new TestCase( SECTION, + "result", + "hello", + result ); + + + + // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] + // LeftHandSideExpression:NewExpression:MemberExpression . Identifier + // LeftHandSideExpression:NewExpression:new MemberExpression Arguments + // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) + // LeftHandSideExpression:CallExpression:MemberExpression Arguments + // LeftHandSideExpression:CallExpression Arguments + // LeftHandSideExpression:CallExpression [ Expression ] + // LeftHandSideExpression:CallExpression . Identifier + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/Statements/12.6.3-2.js b/tests/mozilla/ecma/Statements/12.6.3-2.js new file mode 100644 index 0000000..f025a09 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-2.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-2.js + ECMA Section: 12.6.3 The for...in Statement + Description: Check the Boolean Object + + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + + var SECTION = "12.6.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j]", + 34, + eval("Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j] ") ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.3-3.js b/tests/mozilla/ecma/Statements/12.6.3-3.js new file mode 100644 index 0000000..32cce34 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-3.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-3.js + ECMA Section: for..in loops + Description: + + This verifies the fix to + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112156 + for..in should take general lvalue for first argument + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.6.3-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var o = {}; + + var result = ""; + + for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } + + testcases[testcases.length] = new TestCase( SECTION, + "for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } result", + "123", + result ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Statements/12.6.3-4.js b/tests/mozilla/ecma/Statements/12.6.3-4.js new file mode 100644 index 0000000..d0876b6 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-4.js @@ -0,0 +1,193 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + var o = new MyObject(); + var result = 0; + + for ( MyObject in o ) { + result += o[MyObject]; + } + + testcases[testcases.length] = new TestCase( SECTION, + "for ( MyObject in o ) { result += o[MyObject] }", + 6, + result ); + + var result = 0; + + for ( value in o ) { + result += o[value]; + } + + testcases[testcases.length] = new TestCase( SECTION, + "for ( value in o ) { result += o[value]", + 6, + result ); + + var value = "value"; + var result = 0; + for ( value in o ) { + result += o[value]; + } + + testcases[testcases.length] = new TestCase( SECTION, + "value = \"value\"; for ( value in o ) { result += o[value]", + 6, + result ); + + var value = 0; + var result = 0; + for ( value in o ) { + result += o[value]; + } + + testcases[testcases.length] = new TestCase( SECTION, + "value = 0; for ( value in o ) { result += o[value]", + 6, + result ); + + // this causes a segv + + var ob = { 0:"hello" }; + var result = 0; + for ( ob[0] in o ) { + result += o[ob[0]]; + } + testcases[testcases.length] = new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[0] in o ) { result += o[ob[0]]", + 6, + result ); + + var result = 0; + for ( ob["0"] in o ) { + result += o[ob["0"]]; + } + testcases[testcases.length] = new TestCase( SECTION, + "value = 0; for ( ob[\"0\"] in o ) { result += o[o[\"0\"]]", + 6, + result ); + + var result = 0; + var ob = { value:"hello" }; + for ( ob[value] in o ) { + result += o[ob[value]]; + } + testcases[testcases.length] = new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[value] in o ) { result += o[ob[value]]", + 6, + result ); + + var result = 0; + for ( ob["value"] in o ) { + result += o[ob["value"]]; + } + testcases[testcases.length] = new TestCase( SECTION, + "value = 0; for ( ob[\"value\"] in o ) { result += o[ob[\"value\"]]", + 6, + result ); + + var result = 0; + for ( ob.value in o ) { + result += o[ob.value]; + } + testcases[testcases.length] = new TestCase( SECTION, + "value = 0; for ( ob.value in o ) { result += o[ob.value]", + 6, + result ); + + // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] + // LeftHandSideExpression:NewExpression:MemberExpression . Identifier + // LeftHandSideExpression:NewExpression:new MemberExpression Arguments + // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) + // LeftHandSideExpression:CallExpression:MemberExpression Arguments + // LeftHandSideExpression:CallExpression Arguments + // LeftHandSideExpression:CallExpression [ Expression ] + // LeftHandSideExpression:CallExpression . Identifier + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/mozilla/ecma/Statements/12.6.3-5-n.js b/tests/mozilla/ecma/Statements/12.6.3-5-n.js new file mode 100644 index 0000000..1fb4ce5 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-5-n.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "more than one member expression", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( var i, p in this) { + result += this[p]; + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Statements/12.6.3-6-n.js b/tests/mozilla/ecma/Statements/12.6.3-6-n.js new file mode 100644 index 0000000..bd6bb1b --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-6-n.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "bad left-hand side expression", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( this in o) { + result += this[p]; + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Statements/12.6.3-7-n.js b/tests/mozilla/ecma/Statements/12.6.3-7-n.js new file mode 100644 index 0000000..5dfad13 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-7-n.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "bad left-hand side expression", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( "a" in o) { + result += this[p]; + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Statements/12.6.3-8-n.js b/tests/mozilla/ecma/Statements/12.6.3-8-n.js new file mode 100644 index 0000000..ac93487 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-8-n.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-8-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "bad left-hand side expression", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( 1 in o) { + result += this[p]; + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Statements/12.6.3-9-n.js b/tests/mozilla/ecma/Statements/12.6.3-9-n.js new file mode 100644 index 0000000..06000a4 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.6.3-9-n.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.6.3-9-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "12.6.3-9-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The for..in statment"; + var error = err; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // for ( LeftHandSideExpression in Expression ) + // LeftHandSideExpression:NewExpression:MemberExpression + + testcases[testcases.length] = new TestCase( SECTION, + "object is not defined", + "error", + "" ); + + var o = new MyObject(); + var result = 0; + + for ( var o in foo) { + result += this[o]; + } + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Statements/12.7-1-n.js b/tests/mozilla/ecma/Statements/12.7-1-n.js new file mode 100644 index 0000000..b9b13e8 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.7-1-n.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.7-1-n.js + ECMA Section: 12.7 The continue statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "12.7.1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The continue statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "continue", + "error", + "continue" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/Statements/12.8-1-n.js b/tests/mozilla/ecma/Statements/12.8-1-n.js new file mode 100644 index 0000000..9594a73 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.8-1-n.js @@ -0,0 +1,69 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.8-1-n.js + ECMA Section: 12.8 The break statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "12.8-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The break in statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "break", + "error", + "break" ); + + return ( array ); +} + diff --git a/tests/mozilla/ecma/Statements/12.9-1-n.js b/tests/mozilla/ecma/Statements/12.9-1-n.js new file mode 100644 index 0000000..c0383c2 --- /dev/null +++ b/tests/mozilla/ecma/Statements/12.9-1-n.js @@ -0,0 +1,64 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 12.9-1-n.js + ECMA Section: 12.9 The return statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "12.9-1-n"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " The return statement"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + testcases[tc].actual = eval( testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "return", + "error", + "return" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/String/15.5.1.js b/tests/mozilla/ecma/String/15.5.1.js new file mode 100644 index 0000000..7971afe --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.1.js @@ -0,0 +1,137 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.1.js + ECMA Section: 15.5.1 The String Constructor called as a Function + 15.5.1.1 String(value) + 15.5.1.2 String() + + Description: + When String is called as a function rather than as + a constructor, it performs a type conversion. + - String(value) returns a string value (not a String + object) computed by ToString(value) + - String() returns the empty string "" + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The String Constructor Called as a Function"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String('string primitive')", "string primitive", String('string primitive') ); + array[item++] = new TestCase( SECTION, "String(void 0)", "undefined", String( void 0) ); + array[item++] = new TestCase( SECTION, "String(null)", "null", String( null ) ); + array[item++] = new TestCase( SECTION, "String(true)", "true", String( true) ); + array[item++] = new TestCase( SECTION, "String(false)", "false", String( false ) ); + array[item++] = new TestCase( SECTION, "String(Boolean(true))", "true", String(Boolean(true)) ); + array[item++] = new TestCase( SECTION, "String(Boolean(false))", "false", String(Boolean(false)) ); + array[item++] = new TestCase( SECTION, "String(Boolean())", "false", String(Boolean(false)) ); + array[item++] = new TestCase( SECTION, "String(new Array())", "", String( new Array()) ); + array[item++] = new TestCase( SECTION, "String(new Array(1,2,3))", "1,2,3", String( new Array(1,2,3)) ); + + + array[item++] = new TestCase( SECTION, "String( Number.NaN )", "NaN", String( Number.NaN ) ); + array[item++] = new TestCase( SECTION, "String( 0 )", "0", String( 0 ) ); + array[item++] = new TestCase( SECTION, "String( -0 )", "0", String( -0 ) ); + array[item++] = new TestCase( SECTION, "String( Number.POSITIVE_INFINITY )", "Infinity", String( Number.POSITIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "String( Number.NEGATIVE_INFINITY )", "-Infinity", String( Number.NEGATIVE_INFINITY ) ); + array[item++] = new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); + + // cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 + + array[item++] = new TestCase( SECTION, "String( 1 )", "1", String( 1 ) ); + array[item++] = new TestCase( SECTION, "String( 10 )", "10", String( 10 ) ); + array[item++] = new TestCase( SECTION, "String( 100 )", "100", String( 100 ) ); + array[item++] = new TestCase( SECTION, "String( 1000 )", "1000", String( 1000 ) ); + array[item++] = new TestCase( SECTION, "String( 10000 )", "10000", String( 10000 ) ); + array[item++] = new TestCase( SECTION, "String( 10000000000 )", "10000000000", String( 10000000000 ) ); + array[item++] = new TestCase( SECTION, "String( 10000000000000000000 )", "10000000000000000000", String( 10000000000000000000 ) ); + array[item++] = new TestCase( SECTION, "String( 100000000000000000000 )","100000000000000000000",String( 100000000000000000000 ) ); + + array[item++] = new TestCase( SECTION, "String( 12345 )", "12345", String( 12345 ) ); + array[item++] = new TestCase( SECTION, "String( 1234567890 )", "1234567890", String( 1234567890 ) ); + + array[item++] = new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); + array[item++] = new TestCase( SECTION, "String( -10 )", "-10", String( -10 ) ); + array[item++] = new TestCase( SECTION, "String( -100 )", "-100", String( -100 ) ); + array[item++] = new TestCase( SECTION, "String( -1000 )", "-1000", String( -1000 ) ); + array[item++] = new TestCase( SECTION, "String( -1000000000 )", "-1000000000", String( -1000000000 ) ); + array[item++] = new TestCase( SECTION, "String( -1000000000000000 )", "-1000000000000000", String( -1000000000000000 ) ); + array[item++] = new TestCase( SECTION, "String( -100000000000000000000 )", "-100000000000000000000", String( -100000000000000000000 ) ); + array[item++] = new TestCase( SECTION, "String( -1000000000000000000000 )", "-1e+21", String( -1000000000000000000000 ) ); + + array[item++] = new TestCase( SECTION, "String( -12345 )", "-12345", String( -12345 ) ); + array[item++] = new TestCase( SECTION, "String( -1234567890 )", "-1234567890", String( -1234567890 ) ); + + // cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, + array[item++] = new TestCase( SECTION, "String( 1.0000001 )", "1.0000001", String( 1.0000001 ) ); + + + // cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 + + // cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 + + array[item++] = new TestCase( SECTION, "String( 1000000000000000000000 )", "1e+21", String( 1000000000000000000000 ) ); + array[item++] = new TestCase( SECTION, "String( 10000000000000000000000 )", "1e+22", String( 10000000000000000000000 ) ); + + // cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 + array[item++] = new TestCase( SECTION, "String( 1.2345 )", "1.2345", String( 1.2345)); + array[item++] = new TestCase( SECTION, "String( 1.234567890 )", "1.23456789", String( 1.234567890 )); + + array[item++] = new TestCase( SECTION, "String( .12345 )", "0.12345", String(.12345 ) ); + array[item++] = new TestCase( SECTION, "String( .012345 )", "0.012345", String(.012345) ); + array[item++] = new TestCase( SECTION, "String( .0012345 )", "0.0012345", String(.0012345) ); + array[item++] = new TestCase( SECTION, "String( .00012345 )", "0.00012345", String(.00012345) ); + array[item++] = new TestCase( SECTION, "String( .000012345 )", "0.000012345", String(.000012345) ); + array[item++] = new TestCase( SECTION, "String( .0000012345 )", "0.0000012345", String(.0000012345) ); + array[item++] = new TestCase( SECTION, "String( .00000012345 )", "1.2345e-7", String(.00000012345)); + + array[item++] = new TestCase( "15.5.2", "String()", "", String() ); + + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.2.js b/tests/mozilla/ecma/String/15.5.2.js new file mode 100644 index 0000000..59daad0 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.2.js @@ -0,0 +1,112 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.2.js + ECMA Section: 15.5.2 The String Constructor + 15.5.2.1 new String(value) + 15.5.2.2 new String() + + Description: When String is called as part of a new expression, it + is a constructor; it initializes the newly constructed + object. + + - The prototype property of the newly constructed + object is set to the original String prototype object, + the one that is the intial value of String.prototype + - The internal [[Class]] property of the object is "String" + - The value of the object is ToString(value). + - If no value is specified, its value is the empty string. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof new String('string primitive')", "object", typeof new String('string primitive') ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String('string primitive')).valueOf()", 'string primitive', (new String('string primitive')).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String('string primitive')).substring", String.prototype.substring, (new String('string primitive')).substring ); + + array[item++] = new TestCase( SECTION, "typeof new String(void 0)", "object", typeof new String(void 0) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(void 0)).valueOf()", "undefined", (new String(void 0)).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(void 0)).toString", String.prototype.toString, (new String(void 0)).toString ); + + array[item++] = new TestCase( SECTION, "typeof new String(null)", "object", typeof new String(null) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(null)).valueOf()", "null", (new String(null)).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(null)).valueOf", String.prototype.valueOf, (new String(null)).valueOf ); + + array[item++] = new TestCase( SECTION, "typeof new String(true)", "object", typeof new String(true) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(true)).valueOf()", "true", (new String(true)).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(true)).charAt", String.prototype.charAt, (new String(true)).charAt ); + + array[item++] = new TestCase( SECTION, "typeof new String(false)", "object", typeof new String(false) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(false)).valueOf()", "false", (new String(false)).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(false)).charCodeAt", String.prototype.charCodeAt, (new String(false)).charCodeAt ); + + array[item++] = new TestCase( SECTION, "typeof new String(new Boolean(true))", "object", typeof new String(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String(new Boolean(true))).valueOf()", "true", (new String(new Boolean(true))).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(new Boolean(true))).indexOf", String.prototype.indexOf, (new String(new Boolean(true))).indexOf ); + + array[item++] = new TestCase( SECTION, "typeof new String()", "object", typeof new String() ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String()).valueOf()", '', (new String()).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String()).lastIndexOf", String.prototype.lastIndexOf, (new String()).lastIndexOf ); + + array[item++] = new TestCase( SECTION, "typeof new String('')", "object", typeof new String('') ); + array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, "(new String('')).valueOf()", '', (new String('')).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String('')).split", String.prototype.split, (new String('')).split ); + + return ( array ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.3.1-1.js b/tests/mozilla/ecma/String/15.5.3.1-1.js new file mode 100644 index 0000000..af15536 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.3.1-1.js @@ -0,0 +1,73 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.3.1-1.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontEnum attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.length", 0, String.prototype.length ); + + array[item++] = new TestCase( SECTION, + "var str='';for ( p in String ) { if ( p == 'prototype' ) str += p; } str", + "", + eval("var str='';for ( p in String ) { if ( p == 'prototype' ) str += p; } str") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.3.1-2.js b/tests/mozilla/ecma/String/15.5.3.1-2.js new file mode 100644 index 0000000..d4d7fa3 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.3.1-2.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.3.1-2.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the ReadOnly attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "String.prototype=null;String.prototype", + String.prototype, + eval("String.prototype=null;String.prototype") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.3.1-3.js b/tests/mozilla/ecma/String/15.5.3.1-3.js new file mode 100644 index 0000000..01da54a --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.3.1-3.js @@ -0,0 +1,67 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.3.1-3.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontDelete attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3.1-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "delete( String.prototype )", false, eval("delete ( String.prototype )") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.3.1-4.js b/tests/mozilla/ecma/String/15.5.3.1-4.js new file mode 100644 index 0000000..fbaea31 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.3.1-4.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.3.1-4.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontDelete attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3.1-4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "delete( String.prototype );String.prototype", String.prototype, eval("delete ( String.prototype );String.prototype") ); + return ( array ); +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.3.2-1.js b/tests/mozilla/ecma/String/15.5.3.2-1.js new file mode 100644 index 0000000..f5fb16d --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.3.2-1.js @@ -0,0 +1,195 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.3.2-1.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This test covers Basic Latin (range U+0020 - U+007F) + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + + var SECTION = "15.5.3.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.fromCharCode()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "typeof String.fromCharCode", "function", typeof String.fromCharCode ); + array[item++] = new TestCase( SECTION, "typeof String.prototype.fromCharCode", "undefined", typeof String.prototype.fromCharCode ); + array[item++] = new TestCase( SECTION, "var x = new String(); typeof x.fromCharCode", "undefined", eval("var x = new String(); typeof x.fromCharCode") ); + array[item++] = new TestCase( SECTION, "String.fromCharCode.length", 1, String.fromCharCode.length ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode()", "", String.fromCharCode() ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0020)", " ", String.fromCharCode(0x0020) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0021)", "!", String.fromCharCode(0x0021) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0022)", "\"", String.fromCharCode(0x0022) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0023)", "#", String.fromCharCode(0x0023) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0024)", "$", String.fromCharCode(0x0024) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0025)", "%", String.fromCharCode(0x0025) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0026)", "&", String.fromCharCode(0x0026) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0027)", "\'", String.fromCharCode(0x0027) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0028)", "(", String.fromCharCode(0x0028) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0029)", ")", String.fromCharCode(0x0029) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002A)", "*", String.fromCharCode(0x002A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002B)", "+", String.fromCharCode(0x002B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002C)", ",", String.fromCharCode(0x002C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002D)", "-", String.fromCharCode(0x002D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002E)", ".", String.fromCharCode(0x002E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002F)", "/", String.fromCharCode(0x002F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0030)", "0", String.fromCharCode(0x0030) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0031)", "1", String.fromCharCode(0x0031) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0032)", "2", String.fromCharCode(0x0032) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0033)", "3", String.fromCharCode(0x0033) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0034)", "4", String.fromCharCode(0x0034) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0035)", "5", String.fromCharCode(0x0035) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0036)", "6", String.fromCharCode(0x0036) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0037)", "7", String.fromCharCode(0x0037) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0038)", "8", String.fromCharCode(0x0038) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0039)", "9", String.fromCharCode(0x0039) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003A)", ":", String.fromCharCode(0x003A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003B)", ";", String.fromCharCode(0x003B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003C)", "<", String.fromCharCode(0x003C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003D)", "=", String.fromCharCode(0x003D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003E)", ">", String.fromCharCode(0x003E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003F)", "?", String.fromCharCode(0x003F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0050)", "P", String.fromCharCode(0x0050) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0051)", "Q", String.fromCharCode(0x0051) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0052)", "R", String.fromCharCode(0x0052) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0053)", "S", String.fromCharCode(0x0053) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0054)", "T", String.fromCharCode(0x0054) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0055)", "U", String.fromCharCode(0x0055) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0056)", "V", String.fromCharCode(0x0056) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0057)", "W", String.fromCharCode(0x0057) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0058)", "X", String.fromCharCode(0x0058) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0059)", "Y", String.fromCharCode(0x0059) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005A)", "Z", String.fromCharCode(0x005A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005B)", "[", String.fromCharCode(0x005B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005C)", "\\", String.fromCharCode(0x005C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005D)", "]", String.fromCharCode(0x005D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005E)", "^", String.fromCharCode(0x005E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005F)", "_", String.fromCharCode(0x005F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0060)", "`", String.fromCharCode(0x0060) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0061)", "a", String.fromCharCode(0x0061) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0062)", "b", String.fromCharCode(0x0062) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0063)", "c", String.fromCharCode(0x0063) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0064)", "d", String.fromCharCode(0x0064) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0065)", "e", String.fromCharCode(0x0065) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0066)", "f", String.fromCharCode(0x0066) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0067)", "g", String.fromCharCode(0x0067) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0068)", "h", String.fromCharCode(0x0068) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0069)", "i", String.fromCharCode(0x0069) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006A)", "j", String.fromCharCode(0x006A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006B)", "k", String.fromCharCode(0x006B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006C)", "l", String.fromCharCode(0x006C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006D)", "m", String.fromCharCode(0x006D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006E)", "n", String.fromCharCode(0x006E) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006F)", "o", String.fromCharCode(0x006F) ); + + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0070)", "p", String.fromCharCode(0x0070) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0071)", "q", String.fromCharCode(0x0071) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0072)", "r", String.fromCharCode(0x0072) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0073)", "s", String.fromCharCode(0x0073) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0074)", "t", String.fromCharCode(0x0074) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0075)", "u", String.fromCharCode(0x0075) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0076)", "v", String.fromCharCode(0x0076) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0077)", "w", String.fromCharCode(0x0077) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0078)", "x", String.fromCharCode(0x0078) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0079)", "y", String.fromCharCode(0x0079) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007A)", "z", String.fromCharCode(0x007A) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007B)", "{", String.fromCharCode(0x007B) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007C)", "|", String.fromCharCode(0x007C) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007D)", "}", String.fromCharCode(0x007D) ); + array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007E)", "~", String.fromCharCode(0x007E) ); +// array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0020, 0x007F)", "", String.fromCharCode(0x0040, 0x007F) ); + + return array; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.3.2-2.js b/tests/mozilla/ecma/String/15.5.3.2-2.js new file mode 100644 index 0000000..4ff3693 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.3.2-2.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.3.2-2.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This tests String.fromCharCode with multiple arguments. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + + var SECTION = "15.5.3.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.fromCharCode()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var MYSTRING = String.fromCharCode(eval(\"var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;\")); MYSTRING", + " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", + eval( "var MYSTRING = String.fromCharCode(" + eval("var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;") +"); MYSTRING" )); + + array[item++] = new TestCase( SECTION, + "MYSTRING.length", + 0x007f - 0x0020, + MYSTRING.length ); + return array; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.3.2-3.js b/tests/mozilla/ecma/String/15.5.3.2-3.js new file mode 100644 index 0000000..e6b515e --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.3.2-3.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.3.2-1.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This test covers Basic Latin (range U+0020 - U+007F) + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + + var SECTION = "15.5.3.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.fromCharCode()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + for ( CHARCODE = 256; CHARCODE < 65536; CHARCODE+=333 ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + for ( CHARCODE = 65535; CHARCODE < 65538; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + for ( CHARCODE = Math.pow(2,32)-1; CHARCODE < Math.pow(2,32)+1; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + for ( CHARCODE = 0; CHARCODE > -65536; CHARCODE-=3333 ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); + } + array[item++] = new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "(String.fromCharCode(65536)).charCodeAt(0)", 0, (String.fromCharCode(65536)).charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "(String.fromCharCode(65537)).charCodeAt(0)", 1, (String.fromCharCode(65537)).charCodeAt(0) ); + + return array; +} +function ToUint16( num ) { + num = Number( num ); + if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( num < 0 ) ? -1 : 1; + + num = sign * Math.floor( Math.abs( num ) ); + num = num % Math.pow(2,16); + num = ( num > -65536 && num < 0) ? 65536 + num : num; + return num; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.3.js b/tests/mozilla/ecma/String/15.5.3.js new file mode 100644 index 0000000..3a1012d --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.3.js @@ -0,0 +1,74 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.3.1.js + ECMA Section: 15.5.3 Properties of the String Constructor + + Description: The value of the internal [[Prototype]] property of + the String constructor is the Function prototype + object. + + In addition to the internal [[Call]] and [[Construct]] + properties, the String constructor also has the length + property, as well as properties described in 15.5.3.1 + and 15.5.3.2. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.3"; + var VERSION = "ECMA_2"; + startTest(); + var passed = true; + writeHeaderToLog( SECTION + " Properties of the String Constructor" ); + + var testcases = getTestCases(); + var tc= 0; + +// all tests must call a function that returns an array of TestCase objects. + test( testcases ); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype", Function.prototype, String.__proto__ ); + array[item++] = new TestCase( SECTION, "String.length", 1, String.length ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + + stopTest(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/String/15.5.4.1.js b/tests/mozilla/ecma/String/15.5.4.1.js new file mode 100644 index 0000000..393f25a --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.1.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.1.js + ECMA Section: 15.5.4.1 String.prototype.constructor + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.5.4.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.constructor"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.constructor == String", true, String.prototype.constructor == String ); + array[item++] = new TestCase( SECTION, "var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()", + "[object String]", + eval("var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()") ); + return ( array ); +} +function test( array ) { + for ( ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + + stopTest(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.10-1.js b/tests/mozilla/ecma/String/15.5.4.10-1.js new file mode 100644 index 0000000..454afef --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.10-1.js @@ -0,0 +1,218 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.10-1.js + ECMA Section: 15.5.4.10 String.prototype.substring( start, end ) + Description: + + 15.5.4.10 String.prototype.substring(start, end) + + Returns a substring of the result of converting this object to a string, + starting from character position start and running to character position + end of the string. The result is a string value, not a String object. + + If either argument is NaN or negative, it is replaced with zero; if either + argument is larger than the length of the string, it is replaced with the + length of the string. + + If start is larger than end, they are swapped. + + When the substring method is called with two arguments start and end, the + following steps are taken: + + 1. Call ToString, giving it the this value as its argument. + 2. Call ToInteger(start). + 3. Call ToInteger (end). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(2), 0), Result(4)). + 6. Compute min(max(Result(3), 0), Result(4)). + 7. Compute min(Result(5), Result(6)). + 8. Compute max(Result(5), Result(6)). + 9. Return a string whose length is the difference between Result(8) and + Result(7), containing characters from Result(1), namely the characters + with indices Result(7) through Result(8)1, in ascending order. + + Note that the substring function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.10-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.substring( start, end )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); + + // test cases for when substring is called with no arguments. + + // this is a string object + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.substring()", + "string", + eval("var s = new String('this is a string object'); typeof s.substring()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(''); s.substring(1,0)", + "", + eval("var s = new String(''); s.substring(1,0)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(true, false)", + "t", + eval("var s = new String('this is a string object'); s.substring(false, true)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(NaN, Infinity)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(NaN, Infinity)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity, NaN)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(Infinity, NaN)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity, Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(Infinity, Infinity)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-0.01, 0)", + "", + eval("var s = new String('this is a string object'); s.substring(-0.01,0)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length, s.length)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length, s.length)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length+1, 0)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(s.length+1, 0)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)") ); + + // this is not a String object, start is not an integer + + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)", + "1,2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)", + "1", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')", + "3", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')") ); + + + // this is an object object + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)", + "[object ", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,obj.toString().length)", + "Object]", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8, obj.toString().length)") ); + + // this is a function object + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8, Infinity)", + "Function]", + eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8,Infinity)") ); + // this is a number object + array[item++] = new TestCase( SECTION, + "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)", + "NaN", + eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)") ); + + // this is the Math object + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)", + "[ob", + eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)") ); + + // this is a Boolean object + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))", + "f", + eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))") ); + + // this is a user defined object + + array[item++] = new TestCase( SECTION, + "var obj = new MyObject( void 0 ); obj.substring(0, 100)", + "undefined", + eval( "var obj = new MyObject( void 0 ); obj.substring(0,100)") ); + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.11-1.js b/tests/mozilla/ecma/String/15.5.4.11-1.js new file mode 100644 index 0000000..b24a9cc --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.11-1.js @@ -0,0 +1,514 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.11-1.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); + + // Basic Latin, Latin-1 Supplement, Latin Extended A + for ( var i = 0; i <= 0x017f; i++ ) { + var U = new Unicode(i); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + + } + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.11-2.js b/tests/mozilla/ecma/String/15.5.4.11-2.js new file mode 100644 index 0000000..b75f3e8 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.11-2.js @@ -0,0 +1,633 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +/** + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +/* + Safari Changes: This test differs from the mozilla tests in two significant + ways. + First, the lower case range for Georgian letters in this file is the + correct range according to the Unicode 5.0 standard, as opposed to the + Georgian caseless range that mozilla uses. + Secondly this test uses an array for expected results with two entries, + instead of a single expected result. This allows us to accept Unicode 4.0 or + Unicode 5.0 results as correct, as opposed to the mozilla test, which assumes + Unicode 5.0. This allows Safari to pass this test on OS' with different + Unicode standards implemented (e.g. Tiger and XP) +*/ + var SECTION = "15.5.4.11-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Georgian + // Range: U+10A0 to U+10FF + for ( var i = 0x10A0; i <= 0x10FF; i++ ) { + var U = new Array(new Unicode( i, 4 ), new Unicode( i, 5 )); + +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCaseDualExpected( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + } + + return array; +} + +/* + * TestCase constructor + * + */ + +function TestCaseDualExpected( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResultDualExpected( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} + +// Added so that either Unicode 4.0 or 5.0 results will be considered correct. +function writeTestCaseResultDualExpected( expect, actual, string ) { + var passed = getTestCaseResultDualExpected( expect, actual ); + writeFormattedResult( expect[1].lower, actual, string, passed ); + return passed; +} +/* + * Added so that either Unicode 4.0 or 5.0 results will be considered correct. + * Compare expected result to the actual result and figure out whether + * the test case passed. + */ +function getTestCaseResultDualExpected( expect, actual ) { + expectedU4 = expect[0].lower; + expectedU5 = expect[1].lower; + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + + if ( expectedU4 != expectedU4 ) { + if ( typeof expectedU4 == "object" ) { + expectedU4 = "NaN object"; + } else { + expectedU4 = "NaN number"; + } + } + if ( expectedU5 != expectedU5 ) { + if ( typeof expectedU5 == "object" ) { + expectedU5 = "NaN object"; + } else { + expectedU5 = "NaN number"; + } + } + + var passed = ( expectedU4 == actual || expectedU5 == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed && + typeof(actual) == "number" && + (typeof(expectedU4) == "number" || + typeof(expectedU5) == "number")) { + if (( Math.abs(actual-expectedU4) < 0.0000001 ) || ( Math.abs(actual-expectedU5) < 0.0000001 )) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expectedU4) != typeof(actual) && typeof(expectedU5) != typeof(actual) ) { + passed = false; + } + + return passed; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResultDualExpected( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} + +function Unicode( c, version ) { + u = GetUnicodeValues( c, version ); + this.upper = u[0]; + this.lower = u[1] + return this; +} + +function GetUnicodeValues( c, version ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = c; + u[1] = 0x039C; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( version == 5 ) { + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 7264; //48; + return u; + } + if ( c >= 0x2D00 && c <= 0x2D25 ) { + u[0] = c; + u[1] = c; + return u; + } + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.11-3.js b/tests/mozilla/ecma/String/15.5.4.11-3.js new file mode 100644 index 0000000..b718188 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.11-3.js @@ -0,0 +1,509 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { + var U = new Unicode(i); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + } + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = c; + u[1] = 0x039C; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.11-4.js b/tests/mozilla/ecma/String/15.5.4.11-4.js new file mode 100644 index 0000000..5258dc2 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.11-4.js @@ -0,0 +1,508 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Hiragana (no upper / lower case) + // Range: U+3040 to U+309F + + for ( var i = 0x3040; i <= 0x309F; i++ ) { + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + } + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + this.upper = c; + this.lower = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + this.upper = c; + this.lower = c + 32; + return this; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + this.upper = c - 32; + this.lower = c; + return this; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + this.upper = c - 32; + this.lower = c; + return this; + } + if ( c == 0x00FF ) { + this.upper = 0x0178; + this.lower = c; + return this; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + this.upper = c; + this.lower = 0x0069; + return this; + } + if ( c == 0x0131 ) { + this.upper = 0x0049; + this.lower = c; + return this; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + this.upper = c; + this.lower = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + this.upper = c-1; + this.lower = c; + } + return this; + } + if ( c == 0x0178 ) { + this.upper = c; + this.lower = 0x00FF; + return this; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + this.upper = c; + this.lower = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + this.upper = c-1; + this.lower = c; + } + return this; + } + if ( c == 0x017F ) { + this.upper = 0x0053; + this.lower = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + this.upper = c; + this.lower = c+1; + } else { + this.upper = c-1; + this.lower = c; + } + return this; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + this.upper = c; + this.lower = c + 80; + return this; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + this.upper = c - 32; + this.lower = c; + return this; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + this.upper = c -80; + this.lower = c; + return this; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + this.upper = c; + this.lower = c +1; + } else { + this.upper = c - 1; + this.lower = c; + } + return this; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + this.upper = c; + this.lower = c + 48; + return this; + } + if ( c >= 0x0561 && c < 0x0587 ) { + this.upper = c - 48; + this.lower = c; + return this; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + this.upper = c; + this.lower = c + 48; + return this; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + this.upper = c; + this.lower = c; + return this; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + this.upper = c - 32; + this.lower = c; + return this; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return this; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.11-5.js b/tests/mozilla/ecma/String/15.5.4.11-5.js new file mode 100644 index 0000000..4d42091 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.11-5.js @@ -0,0 +1,514 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.11-5.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); + + // Cyrillic (part) + // Range: U+0400 to U+04FF + for ( var i = 0x0400; i <= 0x047F; i++ ) { + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + + } + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = c; + u[1] = 0x039C; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.11-6.js b/tests/mozilla/ecma/String/15.5.4.11-6.js new file mode 100644 index 0000000..a3282f6 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.11-6.js @@ -0,0 +1,511 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.11-6.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.11-6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toLowerCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Armenian + // Range: U+0530 to U+058F + for ( var i = 0x0530; i <= 0x058F; i++ ) { + + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + + } + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = c; + u[1] = 0x039C; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.12-1.js b/tests/mozilla/ecma/String/15.5.4.12-1.js new file mode 100644 index 0000000..fb8f0df --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.12-1.js @@ -0,0 +1,527 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.toUpperCase.length", 0, String.prototype.toUpperCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toUpperCase.length", false, delete String.prototype.toUpperCase.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.toupperCase.length; String.prototype.toupperCase.length", 0, eval("delete String.prototype.toUpperCase.length; String.prototype.toUpperCase.length") ); + + // Basic Latin, Latin-1 Supplement, Latin Extended A + for ( var i = 0; i <= 0x017f; i++ ) { + var U = new Unicode( i ); + + // XXX DF fails in java + + if ( i == 0x00DF ) { + continue; + } + + + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + } + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + // LATIN SMALL LETTER N PRECEDED BY APOSTROPHE, uppercase takes two code points + if (c == 0x0149) { + u[0] = 0x02bc; + u[1] = c; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + if (c == 0x0587) { + u[0] = 0x0535; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.12-2.js b/tests/mozilla/ecma/String/15.5.4.12-2.js new file mode 100644 index 0000000..2d8c694 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.12-2.js @@ -0,0 +1,514 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.12-2.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var TEST_STRING = ""; + var EXPECT_STRING = ""; + + // basic latin test + + for ( var i = 0; i < 0x007A; i++ ) { + var u = new Unicode(i); + TEST_STRING += String.fromCharCode(i); + EXPECT_STRING += String.fromCharCode( u.upper ); + } + + // don't print out the value of the strings since they contain control + // characters that break the driver + var isEqual = EXPECT_STRING == (new String( TEST_STRING )).toUpperCase(); + + array[item++] = new TestCase( SECTION, + "isEqual", + true, + isEqual); + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} + diff --git a/tests/mozilla/ecma/String/15.5.4.12-3.js b/tests/mozilla/ecma/String/15.5.4.12-3.js new file mode 100644 index 0000000..1561db5 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.12-3.js @@ -0,0 +1,556 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.12-3.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Georgian + // Range: U+10A0 to U+10FF + for ( var i = 0x10A0; i <= 0x10FF; i++ ) { + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + String.fromCharCode(U.upper), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + + } + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + eval( "var u = new Unicode( i ); u.upper" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); + } + + // Hiragana (no upper / lower case) + // Range: U+3040 to U+309F + + for ( var i = 0x3040; i <= 0x309F; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + eval( "var u = new Unicode( i ); u.upper" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); + } + + +/* + var TEST_STRING = ""; + var EXPECT_STRING = ""; + + // basic latin test + + for ( var i = 0; i < 0x007A; i++ ) { + var u = new Unicode(i); + TEST_STRING += String.fromCharCode(i); + EXPECT_STRING += String.fromCharCode( u.upper ); + } +*/ + + + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.12-4.js b/tests/mozilla/ecma/String/15.5.4.12-4.js new file mode 100644 index 0000000..54e365e --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.12-4.js @@ -0,0 +1,511 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Cyrillic (part) + // Range: U+0400 to U+04FF + for ( var i = 0x0400; i <= 0x047F; i++ ) { + var U =new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + U.upper, + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + + } + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.12-5.js b/tests/mozilla/ecma/String/15.5.4.12-5.js new file mode 100644 index 0000000..bbcfad4 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.12-5.js @@ -0,0 +1,523 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.12-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toUpperCase()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // Armenian + // Range: U+0530 to U+058F + for ( var i = 0x0530; i <= 0x058F; i++ ) { + var U = new Unicode( i ); +/* + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + String.fromCharCode(U.upper), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +*/ + array[item++] = new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + + } + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( c == 0x00B5 ) { + u[0] = 0x039C; + u[1] = c; + return u; + } + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + // LATIN SMALL LETTER N PRECEDED BY APOSTROPHE, uppercase takes two code points + if (c == 0x0149) { + u[0] = 0x02bc; + u[1] = c; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( c >= 0x0400 && c <= 0x040F) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( c >= 0x0450 && c<= 0x045F ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + if (c == 0x0587) { + u[0] = 0x0535; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.2-1.js b/tests/mozilla/ecma/String/15.5.4.2-1.js new file mode 100644 index 0000000..3569556 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.2-1.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.2-1.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.4.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); + array[item++] = new TestCase( SECTION, "(new String()).toString()", "", (new String()).toString() ); + array[item++] = new TestCase( SECTION, "(new String(\"\")).toString()", "", (new String("")).toString() ); + array[item++] = new TestCase( SECTION, "(new String( String() )).toString()","", (new String(String())).toString() ); + array[item++] = new TestCase( SECTION, "(new String( \"h e l l o\" )).toString()", "h e l l o", (new String("h e l l o")).toString() ); + array[item++] = new TestCase( SECTION, "(new String( 0 )).toString()", "0", (new String(0)).toString() ); + return ( array ); +} +function test( array ) { + for ( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.2-2-n.js b/tests/mozilla/ecma/String/15.5.4.2-2-n.js new file mode 100644 index 0000000..b444bae --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.2-2-n.js @@ -0,0 +1,74 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.2-2-n.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.4.2-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()", + "error", + "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.2-3.js b/tests/mozilla/ecma/String/15.5.4.2-3.js new file mode 100644 index 0000000..f1855e2 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.2-3.js @@ -0,0 +1,87 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.2-3.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + + var SECTION = "15.5.4.2-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + testcases[tc].actual = eval( testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()", + "", + "var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()" ); + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()", + "0", + "var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()" ); + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()", + "hello", + "var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()" ); + array[item++] = new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()", + "", + "var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.2.js b/tests/mozilla/ecma/String/15.5.4.2.js new file mode 100644 index 0000000..8779e33 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.2.js @@ -0,0 +1,92 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.2.js + ECMA Section: 15.5.4.2 String.prototype.toString + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.5.4.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.tostring"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.toString.__proto__", Function.prototype, String.prototype.toString.__proto__ ); + array[item++] = new TestCase( SECTION, + "String.prototype.toString() == String.prototype.valueOf()", + true, + String.prototype.toString() == String.prototype.valueOf() ); + + array[item++] = new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); + array[item++] = new TestCase( SECTION, "String.prototype.toString.length", 0, String.prototype.toString.length ); + + + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()") ); + array[item++] = new TestCase( SECTION, + "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); + + return ( array ); +} +function test( array ) { + for ( ; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + + stopTest(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.3-1.js b/tests/mozilla/ecma/String/15.5.4.3-1.js new file mode 100644 index 0000000..d55c437 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.3-1.js @@ -0,0 +1,70 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.3-1.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + var SECTION = "15.5.4.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.valueOf.length", 0, String.prototype.valueOf.length ); + + array[item++] = new TestCase( SECTION, "String.prototype.valueOf()", "", String.prototype.valueOf() ); + array[item++] = new TestCase( SECTION, "(new String()).valueOf()", "", (new String()).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String(\"\")).valueOf()", "", (new String("")).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String( String() )).valueOf()","", (new String(String())).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String( \"h e l l o\" )).valueOf()", "h e l l o", (new String("h e l l o")).valueOf() ); + array[item++] = new TestCase( SECTION, "(new String( 0 )).valueOf()", "0", (new String(0)).valueOf() ); + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.3-2.js b/tests/mozilla/ecma/String/15.5.4.3-2.js new file mode 100644 index 0000000..21d3407 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.3-2.js @@ -0,0 +1,89 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.3-2.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + + var SECTION = "15.5.4.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval(testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valof()", + "", + "var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valueOf()" ); + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valof()", + "0", + "var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valueOf()" ); + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valof()", + "hello", + "var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valueOf()" ); + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valof()", + "", + "var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valueOf()" ); +/* + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", + "error", + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()" ); +*/ + return ( array ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.3-3-n.js b/tests/mozilla/ecma/String/15.5.4.3-3-n.js new file mode 100644 index 0000000..f7c420a --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.3-3-n.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.3-3-n.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + + var SECTION = "15.5.4.3-3-n"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.valueOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].actual = eval(testcases[tc].actual ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", + "error", + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()" ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.4-1.js b/tests/mozilla/ecma/String/15.5.4.4-1.js new file mode 100644 index 0000000..e0dc042 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.4-1.js @@ -0,0 +1,87 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.4-1.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + + In this test, this is a String, pos is an integer, and + all pos are in range. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + for ( i = 0x0020; i < 0x007e; i++, item++) { + array[item] = new TestCase( SECTION, + "TEST_STRING.charAt("+item+")", + String.fromCharCode( i ), + TEST_STRING.charAt( item ) ); + } + for ( i = 0x0020; i < 0x007e; i++, item++) { + array[item] = new TestCase( SECTION, + "TEST_STRING.charAt("+item+") == TEST_STRING.substring( "+item +", "+ (item+1) + ")", + true, + TEST_STRING.charAt( item ) == TEST_STRING.substring( item, item+1 ) + ); + } + array[item++] = new TestCase( SECTION, "String.prototype.charAt.length", 1, String.prototype.charAt.length ); + + return array; +} +function test() { + writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + } + stopTest(); + + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.4-2.js b/tests/mozilla/ecma/String/15.5.4.4-2.js new file mode 100644 index 0000000..0ca8fb2 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.4-2.js @@ -0,0 +1,141 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.4-1.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.4-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)", "u", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)", "e", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(0)", "", eval("x=new String();x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(1)", "", eval("x=new String();x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(-1)", "", eval("x=new String();x.charAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(NaN)", "", eval("x=new String();x.charAt(Number.NaN)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(Number.POSITIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.POSITIVE_INFINITY)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(Number.NEGATIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.NEGATIVE_INFINITY)") ); + + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(0)", "1", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(0)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(1)", "2", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(1)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(2)", "3", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(2)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(3)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(3)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(4)", "5", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(4)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(5)", "6", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(5)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(6)", "7", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(6)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(7)", "8", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(7)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(8)", "9", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(8)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(9)", "0", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(9)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(10)", "", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(10)") ); + + array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)") ); + + // MyOtherObject.toString will return "[object Object] + + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)", "[", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)", "o", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)", " ", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)", "O", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)") ); + array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)", "]", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)") ); + + return (array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value " + } + + stopTest(); + return ( testcases ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return this.value +''" ); + this.charAt = String.prototype.charAt; +} +function MyOtherObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.charAt = String.prototype.charAt; +} diff --git a/tests/mozilla/ecma/String/15.5.4.4-3.js b/tests/mozilla/ecma/String/15.5.4.4-3.js new file mode 100644 index 0000000..7de6788 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.4-3.js @@ -0,0 +1,117 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.4-3.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + This tests assiging charAt to a user-defined function. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.4-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function MyObject (v) { + this.value = v; + this.toString = new Function( "return this.value +'';" ); + this.valueOf = new Function( "return this.value" ); + this.charAt = String.prototype.charAt; +} +function getTestCases() { + var array = new Array(); + var item = 0; + + var foo = new MyObject('hello'); + + + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "h", foo.charAt(0) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "e", foo.charAt(1) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(2) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(3) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "o", foo.charAt(4) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(-1) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(5) ); + + var boo = new MyObject(true); + + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "t", boo.charAt(0) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "r", boo.charAt(1) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "u", boo.charAt(2) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "e", boo.charAt(3) ); + + var noo = new MyObject( Math.PI ); + + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "3", noo.charAt(0) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", ".", noo.charAt(1) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(2) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "4", noo.charAt(3) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(4) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "5", noo.charAt(5) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "9", noo.charAt(6) ); + + return array; +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value " + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.4-4.js b/tests/mozilla/ecma/String/15.5.4.4-4.js new file mode 100644 index 0000000..69ee2e5 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.4-4.js @@ -0,0 +1,159 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.4-4.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + This tests assiging charAt to primitive types.. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.4-4"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "String.prototype.charAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; +/* + array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "n", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "u", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + + array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "u", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "n", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "d", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); +*/ + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "f", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "s", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(4)") ); + + array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "t", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "r", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "u", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + + array[item++] = new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + + array[item++] = new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + + + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)", "2", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)", "3", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)") ); + + array[item++] = new TestCase( SECTION, "x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)", "", eval("x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)") ); + + array[item++] = new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)") ); + + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(5)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(6)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(7)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(8)", "O", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(8)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(9)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(9)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(10)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(10)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(11)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(11)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(12)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(12)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(13)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(13)") ); + array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(14)", "]", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(14)") ); + + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)", "F", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)", "u", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)", "i", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)", "]", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)") ); + array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)", "", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)") ); + + + return array; +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.5-1.js b/tests/mozilla/ecma/String/15.5.4.5-1.js new file mode 100644 index 0000000..62d42b4 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.5-1.js @@ -0,0 +1,89 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + + for ( j = 0, i = 0x0020; i < 0x007e; i++, j++ ) { + array[j] = new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", i, TEST_STRING.charCodeAt( j ) ); + } + + item = array.length; + + array[item++] = new TestCase( SECTION, 'TEST_STRING.charCodeAt('+i+')', NaN, TEST_STRING.charCodeAt( i ) ); + return array; +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + } + stopTest(); + + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.5-2.js b/tests/mozilla/ecma/String/15.5.4.5-2.js new file mode 100644 index 0000000..2570687 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.5-2.js @@ -0,0 +1,128 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + var testcases = getTestCases(); + + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var x; + + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); + + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)", 0x0031, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)", 0x0032, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)", 0x0033, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)", NaN, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)") ); + + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)", 0x005B, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)", 0x006F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)", 0x0065, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)", 0x0063, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)", 0x0074, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)") ); + + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)", 0x0020, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)") ); + + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)", 0x004F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)") ); + array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)") ); + + return (array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.5-3.js b/tests/mozilla/ecma/String/15.5.4.5-3.js new file mode 100644 index 0000000..20d380b --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.5-3.js @@ -0,0 +1,136 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.5-3.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + var testcases = getTestCases(); + test(); + +function MyObject (v) { + this.value = v; + this.toString = new Function ( "return this.value +\"\"" ); + this.charCodeAt = String.prototype.charCodeAt; +} + +function getTestCases() { + var array = new Array(); + var item = 0; + + var foo = new MyObject('hello'); + + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(0)", 0x0068, foo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(1)", 0x0065, foo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(2)", 0x006c, foo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(3)", 0x006c, foo.charCodeAt(3) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(4)", 0x006f, foo.charCodeAt(4) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(-1)", Number.NaN, foo.charCodeAt(-1) ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(5)", Number.NaN, foo.charCodeAt(5) ); + + var boo = new MyObject(true); + + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(0)", 0x0074, boo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(1)", 0x0072, boo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(2)", 0x0075, boo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(3)", 0x0065, boo.charCodeAt(3) ); + + var noo = new MyObject( Math.PI ); + + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(0)", 0x0033, noo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(1)", 0x002E, noo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(2)", 0x0031, noo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(3)", 0x0034, noo.charCodeAt(3) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(4)", 0x0031, noo.charCodeAt(4) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(5)", 0x0035, noo.charCodeAt(5) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(6)", 0x0039, noo.charCodeAt(6) ); + + var noo = new MyObject( null ); + + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(0)", 0x006E, noo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(1)", 0x0075, noo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(2)", 0x006C, noo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(3)", 0x006C, noo.charCodeAt(3) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(4)", NaN, noo.charCodeAt(4) ); + + var noo = new MyObject( void 0 ); + + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(0)", 0x0075, noo.charCodeAt(0) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(1)", 0x006E, noo.charCodeAt(1) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(2)", 0x0064, noo.charCodeAt(2) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(3)", 0x0065, noo.charCodeAt(3) ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(4)", 0x0066, noo.charCodeAt(4) ); + + return array; +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value "; + + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.5-4.js b/tests/mozilla/ecma/String/15.5.4.5-4.js new file mode 100644 index 0000000..cd99bc2 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.5-4.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.5-4.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + + Description: Returns a nonnegative integer less than 2^16. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var VERSION = "0697"; + startTest(); + var SECTION = "15.5.4.5-4"; + + writeHeaderToLog( SECTION + " String.prototype.charCodeAt(pos)" ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var MAXCHARCODE = Math.pow(2,16); + var item=0, CHARCODE; + + for ( CHARCODE=0; CHARCODE <256; CHARCODE++ ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", + CHARCODE, + (String.fromCharCode(CHARCODE)).charCodeAt(0) ); + } + for ( CHARCODE=256; CHARCODE < 65536; CHARCODE+=999 ) { + array[item++] = new TestCase( SECTION, + "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", + CHARCODE, + (String.fromCharCode(CHARCODE)).charCodeAt(0) ); + } + + array[item++] = new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); + + return ( array ); +} +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + } + + stopTest(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.5-5.js b/tests/mozilla/ecma/String/15.5.4.5-5.js new file mode 100644 index 0000000..091f5e8 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.5-5.js @@ -0,0 +1,111 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-5"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var TEST_STRING = ""; + + for ( var i = 0x0000; i < 255; i++ ) { + TEST_STRING += String.fromCharCode( i ); + } + + + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); + array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); + + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); + array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); + + for ( var j = 0; j < 255; j++ ) { + array[item++] = new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", j, TEST_STRING.charCodeAt(j) ); + } + return (array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.5-6.js b/tests/mozilla/ecma/String/15.5.4.5-6.js new file mode 100644 index 0000000..8b7ae18 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.5-6.js @@ -0,0 +1,97 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.5-6.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.5-6"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "String.prototype.charCodeAt"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "true", + eval("var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); + + array[item++] = new TestCase( SECTION, + "var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "1234", + eval("var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); + + array[item++] = new TestCase( SECTION, + "var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "hello", + eval("var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); + return (array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value " + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.6-1.js b/tests/mozilla/ecma/String/15.5.4.6-1.js new file mode 100644 index 0000000..ab9d725 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.6-1.js @@ -0,0 +1,158 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.6-1.js + ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) + Description: If the given searchString appears as a substring of the + result of converting this object to a string, at one or + more positions that are at or to the right of the + specified position, then the index of the leftmost such + position is returned; otherwise -1 is returned. If + positionis undefined or not supplied, 0 is assumed, so + as to search all of the string. + + When the indexOf method is called with two arguments, + searchString and pos, the following steps are taken: + + 1. Call ToString, giving it the this value as its + argument. + 2. Call ToString(searchString). + 3. Call ToInteger(position). (If position is undefined + or not supplied, this step produces the value 0). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(3), 0), Result(4)). + 6. Compute the number of characters in the string that + is Result(2). + 7. Compute the smallest possible integer k not smaller + than Result(5) such that k+Result(6) is not greater + than Result(4), and for all nonnegative integers j + less than Result(6), the character at position k+j + of Result(1) is the same as the character at position + j of Result(2); but if there is no such integer k, + then compute the value -1. + 8. Return Result(7). + + Note that the indexOf function is intentionally generic; + it does not require that its this value be a String object. + Therefore it can be transferred to other kinds of objects + for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.6-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.protoype.indexOf"; + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var j = 0; + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf(" +String.fromCharCode(i)+ ", 0)", + k, + TEST_STRING.indexOf( String.fromCharCode(i), 0 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+String.fromCharCode(i)+ ", "+ k +")", + k, + TEST_STRING.indexOf( String.fromCharCode(i), k ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+String.fromCharCode(i)+ ", "+k+1+")", + -1, + TEST_STRING.indexOf( String.fromCharCode(i), k+1 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+0+")", + k, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + 0 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k +")", + k, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k ) ); + } + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k+1 +")", + -1, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k+1 ) ); + } + + array[j++] = new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.indexOf( TEST_STRING, 0 ) ); + array[j++] = new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 1 )", -1, TEST_STRING.indexOf( TEST_STRING, 1 )); + + return array; +} + +function test() { + writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + + for ( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + + } + stopTest(); + + return ( testcases ); +} + diff --git a/tests/mozilla/ecma/String/15.5.4.6-2.js b/tests/mozilla/ecma/String/15.5.4.6-2.js new file mode 100644 index 0000000..6054a51 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.6-2.js @@ -0,0 +1,259 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.6-1.js + ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) + Description: If the given searchString appears as a substring of the + result of converting this object to a string, at one or + more positions that are at or to the right of the + specified position, then the index of the leftmost such + position is returned; otherwise -1 is returned. If + positionis undefined or not supplied, 0 is assumed, so + as to search all of the string. + + When the indexOf method is called with two arguments, + searchString and pos, the following steps are taken: + + 1. Call ToString, giving it the this value as its + argument. + 2. Call ToString(searchString). + 3. Call ToInteger(position). (If position is undefined + or not supplied, this step produces the value 0). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(3), 0), Result(4)). + 6. Compute the number of characters in the string that + is Result(2). + 7. Compute the smallest possible integer k not smaller + than Result(5) such that k+Result(6) is not greater + than Result(4), and for all nonnegative integers j + less than Result(6), the character at position k+j + of Result(1) is the same as the character at position + j of Result(2); but if there is no such integer k, + then compute the value -1. + 8. Return Result(7). + + Note that the indexOf function is intentionally generic; + it does not require that its this value be a String object. + Therefore it can be transferred to other kinds of objects + for use as a method. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 02 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.7 + The length property of the indexOf method is 1 +* +*/ + var SECTION = "15.5.4.6-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.protoype.indexOf"; + var BUGNUMBER="105721"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +// the following test regresses http://scopus/bugsplat/show_bug.cgi?id=105721 + +function f() { + return this; +} +function g() { + var h = f; + return h(); +} + +function MyObject (v) { + this.value = v; + this.toString = new Function ( "return this.value +\"\""); + this.indexOf = String.prototype.indexOf; +} + +function getTestCases() { + var array = new Array(); + var item = 0; + + // regress http://scopus/bugsplat/show_bug.cgi?id=105721 + + array[item++] = new TestCase( SECTION, "function f() { return this; }; function g() { var h = f; return h(); }; g().toString()", GLOBAL, g().toString() ); + + + array[item++] = new TestCase( SECTION, "String.prototype.indexOf.length", 1, String.prototype.indexOf.length ); + array[item++] = new TestCase( SECTION, "String.prototype.indexOf.length = null; String.prototype.indexOf.length", 1, eval("String.prototype.indexOf.length = null; String.prototype.indexOf.length") ); + array[item++] = new TestCase( SECTION, "delete String.prototype.indexOf.length", false, delete String.prototype.indexOf.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.indexOf.length; String.prototype.indexOf.length", 1, eval("delete String.prototype.indexOf.length; String.prototype.indexOf.length") ); + + array[item++] = new TestCase( SECTION, "var s = new String(); s.indexOf()", -1, eval("var s = new String(); s.indexOf()") ); + + // some Unicode tests. + + // generate a test string. + + var TEST_STRING = ""; + + for ( var u = 0x00A1; u <= 0x00FF; u++ ) { + TEST_STRING += String.fromCharCode( u ); + } + + for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { + array[item++] = new TestCase( SECTION, + "TEST_STRING.indexOf( " + String.fromCharCode(u) + " )", + i, + TEST_STRING.indexOf( String.fromCharCode(u) ) ); + } + for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { + array[item++] = new TestCase( SECTION, + "TEST_STRING.indexOf( " + String.fromCharCode(u) + ", void 0 )", + i, + TEST_STRING.indexOf( String.fromCharCode(u), void 0 ) ); + } + + + + var foo = new MyObject('hello'); + + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('h')", 0, foo.indexOf("h") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('e')", 1, foo.indexOf("e") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('o')", 4, foo.indexOf("o") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('X')", -1, foo.indexOf("X") ); + array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf(5) ", -1, foo.indexOf(5) ); + + var boo = new MyObject(true); + + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('t')", 0, boo.indexOf("t") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('r')", 1, boo.indexOf("r") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('u')", 2, boo.indexOf("u") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('e')", 3, boo.indexOf("e") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('true')", 0, boo.indexOf("true") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('rue')", 1, boo.indexOf("rue") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('ue')", 2, boo.indexOf("ue") ); + array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('oy')", -1, boo.indexOf("oy") ); + + + var noo = new MyObject( Math.PI ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('3') ", 0, noo.indexOf('3') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('.') ", 1, noo.indexOf('.') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('4') ", 3, noo.indexOf('4') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('5') ", 5, noo.indexOf('5') ); + array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('9') ", 6, noo.indexOf('9') ); + + array[item++] = new TestCase( SECTION, + "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')", + 0, + eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')") ); + + array[item++] = new TestCase( SECTION, + "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')", + 3, + eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')", + 0, + eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')", + 2, + eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')") ); + + array[item++] = new TestCase( SECTION, + "var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')", + 0, + eval("var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')") ); + + array[item++] = new TestCase( SECTION, + "var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')", + 0, + eval("var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')") ); + + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')", + -1, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')") ); + + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)", + -1, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)") ); + + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)", + 0, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)") ); + + array[item++] = new TestCase( SECTION, + "var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')", + 1, + eval("var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')") ); + + array[item++] = new TestCase( SECTION, + "var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')", + 0, + eval("var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')") ); + + array[item++] = new TestCase( SECTION, + "var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')", + 1, + eval("var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')") ); + + array[item++] = new TestCase( SECTION, + "var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )", + 8, + eval("var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )") ); + + // new Date(0) has '31' or '01' at index 8 depending on whether tester is (GMT-) or (GMT+), respectively + array[item++] = new TestCase( SECTION, + "var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')", + 8, + eval("var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')") ); + + + return array; +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) + ? "" + : "wrong value " + } + stopTest(); + + // all tests must return a boolean value + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.7-1.js b/tests/mozilla/ecma/String/15.5.4.7-1.js new file mode 100644 index 0000000..55d0313 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.7-1.js @@ -0,0 +1,221 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.7-1.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: + + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. + + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToString(searchString). + 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). + 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). + 5.Compute the number of characters in Result(1). + 6.Compute min(max(Result(4), 0), Result(5)). + 7.Compute the number of characters in the string that is Result(2). + 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. + + 1.Return Result(8). + + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.7-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.protoype.lastIndexOf"; + + var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var j = 0; + + for ( k = 0, i = 0x0021; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf(" +String.fromCharCode(i)+ ", 0)", + -1, + TEST_STRING.lastIndexOf( String.fromCharCode(i), 0 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+String.fromCharCode(i)+ ", "+ k +")", + k, + TEST_STRING.lastIndexOf( String.fromCharCode(i), k ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+String.fromCharCode(i)+ ", "+k+1+")", + k, + TEST_STRING.lastIndexOf( String.fromCharCode(i), k+1 ) ); + } + + for ( k = 9, i = 0x0021; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ 0 + ")", + LastIndexOf( TEST_STRING, String.fromCharCode(i) + + String.fromCharCode(i+1)+String.fromCharCode(i+2), 0), + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + 0 ) ); + } + + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k +")", + k, + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k ) ); + } + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k+1 +")", + k, + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k+1 ) ); + } + for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + array[j] = new TestCase( SECTION, + "String.lastIndexOf("+ + (String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ (k-1) +")", + LastIndexOf( TEST_STRING, String.fromCharCode(i) + + String.fromCharCode(i+1)+String.fromCharCode(i+2), k-1), + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k-1 ) ); + } + + array[j++] = new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 0 ) ); +// array[j++] = new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 1 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 1 )); + array[j++] = new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ")", 0, TEST_STRING.lastIndexOf( TEST_STRING )); + + return array; +} + +function test() { + writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + + for ( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + + } + stopTest(); + + return ( testcases ); +} + +function LastIndexOf( string, search, position ) { + string = String( string ); + search = String( search ); + + position = Number( position ) + + if ( isNaN( position ) ) { + position = Infinity; + } else { + position = ToInteger( position ); + } + + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; + + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; + } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } + } + } + + return result8; +} +function ToInteger( n ) { + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } + + var sign = ( n < 0 ) ? -1 : 1; + + return ( sign * Math.floor(Math.abs(n)) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.7-2.js b/tests/mozilla/ecma/String/15.5.4.7-2.js new file mode 100644 index 0000000..9972c7e --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.7-2.js @@ -0,0 +1,220 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.7-2.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: + + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. + + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToString(searchString). + 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). + 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). + 5.Compute the number of characters in Result(1). + 6.Compute min(max(Result(4), 0), Result(5)). + 7.Compute the number of characters in the string that is Result(2). + 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. + + 1.Return Result(8). + + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 02 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.8 + The length property of the lastIndexOf method is 1 +* +*/ + var SECTION = "15.5.4.7-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.protoype.lastIndexOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.lastIndexOf.length", 1, String.prototype.lastIndexOf.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.lastIndexOf.length", false, delete String.prototype.lastIndexOf.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length", 1, eval("delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length" ) ); + + array[item++] = new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('', 0)", LastIndexOf("","",0), eval("var s = new String(''); s.lastIndexOf('', 0)") ); + array[item++] = new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('')", LastIndexOf("",""), eval("var s = new String(''); s.lastIndexOf('')") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('', 0)", LastIndexOf("hello","",0), eval("var s = new String('hello'); s.lastIndexOf('',0)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('')", LastIndexOf("hello",""), eval("var s = new String('hello'); s.lastIndexOf('')") ); + + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll')", LastIndexOf("hello","ll"), eval("var s = new String('hello'); s.lastIndexOf('ll')") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 0)", LastIndexOf("hello","ll",0), eval("var s = new String('hello'); s.lastIndexOf('ll', 0)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1)", LastIndexOf("hello","ll",1), eval("var s = new String('hello'); s.lastIndexOf('ll', 1)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2)", LastIndexOf("hello","ll",2), eval("var s = new String('hello'); s.lastIndexOf('ll', 2)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 3)", LastIndexOf("hello","ll",3), eval("var s = new String('hello'); s.lastIndexOf('ll', 3)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 4)", LastIndexOf("hello","ll",4), eval("var s = new String('hello'); s.lastIndexOf('ll', 4)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 5)", LastIndexOf("hello","ll",5), eval("var s = new String('hello'); s.lastIndexOf('ll', 5)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 6)", LastIndexOf("hello","ll",6), eval("var s = new String('hello'); s.lastIndexOf('ll', 6)") ); + + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1.5)", LastIndexOf('hello','ll', 1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 1.5)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2.5)", LastIndexOf('hello','ll', 2.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 2.5)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1)", LastIndexOf('hello','ll', -1), eval("var s = new String('hello'); s.lastIndexOf('ll', -1)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1.5)",LastIndexOf('hello','ll', -1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', -1.5)") ); + + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -Infinity)", LastIndexOf("hello","ll",-Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', -Infinity)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', Infinity)", LastIndexOf("hello","ll",Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', Infinity)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', NaN)", LastIndexOf("hello","ll",NaN), eval("var s = new String('hello'); s.lastIndexOf('ll', NaN)") ); + array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -0)", LastIndexOf("hello","ll",-0), eval("var s = new String('hello'); s.lastIndexOf('ll', -0)") ); + for ( var i = 0; i < ( "[object Object]" ).length; i++ ) { + array[item++] = new TestCase( SECTION, + "var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")", + ( i < 2 ? -1 : ( i < 9 ? 2 : 9 )) , + eval("var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")") ); + } + for ( var i = 0; i < 5; i ++ ) { + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")", + ( i < 2 ? -1 : 2 ), + eval("var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")") ); + } + for ( var i = 0; i < 5; i ++ ) { + array[item++] = new TestCase( SECTION, + "var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")", + ( i < 1 ? -1 : ( i < 9 ? 1 : ( i < 10 ? 9 : 10 ) ) ), + eval("var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")") ); + } + for ( var i = 0; i < 9; i++ ) { + array[item++] = new TestCase( SECTION, + "var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )", + ( i < 3 ? -1 : ( i < 5 ? 3 : 5 ) ), + eval("var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )") ); + } + var a = new Array( "abc","def","ghi","jkl","mno","pqr","stu","vwx","yz" ); + + for ( var i = 0; i < (a.toString()).length; i++ ) { + array[item++] = new TestCase( SECTION, + "var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )", + ( i < 15 ? -1 : 15 ), + eval("var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )") ); + } + + for ( var i = 0; i < 15; i ++ ) { + array[item++] = new TestCase( SECTION, + "var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")", + ( i < 6 ? -1 : ( i < 10 ? 6 : 10 ) ), + eval("var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")") ); + } +/* + for ( var i = 0; i < 15; i++ ) { + array[item++] = new TestCase( SECTION, + "var d = new Date(); d.lastIndexOf = String.prototype.lastIndexOf; d.lastIndexOf( '0' )", + ) + } + +*/ + return array; +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + } + stopTest(); + + return ( testcases ); +} + +function LastIndexOf( string, search, position ) { + string = String( string ); + search = String( search ); + + position = Number( position ) + + if ( isNaN( position ) ) { + position = Infinity; + } else { + position = ToInteger( position ); + } + + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; + + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; + } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } + } + } + + return result8; +} +function ToInteger( n ) { + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } + + var sign = ( n < 0 ) ? -1 : 1; + + return ( sign * Math.floor(Math.abs(n)) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.7-3.js b/tests/mozilla/ecma/String/15.5.4.7-3.js new file mode 100644 index 0000000..aed400c --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.7-3.js @@ -0,0 +1,166 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.7-3.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: + + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. + + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToString(searchString). + 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). + 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). + 5.Compute the number of characters in Result(1). + 6.Compute min(max(Result(4), 0), Result(5)). + 7.Compute the number of characters in the string that is Result(2). + 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. + + 1.Return Result(8). + + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + var SECTION = "15.5.4.7-3"; + var VERSION = "ECMA_2"; + startTest(); + var TITLE = "String.protoype.lastIndexOf"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )", + -1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )") ); + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )") ); + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )") ); + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )") ); + + array[item++] = new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )") ); + + return array; +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " + } + stopTest(); + + return ( testcases ); +} + +function LastIndexOf( string, search, position ) { + string = String( string ); + search = String( search ); + + position = Number( position ) + + if ( isNaN( position ) ) { + position = Infinity; + } else { + position = ToInteger( position ); + } + + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; + + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; + } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } + } + } + + return result8; +} +function ToInteger( n ) { + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } + + var sign = ( n < 0 ) ? -1 : 1; + + return ( sign * Math.floor(Math.abs(n)) ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.8-1.js b/tests/mozilla/ecma/String/15.5.4.8-1.js new file mode 100644 index 0000000..1dddd41 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.8-1.js @@ -0,0 +1,234 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.8-1.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 12 November 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.14 + The length property of the split method is 2 +* +*/ + + var SECTION = "15.5.4.8-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.split"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.split.length", 2, String.prototype.split.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.split.length", false, delete String.prototype.split.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.split.length; String.prototype.split.length", 2, eval("delete String.prototype.split.length; String.prototype.split.length") ); + + // test cases for when split is called with no arguments. + + // this is a string object + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.split()", + "object", + eval("var s = new String('this is a string object'); typeof s.split()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()", + "[object Array]", + eval("var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.split().length", + 1, + eval("var s = new String('this is a string object'); s.split().length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.split()[0]", + "this is a string object", + eval("var s = new String('this is a string object'); s.split()[0]") ); + + // this is an object object + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Object(); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]", + "[object Object]", + eval("var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]") ); + + // this is a function object + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Function(); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]", + "[object Function]", + eval("var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]") ); + + // this is a number object + array[item++] = new TestCase( SECTION, + "var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]", + "-1e+21", + eval("var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]") ); + + + // this is the Math object + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = Math; obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = Math; obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; obj.split()[0]", + "[object Math]", + eval("var obj = Math; obj.split = String.prototype.split; obj.split()[0]") ); + + // this is an array object + array[item++] = new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]", + "1,2,3,4,5", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]") ); + + // this is a Boolean object + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length") ); + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]", + "false", + eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]") ); + + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.8-2.js b/tests/mozilla/ecma/String/15.5.4.8-2.js new file mode 100644 index 0000000..18e41cd --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.8-2.js @@ -0,0 +1,248 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.8-2.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + When the split method is called with one argument separator, the following steps are taken: + + 1. Call ToString, giving it the this value as its argument. + 2. Create a new Array object of length 0 and call it A. + 3. If separator is not supplied, call the [[Put]] method of A with 0 and + Result(1) as arguments, and then return A. + 4. Call ToString(separator). + 5. Compute the number of characters in Result(1). + 6. Compute the number of characters in the string that is Result(4). + 7. Let p be 0. + 8. If Result(6) is zero (the separator string is empty), go to step 17. + 9. Compute the smallest possible integer k not smaller than p such that + k+Result(6) is not greater than Result(5), and for all nonnegative + integers j less than Result(6), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); + but if there is no such integer k, then go to step 14. + 10. Compute a string value equal to the substring of Result(1), consisting + of the characters at positions p through k1, inclusive. + 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. + 12. Let p be k+Result(6). + 13. Go to step 9. + 14. Compute a string value equal to the substring of Result(1), consisting + of the characters from position p to the end of Result(1). + 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. + 16. Return A. + 17. If p equals Result(5), return A. + 18. Compute a string value equal to the substring of Result(1), consisting of + the single character at position p. + 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. + 20. Increase p by 1. + 21. Go to step 17. + +Note that the split function is intentionally generic; it does not require that its this value be a String +object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.8-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.split"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + // case where separator is the empty string. + + var TEST_STRING = "this is a string object"; + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split('').length", + TEST_STRING.length, + eval("var s = new String( TEST_STRING ); s.split('').length") ); + + for ( var i = 0; i < TEST_STRING.length; i++ ) { + + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split('')["+i+"]", + TEST_STRING.charAt(i), + eval("var s = new String( TEST_STRING ); s.split('')["+i+"]") ); + } + + // case where the value of the separator is undefined. in this case. the value of the separator + // should be ToString( separator ), or "undefined". + + var TEST_STRING = "thisundefinedisundefinedaundefinedstringundefinedobject"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(void 0).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(void 0).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(void 0)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(void 0)["+i+"]") ); + } + + // case where the value of the separator is null. in this case the value of the separator is "null". + TEST_STRING = "thisnullisnullanullstringnullobject"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(null).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(null).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(null)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(null)["+i+"]") ); + } + + // case where the value of the separator is a boolean. + TEST_STRING = "thistrueistrueatruestringtrueobject"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(true).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(true).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(true)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(true)["+i+"]") ); + } + + // case where the value of the separator is a number + TEST_STRING = "this123is123a123string123object"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(123).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(123).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); + } + + + // case where the value of the separator is a number + TEST_STRING = "this123is123a123string123object"; + var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(123).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(123).length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); + } + + // case where the separator is not in the string + TEST_STRING = "this is a string"; + EXPECT_STRING = new Array( "this is a string" ); + + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split(':').length", + 1, + eval("var s = new String( TEST_STRING ); s.split(':').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split(':')[0]", + TEST_STRING, + eval("var s = new String( TEST_STRING ); s.split(':')[0]") ); + + // case where part but not all of separator is in the string. + TEST_STRING = "this is a string"; + EXPECT_STRING = new Array( "this is a string" ); + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('strings').length", + 1, + eval("var s = new String( TEST_STRING ); s.split('strings').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('strings')[0]", + TEST_STRING, + eval("var s = new String( TEST_STRING ); s.split('strings')[0]") ); + + // case where the separator is at the end of the string + TEST_STRING = "this is a string"; + EXPECT_STRING = new Array( "this is a " ); + array[item++] = new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('string').length", + 2, + eval("var s = new String( TEST_STRING ); s.split('string').length") ); + + for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + array[item++] = new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split('string')["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split('string')["+i+"]") ); + } + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.4.8-3.js b/tests/mozilla/ecma/String/15.5.4.8-3.js new file mode 100644 index 0000000..d3861bb --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.8-3.js @@ -0,0 +1,205 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.8-3.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + When the split method is called with one argument separator, the following steps are taken: + + 1. Call ToString, giving it the this value as its argument. + 2. Create a new Array object of length 0 and call it A. + 3. If separator is not supplied, call the [[Put]] method of A with 0 and + Result(1) as arguments, and then return A. + 4. Call ToString(separator). + 5. Compute the number of characters in Result(1). + 6. Compute the number of characters in the string that is Result(4). + 7. Let p be 0. + 8. If Result(6) is zero (the separator string is empty), go to step 17. + 9. Compute the smallest possible integer k not smaller than p such that + k+Result(6) is not greater than Result(5), and for all nonnegative + integers j less than Result(6), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); + but if there is no such integer k, then go to step 14. + 10. Compute a string value equal to the substring of Result(1), consisting + of the characters at positions p through k1, inclusive. + 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. + 12. Let p be k+Result(6). + 13. Go to step 9. + 14. Compute a string value equal to the substring of Result(1), consisting + of the characters from position p to the end of Result(1). + 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. + 16. Return A. + 17. If p equals Result(5), return A. + 18. Compute a string value equal to the substring of Result(1), consisting of + the single character at position p. + 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. + 20. Increase p by 1. + 21. Go to step 17. + +Note that the split function is intentionally generic; it does not require that its this value be a String +object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.8-3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.split"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + var TEST_STRING = ""; + var EXPECT = new Array(); + + // this.toString is the empty string. + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.split().length", + 1, + eval("var s = new String(); s.split().length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.split()[0]", + "", + eval("var s = new String(); s.split()[0]") ); + + // this.toString() is the empty string, separator is specified. + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.split('').length", + 0, + eval("var s = new String(); s.split('').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.split(' ').length", + 1, + eval("var s = new String(); s.split(' ').length") ); + + // this to string is " " + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split().length", + 1, + eval("var s = new String(' '); s.split().length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split()[0]", + " ", + eval("var s = new String(' '); s.split()[0]") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split('').length", + 1, + eval("var s = new String(' '); s.split('').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split('')[0]", + " ", + eval("var s = new String(' '); s.split('')[0]") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split(' ').length", + 2, + eval("var s = new String(' '); s.split(' ').length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(' '); s.split(' ')[0]", + "", + eval("var s = new String(' '); s.split(' ')[0]") ); + + array[item++] = new TestCase( SECTION, + "\"\".split(\"\").length", + 0, + ("".split("")).length ); + + array[item++] = new TestCase( SECTION, + "\"\".split(\"x\").length", + 1, + ("".split("x")).length ); + + array[item++] = new TestCase( SECTION, + "\"\".split(\"x\")[0]", + "", + ("".split("x"))[0] ); + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function Split( string, separator ) { + string = String( string ); + + var A = new Array(); + + if ( arguments.length < 2 ) { + A[0] = string; + return A; + } + + separator = String( separator ); + + var str_len = String( string ).length; + var sep_len = String( separator ).length; + + var p = 0; + var k = 0; + + if ( sep_len == 0 ) { + for ( ; p < str_len; p++ ) { + A[A.length] = String( string.charAt(p) ); + } + } + return A; +} diff --git a/tests/mozilla/ecma/String/15.5.4.9-1.js b/tests/mozilla/ecma/String/15.5.4.9-1.js new file mode 100644 index 0000000..9ae08dc --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.9-1.js @@ -0,0 +1,202 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.9-1.js + ECMA Section: 15.5.4.9 String.prototype.substring( start ) + Description: + + 15.5.4.9 String.prototype.substring(start) + + Returns a substring of the result of converting this object to a string, + starting from character position start and running to the end of the + string. The result is a string value, not a String object. + + If the argument is NaN or negative, it is replaced with zero; if the + argument is larger than the length of the string, it is replaced with the + length of the string. + + When the substring method is called with one argument start, the following + steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToInteger(start). + 3.Compute the number of characters in Result(1). + 4.Compute min(max(Result(2), 0), Result(3)). + 5.Return a string whose length is the difference between Result(3) and Result(4), + containing characters from Result(1), namely the characters with indices Result(4) + through Result(3)1, in ascending order. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.4.9-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.prototype.substring( start )"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); + array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); + + // test cases for when substring is called with no arguments. + + // this is a string object + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.substring()", + "string", + eval("var s = new String('this is a string object'); typeof s.substring()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(''); s.substring()", + "", + eval("var s = new String(''); s.substring()") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring()", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring()") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(NaN)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(NaN)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-0.01)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(-0.01)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length+1)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length+1)") ); + + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(Infinity)") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-Infinity)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(-Infinity)") ); + + // this is not a String object, start is not an integer + + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()", + "1,2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)", + ",2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')", + "3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')") ); + + array[item++] = new TestCase( SECTION, + "var s = new Array(); s.substring = String.prototype.substring; s.substring('4')", + "", + eval("var s = new Array(); s.substring = String.prototype.substring; s.substring('4')") ); + + // this is an object object + array[item++] = new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)", + "Object]", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)") ); + + // this is a function object + array[item++] = new TestCase( SECTION, + "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)", + "Function]", + eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)") ); + // this is a number object + array[item++] = new TestCase( SECTION, + "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)", + "NaN", + eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)") ); + + // this is the Math object + array[item++] = new TestCase( SECTION, + "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)", + "ject Math]", + eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)") ); + + // this is a Boolean object + + array[item++] = new TestCase( SECTION, + "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())", + "false", + eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())") ); + + // this is a user defined object + + array[item++] = new TestCase( SECTION, + "var obj = new MyObject( null ); obj.substring(0)", + "null", + eval( "var obj = new MyObject( null ); obj.substring(0)") ); + + return array; +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/String/15.5.4.js b/tests/mozilla/ecma/String/15.5.4.js new file mode 100644 index 0000000..3456a09 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.4.js @@ -0,0 +1,74 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.4.js + ECMA Section: 15.5.4 Properties of the String prototype object + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + var SECTION = "15.5.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Properties of the String Prototype objecta"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()", + "[object String]", + eval("String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()") ); + + array[item++] = new TestCase( SECTION, "typeof String.prototype", "object", typeof String.prototype ); + array[item++] = new TestCase( SECTION, "String.prototype.valueOf()", "", String.prototype.valueOf() ); + array[item++] = new TestCase( SECTION, "String.prototype +''", "", String.prototype + '' ); + array[item++] = new TestCase( SECTION, "String.prototype.length", 0, String.prototype.length ); +// array[item++] = new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); + + + return ( array ); +} +function test( array ) { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + + } + + stopTest(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} diff --git a/tests/mozilla/ecma/String/15.5.5.1.js b/tests/mozilla/ecma/String/15.5.5.1.js new file mode 100644 index 0000000..5f0fe29 --- /dev/null +++ b/tests/mozilla/ecma/String/15.5.5.1.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.5.5.1 + ECMA Section: String.length + Description: + + The number of characters in the String value represented by this String + object. + + Once a String object is created, this property is unchanging. It has the + attributes { DontEnum, DontDelete, ReadOnly }. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "15.5.5.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "String.length"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.length", + 0, + eval("var s = new String(); s.length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); s.length = 10; s.length", + 0, + eval("var s = new String(); s.length = 10; s.length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props", + "", + eval("var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props") ); + + array[item++] = new TestCase( SECTION, + "var s = new String(); delete s.length", + false, + eval("var s = new String(); delete s.length") ); + + array[item++] = new TestCase( SECTION, + "var s = new String('hello'); delete s.length; s.length", + 5, + eval("var s = new String('hello'); delete s.length; s.length") ); + return array; + +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.2.js b/tests/mozilla/ecma/TypeConversion/9.2.js new file mode 100644 index 0000000..c0cb331 --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.2.js @@ -0,0 +1,111 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.2.js + ECMA Section: 9.2 Type Conversion: ToBoolean + Description: rules for converting an argument to a boolean. + undefined false + Null false + Boolean input argument( no conversion ) + Number returns false for 0, -0, and NaN + otherwise return true + String return false if the string is empty + (length is 0) otherwise the result is + true + Object all return true + + Author: christine@netscape.com + Date: 14 july 1997 +*/ + var SECTION = "9.2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToBoolean"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // special cases here + + testcases[tc++] = new TestCase( SECTION, "Boolean()", false, Boolean() ); + testcases[tc++] = new TestCase( SECTION, "Boolean(var x)", false, Boolean(eval("var x")) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(void 0)", false, Boolean(void 0) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(-0)", false, Boolean(-0) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); + testcases[tc++] = new TestCase( SECTION, "Boolean('')", false, Boolean("") ); + + // normal test cases here + + testcases[tc++] = new TestCase( SECTION, "Boolean(Infinity)", true, Boolean(Number.POSITIVE_INFINITY) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(Math.PI)", true, Boolean(Math.PI) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); + testcases[tc++] = new TestCase( SECTION, "Boolean([tab])", true, Boolean("\t") ); + testcases[tc++] = new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); + testcases[tc++] = new TestCase( SECTION, "Boolean('string')", true, Boolean("string") ); + + // ToBoolean (object) should always return true. + testcases[tc++] = new TestCase( SECTION, "Boolean(new String() )", true, Boolean(new String()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new String('') )", true, Boolean(new String("")) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Boolean(true))", true, Boolean(new Boolean(true)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Boolean(false))", true, Boolean(new Boolean(false)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Boolean() )", true, Boolean(new Boolean()) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Array())", true, Boolean(new Array()) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number())", true, Boolean(new Number()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(-0))", true, Boolean(new Number(-0)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(0))", true, Boolean(new Number(0)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(NaN))", true, Boolean(new Number(Number.NaN)) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(-1))", true, Boolean(new Number(-1)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(Infinity))", true, Boolean(new Number(Number.POSITIVE_INFINITY)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(-Infinity))",true, Boolean(new Number(Number.NEGATIVE_INFINITY)) ); + + testcases[tc++] = new TestCase( SECTION, "Boolean(new Object())", true, Boolean(new Object()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Function())", true, Boolean(new Function()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Date())", true, Boolean(new Date()) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(new Date(0))", true, Boolean(new Date(0)) ); + testcases[tc++] = new TestCase( SECTION, "Boolean(Math)", true, Boolean(Math) ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.3-1.js b/tests/mozilla/ecma/TypeConversion/9.3-1.js new file mode 100644 index 0000000..39af328 --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.3-1.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.3-1.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + + This tests ToNumber applied to the object type, except + if object is string. See 9.3-2 for + ToNumber( String object). + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TYPE = "number"; + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " ToNumber"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].passed = writeTestCaseResult( + TYPE, + typeof(testcases[tc].actual), + "typeof( " + testcases[tc].description + + " ) = " + typeof(testcases[tc].actual) ) + ? testcases[tc].passed + : false; + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // object is Number + array[item++] = new TestCase( SECTION, "Number(new Number())", 0, Number(new Number()) ); + array[item++] = new TestCase( SECTION, "Number(new Number(Number.NaN))",Number.NaN, Number(new Number(Number.NaN)) ); + array[item++] = new TestCase( SECTION, "Number(new Number(0))", 0, Number(new Number(0)) ); + array[item++] = new TestCase( SECTION, "Number(new Number(null))", 0, Number(new Number(null)) ); +// array[item++] = new TestCase( SECTION, "Number(new Number(void 0))", Number.NaN, Number(new Number(void 0)) ); + array[item++] = new TestCase( SECTION, "Number(new Number(true))", 1, Number(new Number(true)) ); + array[item++] = new TestCase( SECTION, "Number(new Number(false))", 0, Number(new Number(false)) ); + + // object is boolean + + array[item++] = new TestCase( SECTION, "Number(new Boolean(true))", 1, Number(new Boolean(true)) ); + array[item++] = new TestCase( SECTION, "Number(new Boolean(false))", 0, Number(new Boolean(false)) ); + + // object is array + array[item++] = new TestCase( SECTION, "Number(new Array(2,4,8,16,32))", Number.NaN, Number(new Array(2,4,8,16,32)) ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.3.1-1.js b/tests/mozilla/ecma/TypeConversion/9.3.1-1.js new file mode 100644 index 0000000..4cc8ce0 --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.3.1-1.js @@ -0,0 +1,323 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.3.1-1.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + + This tests ToNumber applied to the string type + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.3.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToNumber applied to the String type"; + var BUGNUMBER="77391"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // StringNumericLiteral:::StrWhiteSpace:::StrWhiteSpaceChar StrWhiteSpace::: + // + // Name Unicode Value Escape Sequence + // 0X0009 \t + // 0X0020 + // 0X000C \f + // 0X000B + // 0X000D \r + // 0X000A \n + array[item++] = new TestCase( SECTION, "Number('')", 0, Number("") ); + array[item++] = new TestCase( SECTION, "Number(' ')", 0, Number(" ") ); + array[item++] = new TestCase( SECTION, "Number(\\t)", 0, Number("\t") ); + array[item++] = new TestCase( SECTION, "Number(\\n)", 0, Number("\n") ); + array[item++] = new TestCase( SECTION, "Number(\\r)", 0, Number("\r") ); + array[item++] = new TestCase( SECTION, "Number(\\f)", 0, Number("\f") ); + + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x0009)", 0, Number(String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x0020)", 0, Number(String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000C)", 0, Number(String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000B)", 0, Number(String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000D)", 0, Number(String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000A)", 0, Number(String.fromCharCode(0x000A)) ); + + // a StringNumericLiteral may be preceeded or followed by whitespace and/or + // line terminators + + array[item++] = new TestCase( SECTION, "Number( ' ' + 999 )", 999, Number( ' '+999) ); + array[item++] = new TestCase( SECTION, "Number( '\\n' + 999 )", 999, Number( '\n' +999) ); + array[item++] = new TestCase( SECTION, "Number( '\\r' + 999 )", 999, Number( '\r' +999) ); + array[item++] = new TestCase( SECTION, "Number( '\\t' + 999 )", 999, Number( '\t' +999) ); + array[item++] = new TestCase( SECTION, "Number( '\\f' + 999 )", 999, Number( '\f' +999) ); + + array[item++] = new TestCase( SECTION, "Number( 999 + ' ' )", 999, Number( 999+' ') ); + array[item++] = new TestCase( SECTION, "Number( 999 + '\\n' )", 999, Number( 999+'\n' ) ); + array[item++] = new TestCase( SECTION, "Number( 999 + '\\r' )", 999, Number( 999+'\r' ) ); + array[item++] = new TestCase( SECTION, "Number( 999 + '\\t' )", 999, Number( 999+'\t' ) ); + array[item++] = new TestCase( SECTION, "Number( 999 + '\\f' )", 999, Number( 999+'\f' ) ); + + array[item++] = new TestCase( SECTION, "Number( '\\n' + 999 + '\\n' )", 999, Number( '\n' +999+'\n' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\r' + 999 + '\\r' )", 999, Number( '\r' +999+'\r' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\t' + 999 + '\\t' )", 999, Number( '\t' +999+'\t' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\f' + 999 + '\\f' )", 999, Number( '\f' +999+'\f' ) ); + + array[item++] = new TestCase( SECTION, "Number( ' ' + '999' )", 999, Number( ' '+'999') ); + array[item++] = new TestCase( SECTION, "Number( '\\n' + '999' )", 999, Number( '\n' +'999') ); + array[item++] = new TestCase( SECTION, "Number( '\\r' + '999' )", 999, Number( '\r' +'999') ); + array[item++] = new TestCase( SECTION, "Number( '\\t' + '999' )", 999, Number( '\t' +'999') ); + array[item++] = new TestCase( SECTION, "Number( '\\f' + '999' )", 999, Number( '\f' +'999') ); + + array[item++] = new TestCase( SECTION, "Number( '999' + ' ' )", 999, Number( '999'+' ') ); + array[item++] = new TestCase( SECTION, "Number( '999' + '\\n' )", 999, Number( '999'+'\n' ) ); + array[item++] = new TestCase( SECTION, "Number( '999' + '\\r' )", 999, Number( '999'+'\r' ) ); + array[item++] = new TestCase( SECTION, "Number( '999' + '\\t' )", 999, Number( '999'+'\t' ) ); + array[item++] = new TestCase( SECTION, "Number( '999' + '\\f' )", 999, Number( '999'+'\f' ) ); + + array[item++] = new TestCase( SECTION, "Number( '\\n' + '999' + '\\n' )", 999, Number( '\n' +'999'+'\n' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\r' + '999' + '\\r' )", 999, Number( '\r' +'999'+'\r' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\t' + '999' + '\\t' )", 999, Number( '\t' +'999'+'\t' ) ); + array[item++] = new TestCase( SECTION, "Number( '\\f' + '999' + '\\f' )", 999, Number( '\f' +'999'+'\f' ) ); + + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' )", 99, Number( String.fromCharCode(0x0009) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' )", 99, Number( String.fromCharCode(0x0020) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' )", 99, Number( String.fromCharCode(0x000C) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' )", 99, Number( String.fromCharCode(0x000B) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' )", 99, Number( String.fromCharCode(0x000D) + '99' ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' )", 99, Number( String.fromCharCode(0x000A) + '99' ) ); + + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0009)", 99, Number( '99' + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0020)", 99, Number( '99' + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000C)", 99, Number( '99' + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000D)", 99, Number( '99' + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000B)", 99, Number( '99' + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000A)", 99, Number( '99' + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 )", 99, Number( String.fromCharCode(0x0009) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 )", 99, Number( String.fromCharCode(0x0020) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 )", 99, Number( String.fromCharCode(0x000C) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 )", 99, Number( String.fromCharCode(0x000B) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 )", 99, Number( String.fromCharCode(0x000D) + 99 ) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 )", 99, Number( String.fromCharCode(0x000A) + 99 ) ); + + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); + + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0009)", 99, Number( 99 + String.fromCharCode(0x0009)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0020)", 99, Number( 99 + String.fromCharCode(0x0020)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000C)", 99, Number( 99 + String.fromCharCode(0x000C)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000D)", 99, Number( 99 + String.fromCharCode(0x000D)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000B)", 99, Number( 99 + String.fromCharCode(0x000B)) ); + array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000A)", 99, Number( 99 + String.fromCharCode(0x000A)) ); + + + // StrNumericLiteral:::StrDecimalLiteral:::Infinity + + array[item++] = new TestCase( SECTION, "Number('Infinity')", Math.pow(10,10000), Number("Infinity") ); + array[item++] = new TestCase( SECTION, "Number('-Infinity')", -Math.pow(10,10000), Number("-Infinity") ); + array[item++] = new TestCase( SECTION, "Number('+Infinity')", Math.pow(10,10000), Number("+Infinity") ); + + // StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt + + array[item++] = new TestCase( SECTION, "Number('0')", 0, Number("0") ); + array[item++] = new TestCase( SECTION, "Number('-0')", -0, Number("-0") ); + array[item++] = new TestCase( SECTION, "Number('+0')", 0, Number("+0") ); + + array[item++] = new TestCase( SECTION, "Number('1')", 1, Number("1") ); + array[item++] = new TestCase( SECTION, "Number('-1')", -1, Number("-1") ); + array[item++] = new TestCase( SECTION, "Number('+1')", 1, Number("+1") ); + + array[item++] = new TestCase( SECTION, "Number('2')", 2, Number("2") ); + array[item++] = new TestCase( SECTION, "Number('-2')", -2, Number("-2") ); + array[item++] = new TestCase( SECTION, "Number('+2')", 2, Number("+2") ); + + array[item++] = new TestCase( SECTION, "Number('3')", 3, Number("3") ); + array[item++] = new TestCase( SECTION, "Number('-3')", -3, Number("-3") ); + array[item++] = new TestCase( SECTION, "Number('+3')", 3, Number("+3") ); + + array[item++] = new TestCase( SECTION, "Number('4')", 4, Number("4") ); + array[item++] = new TestCase( SECTION, "Number('-4')", -4, Number("-4") ); + array[item++] = new TestCase( SECTION, "Number('+4')", 4, Number("+4") ); + + array[item++] = new TestCase( SECTION, "Number('5')", 5, Number("5") ); + array[item++] = new TestCase( SECTION, "Number('-5')", -5, Number("-5") ); + array[item++] = new TestCase( SECTION, "Number('+5')", 5, Number("+5") ); + + array[item++] = new TestCase( SECTION, "Number('6')", 6, Number("6") ); + array[item++] = new TestCase( SECTION, "Number('-6')", -6, Number("-6") ); + array[item++] = new TestCase( SECTION, "Number('+6')", 6, Number("+6") ); + + array[item++] = new TestCase( SECTION, "Number('7')", 7, Number("7") ); + array[item++] = new TestCase( SECTION, "Number('-7')", -7, Number("-7") ); + array[item++] = new TestCase( SECTION, "Number('+7')", 7, Number("+7") ); + + array[item++] = new TestCase( SECTION, "Number('8')", 8, Number("8") ); + array[item++] = new TestCase( SECTION, "Number('-8')", -8, Number("-8") ); + array[item++] = new TestCase( SECTION, "Number('+8')", 8, Number("+8") ); + + array[item++] = new TestCase( SECTION, "Number('9')", 9, Number("9") ); + array[item++] = new TestCase( SECTION, "Number('-9')", -9, Number("-9") ); + array[item++] = new TestCase( SECTION, "Number('+9')", 9, Number("+9") ); + + array[item++] = new TestCase( SECTION, "Number('3.14159')", 3.14159, Number("3.14159") ); + array[item++] = new TestCase( SECTION, "Number('-3.14159')", -3.14159, Number("-3.14159") ); + array[item++] = new TestCase( SECTION, "Number('+3.14159')", 3.14159, Number("+3.14159") ); + + array[item++] = new TestCase( SECTION, "Number('3.')", 3, Number("3.") ); + array[item++] = new TestCase( SECTION, "Number('-3.')", -3, Number("-3.") ); + array[item++] = new TestCase( SECTION, "Number('+3.')", 3, Number("+3.") ); + + array[item++] = new TestCase( SECTION, "Number('3.e1')", 30, Number("3.e1") ); + array[item++] = new TestCase( SECTION, "Number('-3.e1')", -30, Number("-3.e1") ); + array[item++] = new TestCase( SECTION, "Number('+3.e1')", 30, Number("+3.e1") ); + + array[item++] = new TestCase( SECTION, "Number('3.e+1')", 30, Number("3.e+1") ); + array[item++] = new TestCase( SECTION, "Number('-3.e+1')", -30, Number("-3.e+1") ); + array[item++] = new TestCase( SECTION, "Number('+3.e+1')", 30, Number("+3.e+1") ); + + array[item++] = new TestCase( SECTION, "Number('3.e-1')", .30, Number("3.e-1") ); + array[item++] = new TestCase( SECTION, "Number('-3.e-1')", -.30, Number("-3.e-1") ); + array[item++] = new TestCase( SECTION, "Number('+3.e-1')", .30, Number("+3.e-1") ); + + // StrDecimalLiteral::: .DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "Number('.00001')", 0.00001, Number(".00001") ); + array[item++] = new TestCase( SECTION, "Number('+.00001')", 0.00001, Number("+.00001") ); + array[item++] = new TestCase( SECTION, "Number('-0.0001')", -0.00001, Number("-.00001") ); + + array[item++] = new TestCase( SECTION, "Number('.01e2')", 1, Number(".01e2") ); + array[item++] = new TestCase( SECTION, "Number('+.01e2')", 1, Number("+.01e2") ); + array[item++] = new TestCase( SECTION, "Number('-.01e2')", -1, Number("-.01e2") ); + + array[item++] = new TestCase( SECTION, "Number('.01e+2')", 1, Number(".01e+2") ); + array[item++] = new TestCase( SECTION, "Number('+.01e+2')", 1, Number("+.01e+2") ); + array[item++] = new TestCase( SECTION, "Number('-.01e+2')", -1, Number("-.01e+2") ); + + array[item++] = new TestCase( SECTION, "Number('.01e-2')", 0.0001, Number(".01e-2") ); + array[item++] = new TestCase( SECTION, "Number('+.01e-2')", 0.0001, Number("+.01e-2") ); + array[item++] = new TestCase( SECTION, "Number('-.01e-2')", -0.0001, Number("-.01e-2") ); + + // StrDecimalLiteral::: DecimalDigits ExponentPart opt + + array[item++] = new TestCase( SECTION, "Number('1234e5')", 123400000, Number("1234e5") ); + array[item++] = new TestCase( SECTION, "Number('+1234e5')", 123400000, Number("+1234e5") ); + array[item++] = new TestCase( SECTION, "Number('-1234e5')", -123400000, Number("-1234e5") ); + + array[item++] = new TestCase( SECTION, "Number('1234e+5')", 123400000, Number("1234e+5") ); + array[item++] = new TestCase( SECTION, "Number('+1234e+5')", 123400000, Number("+1234e+5") ); + array[item++] = new TestCase( SECTION, "Number('-1234e+5')", -123400000, Number("-1234e+5") ); + + array[item++] = new TestCase( SECTION, "Number('1234e-5')", 0.01234, Number("1234e-5") ); + array[item++] = new TestCase( SECTION, "Number('+1234e-5')", 0.01234, Number("+1234e-5") ); + array[item++] = new TestCase( SECTION, "Number('-1234e-5')", -0.01234, Number("-1234e-5") ); + + // StrNumericLiteral::: HexIntegerLiteral + + array[item++] = new TestCase( SECTION, "Number('0x0')", 0, Number("0x0")); + array[item++] = new TestCase( SECTION, "Number('0x1')", 1, Number("0x1")); + array[item++] = new TestCase( SECTION, "Number('0x2')", 2, Number("0x2")); + array[item++] = new TestCase( SECTION, "Number('0x3')", 3, Number("0x3")); + array[item++] = new TestCase( SECTION, "Number('0x4')", 4, Number("0x4")); + array[item++] = new TestCase( SECTION, "Number('0x5')", 5, Number("0x5")); + array[item++] = new TestCase( SECTION, "Number('0x6')", 6, Number("0x6")); + array[item++] = new TestCase( SECTION, "Number('0x7')", 7, Number("0x7")); + array[item++] = new TestCase( SECTION, "Number('0x8')", 8, Number("0x8")); + array[item++] = new TestCase( SECTION, "Number('0x9')", 9, Number("0x9")); + array[item++] = new TestCase( SECTION, "Number('0xa')", 10, Number("0xa")); + array[item++] = new TestCase( SECTION, "Number('0xb')", 11, Number("0xb")); + array[item++] = new TestCase( SECTION, "Number('0xc')", 12, Number("0xc")); + array[item++] = new TestCase( SECTION, "Number('0xd')", 13, Number("0xd")); + array[item++] = new TestCase( SECTION, "Number('0xe')", 14, Number("0xe")); + array[item++] = new TestCase( SECTION, "Number('0xf')", 15, Number("0xf")); + array[item++] = new TestCase( SECTION, "Number('0xA')", 10, Number("0xA")); + array[item++] = new TestCase( SECTION, "Number('0xB')", 11, Number("0xB")); + array[item++] = new TestCase( SECTION, "Number('0xC')", 12, Number("0xC")); + array[item++] = new TestCase( SECTION, "Number('0xD')", 13, Number("0xD")); + array[item++] = new TestCase( SECTION, "Number('0xE')", 14, Number("0xE")); + array[item++] = new TestCase( SECTION, "Number('0xF')", 15, Number("0xF")); + + array[item++] = new TestCase( SECTION, "Number('0X0')", 0, Number("0X0")); + array[item++] = new TestCase( SECTION, "Number('0X1')", 1, Number("0X1")); + array[item++] = new TestCase( SECTION, "Number('0X2')", 2, Number("0X2")); + array[item++] = new TestCase( SECTION, "Number('0X3')", 3, Number("0X3")); + array[item++] = new TestCase( SECTION, "Number('0X4')", 4, Number("0X4")); + array[item++] = new TestCase( SECTION, "Number('0X5')", 5, Number("0X5")); + array[item++] = new TestCase( SECTION, "Number('0X6')", 6, Number("0X6")); + array[item++] = new TestCase( SECTION, "Number('0X7')", 7, Number("0X7")); + array[item++] = new TestCase( SECTION, "Number('0X8')", 8, Number("0X8")); + array[item++] = new TestCase( SECTION, "Number('0X9')", 9, Number("0X9")); + array[item++] = new TestCase( SECTION, "Number('0Xa')", 10, Number("0Xa")); + array[item++] = new TestCase( SECTION, "Number('0Xb')", 11, Number("0Xb")); + array[item++] = new TestCase( SECTION, "Number('0Xc')", 12, Number("0Xc")); + array[item++] = new TestCase( SECTION, "Number('0Xd')", 13, Number("0Xd")); + array[item++] = new TestCase( SECTION, "Number('0Xe')", 14, Number("0Xe")); + array[item++] = new TestCase( SECTION, "Number('0Xf')", 15, Number("0Xf")); + array[item++] = new TestCase( SECTION, "Number('0XA')", 10, Number("0XA")); + array[item++] = new TestCase( SECTION, "Number('0XB')", 11, Number("0XB")); + array[item++] = new TestCase( SECTION, "Number('0XC')", 12, Number("0XC")); + array[item++] = new TestCase( SECTION, "Number('0XD')", 13, Number("0XD")); + array[item++] = new TestCase( SECTION, "Number('0XE')", 14, Number("0XE")); + array[item++] = new TestCase( SECTION, "Number('0XF')", 15, Number("0XF")); + + return ( array ); +} + diff --git a/tests/mozilla/ecma/TypeConversion/9.3.1-2.js b/tests/mozilla/ecma/TypeConversion/9.3.1-2.js new file mode 100644 index 0000000..c675e57 --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.3.1-2.js @@ -0,0 +1,89 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.3.1-2.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + This tests special cases of ToNumber(string) that are + not covered in 9.3.1-1.js. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.3.1-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToNumber applied to the String type"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // A StringNumericLiteral may not use octal notation + + array[item++] = new TestCase( SECTION, "Number(00)", 0, Number("00")); + array[item++] = new TestCase( SECTION, "Number(01)", 1, Number("01")); + array[item++] = new TestCase( SECTION, "Number(02)", 2, Number("02")); + array[item++] = new TestCase( SECTION, "Number(03)", 3, Number("03")); + array[item++] = new TestCase( SECTION, "Number(04)", 4, Number("04")); + array[item++] = new TestCase( SECTION, "Number(05)", 5, Number("05")); + array[item++] = new TestCase( SECTION, "Number(06)", 6, Number("06")); + array[item++] = new TestCase( SECTION, "Number(07)", 7, Number("07")); + array[item++] = new TestCase( SECTION, "Number(010)", 10, Number("010")); + array[item++] = new TestCase( SECTION, "Number(011)", 11, Number("011")); + + // A StringNumericLIteral may have any number of leading 0 digits + + array[item++] = new TestCase( SECTION, "Number(001)", 1, Number("001")); + array[item++] = new TestCase( SECTION, "Number(0001)", 1, Number("0001")); + + return ( array ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.3.1-3.js b/tests/mozilla/ecma/TypeConversion/9.3.1-3.js new file mode 100644 index 0000000..69407fb --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.3.1-3.js @@ -0,0 +1,726 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.3.1-3.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + + Test cases provided by waldemar. + + + Author: christine@netscape.com + Date: 10 june 1998 + +*/ + +var SECTION = "9.3.1-3"; +var VERSION = "ECMA_1"; + startTest(); +var BUGNUMBER="129087"; + +var TITLE = "Number To String, String To Number"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcases = new Array(); + + +// test case from http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312954 +var z = 0; + +testcases[tc++] = new TestCase( + SECTION, + "var z = 0; print(1/-z)", + -Infinity, + 1/-z ); + + + + + +// test cases from bug http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122882 + + + +testcases[tc++] = new TestCase( SECTION, + '- -"0x80000000"', + 2147483648, + - -"0x80000000" ); + +testcases[tc++] = new TestCase( SECTION, + '- -"0x100000000"', + 4294967296, + - -"0x100000000" ); + +testcases[tc++] = new TestCase( SECTION, + '- "-0x123456789abcde8"', + 81985529216486880, + - "-0x123456789abcde8" ); + +// Convert some large numbers to string + + +testcases[tc++] = new TestCase( SECTION, + "1e2000 +''", + "Infinity", + 1e2000 +"" ); + +testcases[tc++] = new TestCase( SECTION, + "1e2000", + Infinity, + 1e2000 ); + +testcases[tc++] = new TestCase( SECTION, + "-1e2000 +''", + "-Infinity", + -1e2000 +"" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"1e2000\"", + -Infinity, + -"1e2000" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-1e2000\" +''", + "Infinity", + -"-1e2000" +"" ); + +testcases[tc++] = new TestCase( SECTION, + "1e-2000", + 0, + 1e-2000 ); + +testcases[tc++] = new TestCase( SECTION, + "1/1e-2000", + Infinity, + 1/1e-2000 ); + +// convert some strings to large numbers + +testcases[tc++] = new TestCase( SECTION, + "1/-1e-2000", + -Infinity, + 1/-1e-2000 ); + +testcases[tc++] = new TestCase( SECTION, + "1/\"1e-2000\"", + Infinity, + 1/"1e-2000" ); + +testcases[tc++] = new TestCase( SECTION, + "1/\"-1e-2000\"", + -Infinity, + 1/"-1e-2000" ); + +testcases[tc++] = new TestCase( SECTION, + "parseFloat(\"1e2000\")", + Infinity, + parseFloat("1e2000") ); + +testcases[tc++] = new TestCase( SECTION, + "parseFloat(\"1e-2000\")", + 0, + parseFloat("1e-2000") ); + +testcases[tc++] = new TestCase( SECTION, + "1.7976931348623157E+308", + 1.7976931348623157e+308, + 1.7976931348623157E+308 ); + +testcases[tc++] = new TestCase( SECTION, + "1.7976931348623158e+308", + 1.7976931348623157e+308, + 1.7976931348623158e+308 ); + +testcases[tc++] = new TestCase( SECTION, + "1.7976931348623159e+308", + Infinity, + 1.7976931348623159e+308 ); + +s = +"17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068"; + +testcases[tc++] = new TestCase( SECTION, + "s = " + s +"; s +="+ +"\"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779\""+ + ++"; s", +"17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779", +s += +"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779" +); + +s1 = s+1; + +testcases[tc++] = new TestCase( SECTION, +"s1 = s+1; s1", +"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791", +s1 ); + +/***** This answer is preferred but -Infinity is also acceptable here *****/ + +testcases[tc++] = new TestCase( SECTION, +"-s1 == Infinity || s1 == 1.7976931348623157e+308", +true, +-s1 == Infinity || s1 == 1.7976931348623157e+308 ); + +s2 = s + 2; + +testcases[tc++] = new TestCase( SECTION, +"s2 = s+2; s2", +"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792", +s2 ); + +// ***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here ***** +testcases[tc++] = new TestCase( SECTION, +"-s2 == -Infinity || -s2 == -1.7976931348623157e+308 ", +true, +-s2 == -Infinity || -s2 == -1.7976931348623157e+308 ); + +s3 = s+3; + +testcases[tc++] = new TestCase( SECTION, +"s3 = s+3; s3", +"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497793", +s3 ); + +//***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here ***** + +testcases[tc++] = new TestCase( SECTION, +"-s3 == -Infinity || -s3 == -1.7976931348623157e+308", +true, +-s3 == -Infinity || -s3 == -1.7976931348623157e+308 ); + + +//***** This answer is preferred but Infinity is also acceptable here ***** + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity", +true, +parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity ); + +//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here ***** +testcases[tc++] = new TestCase( SECTION, +"parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308", +true , +parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308 ); + +//***** This answer is preferred but Infinity is also acceptable here ***** + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity", +true, +parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity); + +//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here ***** +testcases[tc++] = new TestCase( SECTION, +"parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308", +true, +parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308 ); + +testcases[tc++] = new TestCase( SECTION, + "0x12345678", + 305419896, + 0x12345678 ); + +testcases[tc++] = new TestCase( SECTION, + "0x80000000", + 2147483648, + 0x80000000 ); + +testcases[tc++] = new TestCase( SECTION, + "0xffffffff", + 4294967295, + 0xffffffff ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000", + 4294967296, + 0x100000000 ); + +testcases[tc++] = new TestCase( SECTION, + "077777777777777777", + 2251799813685247, + 077777777777777777 ); + +testcases[tc++] = new TestCase( SECTION, + "077777777777777776", + 2251799813685246, + 077777777777777776 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1fffffffffffff", + 9007199254740991, + 0x1fffffffffffff ); + +testcases[tc++] = new TestCase( SECTION, + "0x20000000000000", + 9007199254740992, + 0x20000000000000 ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abc", + 9027215253084860, + 0x20123456789abc ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abd", + 9027215253084860, + 0x20123456789abd ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abe", + 9027215253084862, + 0x20123456789abe ); + +testcases[tc++] = new TestCase( SECTION, + "0x20123456789abf", + 9027215253084864, + 0x20123456789abf ); + +/***** These test the round-to-nearest-or-even-if-equally-close rule *****/ + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000080", + 1152921504606847000, + 0x1000000000000080 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000081", + 1152921504606847200, + 0x1000000000000081 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000100", + 1152921504606847200, + 0x1000000000000100 ); +testcases[tc++] = new TestCase( SECTION, + "0x100000000000017f", + 1152921504606847200, + 0x100000000000017f ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000180", + 1152921504606847500, + 0x1000000000000180 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000181", + 1152921504606847500, + 0x1000000000000181 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000001f0", + 1152921504606847500, + 0x10000000000001f0 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000200", + 1152921504606847500, + 0x1000000000000200 ); + +testcases[tc++] = new TestCase( SECTION, + "0x100000000000027f", + 1152921504606847500, + 0x100000000000027f ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000280", + 1152921504606847500, + 0x1000000000000280 ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000281", + 1152921504606847700, + 0x1000000000000281 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000002ff", + 1152921504606847700, + 0x10000000000002ff ); + +testcases[tc++] = new TestCase( SECTION, + "0x1000000000000300", + 1152921504606847700, + 0x1000000000000300 ); + +testcases[tc++] = new TestCase( SECTION, + "0x10000000000000000", + 18446744073709552000, + 0x10000000000000000 ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"000000100000000100100011010001010110011110001001101010111100\",2)", +9027215253084860, +parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"000000100000000100100011010001010110011110001001101010111101\",2)", +9027215253084860, +parseInt("000000100000000100100011010001010110011110001001101010111101",2) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"000000100000000100100011010001010110011110001001101010111111\",2)", +9027215253084864, +parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"0000001000000001001000110100010101100111100010011010101111010\",2)", +18054430506169720, +parseInt("0000001000000001001000110100010101100111100010011010101111010",2)); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"0000001000000001001000110100010101100111100010011010101111011\",2)", +18054430506169724, +parseInt("0000001000000001001000110100010101100111100010011010101111011",2) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"0000001000000001001000110100010101100111100010011010101111100\",2)", +18054430506169724, +parseInt("0000001000000001001000110100010101100111100010011010101111100",2)); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(\"0000001000000001001000110100010101100111100010011010101111110\",2)", +18054430506169728, +parseInt("0000001000000001001000110100010101100111100010011010101111110",2)); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"yz\",35)", + 34, + parseInt("yz",35) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"yz\",36)", + 1259, + parseInt("yz",36) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"yz\",37)", + NaN, + parseInt("yz",37) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"+77\")", + 77, + parseInt("+77") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"-77\",9)", + -70, + parseInt("-77",9) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"\\u20001234\\u2000\")", + 1234, + parseInt("\u20001234\u2000") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"123456789012345678\")", + 123456789012345680, + parseInt("123456789012345678") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"9\",8)", + NaN, + parseInt("9",8) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"1e2\")", + 1, + parseInt("1e2") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"1.9999999999999999999\")", + 1, + parseInt("1.9999999999999999999") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0x10\")", + 16, + parseInt("0x10") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0x10\",10)", + 0, + parseInt("0x10",10) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0022\")", + 18, + parseInt("0022") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0022\",10)", + 22, + parseInt("0022",10) ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0x1000000000000080\")", + 1152921504606847000, + parseInt("0x1000000000000080") ); + +testcases[tc++] = new TestCase( SECTION, + "parseInt(\"0x1000000000000081\")", + 1152921504606847200, + parseInt("0x1000000000000081") ); + +s = +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, "s = "+ +"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ +"s", +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s ); + + +testcases[tc++] = new TestCase( SECTION, "s +="+ +"\"0000000000000000000000000000000000000\"; s", +"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s += "0000000000000000000000000000000000000" ); + +testcases[tc++] = new TestCase( SECTION, "-s", +-1.7976931348623157e+308, +-s ); + +s = +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, "s ="+ +"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ +"s", +"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s ); + +testcases[tc++] = new TestCase( SECTION, +"s += \"0000000000000000000000000000000000001\"", +"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", +s += "0000000000000000000000000000000000001" ); + +testcases[tc++] = new TestCase( SECTION, +"-s", +-1.7976931348623157e+308, +-s ); + +s = +"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, +"s ="+ +"\"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ +"s", +"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s ); + + +testcases[tc++] = new TestCase( SECTION, +"s += \"0000000000000000000000000000000000000\"", +"0xFFFFFFFFFFFFFC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s += "0000000000000000000000000000000000000"); + + +testcases[tc++] = new TestCase( SECTION, +"-s", +-Infinity, +-s ); + +s = +"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +testcases[tc++] = new TestCase( SECTION, +"s = "+ +"\"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";s", +"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", +s); + +testcases[tc++] = new TestCase( SECTION, +"s += \"0000000000000000000000000000000000001\"", +"0xFFFFFFFFFFFFFB00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", +s += "0000000000000000000000000000000000001" ); + +testcases[tc++] = new TestCase( SECTION, +"-s", +-1.7976931348623157e+308, +-s ); + +testcases[tc++] = new TestCase( SECTION, +"s += \"0\"", +"0xFFFFFFFFFFFFFB000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010", +s += "0" ); + +testcases[tc++] = new TestCase( SECTION, +"-s", +-Infinity, +-s ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s)", +Infinity, +parseInt(s) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s,32)", +0, +parseInt(s,32) ); + +testcases[tc++] = new TestCase( SECTION, +"parseInt(s,36)", +Infinity, +parseInt(s,36) ); + +testcases[tc++] = new TestCase( SECTION, + "-\"\"", + 0, + -"" ); + +testcases[tc++] = new TestCase( SECTION, + "-\" \"", + 0, + -" " ); + +testcases[tc++] = new TestCase( SECTION, + "-\"999\"", + -999, + -"999" ); + +testcases[tc++] = new TestCase( SECTION, + "-\" 999\"", + -999, + -" 999" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"\\t999\"", + -999, + -"\t999" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"013 \"", + -13, + -"013 " ); + +testcases[tc++] = new TestCase( SECTION, + "-\"999\\t\"", + -999, + -"999\t" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-Infinity\"", + Infinity, + -"-Infinity" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-infinity\"", + NaN, + -"-infinity" ); + + +testcases[tc++] = new TestCase( SECTION, + "-\"+Infinity\"", + -Infinity, + -"+Infinity" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"+Infiniti\"", + NaN, + -"+Infiniti" ); + +testcases[tc++] = new TestCase( SECTION, + "- -\"0x80000000\"", + 2147483648, + - -"0x80000000" ); + +testcases[tc++] = new TestCase( SECTION, + "- -\"0x100000000\"", + 4294967296, + - -"0x100000000" ); + +testcases[tc++] = new TestCase( SECTION, + "- \"-0x123456789abcde8\"", + 81985529216486880, + - "-0x123456789abcde8" ); + +// the following two tests are not strictly ECMA 1.0 + +testcases[tc++] = new TestCase( SECTION, + "-\"\\u20001234\\u2001\"", + -1234, + -"\u20001234\u2001" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"\\u20001234\\0\"", + NaN, + -"\u20001234\0" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"0x10\"", + -16, + -"0x10" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"+\"", + NaN, + -"+" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-\"", + NaN, + -"-" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"-0-\"", + NaN, + -"-0-" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"1e-\"", + NaN, + -"1e-" ); + +testcases[tc++] = new TestCase( SECTION, + "-\"1e-1\"", + -0.1, + -"1e-1" ); + +test(); + +function test(){ + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.3.js b/tests/mozilla/ecma/TypeConversion/9.3.js new file mode 100644 index 0000000..4645692 --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.3.js @@ -0,0 +1,89 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.3.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + For ToNumber applied to the String type, see test 9.3.1. + For ToNumber applied to the object type, see test 9.3-1. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.3"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToNumber"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // special cases here + + array[item++] = new TestCase( SECTION, "Number()", 0, Number() ); + array[item++] = new TestCase( SECTION, "Number(eval('var x'))", Number.NaN, Number(eval("var x")) ); + array[item++] = new TestCase( SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); + array[item++] = new TestCase( SECTION, "Number(null)", 0, Number(null) ); + array[item++] = new TestCase( SECTION, "Number(true)", 1, Number(true) ); + array[item++] = new TestCase( SECTION, "Number(false)", 0, Number(false) ); + array[item++] = new TestCase( SECTION, "Number(0)", 0, Number(0) ); + array[item++] = new TestCase( SECTION, "Number(-0)", -0, Number(-0) ); + array[item++] = new TestCase( SECTION, "Number(1)", 1, Number(1) ); + array[item++] = new TestCase( SECTION, "Number(-1)", -1, Number(-1) ); + array[item++] = new TestCase( SECTION, "Number(Number.MAX_VALUE)", 1.7976931348623157e308, Number(Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "Number(Number.MIN_VALUE)", 5e-324, Number(Number.MIN_VALUE) ); + + array[item++] = new TestCase( SECTION, "Number(Number.NaN)", Number.NaN, Number(Number.NaN) ); + array[item++] = new TestCase( SECTION, "Number(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, Number(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "Number(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, Number(Number.NEGATIVE_INFINITY) ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.4-1.js b/tests/mozilla/ecma/TypeConversion/9.4-1.js new file mode 100644 index 0000000..4dd331d --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.4-1.js @@ -0,0 +1,120 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.4-1.js + ECMA Section: 9.4 ToInteger + Description: 1. Call ToNumber on the input argument + 2. If Result(1) is NaN, return +0 + 3. If Result(1) is +0, -0, Infinity, or -Infinity, + return Result(1). + 4. Compute sign(Result(1)) * floor(abs(Result(1))). + 5. Return Result(4). + + To test ToInteger, this test uses new Date(value), + 15.9.3.7. The Date constructor sets the [[Value]] + property of the new object to TimeClip(value), which + uses the rules: + + TimeClip(time) + 1. If time is not finite, return NaN + 2. If abs(Result(1)) > 8.64e15, return NaN + 3. Return an implementation dependent choice of either + ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) + (Adding a positive 0 converts -0 to +0). + + This tests ToInteger for values -8.64e15 > value > 8.64e15, + not including -0 and +0. + + For additional special cases (0, +0, Infinity, -Infinity, + and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToInteger"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // some special cases + + array[item++] = new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); + array[item++] = new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); + + // value is not an integer + + array[item++] = new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); + + array[item++] = new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); + + // value is not a number + + array[item++] = new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); + array[item++] = new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); + + array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + + // edge cases + array[item++] = new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.4-2.js b/tests/mozilla/ecma/TypeConversion/9.4-2.js new file mode 100644 index 0000000..4dd331d --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.4-2.js @@ -0,0 +1,120 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.4-1.js + ECMA Section: 9.4 ToInteger + Description: 1. Call ToNumber on the input argument + 2. If Result(1) is NaN, return +0 + 3. If Result(1) is +0, -0, Infinity, or -Infinity, + return Result(1). + 4. Compute sign(Result(1)) * floor(abs(Result(1))). + 5. Return Result(4). + + To test ToInteger, this test uses new Date(value), + 15.9.3.7. The Date constructor sets the [[Value]] + property of the new object to TimeClip(value), which + uses the rules: + + TimeClip(time) + 1. If time is not finite, return NaN + 2. If abs(Result(1)) > 8.64e15, return NaN + 3. Return an implementation dependent choice of either + ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) + (Adding a positive 0 converts -0 to +0). + + This tests ToInteger for values -8.64e15 > value > 8.64e15, + not including -0 and +0. + + For additional special cases (0, +0, Infinity, -Infinity, + and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + var SECTION = "9.4-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "ToInteger"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + // some special cases + + array[item++] = new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); + array[item++] = new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); + + // value is not an integer + + array[item++] = new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); + + array[item++] = new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); + + // value is not a number + + array[item++] = new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); + array[item++] = new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); + + array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + + // edge cases + array[item++] = new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); + array[item++] = new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.5-2.js b/tests/mozilla/ecma/TypeConversion/9.5-2.js new file mode 100644 index 0000000..598cce7 --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.5-2.js @@ -0,0 +1,171 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.5-2.js + ECMA Section: 9.5 Type Conversion: ToInt32 + Description: rules for converting an argument to a signed 32 bit integer + + this test uses << 0 to convert the argument to a 32bit + integer. + + The operator ToInt32 converts its argument to one of 2^32 + integer values in the range -2^31 through 2^31 inclusive. + This operator functions as follows: + + 1 call ToNumber on argument + 2 if result is NaN, 0, -0, return 0 + 3 compute (sign (result(1)) * floor(abs(result 1))) + 4 compute result(3) modulo 2^32: + 5 if result(4) is greater than or equal to 2^31, return + result(5)-2^32. otherwise, return result(5) + + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + ToInt32(ToUint32(x)) == ToInt32(x) for all values of x + Numbers greater than 2^31 (see step 5 above) + (note http://bugzilla.mozilla.org/show_bug.cgi?id=120083) + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + var SECTION = "9.5-2"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " ToInt32"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + if ( sign == -1 ) { + n = ( n < -Math.pow(2,31) ) ? n + Math.pow(2,32) : n; + } else{ + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + } + + return ( n ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "0 << 0", 0, 0 << 0 ); + array[item++] = new TestCase( SECTION, "-0 << 0", 0, -0 << 0 ); + array[item++] = new TestCase( SECTION, "Infinity << 0", 0, "Infinity" << 0 ); + array[item++] = new TestCase( SECTION, "-Infinity << 0", 0, "-Infinity" << 0 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY << 0", 0, Number.POSITIVE_INFINITY << 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY << 0", 0, Number.NEGATIVE_INFINITY << 0 ); + array[item++] = new TestCase( SECTION, "Number.NaN << 0", 0, Number.NaN << 0 ); + + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE << 0", 0, Number.MIN_VALUE << 0 ); + array[item++] = new TestCase( SECTION, "-Number.MIN_VALUE << 0", 0, -Number.MIN_VALUE << 0 ); + array[item++] = new TestCase( SECTION, "0.1 << 0", 0, 0.1 << 0 ); + array[item++] = new TestCase( SECTION, "-0.1 << 0", 0, -0.1 << 0 ); + array[item++] = new TestCase( SECTION, "1 << 0", 1, 1 << 0 ); + array[item++] = new TestCase( SECTION, "1.1 << 0", 1, 1.1 << 0 ); + array[item++] = new TestCase( SECTION, "-1 << 0", ToInt32(-1), -1 << 0 ); + + + array[item++] = new TestCase( SECTION, "2147483647 << 0", ToInt32(2147483647), 2147483647 << 0 ); + array[item++] = new TestCase( SECTION, "2147483648 << 0", ToInt32(2147483648), 2147483648 << 0 ); + array[item++] = new TestCase( SECTION, "2147483649 << 0", ToInt32(2147483649), 2147483649 << 0 ); + + array[item++] = new TestCase( SECTION, "(Math.pow(2,31)-1) << 0", ToInt32(2147483647), (Math.pow(2,31)-1) << 0 ); + array[item++] = new TestCase( SECTION, "Math.pow(2,31) << 0", ToInt32(2147483648), Math.pow(2,31) << 0 ); + array[item++] = new TestCase( SECTION, "(Math.pow(2,31)+1) << 0", ToInt32(2147483649), (Math.pow(2,31)+1) << 0 ); + + array[item++] = new TestCase( SECTION, "(Math.pow(2,32)-1) << 0", ToInt32(4294967295), (Math.pow(2,32)-1) << 0 ); + array[item++] = new TestCase( SECTION, "(Math.pow(2,32)) << 0", ToInt32(4294967296), (Math.pow(2,32)) << 0 ); + array[item++] = new TestCase( SECTION, "(Math.pow(2,32)+1) << 0", ToInt32(4294967297), (Math.pow(2,32)+1) << 0 ); + + array[item++] = new TestCase( SECTION, "4294967295 << 0", ToInt32(4294967295), 4294967295 << 0 ); + array[item++] = new TestCase( SECTION, "4294967296 << 0", ToInt32(4294967296), 4294967296 << 0 ); + array[item++] = new TestCase( SECTION, "4294967297 << 0", ToInt32(4294967297), 4294967297 << 0 ); + + array[item++] = new TestCase( SECTION, "'2147483647' << 0", ToInt32(2147483647), '2147483647' << 0 ); + array[item++] = new TestCase( SECTION, "'2147483648' << 0", ToInt32(2147483648), '2147483648' << 0 ); + array[item++] = new TestCase( SECTION, "'2147483649' << 0", ToInt32(2147483649), '2147483649' << 0 ); + + array[item++] = new TestCase( SECTION, "'4294967295' << 0", ToInt32(4294967295), '4294967295' << 0 ); + array[item++] = new TestCase( SECTION, "'4294967296' << 0", ToInt32(4294967296), '4294967296' << 0 ); + array[item++] = new TestCase( SECTION, "'4294967297' << 0", ToInt32(4294967297), '4294967297' << 0 ); + + array[item++] = new TestCase( SECTION, "-2147483647 << 0", ToInt32(-2147483647), -2147483647 << 0 ); + array[item++] = new TestCase( SECTION, "-2147483648 << 0", ToInt32(-2147483648), -2147483648 << 0 ); + array[item++] = new TestCase( SECTION, "-2147483649 << 0", ToInt32(-2147483649), -2147483649 << 0 ); + + array[item++] = new TestCase( SECTION, "-4294967295 << 0", ToInt32(-4294967295), -4294967295 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967296 << 0", ToInt32(-4294967296), -4294967296 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967297 << 0", ToInt32(-4294967297), -4294967297 << 0 ); + + /* + * Numbers between 2^31 and 2^32 will have a negative ToInt32 per ECMA (see step 5 of introduction) + * (These are by stevechapel@earthlink.net; cf. http://bugzilla.mozilla.org/show_bug.cgi?id=120083) + */ + array[item++] = new TestCase( SECTION, "2147483648.25 << 0", ToInt32(2147483648.25), 2147483648.25 << 0 ); + array[item++] = new TestCase( SECTION, "2147483648.5 << 0", ToInt32(2147483648.5), 2147483648.5 << 0 ); + array[item++] = new TestCase( SECTION, "2147483648.75 << 0", ToInt32(2147483648.75), 2147483648.75 << 0 ); + array[item++] = new TestCase( SECTION, "4294967295.25 << 0", ToInt32(4294967295.25), 4294967295.25 << 0 ); + array[item++] = new TestCase( SECTION, "4294967295.5 << 0", ToInt32(4294967295.5), 4294967295.5 << 0 ); + array[item++] = new TestCase( SECTION, "4294967295.75 << 0", ToInt32(4294967295.75), 4294967295.75 << 0 ); + array[item++] = new TestCase( SECTION, "3000000000.25 << 0", ToInt32(3000000000.25), 3000000000.25 << 0 ); + array[item++] = new TestCase( SECTION, "3000000000.5 << 0", ToInt32(3000000000.5), 3000000000.5 << 0 ); + array[item++] = new TestCase( SECTION, "3000000000.75 << 0", ToInt32(3000000000.75), 3000000000.75 << 0 ); + + /* + * Numbers between - 2^31 and - 2^32 + */ + array[item++] = new TestCase( SECTION, "-2147483648.25 << 0", ToInt32(-2147483648.25), -2147483648.25 << 0 ); + array[item++] = new TestCase( SECTION, "-2147483648.5 << 0", ToInt32(-2147483648.5), -2147483648.5 << 0 ); + array[item++] = new TestCase( SECTION, "-2147483648.75 << 0", ToInt32(-2147483648.75), -2147483648.75 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967295.25 << 0", ToInt32(-4294967295.25), -4294967295.25 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967295.5 << 0", ToInt32(-4294967295.5), -4294967295.5 << 0 ); + array[item++] = new TestCase( SECTION, "-4294967295.75 << 0", ToInt32(-4294967295.75), -4294967295.75 << 0 ); + array[item++] = new TestCase( SECTION, "-3000000000.25 << 0", ToInt32(-3000000000.25), -3000000000.25 << 0 ); + array[item++] = new TestCase( SECTION, "-3000000000.5 << 0", ToInt32(-3000000000.5), -3000000000.5 << 0 ); + array[item++] = new TestCase( SECTION, "-3000000000.75 << 0", ToInt32(-3000000000.75), -3000000000.75 << 0 ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.6.js b/tests/mozilla/ecma/TypeConversion/9.6.js new file mode 100644 index 0000000..c4c3bff --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.6.js @@ -0,0 +1,139 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.6.js + ECMA Section: 9.6 Type Conversion: ToUint32 + Description: rules for converting an argument to an unsigned + 32 bit integer + + this test uses >>> 0 to convert the argument to + an unsigned 32bit integer. + + 1 call ToNumber on argument + 2 if result is NaN, 0, -0, Infinity, -Infinity + return 0 + 3 compute (sign (result(1)) * floor(abs(result 1))) + 4 compute result(3) modulo 2^32: + 5 return result(4) + + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + 0 returns 0 + ToInt32(ToUint32(x)) == ToInt32(x) for all values of x + ** NEED TO DO THIS PART IN A SEPARATE TEST FILE ** + + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + + var SECTION = "9.6"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Type Conversion: ToUint32"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "0 >>> 0", 0, 0 >>> 0 ); +// array[item++] = new TestCase( SECTION, "+0 >>> 0", 0, +0 >>> 0); + array[item++] = new TestCase( SECTION, "-0 >>> 0", 0, -0 >>> 0 ); + array[item++] = new TestCase( SECTION, "'Infinity' >>> 0", 0, "Infinity" >>> 0 ); + array[item++] = new TestCase( SECTION, "'-Infinity' >>> 0", 0, "-Infinity" >>> 0); + array[item++] = new TestCase( SECTION, "'+Infinity' >>> 0", 0, "+Infinity" >>> 0 ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY >>> 0", 0, Number.POSITIVE_INFINITY >>> 0 ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY >>> 0", 0, Number.NEGATIVE_INFINITY >>> 0 ); + array[item++] = new TestCase( SECTION, "Number.NaN >>> 0", 0, Number.NaN >>> 0 ); + + array[item++] = new TestCase( SECTION, "Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); + array[item++] = new TestCase( SECTION, "-Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); + array[item++] = new TestCase( SECTION, "0.1 >>> 0", 0, 0.1 >>> 0 ); + array[item++] = new TestCase( SECTION, "-0.1 >>> 0", 0, -0.1 >>> 0 ); + array[item++] = new TestCase( SECTION, "1 >>> 0", 1, 1 >>> 0 ); + array[item++] = new TestCase( SECTION, "1.1 >>> 0", 1, 1.1 >>> 0 ); + + array[item++] = new TestCase( SECTION, "-1.1 >>> 0", ToUint32(-1.1), -1.1 >>> 0 ); + array[item++] = new TestCase( SECTION, "-1 >>> 0", ToUint32(-1), -1 >>> 0 ); + + array[item++] = new TestCase( SECTION, "2147483647 >>> 0", ToUint32(2147483647), 2147483647 >>> 0 ); + array[item++] = new TestCase( SECTION, "2147483648 >>> 0", ToUint32(2147483648), 2147483648 >>> 0 ); + array[item++] = new TestCase( SECTION, "2147483649 >>> 0", ToUint32(2147483649), 2147483649 >>> 0 ); + + array[item++] = new TestCase( SECTION, "4294967295 >>> 0", ToUint32(4294967295), 4294967295 >>> 0 ); + array[item++] = new TestCase( SECTION, "4294967296 >>> 0", ToUint32(4294967296), 4294967296 >>> 0 ); + array[item++] = new TestCase( SECTION, "4294967297 >>> 0", ToUint32(4294967297), 4294967297 >>> 0 ); + + array[item++] = new TestCase( SECTION, "-2147483647 >>> 0", ToUint32(-2147483647), -2147483647 >>> 0 ); + array[item++] = new TestCase( SECTION, "-2147483648 >>> 0", ToUint32(-2147483648), -2147483648 >>> 0 ); + array[item++] = new TestCase( SECTION, "-2147483649 >>> 0", ToUint32(-2147483649), -2147483649 >>> 0 ); + + array[item++] = new TestCase( SECTION, "-4294967295 >>> 0", ToUint32(-4294967295), -4294967295 >>> 0 ); + array[item++] = new TestCase( SECTION, "-4294967296 >>> 0", ToUint32(-4294967296), -4294967296 >>> 0 ); + array[item++] = new TestCase( SECTION, "-4294967297 >>> 0", ToUint32(-4294967297), -4294967297 >>> 0 ); + + array[item++] = new TestCase( SECTION, "'2147483647' >>> 0", ToUint32(2147483647), '2147483647' >>> 0 ); + array[item++] = new TestCase( SECTION, "'2147483648' >>> 0", ToUint32(2147483648), '2147483648' >>> 0 ); + array[item++] = new TestCase( SECTION, "'2147483649' >>> 0", ToUint32(2147483649), '2147483649' >>> 0 ); + + array[item++] = new TestCase( SECTION, "'4294967295' >>> 0", ToUint32(4294967295), '4294967295' >>> 0 ); + array[item++] = new TestCase( SECTION, "'4294967296' >>> 0", ToUint32(4294967296), '4294967296' >>> 0 ); + array[item++] = new TestCase( SECTION, "'4294967297' >>> 0", ToUint32(4294967297), '4294967297' >>> 0 ); + + return ( array ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.7.js b/tests/mozilla/ecma/TypeConversion/9.7.js new file mode 100644 index 0000000..60322d4 --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.7.js @@ -0,0 +1,158 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.7.js + ECMA Section: 9.7 Type Conversion: ToInt16 + Description: rules for converting an argument to an unsigned + 16 bit integer in the range 0 to 2^16-1. + + this test uses String.prototype.fromCharCode() and + String.prototype.charCodeAt() to test ToInt16. + + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + 0 returns 0 + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + var SECTION = "9.7"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Type Conversion: ToInt16"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function ToInt16( num ) { + num = Number( num ); + if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( num < 0 ) ? -1 : 1; + + num = sign * Math.floor( Math.abs( num ) ); + + num = num % Math.pow(2,16); + + num = ( num > -65536 && num < 0) ? 65536 + num : num; + + return num; +} + +function getTestCases() { + var array = new Array(); + var item = 0; +/* + array[item++] = new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", 0, String.fromCharCode(0).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", 0, String.fromCharCode(-0).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", 1, String.fromCharCode(1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", 64, String.fromCharCode(64).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", 126, String.fromCharCode(126).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", 127, String.fromCharCode(127).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", 128, String.fromCharCode(128).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", 130, String.fromCharCode(130).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", 255, String.fromCharCode(255).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", 256, String.fromCharCode(256).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); +*/ + + + array[item++] = new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", ToInt16(0), String.fromCharCode(0).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", ToInt16(0), String.fromCharCode(-0).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", ToInt16(1), String.fromCharCode(1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", ToInt16(64), String.fromCharCode(64).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", ToInt16(126), String.fromCharCode(126).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", ToInt16(127), String.fromCharCode(127).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", ToInt16(128), String.fromCharCode(128).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", ToInt16(130), String.fromCharCode(130).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", ToInt16(255), String.fromCharCode(255).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", ToInt16(256), String.fromCharCode(256).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(65535).charCodeAt(0)", ToInt16(65535), String.fromCharCode(65535).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(65536).charCodeAt(0)", ToInt16(65536), String.fromCharCode(65536).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(65537).charCodeAt(0)", ToInt16(65537), String.fromCharCode(65537).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(131071).charCodeAt(0)", ToInt16(131071), String.fromCharCode(131071).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(131072).charCodeAt(0)", ToInt16(131072), String.fromCharCode(131072).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(131073).charCodeAt(0)", ToInt16(131073), String.fromCharCode(131073).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode('65535').charCodeAt(0)", 65535, String.fromCharCode("65535").charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode('65536').charCodeAt(0)", 0, String.fromCharCode("65536").charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(-1).charCodeAt(0)", ToInt16(-1), String.fromCharCode(-1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-64).charCodeAt(0)", ToInt16(-64), String.fromCharCode(-64).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-126).charCodeAt(0)", ToInt16(-126), String.fromCharCode(-126).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-127).charCodeAt(0)", ToInt16(-127), String.fromCharCode(-127).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-128).charCodeAt(0)", ToInt16(-128), String.fromCharCode(-128).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-130).charCodeAt(0)", ToInt16(-130), String.fromCharCode(-130).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-255).charCodeAt(0)", ToInt16(-255), String.fromCharCode(-255).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-256).charCodeAt(0)", ToInt16(-256), String.fromCharCode(-256).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(-Math.pow(2,16)).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(-65535).charCodeAt(0)", ToInt16(-65535), String.fromCharCode(-65535).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-65536).charCodeAt(0)", ToInt16(-65536), String.fromCharCode(-65536).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-65537).charCodeAt(0)", ToInt16(-65537), String.fromCharCode(-65537).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode(-131071).charCodeAt(0)", ToInt16(-131071), String.fromCharCode(-131071).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-131072).charCodeAt(0)", ToInt16(-131072), String.fromCharCode(-131072).charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode(-131073).charCodeAt(0)", ToInt16(-131073), String.fromCharCode(-131073).charCodeAt(0) ); + + array[item++] = new TestCase( "9.7", "String.fromCharCode('-65535').charCodeAt(0)", ToInt16(-65535), String.fromCharCode("-65535").charCodeAt(0) ); + array[item++] = new TestCase( "9.7", "String.fromCharCode('-65536').charCodeAt(0)", ToInt16(-65536), String.fromCharCode("-65536").charCodeAt(0) ); + + +// array[item++] = new TestCase( "9.7", "String.fromCharCode(2147483648).charCodeAt(0)", ToInt16(2147483648), String.fromCharCode(2147483648).charCodeAt(0) ); + + + +// the following test cases cause a runtime error. see: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=78878 + +// array[item++] = new TestCase( "9.7", "String.fromCharCode(Infinity).charCodeAt(0)", 0, String.fromCharCode("Infinity").charCodeAt(0) ); +// array[item++] = new TestCase( "9.7", "String.fromCharCode(-Infinity).charCodeAt(0)", 0, String.fromCharCode("-Infinity").charCodeAt(0) ); +// array[item++] = new TestCase( "9.7", "String.fromCharCode(NaN).charCodeAt(0)", 0, String.fromCharCode(Number.NaN).charCodeAt(0) ); +// array[item++] = new TestCase( "9.7", "String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) ); +// array[item++] = new TestCase( "9.7", "String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) ); + return ( array ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.8.1.js b/tests/mozilla/ecma/TypeConversion/9.8.1.js new file mode 100644 index 0000000..38cbb0a --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.8.1.js @@ -0,0 +1,166 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.8.1.js + ECMA Section: 9.8.1 ToString Applied to the Number Type + Description: The operator ToString convers a number m to string + as follows: + + 1. if m is NaN, return the string "NaN" + 2. if m is +0 or -0, return the string "0" + 3. if m is less than zero, return the string + concatenation of the string "-" and ToString(-m). + 4. If m is Infinity, return the string "Infinity". + 5. Otherwise, let n, k, and s be integers such that + k >= 1, 10k1 <= s < 10k, the number value for s10nk + is m, and k is as small as possible. Note that k is + the number of digits in the decimal representation + of s, that s is not divisible by 10, and that the + least significant digit of s is not necessarily + uniquely determined by these criteria. + 6. If k <= n <= 21, return the string consisting of the + k digits of the decimal representation of s (in order, + with no leading zeroes), followed by n-k occurences + of the character '0'. + 7. If 0 < n <= 21, return the string consisting of the + most significant n digits of the decimal + representation of s, followed by a decimal point + '.', followed by the remaining kn digits of the + decimal representation of s. + 8. If 6 < n <= 0, return the string consisting of the + character '0', followed by a decimal point '.', + followed by n occurences of the character '0', + followed by the k digits of the decimal + representation of s. + 9. Otherwise, if k = 1, return the string consisting + of the single digit of s, followed by lowercase + character 'e', followed by a plus sign '+' or minus + sign '' according to whether n1 is positive or + negative, followed by the decimal representation + of the integer abs(n1) (with no leading zeros). + 10. Return the string consisting of the most significant + digit of the decimal representation of s, followed + by a decimal point '.', followed by the remaining k1 + digits of the decimal representation of s, followed + by the lowercase character 'e', followed by a plus + sign '+' or minus sign '' according to whether n1 is + positive or negative, followed by the decimal + representation of the integer abs(n1) (with no + leading zeros). + + Note that if x is any number value other than 0, then + ToNumber(ToString(x)) is exactly the same number value as x. + + As noted, the least significant digit of s is not always + uniquely determined by the requirements listed in step 5. + The following specification for step 5 was considered, but + not adopted: + + Author: christine@netscape.com + Date: 10 july 1997 +*/ + + var SECTION = "9.8.1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " ToString applied to the Number type"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Number.NaN", "NaN", Number.NaN + "" ); + array[item++] = new TestCase( SECTION, "0", "0", 0 + "" ); + array[item++] = new TestCase( SECTION, "-0", "0", -0 + "" ); + array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY", "Infinity", Number.POSITIVE_INFINITY + "" ); + array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY", "-Infinity", Number.NEGATIVE_INFINITY + "" ); + array[item++] = new TestCase( SECTION, "-1", "-1", -1 + "" ); + + // cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 + + array[item++] = new TestCase( SECTION, "1", "1", 1 + "" ); + array[item++] = new TestCase( SECTION, "10", "10", 10 + "" ); + array[item++] = new TestCase( SECTION, "100", "100", 100 + "" ); + array[item++] = new TestCase( SECTION, "1000", "1000", 1000 + "" ); + array[item++] = new TestCase( SECTION, "10000", "10000", 10000 + "" ); + array[item++] = new TestCase( SECTION, "10000000000", "10000000000", 10000000000 + "" ); + array[item++] = new TestCase( SECTION, "10000000000000000000", "10000000000000000000", 10000000000000000000 + "" ); + array[item++] = new TestCase( SECTION, "100000000000000000000","100000000000000000000",100000000000000000000 + "" ); + + array[item++] = new TestCase( SECTION, "12345", "12345", 12345 + "" ); + array[item++] = new TestCase( SECTION, "1234567890", "1234567890", 1234567890 + "" ); + + array[item++] = new TestCase( SECTION, "-1", "-1", -1 + "" ); + array[item++] = new TestCase( SECTION, "-10", "-10", -10 + "" ); + array[item++] = new TestCase( SECTION, "-100", "-100", -100 + "" ); + array[item++] = new TestCase( SECTION, "-1000", "-1000", -1000 + "" ); + array[item++] = new TestCase( SECTION, "-1000000000", "-1000000000", -1000000000 + "" ); + array[item++] = new TestCase( SECTION, "-1000000000000000", "-1000000000000000", -1000000000000000 + "" ); + array[item++] = new TestCase( SECTION, "-100000000000000000000", "-100000000000000000000", -100000000000000000000 + "" ); + array[item++] = new TestCase( SECTION, "-1000000000000000000000", "-1e+21", -1000000000000000000000 + "" ); + + array[item++] = new TestCase( SECTION, "-12345", "-12345", -12345 + "" ); + array[item++] = new TestCase( SECTION, "-1234567890", "-1234567890", -1234567890 + "" ); + + // cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, + array[item++] = new TestCase( SECTION, "1.0000001", "1.0000001", 1.0000001 + "" ); + + // cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 + + // cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 + + array[item++] = new TestCase( SECTION, "1000000000000000000000", "1e+21", 1000000000000000000000 + "" ); + array[item++] = new TestCase( SECTION, "10000000000000000000000", "1e+22", 10000000000000000000000 + "" ); + + // cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 + + array[item++] = new TestCase( SECTION, "1.2345", "1.2345", String( 1.2345)); + array[item++] = new TestCase( SECTION, "1.234567890", "1.23456789", String( 1.234567890 )); + + + array[item++] = new TestCase( SECTION, ".12345", "0.12345", String(.12345 ) ); + array[item++] = new TestCase( SECTION, ".012345", "0.012345", String(.012345) ); + array[item++] = new TestCase( SECTION, ".0012345", "0.0012345", String(.0012345) ); + array[item++] = new TestCase( SECTION, ".00012345", "0.00012345", String(.00012345) ); + array[item++] = new TestCase( SECTION, ".000012345", "0.000012345", String(.000012345) ); + array[item++] = new TestCase( SECTION, ".0000012345", "0.0000012345", String(.0000012345) ); + array[item++] = new TestCase( SECTION, ".00000012345", "1.2345e-7", String(.00000012345)); + + array[item++] = new TestCase( SECTION, "-1e21", "-1e+21", String(-1e21) ); + return ( array ); +} diff --git a/tests/mozilla/ecma/TypeConversion/9.9-1.js b/tests/mozilla/ecma/TypeConversion/9.9-1.js new file mode 100644 index 0000000..0df39f3 --- /dev/null +++ b/tests/mozilla/ecma/TypeConversion/9.9-1.js @@ -0,0 +1,143 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 9.9-1.js + ECMA Section: 9.9 Type Conversion: ToObject + Description: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + Author: christine@netscape.com + Date: 17 july 1997 +*/ + + var VERSION = "ECMA_1"; + startTest(); + var SECTION = "9.9-1"; + + writeHeaderToLog( SECTION + " Type Conversion: ToObject" ); + var tc= 0; + var testcases = getTestCases(); + +// all tests must call a function that returns an array of TestCase objects. + test(); + +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); + array[item++] = new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); + array[item++] = new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); + array[item++] = new TestCase( SECTION, "(Object(0)).__proto__", Number.prototype, (Object(0)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); + array[item++] = new TestCase( SECTION, "(Object(-0)).__proto__", Number.prototype, (Object(-0)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); + array[item++] = new TestCase( SECTION, "(Object(1)).__proto__", Number.prototype, (Object(1)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); + array[item++] = new TestCase( SECTION, "(Object(-1)).__proto__", Number.prototype, (Object(-1)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); + array[item++] = new TestCase( SECTION, "(Object(Number.MAX_VALUE)).__proto__", Number.prototype, (Object(Number.MAX_VALUE)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); + array[item++] = new TestCase( SECTION, "(Object(Number.MIN_VALUE)).__proto__", Number.prototype, (Object(Number.MIN_VALUE)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "(Object(Number.POSITIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.POSITIVE_INFINITY)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); + array[item++] = new TestCase( SECTION, "(Object(Number.NEGATIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.NEGATIVE_INFINITY)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); + array[item++] = new TestCase( SECTION, "(Object(Number.NaN)).__proto__", Number.prototype, (Object(Number.NaN)).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); + array[item++] = new TestCase( SECTION, "(Object('a string')).__proto__", String.prototype, (Object("a string")).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); + array[item++] = new TestCase( SECTION, "(Object('')).__proto__", String.prototype, (Object("")).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); + array[item++] = new TestCase( SECTION, "(Object('\\r\\t\\b\\n\\v\\f')).__proto__", String.prototype, (Object("\\r\\t\\b\\n\\v\\f")).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); + array[item++] = new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); + array[item++] = new TestCase( SECTION, "Object( '\\\'\\\"\\' ).__proto__", String.prototype, (Object("\'\"\\")).__proto__ ); + + array[item++] = new TestCase( SECTION, "Object( new MyObject(true) ).valueOf()", true, eval("Object( new MyObject(true) ).valueOf()") ); + array[item++] = new TestCase( SECTION, "typeof Object( new MyObject(true) )", "object", eval("typeof Object( new MyObject(true) )") ); + array[item++] = new TestCase( SECTION, "(Object( new MyObject(true) )).toString()", "[object Object]", eval("(Object( new MyObject(true) )).toString()") ); + + return ( array ); +} + +function test() { + for ( tc = 0; tc < testcases.length; tc++ ) { + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += + ( testcases[tc].passed ) ? "" : "wrong value "; + + } + stopTest(); + + // all tests must return an array of TestCase objects + return ( testcases ); +} +function MyObject( value ) { + this.value = value; + this.valueOf = new Function ( "return this.value" ); +} \ No newline at end of file diff --git a/tests/mozilla/ecma/Types/8.1.js b/tests/mozilla/ecma/Types/8.1.js new file mode 100644 index 0000000..efc4792 --- /dev/null +++ b/tests/mozilla/ecma/Types/8.1.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 8.1.js + ECMA Section: The undefined type + Description: + + The Undefined type has exactly one value, called undefined. Any variable + that has not been assigned a value is of type Undefined. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "8.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The undefined type"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var x; typeof x", + "undefined", + eval("var x; typeof x") ); + + testcases[tc++] = new TestCase( SECTION, + "var x; typeof x == 'undefined", + true, + eval("var x; typeof x == 'undefined'") ); + + testcases[tc++] = new TestCase( SECTION, + "var x; x == void 0", + true, + eval("var x; x == void 0") ); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Types/8.4.js b/tests/mozilla/ecma/Types/8.4.js new file mode 100644 index 0000000..c18f744 --- /dev/null +++ b/tests/mozilla/ecma/Types/8.4.js @@ -0,0 +1,125 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 8.4.js + ECMA Section: The String type + Description: + + The String type is the set of all finite ordered sequences of zero or more + Unicode characters. Each character is regarded as occupying a position + within the sequence. These positions are identified by nonnegative + integers. The leftmost character (if any) is at position 0, the next + character (if any) at position 1, and so on. The length of a string is the + number of distinct positions within it. The empty string has length zero + and therefore contains no characters. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "8.4"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "The String type"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( SECTION, + "var s = ''; s.length", + 0, + eval("var s = ''; s.length") ); + + testcases[tc++] = new TestCase( SECTION, + "var s = ''; s.charAt(0)", + "", + eval("var s = ''; s.charAt(0)") ); + + + for ( var i = 0x0041, TEST_STRING = "", EXPECT_STRING = ""; i < 0x007B; i++ ) { + TEST_STRING += ("\\u"+ DecimalToHexString( i ) ); + EXPECT_STRING += String.fromCharCode(i); + } + + testcases[tc++] = new TestCase( SECTION, + "var s = '" + TEST_STRING+ "'; s", + EXPECT_STRING, + eval("var s = '" + TEST_STRING+ "'; s") ); + + testcases[tc++] = new TestCase( SECTION, + "var s = '" + TEST_STRING+ "'; s.length", + 0x007B-0x0041, + eval("var s = '" + TEST_STRING+ "'; s.length") ); + + test(); +function DecimalToHexString( n ) { + n = Number( n ); + var h = ""; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma/Types/8.6.2.1-1.js b/tests/mozilla/ecma/Types/8.6.2.1-1.js new file mode 100644 index 0000000..05b9400 --- /dev/null +++ b/tests/mozilla/ecma/Types/8.6.2.1-1.js @@ -0,0 +1,105 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 8.6.2.1-1.js + ECMA Section: 8.6.2.1 Get (Value) + Description: + + When the [[Get]] method of O is called with property name P, the following + steps are taken: + + 1. If O doesn't have a property with name P, go to step 4. + 2. Get the value of the property. + 3. Return Result(2). + 4. If the [[Prototype]] of O is null, return undefined. + 5. Call the [[Get]] method of [[Prototype]] with property name P. + 6. Return Result(5). + + This tests [[Get]] (Value). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "8.6.2.1-1"; + var VERSION = "ECMA_1"; + startTest(); + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " [[Get]] (Value)"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "var OBJ = new MyValuelessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyValuelessObject(true); OBJ.valueOf()") ); +// array[item++] = new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(true); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyProtolessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyProtolessObject(true); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + + array[item++] = new TestCase( SECTION, "var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); +// array[item++] = new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(Number.POSITIVE_INFINITY); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); + + array[item++] = new TestCase( SECTION, "var OBJ = new MyValuelessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyValuelessObject('string'); OBJ.valueOf()") ); +// array[item++] = new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject('string'); OJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyProtolessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyProtolessObject('string'); OBJ.valueOf()") ); + array[item++] = new TestCase( SECTION, "var OBJ = new MyObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyObject('string'); OBJ.valueOf()") ); + + return ( array ); +} +function MyProtoValuelessObject(value) { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} + +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} \ No newline at end of file diff --git a/tests/mozilla/ecma/browser.js b/tests/mozilla/ecma/browser.js new file mode 100644 index 0000000..5bbdf7c --- /dev/null +++ b/tests/mozilla/ecma/browser.js @@ -0,0 +1,80 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * + * + * + */ + +onerror = err; + +function startTest() { + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function writeLineToLog( string ) { + document.write( string + "
\n"); +} +function writeHeaderToLog( string ) { + document.write( "

" + string + "

" ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } + document.write( "
" ); +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = ""+ string ; + s += "" ; + s += ( passed ) ? "  " + PASSED + : " " + FAILED + expect + ""; + writeLineToLog( s + "" ); + return passed; +} +function err( msg, page, line ) { + writeLineToLog( "Test failed with the message: " + msg ); + + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} diff --git a/tests/mozilla/ecma/jsref.js b/tests/mozilla/ecma/jsref.js new file mode 100644 index 0000000..51b5a83 --- /dev/null +++ b/tests/mozilla/ecma/jsref.js @@ -0,0 +1,669 @@ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; +TITLE = ""; + +/* + * constant strings + */ +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; +var DEBUG = false; + +TZ_DIFF = -8; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; +var DEBUG = false; + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} + +/* + * Set up test environment. + * + */ +function startTest() { + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + } + + // print out bugnumber + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + + +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + writeLineToLog( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeLineToLog( string ) { + print( string + BR + CR ); +} +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() +{ + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + } + print(doneTag); + print( HR ); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} + +/** + * Type Conversion functions used by Type Conversion + * + */ + + + + /* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour + +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; + +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); +} +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { + return ( DaysInYear(y) * msPerDay ); +} +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); +} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } +} +function YearNumber( t ) { +} +function TimeFromYear( y ) { + return ( msPerDay * DayFromYear(y) ); +} +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); +} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+t+") case not covered"; + } +} +function YearFromTime( t ) { + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) + + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); +} +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); + + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } +} +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); +} +function DateFromTime( t ) { + var day = DayWithinYear(t); + var month = MonthFromTime(t); + + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); +} +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); +} + +// missing daylight savins time adjustment + +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); +} +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); +} +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +} +function msFromTime( t ) { + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); +} +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); +} +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +} +function DaylightSavingTA( t ) { + t = t - LocalTZA(); + + var dst_start = GetSecondSundayInMarch(t) + 2*msPerHour; + var dst_end = GetFirstSundayInNovember(t)+ 2*msPerHour; + + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } + + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. + + print( new Date( UTC(dst_start + LocalTZA())) ); + + return UTC(dst_start + LocalTZA()); +} +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); + + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} +function GetLastSundayInOctober( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +// Added these two functions because DST rules changed for the US. +function GetSecondSundayInMarch( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var march = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap); + + var sundayCount = 0; + var flag = true; + for ( var second_sunday = march; flag; second_sunday += msPerDay ) + { + if (WeekDay(second_sunday) == 0) { + if(++sundayCount == 2) + flag = false; + } + } + + return second_sunday; +} +function GetFirstSundayInNovember( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var nov = TimeFromYear(year), m = 0; m < 10; m++ ) { + nov += TimeInMonth(m, leap); + } + for ( var first_sunday = nov; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + return first_sunday; +} +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var properties = new Array(); + for ( p in o ) { + properties[ properties.length ] = new Array( p, o[p] ); + } + return properties; +} +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} diff --git a/tests/mozilla/ecma/shell.js b/tests/mozilla/ecma/shell.js new file mode 100644 index 0000000..1c82aed --- /dev/null +++ b/tests/mozilla/ecma/shell.js @@ -0,0 +1,712 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/* + * JavaScript shared functions file for running the tests in either + * stand-alone JavaScript engine. To run a test, first load this file, + * then load the test script. + */ + +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; + +/* + * constant strings + */ +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +var DEBUG = false; + + + +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +/* + * TestCase constructor + * + */ + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} + +/* + * Set up test environment. + * + */ +function startTest() { + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + } + + // print out bugnumber + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +/* + * Compare expected result to the actual result and figure out whether + * the test case passed. + */ +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} + +/* + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. + */ + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +/* end of print functions */ + + +/* + * When running in the shell, run the garbage collector after the + * test has completed. + */ + +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } +} + +/* + * Convenience function for displaying failed test cases. Useful + * when running tests manually. + * + */ +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} + /* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour +var TZ_DIFF = getTimeZoneDiff(); // offset of tester's timezone from UTC +var TZ_PST = -8; // offset of Pacific Standard Time from UTC +var PST_DIFF = TZ_DIFF - TZ_PST; // offset of tester's timezone from PST +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; +var TIME_YEAR_0 = -62167219200000; + + +/* + * Originally, the test suite used a hard-coded value TZ_DIFF = -8. + * But that was only valid for testers in the Pacific Standard Time Zone! + * We calculate the proper number dynamically for any tester. We just + * have to be careful not to use a date subject to Daylight Savings Time... +*/ +function getTimeZoneDiff() +{ + return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; +} + + +/* + * Date test "ResultArrays" are hard-coded for Pacific Standard Time. + * We must adjust them for the tester's own timezone - + */ +function adjustResultArray(ResultArray, msMode) +{ + // If the tester's system clock is in PST, no need to continue - + if (!PST_DIFF) {return;} + + /* The date testcases instantiate Date objects in two different ways: + * + * millisecond mode: e.g. dt = new Date(10000000); + * year-month-day mode: dt = new Date(2000, 5, 1, ...); + * + * In the first case, the date is measured from Time 0 in Greenwich (i.e. UTC). + * In the second case, it is measured with reference to the tester's local timezone. + * + * In the first case we must correct those values expected for local measurements, + * like dt.getHours() etc. No correction is necessary for dt.getUTCHours() etc. + * + * In the second case, it is exactly the other way around - + */ + if (msMode) + { + // The hard-coded UTC milliseconds from Time 0 derives from a UTC date. + // Shift to the right by the offset between UTC and the tester. + var t = ResultArray[TIME] + TZ_DIFF*msPerHour; + + // Use our date arithmetic functions to determine the local hour, day, etc. + ResultArray[HOURS] = HourFromTime(t); + ResultArray[DAY] = WeekDay(t); + ResultArray[DATE] = DateFromTime(t); + ResultArray[MONTH] = MonthFromTime(t); + ResultArray[YEAR] = YearFromTime(t); + } + else + { + // The hard-coded UTC milliseconds from Time 0 derives from a PST date. + // Shift to the left by the offset between PST and the tester. + var t = ResultArray[TIME] - PST_DIFF*msPerHour; + + // Use our date arithmetic functions to determine the UTC hour, day, etc. + ResultArray[TIME] = t; + ResultArray[UTC_HOURS] = HourFromTime(t); + ResultArray[UTC_DAY] = WeekDay(t); + ResultArray[UTC_DATE] = DateFromTime(t); + ResultArray[UTC_MONTH] = MonthFromTime(t); + ResultArray[UTC_YEAR] = YearFromTime(t); + } +} + + +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); +} +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { + return ( DaysInYear(y) * msPerDay ); +} +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); +} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } +} +function YearNumber( t ) { +} +function TimeFromYear( y ) { + return ( msPerDay * DayFromYear(y) ); +} +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); +} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+ t + ") case not covered"; + } +} +function YearFromTime( t ) { + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) + + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); +} +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); + + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } +} +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); +} +function DateFromTime( t ) { + var day = DayWithinYear(t); + var month = MonthFromTime(t); + + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); +} +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); +} + +// missing daylight savins time adjustment + +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); +} +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); +} +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +} +function msFromTime( t ) { + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); +} +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); +} +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +} + +function DaylightSavingTA( t ) { + t = t - LocalTZA(); + + var dst_start = GetSecondSundayInMarch(t) + 2*msPerHour; + var dst_end = GetFirstSundayInNovember(t)+ 2*msPerHour; + + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } + + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. + + print( new Date( UTC(dst_start + LocalTZA())) ); + + return UTC(dst_start + LocalTZA()); +} + +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); + + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} +function GetLastSundayInOctober( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +// Added these two functions because DST rules changed for the US. +function GetSecondSundayInMarch( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var march = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap); + + var sundayCount = 0; + var flag = true; + for ( var second_sunday = march; flag; second_sunday += msPerDay ) + { + if (WeekDay(second_sunday) == 0) { + if(++sundayCount == 2) + flag = false; + } + } + + return second_sunday; +} +function GetFirstSundayInNovember( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var nov = TimeFromYear(year), m = 0; m < 10; m++ ) { + nov += TimeInMonth(m, leap); + } + for ( var first_sunday = nov; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + return first_sunday; +} +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var p; + for ( p in o ) { + print( p +": " + o[p] ); + } +} + +/* these functions are useful for running tests manually in Rhino */ + +function GetContext() { + return Packages.com.netscape.javascript.Context.getCurrentContext(); +} +function OptLevel( i ) { + i = Number(i); + var cx = GetContext(); + cx.setOptimizationLevel(i); +} +/* end of Rhino functions */ diff --git a/tests/mozilla/ecma_2/Exceptions/boolean-001.js b/tests/mozilla/ecma_2/Exceptions/boolean-001.js new file mode 100644 index 0000000..1645ad4 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/boolean-001.js @@ -0,0 +1,43 @@ +/** + File Name: boolean-001.js + Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + var SECTION = "boolean-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Boolean.prototype.toString()"; + startTest(); + writeHeaderToLog( SECTION +" "+ TITLE ); + + var tc = 0; + var testcases = new Array(); + + var exception = "No exception thrown"; + var result = "Failed"; + + var TO_STRING = Boolean.prototype.toString; + + try { + var s = new String("Not a Boolean"); + s.toString = TO_STRING; + s.toString(); + } catch ( e ) { + result = "Passed!"; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Assigning Boolean.prototype.toString to a String object "+ + "(threw " +exception +")", + "Passed!", + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/boolean-002.js b/tests/mozilla/ecma_2/Exceptions/boolean-002.js new file mode 100644 index 0000000..be31b99 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/boolean-002.js @@ -0,0 +1,47 @@ +/** + File Name: boolean-001.js + Description: Corresponds to ecma/Boolean/15.6.4.3-4-n.js + + 15.6.4.3 Boolean.prototype.valueOf() + Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "boolean-002.js"; + var VERSION = "JS1_4"; + var TITLE = "Boolean.prototype.valueOf()"; + startTest(); + writeHeaderToLog( SECTION +" "+ TITLE ); + + var tc = 0; + var testcases = new Array(); + + var exception = "No exception thrown"; + var result = "Failed"; + + var VALUE_OF = Boolean.prototype.valueOf; + + try { + var s = new String("Not a Boolean"); + s.valueOf = VALUE_0F; + s.valueOf(); + } catch ( e ) { + result = "Passed!"; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Assigning Boolean.prototype.valueOf to a String object "+ + "(threw " +exception +")", + "Passed!", + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/date-001.js b/tests/mozilla/ecma_2/Exceptions/date-001.js new file mode 100644 index 0000000..60ef3a4 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/date-001.js @@ -0,0 +1,57 @@ +/** + File Name: date-001.js + Corresponds To: 15.9.5.2-2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + + This verifies that calling toString on an object that is not a string + generates a runtime error. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "date-001"; + var VERSION = "JS1_4"; + var TITLE = "Date.prototype.toString"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJ = new MyObject( new Date(0) ); + result = OBJ.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new MyObject( new Date(0)) ; result = OBJ.toString()" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = Date.prototype.toString; + return this; +} diff --git a/tests/mozilla/ecma_2/Exceptions/date-002.js b/tests/mozilla/ecma_2/Exceptions/date-002.js new file mode 100644 index 0000000..6fd5a64 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/date-002.js @@ -0,0 +1,51 @@ +/** + File Name: date-002.js + Corresponds To: 15.9.5.23-3-n.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "date-002"; + var VERSION = "JS1_4"; + var TITLE = "Date.prototype.setTime()"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var MYDATE = new MyDate(); + result = MYDATE.setTime(0); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "MYDATE = new MyDate(); MYDATE.setTime(0)" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyDate(value) { + this.value = value; + this.setTime = Date.prototype.setTime; + return this; +} diff --git a/tests/mozilla/ecma_2/Exceptions/date-003.js b/tests/mozilla/ecma_2/Exceptions/date-003.js new file mode 100644 index 0000000..b675fdd --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/date-003.js @@ -0,0 +1,53 @@ +/** + File Name: date-003.js + Corresponds To 15.9.5.3-1.js + ECMA Section: 15.9.5.3-1 Date.prototype.valueOf + Description: + + The valueOf function returns a number, which is this time value. + + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "date-003"; + var VERSION = "JS1_4"; + var TITLE = "Date.prototype.valueOf"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJ = new MyObject( new Date(0) ); + result = OBJ.valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJ = new MyObject( new Date(0)); OBJ.valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = Date.prototype.valueOf; +// The following line causes an infinte loop +// this.toString = new Function( "return this+\"\";"); + return this; +} diff --git a/tests/mozilla/ecma_2/Exceptions/date-004.js b/tests/mozilla/ecma_2/Exceptions/date-004.js new file mode 100644 index 0000000..fc2e419 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/date-004.js @@ -0,0 +1,47 @@ +/** + File Name: date-004.js + Corresponds To: 15.9.5.4-2-n.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "date-004"; + var VERSION = "JS1_4"; + var TITLE = "Date.prototype.getTime"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var MYDATE = new MyDate(); + result = MYDATE.getTime(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "MYDATE = new MyDate(); MYDATE.getTime()" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyDate( value ) { + this.value = value; + this.getTime = Date.prototype.getTime; +} diff --git a/tests/mozilla/ecma_2/Exceptions/exception-001.js b/tests/mozilla/ecma_2/Exceptions/exception-001.js new file mode 100644 index 0000000..eeeaa86 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-001.js @@ -0,0 +1,42 @@ +/** + * File Name: exception-001 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Call error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-001"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: CallError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + Call_1(); + + test(); + + function Call_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + Math(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "Math() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/tests/mozilla/ecma_2/Exceptions/exception-002.js b/tests/mozilla/ecma_2/Exceptions/exception-002.js new file mode 100644 index 0000000..680fcbf --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-002.js @@ -0,0 +1,42 @@ +/** + * File Name: exception-002 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Construct error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-002"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: ConstructError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + Construct_1(); + + test(); + + function Construct_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = new Math(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "new Math() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/tests/mozilla/ecma_2/Exceptions/exception-003.js b/tests/mozilla/ecma_2/Exceptions/exception-003.js new file mode 100644 index 0000000..d073fbc --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-003.js @@ -0,0 +1,46 @@ +/** + * File Name: exception-003 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Target error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-003"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: TargetError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + Target_1(); + + test(); + + function Target_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + string = new String("hi"); + string.toString = Boolean.prototype.toString; + string.toString(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "string = new String(\"hi\");"+ + "string.toString = Boolean.prototype.toString" + + "string.toString() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/tests/mozilla/ecma_2/Exceptions/exception-004.js b/tests/mozilla/ecma_2/Exceptions/exception-004.js new file mode 100644 index 0000000..1fde959 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-004.js @@ -0,0 +1,42 @@ +/** + * File Name: exception-004 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * ToObject error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-004"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ToObject_1(); + + test(); + + function ToObject_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = foo["bar"]; + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "foo[\"bar\"] [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/tests/mozilla/ecma_2/Exceptions/exception-005.js b/tests/mozilla/ecma_2/Exceptions/exception-005.js new file mode 100644 index 0000000..2fbb984 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-005.js @@ -0,0 +1,42 @@ +/** + * File Name: exception-005 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * ToObject error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-005"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ToObject_1(); + + test(); + + function ToObject_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = foo["bar"]; + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "foo[\"bar\"] [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/tests/mozilla/ecma_2/Exceptions/exception-006.js b/tests/mozilla/ecma_2/Exceptions/exception-006.js new file mode 100644 index 0000000..583e976 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-006.js @@ -0,0 +1,53 @@ +/** + * File Name: exception-006 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * ToPrimitive error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-006"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ToPrimitive_1(); + + test(); + + + /** + * Getting the [[DefaultValue]] of any instances of MyObject + * should result in a runtime error in ToPrimitive. + */ + + function MyObject() { + this.toString = void 0; + this.valueOf = void 0; + } + + function ToPrimitive_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = new MyObject() + new MyObject(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "new MyObject() + new MyObject() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/tests/mozilla/ecma_2/Exceptions/exception-007.js b/tests/mozilla/ecma_2/Exceptions/exception-007.js new file mode 100644 index 0000000..e26a40e --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-007.js @@ -0,0 +1,54 @@ +/** + * File Name: exception-007 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * DefaultValue error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-007"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; + var BUGNUMBER="318250"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DefaultValue_1(); + + test(); + + + /** + * Getting the [[DefaultValue]] of any instances of MyObject + * should result in a runtime error in ToPrimitive. + */ + + function MyObject() { + this.toString = void 0; + this.valueOf = new Object(); + } + + function DefaultValue_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = new MyObject() + new MyObject(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "new MyObject() + new MyObject() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/tests/mozilla/ecma_2/Exceptions/exception-008.js b/tests/mozilla/ecma_2/Exceptions/exception-008.js new file mode 100644 index 0000000..797f125 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-008.js @@ -0,0 +1,41 @@ +/** + * File Name: exception-008 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * SyntaxError. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-008"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + Syntax_1(); + + test(); + + function Syntax_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = eval("continue;"); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "eval(\"continue\") [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } diff --git a/tests/mozilla/ecma_2/Exceptions/exception-009.js b/tests/mozilla/ecma_2/Exceptions/exception-009.js new file mode 100644 index 0000000..b153532 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-009.js @@ -0,0 +1,50 @@ +/** + * File Name: exception-009 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Regression test for nested try blocks. + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312964 + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-009"; + var VERSION = "JS1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; + var BUGNUMBER= "312964"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + try { + expect = "passed: no exception thrown"; + result = expect; + Nested_1(); + } catch ( e ) { + result = "failed: threw " + e; + } finally { + testcases[tc++] = new TestCase( + SECTION, + "nested try", + expect, + result ); + } + + + test(); + + function Nested_1() { + try { + try { + } catch (a) { + } finally { + } + } catch (b) { + } finally { + } + } diff --git a/tests/mozilla/ecma_2/Exceptions/exception-010-n.js b/tests/mozilla/ecma_2/Exceptions/exception-010-n.js new file mode 100644 index 0000000..3b4ec82 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-010-n.js @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + print ("Null throw test."); + print ("BUGNUMBER: 21799"); + + throw null; + + print ("FAILED!: Should have exited with uncaught exception."); + +} diff --git a/tests/mozilla/ecma_2/Exceptions/exception-011-n.js b/tests/mozilla/ecma_2/Exceptions/exception-011-n.js new file mode 100644 index 0000000..9088420 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/exception-011-n.js @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + print ("Undefined throw test."); + + throw (void 0); + + print ("FAILED!: Should have exited with uncaught exception."); + +} diff --git a/tests/mozilla/ecma_2/Exceptions/expression-001.js b/tests/mozilla/ecma_2/Exceptions/expression-001.js new file mode 100644 index 0000000..b1baf6f --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-001.js @@ -0,0 +1,47 @@ +/** + File Name: expression-001.js + Corresponds to: ecma/Expressions/11.12-2-n.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "expression-001"; + var VERSION = "JS1_4"; + var TITLE = "Conditional operator ( ? : )" + startTest(); + writeHeaderToLog( SECTION + " " + TITLE ); + + var tc = 0; + var testcases = new Array(); + + // the following expression should be an error in JS. + + var result = "Failed" + var exception = "No exception was thrown"; + + try { + eval("var MY_VAR = true ? \"EXPR1\", \"EXPR2\" : \"EXPR3\""); + } catch ( e ) { + result = "Passed"; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "comma expression in a conditional statement "+ + "(threw "+ exception +")", + "Passed", + result ); + + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/expression-002.js b/tests/mozilla/ecma_2/Exceptions/expression-002.js new file mode 100644 index 0000000..1a73ebe --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-002.js @@ -0,0 +1,57 @@ +/** + File Name: expressions-002.js + Corresponds to: ecma/Expressions/11.2.1-3-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Try to access properties of an object whose value is undefined. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "expressions-002.js"; + var VERSION = "JS1_4"; + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + startTest(); + + var tc = 0; + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + OBJECT = new Property( "undefined", void 0, "undefined", NaN ); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = OBJECT.value.valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + + testcases[tc++] = new TestCase( + SECTION, + "Get the value of an object whose value is undefined "+ + "(threw " + exception +")", + expect, + result ); + + test(); + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.valueOf = value; +} \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Exceptions/expression-003.js b/tests/mozilla/ecma_2/Exceptions/expression-003.js new file mode 100644 index 0000000..30b5369 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-003.js @@ -0,0 +1,52 @@ +/** + File Name: expressions-003.js + Corresponds to: ecma/Expressions/11.2.1-3-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Try to access properties of an object whose value is undefined. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "expressions-003.js"; + var VERSION = "JS1_4"; + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + startTest(); + + var tc = 0; + var testcases = new Array(); + + // try to access properties of primitive types + + OBJECT = new Property( "undefined", void 0, "undefined", NaN ); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = OBJECT.value.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + + testcases[tc++] = new TestCase( + SECTION, + "Get the toString value of an object whose value is undefined "+ + "(threw " + exception +")", + expect, + result ); + + test(); + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Exceptions/expression-004.js b/tests/mozilla/ecma_2/Exceptions/expression-004.js new file mode 100644 index 0000000..0ce3864 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-004.js @@ -0,0 +1,46 @@ +/** + File Name: expression-004.js + Corresponds To: 11.2.1-4-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "expression-004"; + var VERSION = "JS1_4"; + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + startTest(); + + var tc = 0; + var testcases = new Array(); + + var OBJECT = new Property( "null", null, "null", 0 ); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = OBJECT.value.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Get the toString value of an object whose value is null "+ + "(threw " + exception +")", + expect, + result ); + + test(); + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/tests/mozilla/ecma_2/Exceptions/expression-005.js b/tests/mozilla/ecma_2/Exceptions/expression-005.js new file mode 100644 index 0000000..df69144 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-005.js @@ -0,0 +1,38 @@ +/** + File Name: expression-005.js + Corresponds To: 11.2.2-10-n.js + ECMA Section: 11.2.2. The new operator + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "expression-005"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var expect = "Passed"; + var exception = "No exception thrown"; + + try { + result = new Math(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "result= new Math() (threw " + exception + ")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/expression-006.js b/tests/mozilla/ecma_2/Exceptions/expression-006.js new file mode 100644 index 0000000..1bf0798 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-006.js @@ -0,0 +1,43 @@ +/** + File Name: expression-006.js + Corresponds to: 11.2.2-1-n.js + ECMA Section: 11.2.2. The new operator + Description: + + http://scopus/bugsplat/show_bug.cgi?id=327765 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-006.js"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + var BUGNUMBER="327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJECT = new Object(); + result = new OBJECT(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new Object; result = new OBJECT()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/expression-007.js b/tests/mozilla/ecma_2/Exceptions/expression-007.js new file mode 100644 index 0000000..988109b --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-007.js @@ -0,0 +1,41 @@ +/** + File Name: expression-007.js + Corresponds To: 11.2.2-2-n.js + ECMA Section: 11.2.2. The new operator + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-007"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + UNDEFINED = void 0; + result = new UNDEFINED(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "UNDEFINED = void 0; result = new UNDEFINED()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/expression-008.js b/tests/mozilla/ecma_2/Exceptions/expression-008.js new file mode 100644 index 0000000..caa8912 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-008.js @@ -0,0 +1,38 @@ +/** + File Name: expression-008 + Corresponds To: 11.2.2-3-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-008"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var NULL = null; + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new NULL(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "NULL = null; result = new NULL()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/expression-009.js b/tests/mozilla/ecma_2/Exceptions/expression-009.js new file mode 100644 index 0000000..2aa63b6 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-009.js @@ -0,0 +1,39 @@ +/** + File Name: expression-009 + Corresponds to: ecma/Expressions/11.2.2-4-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-009"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var STRING = ""; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new STRING(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "STRING = ''; result = new STRING()" + + " (threw " + exception +")", + expect, + result ); + + test(); \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Exceptions/expression-010.js b/tests/mozilla/ecma_2/Exceptions/expression-010.js new file mode 100644 index 0000000..bb21aba --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-010.js @@ -0,0 +1,40 @@ +/** + File Name: expression-010.js + Corresponds To: 11.2.2-5-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-010"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var NUMBER = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new NUMBER(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "NUMBER=0, result = new NUMBER()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/expression-011.js b/tests/mozilla/ecma_2/Exceptions/expression-011.js new file mode 100644 index 0000000..71c601a --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-011.js @@ -0,0 +1,40 @@ +/** + File Name: expression-011.js + Corresponds To: ecma/Expressions/11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-011"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var BOOLEAN = true; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJECT = new BOOLEAN(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "BOOLEAN = true; result = new BOOLEAN()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/expression-012.js b/tests/mozilla/ecma_2/Exceptions/expression-012.js new file mode 100644 index 0000000..31eb099 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-012.js @@ -0,0 +1,41 @@ +/** + File Name: expression-012.js + Corresponds To: ecma/Expressions/11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + http://scopus/bugsplat/show_bug.cgi?id=327765 + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-012"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + var BUGNUMBER= "327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var STRING = new String("hi"); + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new STRING(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "STRING = new String(\"hi\"); result = new STRING()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/expression-013.js b/tests/mozilla/ecma_2/Exceptions/expression-013.js new file mode 100644 index 0000000..cc75a77 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-013.js @@ -0,0 +1,41 @@ +/** + File Name: expression-013.js + Corresponds To: ecma/Expressions/11.2.2-8-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-013"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + var BUGNUMBER= "327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var NUMBER = new Number(1); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new NUMBER(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "NUMBER = new Number(1); result = new NUMBER()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/expression-014.js b/tests/mozilla/ecma_2/Exceptions/expression-014.js new file mode 100644 index 0000000..4a09cd1 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-014.js @@ -0,0 +1,43 @@ +/** + File Name: expression-014.js + Corresponds To: ecma/Expressions/11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-014.js"; + var VERSION = "ECMA_1"; + var TITLE = "The new operator"; + var BUGNUMBER= "327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var BOOLEAN = new Boolean(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new BOOLEAN(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "BOOLEAN = new Boolean(); result = new BOOLEAN()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/expression-015.js b/tests/mozilla/ecma_2/Exceptions/expression-015.js new file mode 100644 index 0000000..09577fc --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-015.js @@ -0,0 +1,37 @@ +/** + File Name: expression-015.js + Corresponds To: ecma/Expressions/11.2.3-2-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-015"; + var VERSION = "JS1_4"; + var TITLE = "Function Calls"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("result = 3.valueOf();"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "3.valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/expression-016.js b/tests/mozilla/ecma_2/Exceptions/expression-016.js new file mode 100644 index 0000000..4a55110 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-016.js @@ -0,0 +1,37 @@ +/** + File Name: expression-016.js + Corresponds To: ecma/Expressions/11.2.3-3-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-016"; + var VERSION = "JS1_4"; + var TITLE = "Function Calls"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = (void 0).valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "(void 0).valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/expression-017.js b/tests/mozilla/ecma_2/Exceptions/expression-017.js new file mode 100644 index 0000000..949cf3f --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-017.js @@ -0,0 +1,37 @@ +/** + File Name: expression-07.js + Corresponds To: ecma/Expressions/11.2.3-4-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-017"; + var VERSION = "JS1_4"; + var TITLE = "Function Calls"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = nullvalueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "null.valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/expression-019.js b/tests/mozilla/ecma_2/Exceptions/expression-019.js new file mode 100644 index 0000000..0ef02cb --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/expression-019.js @@ -0,0 +1,41 @@ +/** + File Name: expression-019.js + Corresponds To: 11.2.2-7-n.js + ECMA Section: 11.2.2. The new operator + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-019"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + var BUGNUMBER= "327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var STRING = new String("hi"); + result = new STRING(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var STRING = new String(\"hi\"); result = new STRING();" + + " (threw " + exception + ")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/function-001.js b/tests/mozilla/ecma_2/Exceptions/function-001.js new file mode 100644 index 0000000..3cbd19e --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/function-001.js @@ -0,0 +1,64 @@ +/** + * File Name: boolean-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232 + * + * eval("function f(){}function g(){}") at top level is an error for JS1.2 + * and above (missing ; between named function expressions), but declares f + * and g as functions below 1.2. + * + * Fails to produce error regardless of version: + * js> version(100) + * 120 + * js> eval("function f(){}function g(){}") + * js> version(120); + * 100 + * js> eval("function f(){}function g(){}") + * js> + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "function-001.js"; + var VERSION = "JS_12"; + var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; + var BUGNUMBER="10278"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "fail"; + var exception = "no exception thrown"; + + try { + eval("function f(){}function g(){}"); + } catch ( e ) { + result = "pass" + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\") (threw "+exception, + "pass", + result ); + + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma_2/Exceptions/global-001.js b/tests/mozilla/ecma_2/Exceptions/global-001.js new file mode 100644 index 0000000..3b1bd98 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/global-001.js @@ -0,0 +1,43 @@ +/** + File Name: global-001 + Corresponds To: ecma/GlobalObject/15.1-1-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "global-001"; + var VERSION = "ECMA_1"; + var TITLE = "The Global Object"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new this(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "result = new this()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/global-002.js b/tests/mozilla/ecma_2/Exceptions/global-002.js new file mode 100644 index 0000000..2453c29 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/global-002.js @@ -0,0 +1,43 @@ +/** + File Name: global-002 + Corresponds To: ecma/GlobalObject/15.1-2-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "global-002"; + var VERSION = "JS1_4"; + var TITLE = "The Global Object"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = this(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "result = this()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-001.js b/tests/mozilla/ecma_2/Exceptions/lexical-001.js new file mode 100644 index 0000000..528a573 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-001.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-001.js + CorrespondsTo: ecma/LexicalConventions/7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-001"; + var VERSION = "JS1_4"; + var TITLE = "Line Terminators"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = eval("\r\n\expect"); + } catch ( e ) { + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new Object; result = new OBJECT()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-002.js b/tests/mozilla/ecma_2/Exceptions/lexical-002.js new file mode 100644 index 0000000..b1521c2 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-002.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-002.js + Corresponds To: ecma/LexicalConventions/7.2-3-n.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-002"; + var VERSION = "JS1_4"; + var TITLE = "Line Terminators"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = eval("\r\n\expect"); + } catch ( e ) { + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "result=eval(\"\r\nexpect\")" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-003.js b/tests/mozilla/ecma_2/Exceptions/lexical-003.js new file mode 100644 index 0000000..a622d12 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-003.js @@ -0,0 +1,41 @@ +/** + File Name: lexical-003.js + Corresponds To: 7.3-13-n.js + ECMA Section: 7.3 Comments + Description: + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-003.js"; + var VERSION = "JS1_4"; + var TITLE = "Comments"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("/*\n/* nested comment */\n*/\n"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "/*/*nested comment*/ */" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-004.js b/tests/mozilla/ecma_2/Exceptions/lexical-004.js new file mode 100644 index 0000000..6475838 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-004.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-004.js + Corresponds To: ecma/LexicalExpressions/7.4.1-1-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-004"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var null = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var null = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-005.js b/tests/mozilla/ecma_2/Exceptions/lexical-005.js new file mode 100644 index 0000000..a9cdd6b --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-005.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-005.js + Corresponds To: 7.4.1-2.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-005"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("true = false;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "true = false" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-006.js b/tests/mozilla/ecma_2/Exceptions/lexical-006.js new file mode 100644 index 0000000..89c45f3 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-006.js @@ -0,0 +1,55 @@ +/** + File Name: lexical-006.js + Corresponds To: 7.4.2-1.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-006"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("break = new Object();"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "break = new Object()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-007.js b/tests/mozilla/ecma_2/Exceptions/lexical-007.js new file mode 100644 index 0000000..d34afe4 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-007.js @@ -0,0 +1,48 @@ +/** + File Name: lexical-005.js + Corresponds To: 7.4.1-3-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-005"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("false = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "false = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-008.js b/tests/mozilla/ecma_2/Exceptions/lexical-008.js new file mode 100644 index 0000000..f819eae --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-008.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-008.js + Corresponds To: 7.4.3-1-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-008.js"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("case = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "case = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-009.js b/tests/mozilla/ecma_2/Exceptions/lexical-009.js new file mode 100644 index 0000000..39fc71a --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-009.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-009 + Corresponds To: 7.4.3-2-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-009"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("debugger = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "debugger = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-010.js b/tests/mozilla/ecma_2/Exceptions/lexical-010.js new file mode 100644 index 0000000..9e9f664 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-010.js @@ -0,0 +1,48 @@ +/** + File Name: lexical-010.js + Corresponds To: 7.4.3-3-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-010"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("export = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "export = true" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-011.js b/tests/mozilla/ecma_2/Exceptions/lexical-011.js new file mode 100644 index 0000000..1c054f2 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-011.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-011.js + Corresponds To: 7.4.3-4-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-011"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("super = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "super = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-012.js b/tests/mozilla/ecma_2/Exceptions/lexical-012.js new file mode 100644 index 0000000..e4579fd --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-012.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-012.js + Corresponds To: 7.4.3-5-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-012"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("catch = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "catch = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-013.js b/tests/mozilla/ecma_2/Exceptions/lexical-013.js new file mode 100644 index 0000000..699d06a --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-013.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-013.js + Corresponds To: 7.4.3-6-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-013"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("default = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "default = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-014.js b/tests/mozilla/ecma_2/Exceptions/lexical-014.js new file mode 100644 index 0000000..41b12ff --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-014.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-014.js + Corresponds To: 7.4.3-7-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-014.js"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("extends = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "extends = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-015.js b/tests/mozilla/ecma_2/Exceptions/lexical-015.js new file mode 100644 index 0000000..7cbcc04 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-015.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-015.js + Corresponds To: 7.4.3-8-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-015"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("switch = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "switch = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-016.js b/tests/mozilla/ecma_2/Exceptions/lexical-016.js new file mode 100644 index 0000000..8126550 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-016.js @@ -0,0 +1,48 @@ +/** + File Name: lexical-016 + Corresponds To: 7.4.3-9-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-016"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("class = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "class = true" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-017.js b/tests/mozilla/ecma_2/Exceptions/lexical-017.js new file mode 100644 index 0000000..96849b7 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-017.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-017.js + Corresponds To: 7.4.3-10-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-017"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("do = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "do = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-018.js b/tests/mozilla/ecma_2/Exceptions/lexical-018.js new file mode 100644 index 0000000..5d46c5f --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-018.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-018 + Corresponds To: 7.4.3-11-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-018"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("finally = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "finally = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-019.js b/tests/mozilla/ecma_2/Exceptions/lexical-019.js new file mode 100644 index 0000000..9f01fc0 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-019.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-019.js + Corresponds To: 7.4.3-12-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-019"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("throw = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "throw = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-020.js b/tests/mozilla/ecma_2/Exceptions/lexical-020.js new file mode 100644 index 0000000..362a3d5 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-020.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-020.js + Corresponds To 7.4.3-13-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-020"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("const = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "const = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-021.js b/tests/mozilla/ecma_2/Exceptions/lexical-021.js new file mode 100644 index 0000000..9fb3ede --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-021.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-021.js + Corresponds To: 7.4.3-14-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-021.js"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("enum = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "enum = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-022.js b/tests/mozilla/ecma_2/Exceptions/lexical-022.js new file mode 100644 index 0000000..54f256a --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-022.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-022 + Corresponds To 7.4.3-15-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-022.js"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("import = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "import = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-023.js b/tests/mozilla/ecma_2/Exceptions/lexical-023.js new file mode 100644 index 0000000..0715a3d --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-023.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-023.js + Corresponds To: 7.4.3-16-n.js + ECMA Section: 7.4.3 + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-023.js"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("try = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "try = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-024.js b/tests/mozilla/ecma_2/Exceptions/lexical-024.js new file mode 100644 index 0000000..d731791 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-024.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-024 + Corresponds To: 7.4.2-1-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-024"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var break;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var break" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-025.js b/tests/mozilla/ecma_2/Exceptions/lexical-025.js new file mode 100644 index 0000000..16a44d6 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-025.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-025.js + Corresponds To 7.4.2-2-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-025"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var for;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var for" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-026.js b/tests/mozilla/ecma_2/Exceptions/lexical-026.js new file mode 100644 index 0000000..73aea73 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-026.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-026.js + Corresponds To: 7.4.2-3-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-026"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var new;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var new" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-027.js b/tests/mozilla/ecma_2/Exceptions/lexical-027.js new file mode 100644 index 0000000..b8f8593 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-027.js @@ -0,0 +1,58 @@ +/** + File Name: lexical-027.js + Corresponds To: 7.4.2-4-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + var + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-027"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var var;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var var" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-028.js b/tests/mozilla/ecma_2/Exceptions/lexical-028.js new file mode 100644 index 0000000..a985527 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-028.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-028.js + Corresponds To: 7.4.2-5-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-028"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var continue=true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var continue=true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-029.js b/tests/mozilla/ecma_2/Exceptions/lexical-029.js new file mode 100644 index 0000000..0b38cbe --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-029.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-029.js + Corresponds To: 7.4.2-6.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-029"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var function = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var function = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-030.js b/tests/mozilla/ecma_2/Exceptions/lexical-030.js new file mode 100644 index 0000000..bc85472 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-030.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-030.js + Corresponds To: 7.4.2-7-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-030"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var return = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var return = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-031.js b/tests/mozilla/ecma_2/Exceptions/lexical-031.js new file mode 100644 index 0000000..d2251ba --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-031.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-031.js + Corresponds To: 7.4.2-8-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-031"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var return;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var return" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-032.js b/tests/mozilla/ecma_2/Exceptions/lexical-032.js new file mode 100644 index 0000000..5ac71cb --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-032.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-032.js + Corresponds To: 7.4.2-9-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-032"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("delete = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "delete = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-033.js b/tests/mozilla/ecma_2/Exceptions/lexical-033.js new file mode 100644 index 0000000..2a357fe --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-033.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-033.js + Corresponds To: 7.4.2-10.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-033"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("if = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "if = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-034.js b/tests/mozilla/ecma_2/Exceptions/lexical-034.js new file mode 100644 index 0000000..d6c03a2 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-034.js @@ -0,0 +1,55 @@ +/** + File Name: 7.4.2-11-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-034"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("this = true"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "this = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-035.js b/tests/mozilla/ecma_2/Exceptions/lexical-035.js new file mode 100644 index 0000000..f5fca59 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-035.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-035.js + Correpsonds To: 7.4.2-12-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-035"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var while"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var while" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-036.js b/tests/mozilla/ecma_2/Exceptions/lexical-036.js new file mode 100644 index 0000000..3512c9b --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-036.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-036.js + Corresponds To: 7.4.2-13-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-036"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("else = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "else = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-037.js b/tests/mozilla/ecma_2/Exceptions/lexical-037.js new file mode 100644 index 0000000..641c9de --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-037.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-037.js + Corresponds To: 7.4.2-14-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-028"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var in;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var in" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-038.js b/tests/mozilla/ecma_2/Exceptions/lexical-038.js new file mode 100644 index 0000000..f44b6b3 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-038.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-038.js + Corresponds To: 7.4.2-15-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-038"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("typeof = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "typeof = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-039.js b/tests/mozilla/ecma_2/Exceptions/lexical-039.js new file mode 100644 index 0000000..e40b21b --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-039.js @@ -0,0 +1,43 @@ +/** + File Name: lexical-039 + Corresponds To: 7.5-2-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-039"; + var VERSION = "JS1_4"; + var TITLE = "Identifiers"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var 0abc;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var 0abc" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-040.js b/tests/mozilla/ecma_2/Exceptions/lexical-040.js new file mode 100644 index 0000000..fb306c1 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-040.js @@ -0,0 +1,43 @@ +/** + File Name: lexical-040.js + Corresponds To: 7.5-2.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-040"; + var VERSION = "JS1_4"; + var TITLE = "Identifiers"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var 1abc;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var 1abc" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-041.js b/tests/mozilla/ecma_2/Exceptions/lexical-041.js new file mode 100644 index 0000000..da830f8 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-041.js @@ -0,0 +1,45 @@ +/** + File Name: lexical-041.js + Corresponds To: 7.5-8-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-041"; + var VERSION = "ECMA_1"; + var TITLE = "Identifiers"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var @abc;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var @abc" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-042.js b/tests/mozilla/ecma_2/Exceptions/lexical-042.js new file mode 100644 index 0000000..88ee509 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-042.js @@ -0,0 +1,46 @@ +/** + File Name: lexical-042.js + Corresponds To: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-042"; + var VERSION = "JS1_4"; + var TITLE = "Identifiers"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var 123;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var 123" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-047.js b/tests/mozilla/ecma_2/Exceptions/lexical-047.js new file mode 100644 index 0000000..b5e3548 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-047.js @@ -0,0 +1,47 @@ +/** + File Name: lexical-047.js + Corresponds To: 7.8.1-7-n.js + ECMA Section: 7.8.1 + Description: + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-047"; + var VERSION = "JS1_4"; + var TITLE = "for loops"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var counter = 0; + eval("for ( counter = 0\n" + + "counter <= 1\n" + + "counter++ )\n" + + "{\n" + + "result += \": got to inner loop\";\n" + + "}\n"); + + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-048.js b/tests/mozilla/ecma_2/Exceptions/lexical-048.js new file mode 100644 index 0000000..39a0600 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-048.js @@ -0,0 +1,41 @@ + /** + File Name: lexical-048.js + Corresponds To: 7.8.1-1.js + ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertion + Description: + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-048"; + var VERSION = "JS1_4"; + var TITLE = "The Rules of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var counter = 0; + eval( "for ( counter = 0;\ncounter <= 1\ncounter++ ) {\nresult += \": got inside for loop\")"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-049.js b/tests/mozilla/ecma_2/Exceptions/lexical-049.js new file mode 100644 index 0000000..e03cfec --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-049.js @@ -0,0 +1,46 @@ + /** + File Name: lexical-049 + Corresponds To: 7.8.1-1.js + ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertioin + Description: + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "lexical-049"; + var VERSION = "JS1_4"; + var TITLE = "The Rules of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var counter = 0; + eval("for ( counter = 0\n" + + "counter <= 1;\n" + + "counter++ )\n" + + "{\n" + + "result += \": got inside for loop\";\n" + + "}\n"); + + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-050.js b/tests/mozilla/ecma_2/Exceptions/lexical-050.js new file mode 100644 index 0000000..bc871a7 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-050.js @@ -0,0 +1,42 @@ +/** + File Name: lexical-050.js + Corresponds to: 7.8.2-1-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-050"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("{ 1 2 } 3"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "{ 1 2 } 3" + + " (threw " + exception +")", + expect, + result ); + + test(); + + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-051.js b/tests/mozilla/ecma_2/Exceptions/lexical-051.js new file mode 100644 index 0000000..68e6b44 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-051.js @@ -0,0 +1,42 @@ +/** + File Name: lexical-051.js + Corresponds to: 7.8.2-3-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-051"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("for (a; b\n) result += \": got to inner loop\";") + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "for (a; b\n)" + + " (threw " + exception +")", + expect, + result ); + + test(); + + + diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-052.js b/tests/mozilla/ecma_2/Exceptions/lexical-052.js new file mode 100644 index 0000000..49aa7c7 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-052.js @@ -0,0 +1,44 @@ +/** + File Name: lexical-052.js + Corresponds to: 7.8.2-4-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-052"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + MyFunction(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "calling return indirectly" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyFunction() { + var s = "return"; + eval(s); +} diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-053.js b/tests/mozilla/ecma_2/Exceptions/lexical-053.js new file mode 100644 index 0000000..6e3ae99 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-053.js @@ -0,0 +1,42 @@ +/** + File Name: lexical-053.js + Corresponds to: 7.8.2-7-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-053"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + a = true + b = false + + eval('if (a > b)\nelse result += ": got to else statement"'); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "calling return indirectly" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/lexical-054.js b/tests/mozilla/ecma_2/Exceptions/lexical-054.js new file mode 100644 index 0000000..c4b9e9f --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/lexical-054.js @@ -0,0 +1,43 @@ +/** + File Name: lexical-054.js + Corresponds to: 7.8.2-7-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-054"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + a=0; + b=1; + c=2; + d=3; + eval("if (a > b)\nelse c = d"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "if (a > b)\nelse c = d" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/number-001.js b/tests/mozilla/ecma_2/Exceptions/number-001.js new file mode 100644 index 0000000..1f45603 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/number-001.js @@ -0,0 +1,52 @@ +/** + File Name: number-001 + Corresponds To: 15.7.4.2-2-n.js + ECMA Section: 15.7.4.2.2 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "number-001"; + var VERSION = "JS1_4"; + var TITLE = "Exceptions for Number.toString()"; + + startTest(); + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + + var testcases = new Array(); + var tc = 0; + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + + try { + object= new Object(); + object.toString = Number.prototype.toString; + result = object.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "object = new Object(); object.toString = Number.prototype.toString; object.toString()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/number-002.js b/tests/mozilla/ecma_2/Exceptions/number-002.js new file mode 100644 index 0000000..5e84ebf --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/number-002.js @@ -0,0 +1,45 @@ +/** + File Name: number-002.js + Corresponds To: ecma/Number/15.7.4.3-2-n.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "number-002"; + var VERSION = "JS1_4"; + var TITLE = "Exceptions for Number.valueOf()"; + + startTest(); + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + object= new Object(); + object.toString = Number.prototype.valueOf; + result = object.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/number-003.js b/tests/mozilla/ecma_2/Exceptions/number-003.js new file mode 100644 index 0000000..947d3d2 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/number-003.js @@ -0,0 +1,47 @@ +/** + File Name: number-003.js + Corresponds To: 15.7.4.3-3.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "number-003"; + var VERSION = "JS1_4"; + var TITLE = "Exceptions for Number.valueOf()"; + + var tc = 0; + var testcases = new Array(); + + startTest(); + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + VALUE_OF = Number.prototype.valueOf; + OBJECT = new String("Infinity"); + OBJECT.valueOf = VALUE_OF; + result = OBJECT.valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Assigning Number.prototype.valueOf as the valueOf of a String object " + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/statement-001.js b/tests/mozilla/ecma_2/Exceptions/statement-001.js new file mode 100644 index 0000000..928a04d --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/statement-001.js @@ -0,0 +1,44 @@ +/** + File Name: statement-001.js + Corresponds To: 12.6.2-9-n.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "statement-001.js"; +// var SECTION = "12.6.2-9-n"; + var VERSION = "ECMA_1"; + var TITLE = "The for statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("for (i) {\n}"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "for(i) {}" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/statement-002.js b/tests/mozilla/ecma_2/Exceptions/statement-002.js new file mode 100644 index 0000000..83c642c --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/statement-002.js @@ -0,0 +1,66 @@ +/** + File Name: statement-002.js + Corresponds To: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-002"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + var testcases = new Array(); + var tc = 0; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval(" for ( var i, p in this) { result += this[p]; }"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "more than one member expression" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/tests/mozilla/ecma_2/Exceptions/statement-003.js b/tests/mozilla/ecma_2/Exceptions/statement-003.js new file mode 100644 index 0000000..c7ffc7f --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/statement-003.js @@ -0,0 +1,77 @@ +/** + File Name: statement-003 + Corresponds To: 12.6.3-7-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-003"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var o = new MyObject(); + var result = 0; + + eval("for ( this in o) {\n" + + "result += this[p];\n" + + "}\n"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/mozilla/ecma_2/Exceptions/statement-004.js b/tests/mozilla/ecma_2/Exceptions/statement-004.js new file mode 100644 index 0000000..9eee4e6 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/statement-004.js @@ -0,0 +1,49 @@ +/** + File Name: statement-004.js + Corresponds To: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-004"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var o = new MyObject(); + + eval("for ( \"a\" in o) {\n" + + "result += this[p];\n" + + "}"); + + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/mozilla/ecma_2/Exceptions/statement-005.js b/tests/mozilla/ecma_2/Exceptions/statement-005.js new file mode 100644 index 0000000..50933b0 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/statement-005.js @@ -0,0 +1,48 @@ +/** + File Name: statement-005.js + Corresponds To: 12.6.3-8-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-005"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var o = new MyObject(); + result = 0; + + eval("for (1 in o) {\n" + + "result += this[p];" + + "}\n"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/mozilla/ecma_2/Exceptions/statement-006.js b/tests/mozilla/ecma_2/Exceptions/statement-006.js new file mode 100644 index 0000000..1fe0325 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/statement-006.js @@ -0,0 +1,48 @@ +/** + File Name: statement-006.js + Corresponds To: 12.6.3-9-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-006"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var o = new MyObject(); + var result = 0; + for ( var o in foo) { + result += this[o]; + } + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "object is not defined" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Exceptions/statement-007.js b/tests/mozilla/ecma_2/Exceptions/statement-007.js new file mode 100644 index 0000000..506578b --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/statement-007.js @@ -0,0 +1,39 @@ +/** + File Name: statement-007.js + Corresponds To: 12.7-1-n.js + ECMA Section: 12.7 The continue statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "statement-007"; + var VERSION = "JS1_4"; + var TITLE = "The continue statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("continue;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "continue outside of an iteration statement" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/statement-008.js b/tests/mozilla/ecma_2/Exceptions/statement-008.js new file mode 100644 index 0000000..e293964 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/statement-008.js @@ -0,0 +1,39 @@ +/** + File Name: statement-008.js + Corresponds To: 12.8-1-n.js + ECMA Section: 12.8 The break statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "statement-008"; + var VERSION = "JS1_4"; + var TITLE = "The break in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("break;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "break outside of an iteration statement" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/statement-009.js b/tests/mozilla/ecma_2/Exceptions/statement-009.js new file mode 100644 index 0000000..136d3f1 --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/statement-009.js @@ -0,0 +1,38 @@ +/** + File Name: 12.9-1-n.js + ECMA Section: 12.9 The return statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "12.9-1-n"; + var VERSION = "ECMA_1"; + var TITLE = "The return statment"; + + startTest(); + writeHeaderToLog( SECTION + " The return statement"); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("return;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "return outside of a function" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/string-001.js b/tests/mozilla/ecma_2/Exceptions/string-001.js new file mode 100644 index 0000000..9ba39af --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/string-001.js @@ -0,0 +1,50 @@ +/** + File Name: string-001.js + Corresponds To: 15.5.4.2-2-n.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + var SECTION = "string-001"; + var VERSION = "JS1_4"; + var TITLE = "String.prototype.toString"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + OBJECT = new Object(); + OBJECT.toString = String.prototype.toString(); + result = OBJECT.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new Object; "+ + " OBJECT.toString = String.prototype.toString; OBJECT.toString()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/tests/mozilla/ecma_2/Exceptions/string-002.js b/tests/mozilla/ecma_2/Exceptions/string-002.js new file mode 100644 index 0000000..857271e --- /dev/null +++ b/tests/mozilla/ecma_2/Exceptions/string-002.js @@ -0,0 +1,49 @@ +/** + File Name: string-002.js + Corresponds To: 15.5.4.3-3-n.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + var SECTION = "string-002"; + var VERSION = "JS1_4"; + var TITLE = "String.prototype.valueOf"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJECT =new Object(); + OBJECT.valueOf = String.prototype.valueOf; + result = OBJECT.valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new Object; OBJECT.valueOf = String.prototype.valueOf;"+ + "result = OBJECT.valueOf();" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/tests/mozilla/ecma_2/Expressions/StrictEquality-001.js b/tests/mozilla/ecma_2/Expressions/StrictEquality-001.js new file mode 100644 index 0000000..c3ac507 --- /dev/null +++ b/tests/mozilla/ecma_2/Expressions/StrictEquality-001.js @@ -0,0 +1,70 @@ +/** + * File Name: StrictEquality-001.js + * ECMA Section: 11.9.6.js + * Description: + * + * Author: christine@netscape.com + * Date: 4 september 1998 + */ + var SECTION = "StrictEquality-001 - 11.9.6"; + var VERSION = "ECMA_2"; + var TITLE = "The strict equality operator ( === )"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + // 1. If Type(x) is different from Type(y) return false + + StrictEquality( true, new Boolean(true), false ); + StrictEquality( new Boolean(), false, false ); + StrictEquality( "", new String(), false ); + StrictEquality( new String("hi"), "hi", false ); + + // 2. If Type(x) is not Number go to step 9. + + // 3. If x is NaN, return false + StrictEquality( NaN, NaN, false ); + StrictEquality( NaN, 0, false ); + + // 4. If y is NaN, return false. + StrictEquality( 0, NaN, false ); + + // 5. if x is the same number value as y, return true + + // 6. If x is +0 and y is -0, return true + + // 7. If x is -0 and y is +0, return true + + // 8. Return false. + + + // 9. If Type(x) is String, then return true if x and y are exactly + // the same sequence of characters ( same length and same characters + // in corresponding positions.) Otherwise return false. + + // 10. If Type(x) is Boolean, return true if x and y are both true or + // both false. otherwise return false. + + + // Return true if x and y refer to the same object. Otherwise return + // false. + + // Return false. + + + test(); + +function StrictEquality( x, y, expect ) { + result = ( x === y ); + + testcases[tc++] = new TestCase( + SECTION, + x +" === " + y, + expect, + result ); +} + diff --git a/tests/mozilla/ecma_2/Expressions/instanceof-001.js b/tests/mozilla/ecma_2/Expressions/instanceof-001.js new file mode 100644 index 0000000..2e7412a --- /dev/null +++ b/tests/mozilla/ecma_2/Expressions/instanceof-001.js @@ -0,0 +1,117 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + // RelationalExpression is not an object. + + InstanceOf( true, Boolean, false ); + InstanceOf( new Boolean(false), Boolean, true ); + + // Identifier is not a function + +// InstanceOf( true, true, false ); +// InstanceOf( new Boolean(true), false, false ); + + // Identifier is a function, prototype of Identifier is not an object + +// InstanceOf( new GenB(), GenB, false ); + + // __proto__ of RelationalExpression is null. should return false + genA = new GenA(); + genA.__proto__ = null; + + InstanceOf( genA, GenA, false ); + + // RelationalExpression.__proto__ == (but not ===) Identifier.prototype + + InstanceOf( new Gen2(), Gen0, false ); + InstanceOf( new Gen2(), Gen1, false ); + InstanceOf( new Gen2(), Gen2, true ); + InstanceOf( new Gen2(), Gen3, true ); + + // RelationalExpression.__proto__.__proto__ === Identifier.prototype + InstanceOf( new Gen0(), Gen0, true ); + InstanceOf( new Gen0(), Gen1, true ); + InstanceOf( new Gen0(), Gen2, true ); + InstanceOf( new Gen0(), Gen3, true ); + + InstanceOf( new Gen0(), Object, true ); + InstanceOf( new Gen0(), Function, false ); + + InstanceOf( Gen0, Function, true ); + InstanceOf( Gen0, Object, true ); + + test(); \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Expressions/instanceof-002.js b/tests/mozilla/ecma_2/Expressions/instanceof-002.js new file mode 100644 index 0000000..68697d0 --- /dev/null +++ b/tests/mozilla/ecma_2/Expressions/instanceof-002.js @@ -0,0 +1,124 @@ +/** + File Name: instanceof-002.js + Section: + Description: Determining Instance Relationships + + This test is the same as js1_3/inherit/proto-002, except that it uses + the builtin instanceof operator rather than a user-defined function + called InstanceOf. + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +// onerror = err; + + var SECTION = "instanceof-002"; + var VERSION = "ECMA_2"; + var TITLE = "Determining Instance Relationships"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + +function InstanceOf( object, constructor ) { + while ( object != null ) { + if ( object == constructor.prototype ) { + return true; + } + object = object.__proto__; + } + return false; +} + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} + +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +var pat = new Engineer() + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__ == WorkerBee.prototype", + true, + pat.__proto__.__proto__ == WorkerBee.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__ == Employee.prototype", + true, + pat.__proto__.__proto__.__proto__ == Employee.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", + true, + pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", + true, + pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof Engineer", + true, + pat instanceof Engineer ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof WorkerBee )", + true, + pat instanceof WorkerBee ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof Employee )", + true, + pat instanceof Employee ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof Object )", + true, + pat instanceof Object ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof SalesPerson )", + false, + pat instanceof SalesPerson ); + test(); diff --git a/tests/mozilla/ecma_2/Expressions/instanceof-003-n.js b/tests/mozilla/ecma_2/Expressions/instanceof-003-n.js new file mode 100644 index 0000000..f48108e --- /dev/null +++ b/tests/mozilla/ecma_2/Expressions/instanceof-003-n.js @@ -0,0 +1,93 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + // RelationalExpression is not an object. + + InstanceOf( true, Boolean, false ); +// InstanceOf( new Boolean(false), Boolean, true ); + + // Identifier is not a function + + InstanceOf( true, true, false ); +// InstanceOf( new Boolean(true), false, false ); + + // Identifier is a function, prototype of Identifier is not an object + +// InstanceOf( new GenB(), GenB, false ); + + + test(); \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Expressions/instanceof-004-n.js b/tests/mozilla/ecma_2/Expressions/instanceof-004-n.js new file mode 100644 index 0000000..664a553 --- /dev/null +++ b/tests/mozilla/ecma_2/Expressions/instanceof-004-n.js @@ -0,0 +1,92 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + // RelationalExpression is not an object. + + InstanceOf( true, Boolean, false ); + InstanceOf( new Boolean(false), Boolean, true ); + + // Identifier is not a function + + InstanceOf( new Boolean(true), false, false ); + + // Identifier is a function, prototype of Identifier is not an object + +// InstanceOf( new GenB(), GenB, false ); + + + test(); \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Expressions/instanceof-005-n.js b/tests/mozilla/ecma_2/Expressions/instanceof-005-n.js new file mode 100644 index 0000000..c3a621d --- /dev/null +++ b/tests/mozilla/ecma_2/Expressions/instanceof-005-n.js @@ -0,0 +1,84 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + + // Identifier is a function, prototype of Identifier is not an object + + InstanceOf( new GenB(), GenB, false ); + + + test(); \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Expressions/instanceof-006.js b/tests/mozilla/ecma_2/Expressions/instanceof-006.js new file mode 100644 index 0000000..f1be0b4 --- /dev/null +++ b/tests/mozilla/ecma_2/Expressions/instanceof-006.js @@ -0,0 +1,83 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + // RelationalExpression is not an object. + +// InstanceOf( true, Boolean, false ); + InstanceOf( new Boolean(false), Boolean, true ); + + test(); \ No newline at end of file diff --git a/tests/mozilla/ecma_2/FunctionObjects/apply-001-n.js b/tests/mozilla/ecma_2/FunctionObjects/apply-001-n.js new file mode 100644 index 0000000..2a2bf40 --- /dev/null +++ b/tests/mozilla/ecma_2/FunctionObjects/apply-001-n.js @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +print ("STATUS: f.apply crash test."); + +print ("BUGNUMBER: 21836"); + +function f () +{ +} + +test (); + +function test () +{ + f.apply(2,2); +} + diff --git a/tests/mozilla/ecma_2/FunctionObjects/call-1.js b/tests/mozilla/ecma_2/FunctionObjects/call-1.js new file mode 100644 index 0000000..9ea9074 --- /dev/null +++ b/tests/mozilla/ecma_2/FunctionObjects/call-1.js @@ -0,0 +1,40 @@ +/** + File Name: call-1.js + Section: Function.prototype.call + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "call-1"; + var VERSION = "ECMA_2"; + var TITLE = "Function.prototype.call"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + testcases[tc++] = new TestCase( SECTION, + "ToString.call( this, this )", + GLOBAL, + ToString.call( this, this ) ); + + testcases[tc++] = new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype )", + "false", + ToString.call( Boolean, Boolean.prototype ) ); + + testcases[tc++] = new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype.valueOf() )", + "false", + ToString.call( Boolean, Boolean.prototype.valueOf() ) ); + + test(); + +function ToString( obj ) { + return obj +""; +} \ No newline at end of file diff --git a/tests/mozilla/ecma_2/LexicalConventions/keywords-001.js b/tests/mozilla/ecma_2/LexicalConventions/keywords-001.js new file mode 100644 index 0000000..19e930d --- /dev/null +++ b/tests/mozilla/ecma_2/LexicalConventions/keywords-001.js @@ -0,0 +1,31 @@ +/** + * File Name: + * ECMA Section: + * Description: + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = ""; + var VERSION = "ECMA_2"; + var TITLE = "Keywords"; + + startTest(); + + var result = "failed"; + + try { + eval("super;"); + } + catch (x) { + if (x instanceof SyntaxError) + result = x.name; + } + + AddTestCase( + "using the expression \"super\" shouldn't cause js to crash", + "SyntaxError", + result ); + + test(); diff --git a/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-001.js b/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-001.js new file mode 100644 index 0000000..6af945b --- /dev/null +++ b/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-001.js @@ -0,0 +1,38 @@ +/** + * File Name: LexicalConventions/regexp-literals-001.js + * ECMA Section: 7.8.5 + * Description: + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "LexicalConventions/regexp-literals-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "Regular Expression Literals"; + + startTest(); + + // Regular Expression Literals may not be empty; // should be regarded + // as a comment, not a RegExp literal. + + s = //; + + "passed"; + + AddTestCase( + "// should be a comment, not a regular expression literal", + "passed", + String(s)); + + AddTestCase( + "// typeof object should be type of object declared on following line", + "passed", + (typeof s) == "string" ? "passed" : "failed" ); + + AddTestCase( + "// should not return an object of the type RegExp", + "passed", + (typeof s == "object") ? "failed" : "passed" ); + + test(); diff --git a/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-002.js b/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-002.js new file mode 100644 index 0000000..c67184b --- /dev/null +++ b/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-002.js @@ -0,0 +1,22 @@ +/** + * File Name: LexicalConventions/regexp-literals-002.js + * ECMA Section: 7.8.5 + * Description: Based on ECMA 2 Draft 8 October 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "LexicalConventions/regexp-literals-002.js"; + var VERSION = "ECMA_2"; + var TITLE = "Regular Expression Literals"; + + startTest(); + + // A regular expression literal represents an object of type RegExp. + + AddTestCase( + "// A regular expression literal represents an object of type RegExp.", + "true", + (/x*/ instanceof RegExp).toString() ); + + test(); diff --git a/tests/mozilla/ecma_2/RegExp/constructor-001.js b/tests/mozilla/ecma_2/RegExp/constructor-001.js new file mode 100644 index 0000000..be904e5 --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/constructor-001.js @@ -0,0 +1,66 @@ +/** + * File Name: RegExp/constructor-001.js + * ECMA Section: 15.7.3.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/constructor-001"; + var VERSION = "ECMA_2"; + var TITLE = "new RegExp()"; + + startTest(); + + /* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ + + RegExp.prototype.getClassProperty = Object.prototype.toString; + var re = new RegExp(); + + AddTestCase( + "new RegExp().__proto__", + RegExp.prototype, + re.__proto__ + ); + + AddTestCase( + "RegExp.prototype.getClassProperty = Object.prototype.toString; " + + "(new RegExp()).getClassProperty()", + "[object RegExp]", + re.getClassProperty() ); + + AddTestCase( + "(new RegExp()).source", + "", + re.source ); + + AddTestCase( + "(new RegExp()).global", + false, + re.global ); + + AddTestCase( + "(new RegExp()).ignoreCase", + false, + re.ignoreCase ); + + AddTestCase( + "(new RegExp()).multiline", + false, + re.multiline ); + + AddTestCase( + "(new RegExp()).lastIndex", + 0, + re.lastIndex ); + + test() diff --git a/tests/mozilla/ecma_2/RegExp/exec-001.js b/tests/mozilla/ecma_2/RegExp/exec-001.js new file mode 100644 index 0000000..69edc11 --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/exec-001.js @@ -0,0 +1,34 @@ +/** + * File Name: RegExp/exec-001.js + * ECMA Section: 15.7.5.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/exec-001"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp.prototype.exec(string)"; + + startTest(); + + /* + * for each test case, verify: + * - type of object returned + * - length of the returned array + * - value of lastIndex + * - value of index + * - value of input + * - value of the array indices + */ + + // test cases without subpatterns + // test cases with subpatterns + // global property is true + // global property is false + // test cases in which the exec returns null + + testcases[0] = { expect:"PASSED", actual:"PASSED", description:"NO TESTS EXIST" }; + + test(); + diff --git a/tests/mozilla/ecma_2/RegExp/exec-002.js b/tests/mozilla/ecma_2/RegExp/exec-002.js new file mode 100644 index 0000000..c811b61 --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/exec-002.js @@ -0,0 +1,182 @@ +/** + * File Name: RegExp/exec-002.js + * ECMA Section: 15.7.5.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Test cases provided by rogerl@netscape.com + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/exec-002"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp.prototype.exec(string)"; + + startTest(); + + /* + * for each test case, verify: + * - type of object returned + * - length of the returned array + * - value of lastIndex + * - value of index + * - value of input + * - value of the array indices + */ + + AddRegExpCases( + /(a|d|q|)x/i, + "bcaDxqy", + 3, + ["Dx", "D"] ); + + AddRegExpCases( + /(a|(e|q))(x|y)/, + "bcaddxqy", + 6, + ["qy","q","q","y"] ); + + + AddRegExpCases( + /a+b+d/, + "aabbeeaabbs", + 0, + null ); + + AddRegExpCases( + /a*b/, + "aaadaabaaa", + 4, + ["aab"] ); + + AddRegExpCases( + /a*b/, + "dddb", + 3, + ["b"] ); + + AddRegExpCases( + /a*b/, + "xxx", + 0, + null ); + + AddRegExpCases( + /x\d\dy/, + "abcx45ysss235", + 3, + ["x45y"] ); + + AddRegExpCases( + /[^abc]def[abc]+/, + "abxdefbb", + 2, + ["xdefbb"] ); + + AddRegExpCases( + /(a*)baa/, + "ccdaaabaxaabaa", + 9, + ["aabaa", "aa"] ); + + AddRegExpCases( + /(a*)baa/, + "aabaa", + 0, + ["aabaa", "aa"] ); + + AddRegExpCases( + /q(a|b)*q/, + "xxqababqyy", + 2, + ["qababq", "b"] ); + + AddRegExpCases( + /(a(.|[^d])c)*/, + "adcaxc", + 0, + ["adcaxc", "axc", "x"] ); + + AddRegExpCases( + /(a*)b\1/, + "abaaaxaabaayy", + 0, + ["aba", "a"] ); + + AddRegExpCases( + /(a*)b\1/, + "abaaaxaabaayy", + 0, + ["aba", "a"] ); + + AddRegExpCases( + /(a*)b\1/, + "cccdaaabaxaabaayy", + 6, + ["aba", "a"] ); + + AddRegExpCases( + /(a*)b\1/, + "cccdaaabqxaabaayy", + 7, + ["b", ""] ); + + AddRegExpCases( + /"(.|[^"\\\\])*"/, + 'xx\"makudonarudo\"yy', + 2, + ["\"makudonarudo\"", "o"] ); + + AddRegExpCases( + /"(.|[^"\\\\])*"/, + "xx\"ma\"yy", + 2, + ["\"ma\"", "a"] ); + + test(); + +function AddRegExpCases( + regexp, pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + regexp + ".exec(" + pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + regexp + ".exec(" + pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + regexp + ".exec(" + pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + regexp + ".exec(" + pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); +/* + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + regexp + ".exec(" + pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +*/ +} diff --git a/tests/mozilla/ecma_2/RegExp/function-001.js b/tests/mozilla/ecma_2/RegExp/function-001.js new file mode 100644 index 0000000..67c4f21 --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/function-001.js @@ -0,0 +1,66 @@ +/** + * File Name: RegExp/function-001.js + * ECMA Section: 15.7.2.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/function-001"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp( pattern, flags )"; + + startTest(); + + /* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ + + RegExp.prototype.getClassProperty = Object.prototype.toString; + var re = new RegExp(); + + AddTestCase( + "new RegExp().__proto__", + RegExp.prototype, + re.__proto__ + ); + + AddTestCase( + "RegExp.prototype.getClassProperty = Object.prototype.toString; " + + "(new RegExp()).getClassProperty()", + "[object RegExp]", + re.getClassProperty() ); + + AddTestCase( + "(new RegExp()).source", + "", + re.source ); + + AddTestCase( + "(new RegExp()).global", + false, + re.global ); + + AddTestCase( + "(new RegExp()).ignoreCase", + false, + re.ignoreCase ); + + AddTestCase( + "(new RegExp()).multiline", + false, + re.multiline ); + + AddTestCase( + "(new RegExp()).lastIndex", + 0, + re.lastIndex ); + + test() diff --git a/tests/mozilla/ecma_2/RegExp/hex-001.js b/tests/mozilla/ecma_2/RegExp/hex-001.js new file mode 100644 index 0000000..122d59c --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/hex-001.js @@ -0,0 +1,63 @@ +/** + * File Name: RegExp/hex-001.js + * ECMA Section: 15.7.3.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Positive test cases for constructing a RegExp object + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/hex-001"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp patterns that contain HexicdecimalEscapeSequences"; + + startTest(); + + // These examples come from 15.7.1, HexidecimalEscapeSequence + + AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] ); + AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] ); + AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] ); + + AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] ); + AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] ); + AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]); + AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + str_regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/RegExp/multiline-001.js b/tests/mozilla/ecma_2/RegExp/multiline-001.js new file mode 100644 index 0000000..51a601c --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/multiline-001.js @@ -0,0 +1,62 @@ +/** + * File Name: RegExp/multiline-001.js + * ECMA Section: + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Date: 19 February 1999 + */ + + var SECTION = "RegExp/multiline-001"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp: multiline flag"; + var BUGNUMBER="343901"; + + startTest(); + + var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" + + "northern flicker\npileated\n"; + + AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] ); + + AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] ); + + test(); + + +function AddRegExpCases + ( regexp, pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + + AddTestCase( + regexp.toString() + ".exec(" + pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + regexp.toString() + ".exec(" + pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + regexp + ".exec(" + pattern +").input", + pattern, + regexp.exec(pattern).input ); + + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + regexp + ".exec(" + pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/RegExp/octal-001.js b/tests/mozilla/ecma_2/RegExp/octal-001.js new file mode 100644 index 0000000..d9d0571 --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/octal-001.js @@ -0,0 +1,72 @@ +/** + * File Name: RegExp/octal-001.js + * ECMA Section: 15.7.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Simple test cases for matching OctalEscapeSequences. + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/octal-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp patterns that contain OctalEscapeSequences"; + var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346196"; + + startTest(); + + +// backreference + AddRegExpCases( + /(.)\1/, + "/(.)\\1/", + "HI!!", + "HI!", + 2, + ["!!", "!"] ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); +/* + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +*/ +} diff --git a/tests/mozilla/ecma_2/RegExp/octal-002.js b/tests/mozilla/ecma_2/RegExp/octal-002.js new file mode 100644 index 0000000..69c8100 --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/octal-002.js @@ -0,0 +1,87 @@ +/** + * File Name: RegExp/octal-002.js + * ECMA Section: 15.7.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Simple test cases for matching OctalEscapeSequences. + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/octal-002.js"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp patterns that contain OctalEscapeSequences"; + var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; + + startTest(); + +// backreference + AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)\8/, + "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", + "aabbccaaabbbccc", + "aabbccaaabbbccc", + 0, + ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); + + AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, + "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", + "aabbccaabbcc", + "aabbccaabbcc", + 0, + ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); + + AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, + "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", + "aabbccaababcc", + "aabbccaababcc", + 0, + ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); +/* + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +*/ +} diff --git a/tests/mozilla/ecma_2/RegExp/octal-003.js b/tests/mozilla/ecma_2/RegExp/octal-003.js new file mode 100644 index 0000000..ac6de01 --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/octal-003.js @@ -0,0 +1,81 @@ +/** + * File Name: RegExp/octal-003.js + * ECMA Section: 15.7.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Simple test cases for matching OctalEscapeSequences. + * Author: christine@netscape.com + * Date: 19 February 1999 + * + * Revised: 02 August 2002 + * Author: pschwartau@netscape.com + * + * WHY: the original test expected the regexp /.\011/ + * to match 'a' + String.fromCharCode(0) + '11' + * + * This is incorrect: the string is a 4-character string consisting of + * the characters <'a'>, , <'1'>, <'1'>. By contrast, the \011 in the + * regexp should be parsed as a single token: it is the octal escape sequence + * for the horizontal tab character '\t' === '\u0009' === '\x09' === '\011'. + * + * So the regexp consists of 2 characters: , <'\t'>. + * There is no match between the regexp and the string. + * + * See the testcase ecma_3/RegExp/octal-002.js for an elaboration. + * + */ + var SECTION = "RegExp/octal-003.js"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp patterns that contain OctalEscapeSequences"; + var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346132"; + + startTest(); + + AddRegExpCases( /.\011/, "/\\011/", "a" + String.fromCharCode(0) + "11", "a\\011", 0, null ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + escape(pattern), + escape(regexp.exec(pattern).input) ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + escape(regexp.exec(pattern).toString()) ); + + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + escape(regexp.exec(pattern)[matches]) ); + } + +} diff --git a/tests/mozilla/ecma_2/RegExp/properties-001.js b/tests/mozilla/ecma_2/RegExp/properties-001.js new file mode 100644 index 0000000..16f265c --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/properties-001.js @@ -0,0 +1,78 @@ +/** + * File Name: RegExp/properties-001.js + * ECMA Section: 15.7.6.js + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/properties-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "Properties of RegExp Instances"; + var BUGNUMBER ="http://scopus/bugsplat/show_bug.cgi?id=346000"; + + startTest(); + + AddRegExpCases( new RegExp, "", false, false, false, 0 ); + AddRegExpCases( /.*/, ".*", false, false, false, 0 ); + AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 ); + AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 ); + AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 ); + AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 ); + AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 ); + AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 ); + + AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 ); + AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 ); + AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 ); + + test(); + +function AddRegExpCases( re, s, g, i, m, l ) { + + AddTestCase( re + ".test == RegExp.prototype.test", + true, + re.test == RegExp.prototype.test ); + + AddTestCase( re + ".toString == RegExp.prototype.toString", + true, + re.toString == RegExp.prototype.toString ); + + AddTestCase( re + ".contructor == RegExp.prototype.constructor", + true, + re.constructor == RegExp.prototype.constructor ); + + AddTestCase( re + ".compile == RegExp.prototype.compile", + true, + re.compile == RegExp.prototype.compile ); + + AddTestCase( re + ".exec == RegExp.prototype.exec", + true, + re.exec == RegExp.prototype.exec ); + + // properties + + AddTestCase( re + ".source", + s, + re.source ); + + AddTestCase( re + ".toString()", + "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), + re.toString() ); + + AddTestCase( re + ".global", + g, + re.global ); + + AddTestCase( re + ".ignoreCase", + i, + re.ignoreCase ); + + AddTestCase( re + ".multiline", + m, + re.multiline); + + AddTestCase( re + ".lastIndex", + l, + re.lastIndex ); +} diff --git a/tests/mozilla/ecma_2/RegExp/properties-002.js b/tests/mozilla/ecma_2/RegExp/properties-002.js new file mode 100644 index 0000000..2496d5f --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/properties-002.js @@ -0,0 +1,125 @@ +/** + * File Name: RegExp/properties-002.js + * ECMA Section: 15.7.6.js + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + //----------------------------------------------------------------------------- +var SECTION = "RegExp/properties-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "Properties of RegExp Instances"; +var BUGNUMBER ="http://scopus/bugsplat/show_bug.cgi?id=346032"; +// ALSO SEE http://bugzilla.mozilla.org/show_bug.cgi?id=124339 + + +startTest(); + +re_1 = /\cA?/g; +re_1.lastIndex = Math.pow(2,31); +AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) ); + +re_2 = /\w*/i; +re_2.lastIndex = Math.pow(2,32) -1; +AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 ); + +re_3 = /\*{0,80}/m; +re_3.lastIndex = Math.pow(2,31) -1; +AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 ); + +re_4 = /^./gim; +re_4.lastIndex = Math.pow(2,30) -1; +AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 ); + +re_5 = /\B/; +re_5.lastIndex = Math.pow(2,30); +AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) ); + +/* + * Brendan: "need to test cases Math.pow(2,32) and greater to see + * whether they round-trip." Reason: thanks to the work done in + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex + * is now stored as a double instead of a uint32 (unsigned integer). + * + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go + * all the way up to Number.MAX_VALUE. So that's why we need cases + * between those two numbers. + * + */ +re_6 = /\B/; +re_6.lastIndex = Math.pow(2,32); +AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) ); + +re_7 = /\B/; +re_7.lastIndex = Math.pow(2,32) + 1; +AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 ); + +re_8 = /\B/; +re_8.lastIndex = Math.pow(2,32) * 2; +AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 ); + +re_9 = /\B/; +re_9.lastIndex = Math.pow(2,40); +AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) ); + +re_10 = /\B/; +re_10.lastIndex = Number.MAX_VALUE; +AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE ); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function AddRegExpCases( re, s, g, i, m, l ){ + + AddTestCase( re + ".test == RegExp.prototype.test", + true, + re.test == RegExp.prototype.test ); + + AddTestCase( re + ".toString == RegExp.prototype.toString", + true, + re.toString == RegExp.prototype.toString ); + + AddTestCase( re + ".contructor == RegExp.prototype.constructor", + true, + re.constructor == RegExp.prototype.constructor ); + + AddTestCase( re + ".compile == RegExp.prototype.compile", + true, + re.compile == RegExp.prototype.compile ); + + AddTestCase( re + ".exec == RegExp.prototype.exec", + true, + re.exec == RegExp.prototype.exec ); + + // properties + + AddTestCase( re + ".source", + s, + re.source ); + + AddTestCase( re + ".toString()", + "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), + re.toString() ); + + AddTestCase( re + ".global", + g, + re.global ); + + AddTestCase( re + ".ignoreCase", + i, + re.ignoreCase ); + + AddTestCase( re + ".multiline", + m, + re.multiline); + + AddTestCase( re + ".lastIndex", + l, + re.lastIndex ); +} diff --git a/tests/mozilla/ecma_2/RegExp/regexp-enumerate-001.js b/tests/mozilla/ecma_2/RegExp/regexp-enumerate-001.js new file mode 100644 index 0000000..9752fa1 --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/regexp-enumerate-001.js @@ -0,0 +1,98 @@ +/** + File Name: regexp-enumerate-001.js + ECMA V2 Section: + Description: Regression Test. + + If instance Native Object have properties that are enumerable, + JavaScript enumerated through the properties twice. This only + happened if objects had been instantiated, but their properties + had not been enumerated. ie, the object inherited properties + from its prototype that are enumerated. + + In the core JavaScript, this is only a problem with RegExp + objects, since the inherited properties of most core JavaScript + objects are not enumerated. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 12 November 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291 + ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5 + RegExp properties should be DontEnum +* +*/ +// onerror = err; + + var SECTION = "regexp-enumerate-001"; + var VERSION = "ECMA_2"; + var TITLE = "Regression Test for Enumerating Properties"; + + var BUGNUMBER="339403"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + /* + * This test expects RegExp instances to have four enumerated properties: + * source, global, ignoreCase, and lastIndex + * + * 99.01.25: now they also have a multiLine instance property. + * + */ + + + var r = new RegExp(); + + var e = new Array(); + + var t = new TestRegExp(); + + for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) }; + + testcases[testcases.length] = new TestCase( SECTION, + "r = new RegExp(); e = new Array(); "+ + "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length", + 0, + e.length ); + + test(); + +function TestRegExp() { + this.addProperty = addProperty; +} +function addProperty(name, value) { + var pass = false; + + if ( eval("this."+name) != void 0 ) { + pass = true; + } else { + eval( "this."+ name+" = "+ false ); + } + + testcases[testcases.length] = new TestCase( SECTION, + "Property: " + name +" already enumerated?", + false, + pass ); + + if ( testcases[ testcases.length-1].passed == false ) { + testcases[testcases.length-1].reason = "property already enumerated"; + + } + +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma_2/RegExp/regress-001.js b/tests/mozilla/ecma_2/RegExp/regress-001.js new file mode 100644 index 0000000..afd45fe --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/regress-001.js @@ -0,0 +1,39 @@ +/** + * File Name: RegExp/regress-001.js + * ECMA Section: N/A + * Description: Regression test case: + * JS regexp anchoring on empty match bug + * http://bugzilla.mozilla.org/show_bug.cgi?id=2157 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/hex-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "JS regexp anchoring on empty match bug"; + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=2157"; + + startTest(); + + AddRegExpCases( /a||b/(''), + "//a||b/('')", + 1, + [''] ); + + test(); + +function AddRegExpCases( regexp, str_regexp, length, matches_array ) { + + AddTestCase( + "( " + str_regexp + " ).length", + regexp.length, + regexp.length ); + + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + "( " + str_regexp + " )[" + matches +"]", + matches_array[matches], + regexp[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/RegExp/unicode-001.js b/tests/mozilla/ecma_2/RegExp/unicode-001.js new file mode 100644 index 0000000..17d0582 --- /dev/null +++ b/tests/mozilla/ecma_2/RegExp/unicode-001.js @@ -0,0 +1,53 @@ +/** + * File Name: RegExp/unicode-001.js + * ECMA Section: 15.7.3.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Positive test cases for constructing a RegExp object + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/unicode-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "new RegExp( pattern, flags )"; + + startTest(); + + // These examples come from 15.7.1, UnicodeEscapeSequence + + AddRegExpCases( /\u0041/, "/\\u0041/", "A", "A", 1, 0, ["A"] ); + AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); + AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); + AddRegExpCases( /\u001g/, "/\\u001g/", "u001g", "u001g", 1, 0, ["u001g"] ); + + AddRegExpCases( /A/, "/A/", "\u0041", "\\u0041", 1, 0, ["A"] ); + AddRegExpCases( /A/, "/A/", "\u00412", "\\u00412", 1, 0, ["A"] ); + AddRegExpCases( /A2/, "/A2/", "\u00412", "\\u00412", 1, 0, ["A2"]); + AddRegExpCases( /A/, "/A/", "A2", "A2", 1, 0, ["A"] ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").length", + length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + str_regexp + " .exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/Statements/dowhile-001.js b/tests/mozilla/ecma_2/Statements/dowhile-001.js new file mode 100644 index 0000000..ffd5300 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/dowhile-001.js @@ -0,0 +1,41 @@ +/** + * File Name: dowhile-001 + * ECMA Section: + * Description: do...while statements + * + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "dowhile-002"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + LabeledContinue( 0, 1 ); + LabeledContinue( 1, 1 ); + LabeledContinue( -1, 1 ); + LabeledContinue( 5, 5 ); + + test(); + +function LabeledContinue( limit, expect ) { + i = 0; + woohoo: + do { + i++; + continue woohoo; + } while ( i < limit ); + + testcases[tc++] = new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); +} diff --git a/tests/mozilla/ecma_2/Statements/dowhile-002.js b/tests/mozilla/ecma_2/Statements/dowhile-002.js new file mode 100644 index 0000000..e921b49 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/dowhile-002.js @@ -0,0 +1,68 @@ +/** + * File Name: dowhile-002 + * ECMA Section: + * Description: do...while statements + * + * Verify that code after a labeled break is not executed. Verify that + * a labeled break breaks you out of the whole labeled block, and not + * just the current iteration statement. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "dowhile-002"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + LabeledContinue( 0, 1 ); + LabeledContinue( 1, 1 ); + LabeledContinue( -1, 1 ); + LabeledContinue( 5, 5 ); + + test(); + +// The labeled statment contains statements after the labeled break. +// Verify that the statements after the break are not executed. + +function LabeledContinue( limit, expect ) { + i = 0; + result1 = "pass"; + result2 = "pass"; + + woohoo: { + do { + i++; + if ( ! (i < limit) ) { + break woohoo; + result1 = "fail: evaluated statement after a labeled break"; + } + } while ( true ); + + result2 = "failed: broke out of loop, but not out of labeled block"; + } + + testcases[tc++] = new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); + + testcases[tc++] = new TestCase( + SECTION, + "breaking out of a do... while loop", + "pass", + result1 ); + + + testcases[tc++] = new TestCase( + SECTION, + "breaking out of a labeled do...while loop", + "pass", + result2 ); +} diff --git a/tests/mozilla/ecma_2/Statements/dowhile-003.js b/tests/mozilla/ecma_2/Statements/dowhile-003.js new file mode 100644 index 0000000..a1ca517 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/dowhile-003.js @@ -0,0 +1,60 @@ +/** + * File Name: dowhile-003 + * ECMA Section: + * Description: do...while statements + * + * Test do while, when the while expression is a JavaScript Number object. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "dowhile-003"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( 1, 1, 0 )); + DoWhile( new DoWhileObject( 1000, 1000, 0 )); + DoWhile( new DoWhileObject( 1001, 1001, 0 )); + DoWhile( new DoWhileObject( 1002, 1001, 1 )); + DoWhile( new DoWhileObject( -1, 1001, -1002 )); + + test(); + +function DoWhileObject( value, iterations, endvalue ) { + this.value = value; + this.iterations = iterations; + this.endvalue = endvalue; +} + +function DoWhile( object ) { + var i = 0; + + do { + object.value = --object.value; + i++; + if ( i > 1000 ) + break; + } while( object.value ); + + testcases[tc++] = new TestCase( + SECTION, + "loop iterations", + object.iterations, + i + ); + + testcases[tc++] = new TestCase( + SECTION, + "object.value", + object.endvalue, + Number( object.value ) + ); + +} \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Statements/dowhile-004.js b/tests/mozilla/ecma_2/Statements/dowhile-004.js new file mode 100644 index 0000000..3c96fc4 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/dowhile-004.js @@ -0,0 +1,64 @@ +/** + * File Name: dowhile-004 + * ECMA Section: + * Description: do...while statements + * + * Test a labeled do...while. Break out of the loop with no label + * should break out of the loop, but not out of the label. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "dowhile-004"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( 0, 1 ); + DoWhile( 1, 1 ); + DoWhile( -1, 1 ); + DoWhile( 5, 5 ); + + test(); + +function DoWhile( limit, expect ) { + i = 0; + result1 = "pass"; + result2 = "failed: broke out of labeled statement unexpectedly"; + + foo: { + do { + i++; + if ( ! (i < limit) ) { + break; + result1 = "fail: evaluated statement after a labeled break"; + } + } while ( true ); + + result2 = "pass"; + } + + testcases[tc++] = new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); + + testcases[tc++] = new TestCase( + SECTION, + "breaking out of a do... while loop", + "pass", + result1 ); + + + testcases[tc++] = new TestCase( + SECTION, + "breaking out of a labeled do...while loop", + "pass", + result2 ); +} diff --git a/tests/mozilla/ecma_2/Statements/dowhile-005.js b/tests/mozilla/ecma_2/Statements/dowhile-005.js new file mode 100644 index 0000000..ce56cb9 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/dowhile-005.js @@ -0,0 +1,70 @@ +/** + * File Name: dowhile-005 + * ECMA Section: + * Description: do...while statements + * + * Test a labeled do...while. Break out of the loop with no label + * should break out of the loop, but not out of the label. + * + * Currently causes an infinite loop in the monkey. Uncomment the + * print statement below and it works OK. + * + * Author: christine@netscape.com + * Date: 26 August 1998 + */ + var SECTION = "dowhile-005"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + var BUGNUMBER = "316293"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + NestedLabel(); + + + test(); + + function NestedLabel() { + i = 0; + result1 = "pass"; + result2 = "fail: did not hit code after inner loop"; + result3 = "pass"; + + outer: { + do { + inner: { +// print( i ); + break inner; + result1 = "fail: did break out of inner label"; + } + result2 = "pass"; + break outer; + print (i); + } while ( i++ < 100 ); + + } + + result3 = "fail: did not break out of outer label"; + + testcases[tc++] = new TestCase( + SECTION, + "number of loop iterations", + 0, + i ); + + testcases[tc++] = new TestCase( + SECTION, + "break out of inner loop", + "pass", + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "break out of outer loop", + "pass", + result2 ); + } \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Statements/dowhile-006.js b/tests/mozilla/ecma_2/Statements/dowhile-006.js new file mode 100644 index 0000000..67dce64 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/dowhile-006.js @@ -0,0 +1,86 @@ +/** + * File Name: dowhile-006 + * ECMA Section: + * Description: do...while statements + * + * A general do...while test. + * + * Author: christine@netscape.com + * Date: 26 August 1998 + */ + var SECTION = "dowhile-006"; + var VERSION = "ECMA_2"; + var TITLE = "do...while"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( false, false, 10 ) ); + DoWhile( new DoWhileObject( true, false, 2 ) ); + DoWhile( new DoWhileObject( false, true, 3 ) ); + DoWhile( new DoWhileObject( true, true, 4 ) ); + + test(); + +function looping( object ) { + object.iterations--; + + if ( object.iterations <= 0 ) { + return false; + } else { + return true; + } +} +function DoWhileObject( breakOut, breakIn, iterations, loops ) { + this.iterations = iterations; + this.loops = loops; + this.breakOut = breakOut; + this.breakIn = breakIn; + this.looping = looping; +} +function DoWhile( object ) { + var result1 = false; + var result2 = false; + + outie: { + innie: { + do { + if ( object.breakOut ) + break outie; + + if ( object.breakIn ) + break innie; + + } while ( looping(object) ); + + // statements should be executed if: + // do...while exits normally + // do...while exits abruptly with no label + + result1 = true; + + } + + // statements should be executed if: + // do...while breaks out with label "innie" + // do...while exits normally + // do...while does not break out with "outie" + + result2 = true; + } + + testcases[tc++] = new TestCase( + SECTION, + "hit code after loop in inner loop", + ( object.breakIn || object.breakOut ) ? false : true , + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "hit code after loop in outer loop", + ( object.breakOut ) ? false : true, + result2 ); +} diff --git a/tests/mozilla/ecma_2/Statements/dowhile-007.js b/tests/mozilla/ecma_2/Statements/dowhile-007.js new file mode 100644 index 0000000..849e70e --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/dowhile-007.js @@ -0,0 +1,94 @@ +/** + * File Name: dowhile-007 + * ECMA Section: + * Description: do...while statements + * + * A general do...while test. + * + * Author: christine@netscape.com + * Date: 26 August 1998 + */ + var SECTION = "dowhile-007"; + var VERSION = "ECMA_2"; + var TITLE = "do...while"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( false, false, false, false )); + DoWhile( new DoWhileObject( true, false, false, false )); + DoWhile( new DoWhileObject( true, true, false, false )); + DoWhile( new DoWhileObject( true, true, true, false )); + DoWhile( new DoWhileObject( true, true, true, true )); + DoWhile( new DoWhileObject( false, false, false, true )); + DoWhile( new DoWhileObject( false, false, true, true )); + DoWhile( new DoWhileObject( false, true, true, true )); + DoWhile( new DoWhileObject( false, false, true, false )); + + test(); + +function DoWhileObject( out1, out2, out3, in1 ) { + this.breakOutOne = out1; + this.breakOutTwo = out2; + this.breakOutThree = out3; + this.breakIn = in1; +} +function DoWhile( object ) { + result1 = false; + result2 = false; + result3 = false; + result4 = false; + + outie: + do { + if ( object.breakOutOne ) { + break outie; + } + result1 = true; + + innie: + do { + if ( object.breakOutTwo ) { + break outie; + } + result2 = true; + + if ( object.breakIn ) { + break innie; + } + result3 = true; + + } while ( false ); + if ( object.breakOutThree ) { + break outie; + } + result4 = true; + } while ( false ); + + testcases[tc++] = new TestCase( + SECTION, + "break one: ", + (object.breakOutOne) ? false : true, + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "break two: ", + (object.breakOutOne||object.breakOutTwo) ? false : true, + result2 ); + + testcases[tc++] = new TestCase( + SECTION, + "break three: ", + (object.breakOutOne||object.breakOutTwo||object.breakIn) ? false : true, + result3 ); + + testcases[tc++] = new TestCase( + SECTION, + "break four: ", + (object.breakOutOne||object.breakOutTwo||object.breakOutThree) ? false: true, + result4 ); +} diff --git a/tests/mozilla/ecma_2/Statements/forin-001.js b/tests/mozilla/ecma_2/Statements/forin-001.js new file mode 100644 index 0000000..63119af --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/forin-001.js @@ -0,0 +1,294 @@ +/** + * File Name: forin-001.js + * ECMA Section: + * Description: The forin-001 statement + * + * Verify that the property name is assigned to the property on the left + * hand side of the for...in expression. + * + * Author: christine@netscape.com + * Date: 28 August 1998 + */ + var SECTION = "forin-001"; + var VERSION = "ECMA_2"; + var TITLE = "The for...in statement"; + var BUGNUMBER="330890"; + var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ForIn_1( { length:4, company:"netscape", year:2000, 0:"zero" } ); + ForIn_2( { length:4, company:"netscape", year:2000, 0:"zero" } ); + ForIn_3( { length:4, company:"netscape", year:2000, 0:"zero" } ); + +// ForIn_6({ length:4, company:"netscape", year:2000, 0:"zero" }); +// ForIn_7({ length:4, company:"netscape", year:2000, 0:"zero" }); + ForIn_8({ length:4, company:"netscape", year:2000, 0:"zero" }); + + test(); + + /** + * Verify that the left side argument is evaluated with every iteration. + * Verify that the name of each property of the object is assigned to a + * a property. + * + */ + function ForIn_1( object ) { + PropertyArray = new Array(); + ValueArray = new Array(); + + for ( PropertyArray[PropertyArray.length] in object ) { + ValueArray[ValueArray.length] = + object[PropertyArray[PropertyArray.length-1]]; + } + + for ( var i = 0; i < PropertyArray.length; i++ ) { + testcases[tc++] = new TestCase( + SECTION, + "object[" + PropertyArray[i] +"]", + object[PropertyArray[i]], + ValueArray[i] + ); + } + + testcases[tc++] = new TestCase( + SECTION, + "object.length", + PropertyArray.length, + object.length ); + } + + /** + * Similar to ForIn_1, except it should increment the counter variable + * every time the left hand expression is evaluated. + */ + function ForIn_2( object ) { + PropertyArray = new Array(); + ValueArray = new Array(); + var i = 0; + + for ( PropertyArray[i++] in object ) { + ValueArray[ValueArray.length] = + object[PropertyArray[PropertyArray.length-1]]; + } + + for ( i = 0; i < PropertyArray.length; i++ ) { + testcases[tc++] = new TestCase( + SECTION, + "object[" + PropertyArray[i] +"]", + object[PropertyArray[i]], + ValueArray[i] + ); + } + + testcases[tc++] = new TestCase( + SECTION, + "object.length", + PropertyArray.length, + object.length ); + } + + /** + * Break out of a for...in loop + * + * + */ + function ForIn_3( object ) { + var checkBreak = "pass"; + var properties = new Array(); + var values = new Array(); + + for ( properties[properties.length] in object ) { + values[values.length] = object[properties[properties.length-1]]; + break; + checkBreak = "fail"; + } + + testcases[tc++] = new TestCase( + SECTION, + "check break out of for...in", + "pass", + checkBreak ); + + testcases[tc++] = new TestCase( + SECTION, + "properties.length", + 1, + properties.length ); + + testcases[tc++] = new TestCase( + SECTION, + "object["+properties[0]+"]", + values[0], + object[properties[0]] ); + } + + /** + * Break out of a labeled for...in loop. + */ + function ForIn_4( object ) { + var result1 = 0; + var result2 = 0; + var result3 = 0; + var result4 = 0; + var i = 0; + var property = new Array(); + + butterbean: { + result1++; + + for ( property[i++] in object ) { + result2++; + break; + result4++; + } + result3++; + } + + testcases[tc++] = new TestCase( + SECTION, + "verify labeled statement is only executed once", + true, + result1 == 1 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify statements in for loop are evaluated", + true, + result2 == i ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled for...in loop", + true, + result4 == 0 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled block", + true, + result3 == 0 ); + } + + /** + * Labeled break out of a labeled for...in loop. + */ + function ForIn_5 (object) { + var result1 = 0; + var result2 = 0; + var result3 = 0; + var result4 = 0; + var i = 0; + var property = new Array(); + + bigredbird: { + result1++; + for ( property[i++] in object ) { + result2++; + break bigredbird; + result4++; + } + result3++; + } + + testcases[tc++] = new TestCase( + SECTION, + "verify labeled statement is only executed once", + true, + result1 == 1 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify statements in for loop are evaluated", + true, + result2 == i ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled for...in loop", + true, + result4 == 0 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled block", + true, + result3 == 0 ); + } + + /** + * Labeled continue from a labeled for...in loop + */ + function ForIn_7( object ) { + var result1 = 0; + var result2 = 0; + var result3 = 0; + var result4 = 0; + var i = 0; + var property = new Array(); + + bigredbird: + for ( property[i++] in object ) { + result2++; + continue bigredbird; + result4++; + } + + testcases[tc++] = new TestCase( + SECTION, + "verify statements in for loop are evaluated", + true, + result2 == i ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled for...in loop", + true, + result4 == 0 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled block", + true, + result3 == 1 ); + } + + + /** + * continue in a for...in loop + * + */ + function ForIn_8( object ) { + var checkBreak = "pass"; + var properties = new Array(); + var values = new Array(); + + for ( properties[properties.length] in object ) { + values[values.length] = object[properties[properties.length-1]]; + break; + checkBreak = "fail"; + } + + testcases[tc++] = new TestCase( + SECTION, + "check break out of for...in", + "pass", + checkBreak ); + + testcases[tc++] = new TestCase( + SECTION, + "properties.length", + 1, + properties.length ); + + testcases[tc++] = new TestCase( + SECTION, + "object["+properties[0]+"]", + values[0], + object[properties[0]] ); + } + diff --git a/tests/mozilla/ecma_2/Statements/forin-002.js b/tests/mozilla/ecma_2/Statements/forin-002.js new file mode 100644 index 0000000..1f527a9 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/forin-002.js @@ -0,0 +1,73 @@ +/** + * File Name: forin-002.js + * ECMA Section: + * Description: The forin-001 statement + * + * Verify that the property name is assigned to the property on the left + * hand side of the for...in expression. + * + * Author: christine@netscape.com + * Date: 28 August 1998 + */ + var SECTION = "forin-002"; + var VERSION = "ECMA_2"; + var TITLE = "The for...in statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function MyObject( value ) { + this.value = value; + this.valueOf = new Function ( "return this.value" ); + this.toString = new Function ( "return this.value + \"\"" ); + this.toNumber = new Function ( "return this.value + 0" ); + this.toBoolean = new Function ( "return Boolean( this.value )" ); + } + + ForIn_1(this); + ForIn_2(this); + + ForIn_1(new MyObject(true)); + ForIn_2(new MyObject(new Boolean(true))); + + ForIn_2(3); + + test(); + + /** + * For ... In in a With Block + * + */ + function ForIn_1( object) { + with ( object ) { + for ( property in object ) { + testcases[tc++] = new TestCase( + SECTION, + "with loop in a for...in loop. ("+object+")["+property +"] == "+ + "eval ( " + property +" )", + true, + object[property] == eval(property) ); + } + } + } + + /** + * With block in a For...In loop + * + */ + function ForIn_2(object) { + for ( property in object ) { + with ( object ) { + testcases[tc++] = new TestCase( + SECTION, + "with loop in a for...in loop. ("+object+")["+property +"] == "+ + "eval ( " + property +" )", + true, + object[property] == eval(property) ); + } + } + } + diff --git a/tests/mozilla/ecma_2/Statements/if-001.js b/tests/mozilla/ecma_2/Statements/if-001.js new file mode 100644 index 0000000..0da212d --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/if-001.js @@ -0,0 +1,39 @@ +/** + * File Name: if-001.js + * ECMA Section: + * Description: The if statement + * + * Verify that assignment in the if expression is evaluated correctly. + * Verifies the fix for bug http://scopus/bugsplat/show_bug.cgi?id=148822. + * + * Author: christine@netscape.com + * Date: 28 August 1998 + */ + var SECTION = "for-001"; + var VERSION = "ECMA_2"; + var TITLE = "The if statement"; + var BUGNUMBER="148822"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var a = 0; + var b = 0; + var result = "passed"; + + if ( a = b ) { + result = "failed: a = b should return 0"; + } + + testcases[tc++] = new TestCase( + SECTION, + "if ( a = b ), where a and b are both equal to 0", + "passed", + result ); + + + test(); + diff --git a/tests/mozilla/ecma_2/Statements/label-001.js b/tests/mozilla/ecma_2/Statements/label-001.js new file mode 100644 index 0000000..83b51ce --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/label-001.js @@ -0,0 +1,39 @@ +/** + * File Name: label-001.js + * ECMA Section: + * Description: Labeled statements + * + * Labeled break and continue within a for loop. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "label-003"; + var VERSION = "ECMA_2"; + var TITLE = "Labeled statements"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + LabelTest(0, 0); + LabelTest(1, 1) + LabelTest(-1, 1000); + LabelTest(false, 0); + LabelTest(true, 1); + + test(); + + function LabelTest( limit, expect) { + woo: for ( var result = 0; result < 1000; result++ ) { if (result == limit) { break woo; } else { continue woo; } }; + + testcases[tc++] = new TestCase( + SECTION, + "break out of a labeled for loop: "+ limit, + expect, + result ); + } + diff --git a/tests/mozilla/ecma_2/Statements/label-002.js b/tests/mozilla/ecma_2/Statements/label-002.js new file mode 100644 index 0000000..64b01a8 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/label-002.js @@ -0,0 +1,53 @@ +/** + * File Name: label-002.js + * ECMA Section: + * Description: Labeled statements + * + * Labeled break and continue within a for-in loop. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "label-002"; + var VERSION = "ECMA_2"; + var TITLE = "Labeled statements"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + LabelTest( { p1:"hi,", p2:" norris" }, "hi, norris", " norrishi," ); + LabelTest( { 0:"zero", 1:"one" }, "zeroone", "onezero" ); + + LabelTest2( { p1:"hi,", p2:" norris" }, "hi,", " norris" ); + LabelTest2( { 0:"zero", 1:"one" }, "zero", "one" ); + + test(); + + function LabelTest( object, expect1, expect2 ) { + result = ""; + + yoohoo: { for ( property in object ) { result += object[property]; }; break yoohoo }; + + testcases[tc++] = new TestCase( + SECTION, + "yoohoo: for ( property in object ) { result += object[property]; } break yoohoo }", + true, + result == expect1 || result == expect2 ); + } + + function LabelTest2( object, expect1, expect2 ) { + result = ""; + + yoohoo: { for ( property in object ) { result += object[property]; break yoohoo } }; ; + + testcases[tc++] = new TestCase( + SECTION, + "yoohoo: for ( property in object ) { result += object[property]; break yoohoo }}", + true, + result == expect1 || result == expect2 ); + } + diff --git a/tests/mozilla/ecma_2/Statements/switch-001.js b/tests/mozilla/ecma_2/Statements/switch-001.js new file mode 100644 index 0000000..6336518 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/switch-001.js @@ -0,0 +1,64 @@ +/** + * File Name: switch-001.js + * ECMA Section: + * Description: The switch Statement + * + * A simple switch test with no abrupt completions. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ + var SECTION = "switch-001"; + var VERSION = "ECMA_2"; + var TITLE = "The switch statement"; + + var BUGNUMBER="315767"; + + + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + SwitchTest( 0, 126 ); + SwitchTest( 1, 124 ); + SwitchTest( 2, 120 ); + SwitchTest( 3, 112 ); + SwitchTest( 4, 64 ); + SwitchTest( 5, 96 ); + SwitchTest( true, 96 ); + SwitchTest( false, 96 ); + SwitchTest( null, 96 ); + SwitchTest( void 0, 96 ); + SwitchTest( "0", 96 ); + + test(); + + function SwitchTest( input, expect ) { + var result = 0; + + switch ( input ) { + case 0: + result += 2; + case 1: + result += 4; + case 2: + result += 8; + case 3: + result += 16; + default: + result += 32; + case 4: + result +=64; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch with no breaks, case expressions are numbers. input is "+ + input, + expect, + result ); + } diff --git a/tests/mozilla/ecma_2/Statements/switch-002.js b/tests/mozilla/ecma_2/Statements/switch-002.js new file mode 100644 index 0000000..20746a8 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/switch-002.js @@ -0,0 +1,60 @@ +/** + * File Name: switch-002.js + * ECMA Section: + * Description: The switch Statement + * + * A simple switch test with no abrupt completions. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ + var SECTION = "switch-002"; + var VERSION = "ECMA_2"; + var TITLE = "The switch statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + SwitchTest( 0, 6 ); + SwitchTest( 1, 4 ); + SwitchTest( 2, 56 ); + SwitchTest( 3, 48 ); + SwitchTest( 4, 64 ); + SwitchTest( true, 32 ); + SwitchTest( false, 32 ); + SwitchTest( null, 32 ); + SwitchTest( void 0, 32 ); + SwitchTest( "0", 32 ); + + test(); + + function SwitchTest( input, expect ) { + var result = 0; + + switch ( input ) { + case 0: + result += 2; + case 1: + result += 4; + break; + case 2: + result += 8; + case 3: + result += 16; + default: + result += 32; + break; + case 4: + result += 64; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); + } diff --git a/tests/mozilla/ecma_2/Statements/switch-003.js b/tests/mozilla/ecma_2/Statements/switch-003.js new file mode 100644 index 0000000..6a1389c --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/switch-003.js @@ -0,0 +1,54 @@ +/** + * File Name: switch-003.js + * ECMA Section: + * Description: The switch Statement + * + * Attempt to verify that case statements are evaluated in source order + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ + var SECTION = "switch-003"; + var VERSION = "ECMA_2"; + var TITLE = "The switch statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + SwitchTest( "a", "abc" ); + SwitchTest( "b", "bc" ); + SwitchTest( "c", "c" ); + SwitchTest( "d", "*abc" ); + SwitchTest( "v", "*abc" ); + SwitchTest( "w", "w*abc" ); + SwitchTest( "x", "xw*abc" ); + SwitchTest( "y", "yxw*abc" ); + SwitchTest( "z", "zyxw*abc" ); +// SwitchTest( new java.lang.String("z"), "*abc" ); + + test(); + + function SwitchTest( input, expect ) { + var result = ""; + + switch ( input ) { + case "z": result += "z"; + case "y": result += "y"; + case "x": result += "x"; + case "w": result += "w"; + default: result += "*"; + case "a": result += "a"; + case "b": result += "b"; + case "c": result += "c"; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); + } \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Statements/switch-004.js b/tests/mozilla/ecma_2/Statements/switch-004.js new file mode 100644 index 0000000..23da926 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/switch-004.js @@ -0,0 +1,91 @@ +/** + * File Name: switch-003.js + * ECMA Section: + * Description: The switch Statement + * + * This uses variables and objects as case expressions in switch statements. + * This verifies a bunch of bugs: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315988 + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315975 + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315954 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ + var SECTION = "switch-003"; + var VERSION = "ECMA_2"; + var TITLE = "The switch statement"; + var BUGNUMBER= "315988"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ONE = new Number(1); + ZERO = new Number(0); + var A = new String("A"); + var B = new String("B"); + TRUE = new Boolean( true ); + FALSE = new Boolean( false ); + UNDEFINED = void 0; + NULL = null; + + SwitchTest( ZERO, "ZERO" ); + SwitchTest( NULL, "NULL" ); + SwitchTest( UNDEFINED, "UNDEFINED" ); + SwitchTest( FALSE, "FALSE" ); + SwitchTest( false, "false" ); + SwitchTest( 0, "0" ); + + SwitchTest ( TRUE, "TRUE" ); + SwitchTest( 1, "1" ); + SwitchTest( ONE, "ONE" ); + SwitchTest( true, "true" ); + + SwitchTest( "a", "a" ); + SwitchTest( A, "A" ); + SwitchTest( "b", "b" ); + SwitchTest( B, "B" ); + + SwitchTest( new Boolean( true ), "default" ); + SwitchTest( new Boolean(false ), "default" ); + SwitchTest( new String( "A" ), "default" ); + SwitchTest( new Number( 0 ), "default" ); + + test(); + + function SwitchTest( input, expect ) { + var result = ""; + + switch ( input ) { + default: result += "default"; break; + case "a": result += "a"; break; + case "b": result += "b"; break; + case A: result += "A"; break; + case B: result += "B"; break; + case new Boolean(true): result += "new TRUE"; break; + case new Boolean(false): result += "new FALSE"; break; + case NULL: result += "NULL"; break; + case UNDEFINED: result += "UNDEFINED"; break; + case true: result += "true"; break; + case false: result += "false"; break; + case TRUE: result += "TRUE"; break; + case FALSE: result += "FALSE"; break; + case 0: result += "0"; break; + case 1: result += "1"; break; + case new Number(0) : result += "new ZERO"; break; + case new Number(1) : result += "new ONE"; break; + case ONE: result += "ONE"; break; + case ZERO: result += "ZERO"; break; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); + } diff --git a/tests/mozilla/ecma_2/Statements/try-001.js b/tests/mozilla/ecma_2/Statements/try-001.js new file mode 100644 index 0000000..bcd0eac --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-001.js @@ -0,0 +1,82 @@ +/** + * File Name: try-001.js + * ECMA Section: + * Description: The try statement + * + * This test contains try, catch, and finally blocks. An exception is + * sometimes thrown by a function called from within the try block. + * + * This test doesn't actually make any LiveConnect calls. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = ""; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var INVALID_JAVA_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; + + TryNewJavaInteger( "3.14159", INVALID_JAVA_INTEGER_VALUE ); + TryNewJavaInteger( NaN, INVALID_JAVA_INTEGER_VALUE ); + TryNewJavaInteger( 0, 0 ); + TryNewJavaInteger( -1, -1 ); + TryNewJavaInteger( 1, 1 ); + TryNewJavaInteger( Infinity, Infinity ); + + test(); + + /** + * Check to see if the input is valid for java.lang.Integer. If it is + * not valid, throw INVALID_JAVA_INTEGER_VALUE. If input is valid, + * return Number( v ) + * + */ + + function newJavaInteger( v ) { + value = Number( v ); + if ( Math.floor(value) != value || isNaN(value) ) { + throw ( INVALID_JAVA_INTEGER_VALUE ); + } else { + return value; + } + } + + /** + * Call newJavaInteger( value ) from within a try block. Catch any + * exception, and store it in result. Verify that we got the right + * return value from newJavaInteger in cases in which we do not expect + * exceptions, and that we got the exception in cases where an exception + * was expected. + */ + function TryNewJavaInteger( value, expect ) { + var finalTest = false; + + try { + result = newJavaInteger( value ); + } catch ( e ) { + result = String( e ); + } finally { + finalTest = true; + } + testcases[tc++] = new TestCase( + SECTION, + "newJavaValue( " + value +" )", + expect, + result); + + testcases[tc++] = new TestCase( + SECTION, + "newJavaValue( " + value +" ) hit finally block", + true, + finalTest); + + } + diff --git a/tests/mozilla/ecma_2/Statements/try-003.js b/tests/mozilla/ecma_2/Statements/try-003.js new file mode 100644 index 0000000..de1e213 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-003.js @@ -0,0 +1,79 @@ +/** + * File Name: try-003.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with no catch, and a finally. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-003"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=313585"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + // Tests start here. + + TrySomething( "x = \"hi\"", false ); + TrySomething( "throw \"boo\"", true ); + TrySomething( "throw 3", true ); + + test(); + + /** + * This function contains a try block with no catch block, + * but it does have a finally block. Try to evaluate expressions + * that do and do not throw exceptions. + */ + + function TrySomething( expression, throwing ) { + innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; + if (throwing) { + outerCatch = "FAILED: NO EXCEPTION CAUGHT"; + } else { + outerCatch = "PASS"; + } + outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; + + try { + try { + eval( expression ); + } finally { + innerFinally = "PASS"; + } + } catch ( e ) { + if (throwing) { + outerCatch = "PASS"; + } else { + outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; + } + } finally { + outerFinally = "PASS"; + } + + + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + innerFinally ); + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + outerCatch ); + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + outerFinally ); + + + } diff --git a/tests/mozilla/ecma_2/Statements/try-004.js b/tests/mozilla/ecma_2/Statements/try-004.js new file mode 100644 index 0000000..b36dc44 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-004.js @@ -0,0 +1,51 @@ +/** + * File Name: try-004.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with one catch block but no finally. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-004"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + TryToCatch( "Math.PI", Math.PI ); + TryToCatch( "Thrower(5)", "Caught 5" ); + TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); + + test(); + + function Thrower( v ) { + throw "Caught " + v; + } + + /** + * Evaluate a string. Catch any exceptions thrown. If no exception is + * expected, verify the result of the evaluation. If an exception is + * expected, verify that we got the right exception. + */ + + function TryToCatch( value, expect ) { + try { + result = eval( value ); + } catch ( e ) { + result = e; + } + + testcases[tc++] = new TestCase( + SECTION, + "eval( " + value +" )", + expect, + result ); + } + + diff --git a/tests/mozilla/ecma_2/Statements/try-005.js b/tests/mozilla/ecma_2/Statements/try-005.js new file mode 100644 index 0000000..94b5beb --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-005.js @@ -0,0 +1,54 @@ +/** + * File Name: try-005.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with one catch block but no finally. Same + * as try-004, but the eval statement is called from a function, not + * directly from within the try block. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-005"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + TryToCatch( "Math.PI", Math.PI ); + TryToCatch( "Thrower(5)", "Caught 5" ); + TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); + + test(); + + function Thrower( v ) { + throw "Caught " + v; + } + function Eval( v ) { + return eval( v ); + } + + /** + * Evaluate a string. Catch any exceptions thrown. If no exception is + * expected, verify the result of the evaluation. If an exception is + * expected, verify that we got the right exception. + */ + + function TryToCatch( value, expect ) { + try { + result = Eval( value ); + } catch ( e ) { + result = e; + } + + testcases[tc++] = new TestCase( + SECTION, + "eval( " + value +" )", + expect, + result ); + } diff --git a/tests/mozilla/ecma_2/Statements/try-006.js b/tests/mozilla/ecma_2/Statements/try-006.js new file mode 100644 index 0000000..924f24d --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-006.js @@ -0,0 +1,84 @@ +/** + * File Name: try-006.js + * ECMA Section: + * Description: The try statement + * + * Throw an exception from within a With block in a try block. Verify + * that any expected exceptions are caught. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-006"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + /** + * This is the "check" function for test objects that will + * throw an exception. + */ + function throwException() { + throw EXCEPTION_STRING +": " + this.valueOf(); + } + var EXCEPTION_STRING = "Exception thrown:"; + + /** + * This is the "check" function for test objects that do not + * throw an exception + */ + function noException() { + return this.valueOf(); + } + + /** + * Add test cases here + */ + TryWith( new TryObject( "hello", throwException, true )); + TryWith( new TryObject( "hola", noException, false )); + + /** + * Run the test. + */ + + test(); + + /** + * This is the object that will be the "this" in a with block. + */ + function TryObject( value, fun, exception ) { + this.value = value; + this.exception = exception; + + this.valueOf = new Function ( "return this.value" ); + this.check = fun; + } + + /** + * This function has the try block that has a with block within it. + * Test cases are added in this function. Within the with block, the + * object's "check" function is called. If the test object's exception + * property is true, we expect the result to be the exception value. + * If exception is false, then we expect the result to be the value of + * the object. + */ + function TryWith( object ) { + try { + with ( object ) { + result = check(); + } + } catch ( e ) { + result = e; + } + + testcases[tc++] = new TestCase( + SECTION, + "TryWith( " + object.value +" )", + (object.exception ? EXCEPTION_STRING +": " + object.valueOf() : object.valueOf()), + result ); + } diff --git a/tests/mozilla/ecma_2/Statements/try-007.js b/tests/mozilla/ecma_2/Statements/try-007.js new file mode 100644 index 0000000..14a960a --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-007.js @@ -0,0 +1,89 @@ +/** + * File Name: try-007.js + * ECMA Section: + * Description: The try statement + * + * This test has a for-in statement within a try block. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-007"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement: for-in"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + /** + * This is the "check" function for test objects that will + * throw an exception. + */ + function throwException() { + throw EXCEPTION_STRING +": " + this.valueOf(); + } + var EXCEPTION_STRING = "Exception thrown:"; + + /** + * This is the "check" function for test objects that do not + * throw an exception + */ + function noException() { + return this.valueOf(); + } + + /** + * Add test cases here + */ + TryForIn( new TryObject( "hello", throwException, true )); + TryForIn( new TryObject( "hola", noException, false )); + + /** + * Run the test. + */ + + test(); + +/** + * This is the object that will be the "this" in a with block. + * The check function is either throwExeption() or noException(). + * See above. + * + */ +function TryObject( value, fun, exception ) { + this.value = value; + this.exception = exception; + + this.check = fun; + this.valueOf = function () { return this.value; } +} + +/** + * This function has a for-in statement within a try block. Test cases + * are added after the try-catch-finally statement. Within the for-in + * block, call a function that can throw an exception. Verify that any + * exceptions are properly caught. + */ + + function TryForIn( object ) { + try { + for ( p in object ) { + if ( typeof object[p] == "function" ) { + result = object[p](); + } + } + } catch ( e ) { + result = e; + } + + testcases[tc++] = new TestCase( + SECTION, + "TryForIn( " + object+ " )", + (object.exception ? EXCEPTION_STRING +": " + object.value : object.value), + result ); + + } diff --git a/tests/mozilla/ecma_2/Statements/try-008.js b/tests/mozilla/ecma_2/Statements/try-008.js new file mode 100644 index 0000000..78092b6 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-008.js @@ -0,0 +1,56 @@ +/** + * File Name: try-008.js + * ECMA Section: + * Description: The try statement + * + * This test has a try block in a constructor. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-008"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement: try in a constructor"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function Integer( value, exception ) { + try { + this.value = checkValue( value ); + } catch ( e ) { + this.value = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Integer( " + value +" )", + (exception ? INVALID_INTEGER_VALUE +": " + value : this.value), + this.value ); + } + + var INVALID_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; + + function checkValue( value ) { + if ( Math.floor(value) != value || isNaN(value) ) { + throw ( INVALID_INTEGER_VALUE +": " + value ); + } else { + return value; + } + } + + // add test cases + + new Integer( 3, false ); + new Integer( NaN, true ); + new Integer( 0, false ); + new Integer( Infinity, false ); + new Integer( -2.12, true ); + new Integer( Math.LN2, true ); + + + test(); diff --git a/tests/mozilla/ecma_2/Statements/try-009.js b/tests/mozilla/ecma_2/Statements/try-009.js new file mode 100644 index 0000000..778e647 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-009.js @@ -0,0 +1,63 @@ +/** + * File Name: try-009.js + * ECMA Section: + * Description: The try statement + * + * This test has a try block within a while block. Verify that an exception + * breaks out of the while. I don't really know why this is an interesting + * test case but Mike Shaver had two of these so what the hey. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-009"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement: try in a while block"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var EXCEPTION_STRING = "Exception thrown: "; + var NO_EXCEPTION_STRING = "No exception thrown: "; + + + TryInWhile( new TryObject( "hello", ThrowException, true ) ); + TryInWhile( new TryObject( "aloha", NoException, false )); + + test(); + + function TryObject( value, throwFunction, result ) { + this.value = value; + this.thrower = throwFunction; + this.result = result; + } + function ThrowException() { + throw EXCEPTION_STRING + this.value; + } + function NoException() { + return NO_EXCEPTION_STRING + this.value; + } + function TryInWhile( object ) { + result = null; + while ( true ) { + try { + object.thrower(); + result = NO_EXCEPTION_STRING + object.value; + break; + } catch ( e ) { + result = e; + break; + } + } + + testcases[tc++] = new TestCase( + SECTION, + "( "+ object +".thrower() )", + (object.result + ? EXCEPTION_STRING + object.value : + NO_EXCEPTION_STRING + object.value), + result ); + } diff --git a/tests/mozilla/ecma_2/Statements/try-010.js b/tests/mozilla/ecma_2/Statements/try-010.js new file mode 100644 index 0000000..eeb7f88 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-010.js @@ -0,0 +1,70 @@ +/** + * File Name: try-010.js + * ECMA Section: + * Description: The try statement + * + * This has a try block nested in the try block. Verify that the + * exception is caught by the right try block, and all finally blocks + * are executed. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-010"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement: try in a tryblock"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var EXCEPTION_STRING = "Exception thrown: "; + var NO_EXCEPTION_STRING = "No exception thrown: "; + + + NestedTry( new TryObject( "No Exceptions Thrown", NoException, NoException, 43 ) ); + NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 )); + NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 )); + NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 )); + + test(); + + function TryObject( description, tryOne, tryTwo, result ) { + this.description = description; + this.tryOne = tryOne; + this.tryTwo = tryTwo; + this.result = result; + } + function ThrowException() { + throw EXCEPTION_STRING + this.value; + } + function NoException() { + return NO_EXCEPTION_STRING + this.value; + } + function NestedTry( object ) { + result = 0; + try { + object.tryOne(); + result += 1; + try { + object.tryTwo(); + result += 2; + } catch ( e ) { + result +=4; + } finally { + result += 8; + } + } catch ( e ) { + result += 16; + } finally { + result += 32; + } + + testcases[tc++] = new TestCase( + SECTION, + object.description, + object.result, + result ); + } diff --git a/tests/mozilla/ecma_2/Statements/try-012.js b/tests/mozilla/ecma_2/Statements/try-012.js new file mode 100644 index 0000000..f8c8e00 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/try-012.js @@ -0,0 +1,92 @@ +/** + * File Name: try-012.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with no catch, and a finally. This is like try-003, + * but throws from a finally block, not the try block. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-012"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + var BUGNUMBER="336872"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + // Tests start here. + + TrySomething( "x = \"hi\"", true ); + TrySomething( "throw \"boo\"", true ); + TrySomething( "throw 3", true ); + + test(); + + /** + * This function contains a try block with no catch block, + * but it does have a finally block. Try to evaluate expressions + * that do and do not throw exceptions. + * + * The productioni TryStatement Block Finally is evaluated as follows: + * 1. Evaluate Block + * 2. Evaluate Finally + * 3. If Result(2).type is normal return result 1 (in the test case, result 1 has + * the completion type throw) + * 4. return result 2 (does not get hit in this case) + * + */ + + function TrySomething( expression, throwing ) { + innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; + if (throwing) { + outerCatch = "FAILED: NO EXCEPTION CAUGHT"; + } else { + outerCatch = "PASS"; + } + outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; + + + // If the inner finally does not throw an exception, the result + // of the try block should be returned. (Type of inner return + // value should be throw if finally executes correctly + + try { + try { + throw 0; + } finally { + innerFinally = "PASS"; + eval( expression ); + } + } catch ( e ) { + if (throwing) { + outerCatch = "PASS"; + } else { + outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; + } + } finally { + outerFinally = "PASS"; + } + + + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" ): evaluated inner finally block", + "PASS", + innerFinally ); + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" ): evaluated outer catch block ", + "PASS", + outerCatch ); + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" ): evaluated outer finally block", + "PASS", + outerFinally ); + } diff --git a/tests/mozilla/ecma_2/Statements/while-001.js b/tests/mozilla/ecma_2/Statements/while-001.js new file mode 100644 index 0000000..f9c0d64 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/while-001.js @@ -0,0 +1,39 @@ +/** + * File Name: while-001 + * ECMA Section: + * Description: while statement + * + * Verify that the while statement is not executed if the while expression is + * false + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "while-001"; + var VERSION = "ECMA_2"; + var TITLE = "while statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile(); + test(); + + function DoWhile() { + result = "pass"; + + while (false) { + result = "fail"; + break; + } + + testcases[tc++] = new TestCase( + SECTION, + "while statement: don't evaluate statement is expression is false", + "pass", + result ); + + } \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Statements/while-002.js b/tests/mozilla/ecma_2/Statements/while-002.js new file mode 100644 index 0000000..3fda04b --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/while-002.js @@ -0,0 +1,83 @@ +/** + * File Name: while-002 + * ECMA Section: + * Description: while statement + * + * Verify that the while statement is not executed if the while expression is + * false + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "while-002"; + var VERSION = "ECMA_2"; + var TITLE = "while statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( + "while expression is null", + null, + "result = \"fail: should not have evaluated statements in while block;break" + ) ); + + DoWhile( new DoWhileObject( + "while expression is undefined", + void 0, + "result = \"fail: should not have evaluated statements in while block; break" + )); + + DoWhile( new DoWhileObject( + "while expression is 0", + 0, + "result = \"fail: should not have evaluated statements in while block; break;" + )); + + DoWhile( new DoWhileObject( + "while expression is eval(\"\")", + eval(""), + "result = \"fail: should not have evaluated statements in while block; break" + )); + + DoWhile( new DoWhileObject( + "while expression is NaN", + NaN, + "result = \"fail: should not have evaluated statements in while block; break" + )); + + test(); + + function DoWhileObject( d, e, s ) { + this.description = d; + this.whileExpression = e; + this.statements = s; + } + + function DoWhile( object ) { + result = "pass"; + + while ( expression = object.whileExpression ) { + eval( object.statements ); + } + + // verify that the while expression was evaluated + + testcases[tc++] = new TestCase( + SECTION, + "verify that while expression was evaluated (should be "+ + object.whileExpression +")", + "pass", + (object.whileExpression == expression || + ( isNaN(object.whileExpression) && isNaN(expression) ) + ) ? "pass" : "fail" ); + + testcases[tc++] = new TestCase( + SECTION, + object.description, + "pass", + result ); + } \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Statements/while-003.js b/tests/mozilla/ecma_2/Statements/while-003.js new file mode 100644 index 0000000..0164f05 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/while-003.js @@ -0,0 +1,84 @@ +/** + * File Name: while-003 + * ECMA Section: + * Description: while statement + * + * The while expression evaluates to true, Statement returns abrupt completion. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "while-003"; + var VERSION = "ECMA_2"; + var TITLE = "while statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( + "while expression is true", + true, + "result = \"pass\";" )); + + DoWhile( new DoWhileObject( + "while expression is 1", + 1, + "result = \"pass\";" )); + + DoWhile( new DoWhileObject( + "while expression is new Boolean(false)", + new Boolean(false), + "result = \"pass\";" )); + + DoWhile( new DoWhileObject( + "while expression is new Object()", + new Object(), + "result = \"pass\";" )); + + DoWhile( new DoWhileObject( + "while expression is \"hi\"", + "hi", + "result = \"pass\";" )); +/* + DoWhile( new DoWhileObject( + "while expression has a continue in it", + "true", + "if ( i == void 0 ) i = 0; result=\"pass\"; if ( ++i == 1 ) {continue;} else {break;} result=\"fail\";" + )); +*/ + test(); + + function DoWhileObject( d, e, s ) { + this.description = d; + this.whileExpression = e; + this.statements = s; + } + + function DoWhile( object ) { + result = "fail: statements in while block were not evaluated"; + + while ( expression = object.whileExpression ) { + eval( object.statements ); + break; + } + + // verify that the while expression was evaluated + + testcases[tc++] = new TestCase( + SECTION, + "verify that while expression was evaluated (should be "+ + object.whileExpression +")", + "pass", + (object.whileExpression == expression || + ( isNaN(object.whileExpression) && isNaN(expression) ) + ) ? "pass" : "fail" ); + + testcases[tc++] = new TestCase( + SECTION, + object.description, + "pass", + result ); + } \ No newline at end of file diff --git a/tests/mozilla/ecma_2/Statements/while-004.js b/tests/mozilla/ecma_2/Statements/while-004.js new file mode 100644 index 0000000..48faeb0 --- /dev/null +++ b/tests/mozilla/ecma_2/Statements/while-004.js @@ -0,0 +1,214 @@ +/** + * File Name: while-004 + * ECMA Section: + * Description: while statement + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "while-004"; + var VERSION = "ECMA_2"; + var TITLE = "while statement"; + var BUGNUMBER="316725"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile_1(); + DoWhile_2(); + DoWhile_3(); + DoWhile_4(); + DoWhile_5(); + + test(); + + /** + * Break out of a while by calling return. + * + * Tests: 12.6.2 step 6. + */ + function dowhile() { + result = "pass"; + + while (true) { + return result; + result = "fail: hit code after return statement"; + break; + } + } + + function DoWhile_1() { + description = "return statement in a while block"; + + result = dowhile(); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_1" + description, + "pass", + result ); + } + + /** + * While with a labeled continue statement. Verify that statements + * after the continue statement are not evaluated. + * + * Tests: 12.6.2 step 8. + * + */ + function DoWhile_2() { + var description = "while with a labeled continue statement"; + var result1 = "pass"; + var result2 = "fail: did not execute code after loop, but inside label"; + var i = 0; + var j = 0; + + theloop: + while( i++ < 10 ) { + j++; + continue theloop; + result1 = "failed: hit code after continue statement"; + } + result2 = "pass"; + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_2: " +description + " - code inside the loop, before the continue should be executed ("+j+")", + true, + j == 10 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_2: " +description +" - code after labeled continue should not be executed", + "pass", + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_2: " +description +" - code after loop but inside label should be executed", + "pass", + result2 ); + } + + /** + * While with a labeled break. + * + */ + function DoWhile_3() { + var description = "while with a labeled break statement"; + var result1 = "pass"; + var result2 = "pass"; + var result3 = "fail: did not get to code after label"; + + woohoo: { + while( true ) { + break woohoo; + result1 = "fail: got to code after a break"; + } + result2 = "fail: got to code outside of loop but inside label"; + } + + result3 = "pass"; + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_3: " +description +" - verify break out of loop", + "pass", + result1 ); + + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_3: " +description +" - verify break out of label", + "pass", + result2 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_3: " +description + " - verify correct exit from label", + "pass", + result3 ); + } + + + /** + * Labled while with an unlabeled break + * + */ + function DoWhile_4() { + var description = "labeled while with an unlabeled break"; + var result1 = "pass"; + var result2 = "pass"; + var result3 = "fail: did not evaluate statement after label"; + + woohooboy: { + while( true ) { + break woohooboy; + result1 = "fail: got to code after the break"; + } + result2 = "fail: broke out of while, but not out of label"; + } + result3 = "pass"; + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_4: " +description +" - verify break out of while loop", + "pass", + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_4: " +description + " - verify break out of label", + "pass", + result2 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_4: " +description +" - verify that statements after label are evaluated", + "pass", + result3 ); + } + + /** + * in this case, should behave the same way as + * + * + */ + function DoWhile_5() { + var description = "while with a labeled continue statement"; + var result1 = "pass"; + var result2 = "fail: did not execute code after loop, but inside label"; + var i = 0; + var j = 0; + + theloop: { + j++; + while( i++ < 10 ) { + continue; + result1 = "failed: hit code after continue statement"; + } + result2 = "pass"; + } + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_5: " +description + " - continue should not execute statements above the loop", + true, + ( j == 1 ) ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_5: " +description +" - code after labeled continue should not be executed", + "pass", + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_5: " +description +" - code after loop but inside label should be executed", + "pass", + result2 ); + } + diff --git a/tests/mozilla/ecma_2/String/match-001.js b/tests/mozilla/ecma_2/String/match-001.js new file mode 100644 index 0000000..738264e --- /dev/null +++ b/tests/mozilla/ecma_2/String/match-001.js @@ -0,0 +1,100 @@ +/** + * File Name: String/match-001.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ + + var SECTION = "String/match-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.match( regexp )"; + + startTest(); + + // the regexp argument is not a RegExp object + // this is not a string object + + // cases in which the regexp global property is false + + AddRegExpCases( 3, "3", "1234567890", 1, 2, ["3"] ); + + // cases in which the regexp object global property is true + + AddGlobalRegExpCases( /34/g, "/34/g", "343443444", 3, ["34", "34", "34"] ); + AddGlobalRegExpCases( /\d{1}/g, "/d{1}/g", "123456abcde7890", 10, + ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] ); + + AddGlobalRegExpCases( /\d{2}/g, "/d{2}/g", "123456abcde7890", 5, + ["12", "34", "56", "78", "90"] ); + + AddGlobalRegExpCases( /\D{2}/g, "/d{2}/g", "123456abcde7890", 2, + ["ab", "cd"] ); + + test(); + + +function AddRegExpCases( + regexp, str_regexp, string, length, index, matches_array ) { + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + string, + string.match(regexp).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} + +function AddGlobalRegExpCases( + regexp, str_regexp, string, length, matches_array ) { + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + length, + string.match(regexp).length ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/String/match-002.js b/tests/mozilla/ecma_2/String/match-002.js new file mode 100644 index 0000000..83ac2fa --- /dev/null +++ b/tests/mozilla/ecma_2/String/match-002.js @@ -0,0 +1,168 @@ +/** + * File Name: String/match-002.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + * + * This file tests cases in which regexp.global is false. Therefore, + * results should behave as regexp.exec with string passed as a parameter. + * + */ + + var SECTION = "String/match-002.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.match( regexp )"; + + startTest(); + + // the regexp argument is not a RegExp object + // this is not a string object + + AddRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/, + "/([\d]{5})([-\ ]?[\d]{4})?$/", + "Boston, Mass. 02134", + 14, + ["02134", "02134", undefined]); + + AddGlobalRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/g, + "/([\d]{5})([-\ ]?[\d]{4})?$/g", + "Boston, Mass. 02134", + ["02134"]); + + // set the value of lastIndex + re = /([\d]{5})([-\ ]?[\d]{4})?$/; + re.lastIndex = 0; + + s = "Boston, MA 02134"; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex =0", + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); + + + re.lastIndex = s.length; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.length, + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined] ); + + re.lastIndex = s.lastIndexOf("0"); + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0"), + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); + + re.lastIndex = s.lastIndexOf("0") + 1; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0") +1, + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); + + test(); + +function AddRegExpCases( + regexp, str_regexp, string, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + string + ".match(" + regexp +")", + matches_array, + string.match(regexp) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + string, + string.match(regexp).input ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} + +function AddGlobalRegExpCases( + regexp, str_regexp, string, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + string +")", + matches_array, + regexp.exec(string) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/String/match-003.js b/tests/mozilla/ecma_2/String/match-003.js new file mode 100644 index 0000000..f63e9e2 --- /dev/null +++ b/tests/mozilla/ecma_2/String/match-003.js @@ -0,0 +1,126 @@ +/** + * File Name: String/match-003.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ + + var SECTION = "String/match-003.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.match( regexp )"; + + startTest(); + + // the regexp argument is not a RegExp object + // this is not a string object + + +// [if regexp.global is true] set the regexp.lastIndex property to 0 and +// invoke RegExp.prototype.exec repeatedly until there is no match. If +// there is a match with an empty string (in other words, if the value of +// regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. +// The value returned is an array with the properties 0 through n-1 +// corresponding to the first element of the result of each matching invocation +// of RegExp.prototype.exec. + + + // set the value of lastIndex + re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + + + s = "Boston, MA 02134"; + + AddGlobalRegExpCases( re, + "re = " + re, + s, + ["02134" ]); + + re.lastIndex = 0; + + AddGlobalRegExpCases( + re, + "re = " + re + "; re.lastIndex = 0 ", + s, + ["02134"]); + + + re.lastIndex = s.length; + + AddGlobalRegExpCases( + re, + "re = " + re + "; re.lastIndex = " + s.length, + s, + ["02134"] ); + + re.lastIndex = s.lastIndexOf("0"); + + AddGlobalRegExpCases( + re, + "re = "+ re +"; re.lastIndex = " + s.lastIndexOf("0"), + s, + ["02134"]); + + re.lastIndex = s.lastIndexOf("0") + 1; + + AddGlobalRegExpCases( + re, + "re = " +re+ "; re.lastIndex = " + (s.lastIndexOf("0") +1), + s, + ["02134"]); + + test(); + +function AddGlobalRegExpCases( + regexp, str_regexp, string, matches_array ) { + + // prevent a runtime error + + if ( string.match(regexp) == null || matches_array == null ) { + AddTestCase( + string + ".match(" + str_regexp +")", + matches_array, + string.match(regexp) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/String/match-004.js b/tests/mozilla/ecma_2/String/match-004.js new file mode 100644 index 0000000..c35d988 --- /dev/null +++ b/tests/mozilla/ecma_2/String/match-004.js @@ -0,0 +1,167 @@ +/** + * File Name: String/match-004.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + * + * + * The match function should be intentionally generic, and not require + * this to be a string. + * + */ + + var SECTION = "String/match-004.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.match( regexp )"; + + var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=345818"; + + startTest(); + + // set the value of lastIndex + re = /0./; + s = 10203040506070809000; + + Number.prototype.match = String.prototype.match; + + AddRegExpCases( re, + "re = " + re , + s, + String(s), + 1, + ["02"]); + + + re.lastIndex = 0; + AddRegExpCases( re, + "re = " + re +" [lastIndex is " + re.lastIndex+"]", + s, + String(s), + 1, + ["02"]); +/* + + re.lastIndex = s.length; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.length, + s, + s.lastIndexOf("0"), + null ); + + re.lastIndex = s.lastIndexOf("0"); + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0"), + s, + s.lastIndexOf("0"), + ["02134"]); + + re.lastIndex = s.lastIndexOf("0") + 1; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0") +1, + s, + 0, + null); +*/ + test(); + +function AddRegExpCases( + regexp, str_regexp, string, str_string, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + string + ".match(" + regexp +")", + matches_array, + string.match(regexp) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + str_string, + string.match(regexp).input ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} + +function AddGlobalRegExpCases( + regexp, str_regexp, string, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + string +")", + matches_array, + regexp.exec(string) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/String/replace-001.js b/tests/mozilla/ecma_2/String/replace-001.js new file mode 100644 index 0000000..5ff8dc0 --- /dev/null +++ b/tests/mozilla/ecma_2/String/replace-001.js @@ -0,0 +1,60 @@ +/** + * File Name: String/replace-001.js + * ECMA Section: 15.6.4.10 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + + var SECTION = "String/replace-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.replace( regexp, replaceValue )"; + + startTest(); + + /* + * If regexp is not an object of type RegExp, it is replaced with the + * result of the expression new RegExp(regexp). Let string denote the + * result of converting the this value to a string. String is searched + * for the first occurrence of the regular expression pattern regexp if + * regexp.global is false, or all occurrences if regexp.global is true. + * + * The match is performed as in String.prototype.match, including the + * update of regexp.lastIndex. Let m be the number of matched + * parenthesized subexpressions as specified in section 15.7.5.3. + * + * If replaceValue is a function, then for each matched substring, call + * the function with the following m + 3 arguments. Argument 1 is the + * substring that matched. The next m arguments are all of the matched + * subexpressions. Argument m + 2 is the length of the left context, and + * argument m + 3 is string. + * + * The result is a string value derived from the original input by + * replacing each matched substring with the corresponding return value + * of the function call, converted to a string if need be. + * + * Otherwise, let newstring denote the result of converting replaceValue + * to a string. The result is a string value derived from the original + * input string by replacing each matched substring with a string derived + * from newstring by replacing characters in newstring by replacement text + * as specified in the following table: + * + * $& The matched substring. + * $‘ The portion of string that precedes the matched substring. + * $’ The portion of string that follows the matched substring. + * $+ The substring matched by the last parenthesized subexpressions in + * the regular expression. + * $n The corresponding matched parenthesized subexpression n, where n + * is a single digit 0-9. If there are fewer than n subexpressions, “$n + * is left unchanged. + * + * Note that the replace function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ + + + testcases[0] = { expect:"PASSED", actual:"PASSED", description:"NO TESTS EXIST" }; + + test(); diff --git a/tests/mozilla/ecma_2/String/split-001.js b/tests/mozilla/ecma_2/String/split-001.js new file mode 100644 index 0000000..b2d7c9c --- /dev/null +++ b/tests/mozilla/ecma_2/String/split-001.js @@ -0,0 +1,106 @@ +/** + * File Name: String/split-001.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * Since regular expressions have been part of JavaScript since 1.2, there + * are already tests for regular expressions in the js1_2/regexp folder. + * + * These new tests try to supplement the existing tests, and verify that + * our implementation of RegExp conforms to the ECMA specification, but + * does not try to be as exhaustive as in previous tests. + * + * The [,limit] argument to String.split is new, and not covered in any + * existing tests. + * + * String.split cases are covered in ecma/String/15.5.4.8-*.js. + * String.split where separator is a RegExp are in + * js1_2/regexp/string_split.js + * + */ + + var SECTION = "ecma_2/String/split-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.split( regexp, [,limit] )"; + + startTest(); + + // the separator is not supplied + // separator is undefined + // separator is an empty string + + AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); + AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); + + // separartor is a regexp + // separator regexp value global setting is set + // string is an empty string + // if separator is an empty string, split each by character + + // this is not a String object + + // limit is not a number + // limit is undefined + // limit is larger than 2^32-1 + // limit is a negative number + + test(); + +function AddSplitCases( string, separator, str_sep, split_array ) { + + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +").constructor == Array", + true, + string.split(separator).constructor == Array ); + + // check the number of items in the array + AddTestCase( + "( " + string + " ).split(" + str_sep +").length", + split_array.length, + string.split(separator).length ); + + // check the value of each array item + var limit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator).length; + + for ( var matches = 0; matches < split_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +")[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } +} + +function AddLimitedSplitCases( + string, separator, str_sep, limit, str_limit, split_array ) { + + // verify that the result of split is an object of type Array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + + " ).constructor == Array", + true, + string.split(separator, limit).constructor == Array ); + + // check the length of the array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + " ).length", + length, + string.split(separator).length ); + + // check the value of each array item + + for ( var matches = 0; matches < split_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + " )[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/String/split-002.js b/tests/mozilla/ecma_2/String/split-002.js new file mode 100644 index 0000000..1007a31 --- /dev/null +++ b/tests/mozilla/ecma_2/String/split-002.js @@ -0,0 +1,264 @@ +/** + * File Name: String/split-002.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * Since regular expressions have been part of JavaScript since 1.2, there + * are already tests for regular expressions in the js1_2/regexp folder. + * + * These new tests try to supplement the existing tests, and verify that + * our implementation of RegExp conforms to the ECMA specification, but + * does not try to be as exhaustive as in previous tests. + * + * The [,limit] argument to String.split is new, and not covered in any + * existing tests. + * + * String.split cases are covered in ecma/String/15.5.4.8-*.js. + * String.split where separator is a RegExp are in + * js1_2/regexp/string_split.js + * + */ + + var SECTION = "ecma_2/String/split-002.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.split( regexp, [,limit] )"; + + startTest(); + + // the separator is not supplied + // separator is undefined + // separator is an empty string + +// AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); +// AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); + + // separator is an empty regexp + // separator is not supplied + + CompareSplit( "hello", "ll" ); + + CompareSplit( "hello", "l" ); + CompareSplit( "hello", "x" ); + CompareSplit( "hello", "h" ); + CompareSplit( "hello", "o" ); + CompareSplit( "hello", "hello" ); + CompareSplit( "hello", undefined ); + + CompareSplit( "hello", ""); + CompareSplit( "hello", "hellothere" ); + + CompareSplit( new String("hello" ) ); + + + Number.prototype.split = String.prototype.split; + + CompareSplit( new Number(100111122133144155), 1 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, 1 ); + + CompareSplitWithLimit(new Number(100111122133144155), 1, 2 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, 0 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, 100 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, void 0 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, Math.pow(2,32)-1 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, "boo" ); + CompareSplitWithLimit(new Number(100111122133144155), 1, -(Math.pow(2,32)-1) ); + CompareSplitWithLimit( "hello", "l", NaN ); + CompareSplitWithLimit( "hello", "l", 0 ); + CompareSplitWithLimit( "hello", "l", 1 ); + CompareSplitWithLimit( "hello", "l", 2 ); + CompareSplitWithLimit( "hello", "l", 3 ); + CompareSplitWithLimit( "hello", "l", 4 ); + + +/* + CompareSplitWithLimit( "hello", "ll", 0 ); + CompareSplitWithLimit( "hello", "ll", 1 ); + CompareSplitWithLimit( "hello", "ll", 2 ); + CompareSplit( "", " " ); + CompareSplit( "" ); +*/ + + // separartor is a regexp + // separator regexp value global setting is set + // string is an empty string + // if separator is an empty string, split each by character + + // this is not a String object + + // limit is not a number + // limit is undefined + // limit is larger than 2^32-1 + // limit is a negative number + + test(); + +function CompareSplit( string, separator ) { + split_1 = string.split( separator ); + split_2 = string_split( string, separator ); + + AddTestCase( + "( " + string +".split(" + separator + ") ).length" , + split_2.length, + split_1.length ); + + var limit = split_1.length > split_2.length ? + split_1.length : split_2.length; + + for ( var split_item = 0; split_item < limit; split_item++ ) { + AddTestCase( + string + ".split(" + separator + ")["+split_item+"]", + split_2[split_item], + split_1[split_item] ); + } +} + +function CompareSplitWithLimit( string, separator, splitlimit ) { + split_1 = string.split( separator, splitlimit ); + split_2 = string_split( string, separator, splitlimit ); + + AddTestCase( + "( " + string +".split(" + separator + ", " + splitlimit+") ).length" , + split_2.length, + split_1.length ); + + var limit = split_1.length > split_2.length ? + split_1.length : split_2.length; + + for ( var split_item = 0; split_item < limit; split_item++ ) { + AddTestCase( + string + ".split(" + separator + ", " + splitlimit+")["+split_item+"]", + split_2[split_item], + split_1[split_item] ); + } +} + +function string_split ( __this, separator, limit ) { + var S = String(__this ); // 1 + + var A = new Array(); // 2 + + if ( limit == undefined ) { // 3 + lim = Math.pow(2, 31 ) -1; + } else { + lim = ToUint32( limit ); + } + + var s = S.length; // 4 + var p = 0; // 5 + + if ( separator == undefined ) { // 8 + A[0] = S; + return A; + } + + if ( separator.constructor == RegExp ) // 6 + R = separator; + else + R = separator.toString(); + + if (lim == 0) return A; // 7 + + if ( separator == undefined ) { // 8 + A[0] = S; + return A; + } + + if (s == 0) { // 9 + z = SplitMatch(R, S, 0); + if (z != false) return A; + A[0] = S; + return A; + } + + var q = p; // 10 +loop: + while (true ) { + + if ( q == s ) break; // 11 + + z = SplitMatch(R, S, q); // 12 + +//print("Returned ", z); + + if (z != false) { // 13 + e = z.endIndex; // 14 + cap = z.captures; // 14 + if (e != p) { // 15 +//print("S = ", S, ", p = ", p, ", q = ", q); + T = S.slice(p, q); // 16 +//print("T = ", T); + A[A.length] = T; // 17 + if (A.length == lim) return A; // 18 + p = e; // 19 + i = 0; // 20 + while (true) { // 25 + if (i == cap.length) { // 21 + q = p; // 10 + continue loop; + } + i = i + 1; // 22 + A[A.length] = cap[i] // 23 + if (A.length == lim) return A; // 24 + } + } + } + + q = q + 1; // 26 + } + + T = S.slice(p, q); + A[A.length] = T; + return A; +} + +function SplitMatch(R, S, q) +{ + if (R.constructor == RegExp) { // 1 + var reResult = R.match(S, q); // 8 + if (reResult == undefined) + return false; + else { + a = new Array(reResult.length - 1); + for (var i = 1; i < reResult.length; i++) + a[a.length] = reResult[i]; + return { endIndex : reResult.index + reResult[0].length, captures : cap }; + } + } + else { + var r = R.length; // 2 + s = S.length; // 3 + if ((q + r) > s) return false; // 4 + for (var i = 0; i < r; i++) { +//print("S.charAt(", q + i, ") = ", S.charAt(q + i), ", R.charAt(", i, ") = ", R.charAt(i)); + if (S.charAt(q + i) != R.charAt(i)) // 5 + return false; + } + cap = new Array(); // 6 + return { endIndex : q + r, captures : cap }; // 7 + } +} + +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 + || Math.abs( n ) == Number.POSITIVE_INFINITY + || n != n) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} diff --git a/tests/mozilla/ecma_2/String/split-003.js b/tests/mozilla/ecma_2/String/split-003.js new file mode 100644 index 0000000..e2f2b92 --- /dev/null +++ b/tests/mozilla/ecma_2/String/split-003.js @@ -0,0 +1,117 @@ +/** + * File Name: String/split-003.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * Since regular expressions have been part of JavaScript since 1.2, there + * are already tests for regular expressions in the js1_2/regexp folder. + * + * These new tests try to supplement the existing tests, and verify that + * our implementation of RegExp conforms to the ECMA specification, but + * does not try to be as exhaustive as in previous tests. + * + * The [,limit] argument to String.split is new, and not covered in any + * existing tests. + * + * String.split cases are covered in ecma/String/15.5.4.8-*.js. + * String.split where separator is a RegExp are in + * js1_2/regexp/string_split.js + * + */ + + var SECTION = "ecma_2/String/split-003.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.split( regexp, [,limit] )"; + + startTest(); + + // separartor is a regexp + // separator regexp value global setting is set + // string is an empty string + // if separator is an empty string, split each by character + + + AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); + + AddSplitCases( "hello", /l/, "/l/", ["he","","o"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 0, [] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 1, ["he"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 2, ["he",""] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 3, ["he","","o"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 4, ["he","","o"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", void 0, ["he","","o"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", "hi", [] ); + AddLimitedSplitCases( "hello", /l/, "/l/", undefined, ["he","","o"] ); + + AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 0, [] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 1, ["h"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 2, ["h","e"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 3, ["h","e","l"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 4, ["h","e","l","l"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", void 0, ["h","e","l","l","o"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", "hi", [] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", undefined, ["h","e","l","l","o"] ); + + test(); + +function AddSplitCases( string, separator, str_sep, split_array ) { + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +").constructor == Array", + true, + string.split(separator).constructor == Array ); + + // check the number of items in the array + AddTestCase( + "( " + string + " ).split(" + str_sep +").length", + split_array.length, + string.split(separator).length ); + + // check the value of each array item + var limit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator).length; + + for ( var matches = 0; matches < split_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +")[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } +} + +function AddLimitedSplitCases( + string, separator, str_sep, limit, split_array ) { + + // verify that the result of split is an object of type Array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + + " ).constructor == Array", + true, + string.split(separator, limit).constructor == Array ); + + // check the length of the array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + " ).length", + split_array.length, + string.split(separator, limit).length ); + + // check the value of each array item + + var slimit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator, limit).length; + + for ( var matches = 0; matches < slimit; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + " )[" + matches +"]", + split_array[matches], + string.split( separator, limit )[matches] ); + } +} diff --git a/tests/mozilla/ecma_2/browser.js b/tests/mozilla/ecma_2/browser.js new file mode 100644 index 0000000..ccc1bb4 --- /dev/null +++ b/tests/mozilla/ecma_2/browser.js @@ -0,0 +1,83 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * + * + * + */ + +onerror = err; + +var GLOBAL = "[object Window]"; + +function startTest() { + writeHeaderToLog( SECTION + " "+ TITLE); + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function writeLineToLog( string ) { + document.write( string + "
\n"); +} +function writeHeaderToLog( string ) { + document.write( "

" + string + "

" ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } + document.write( "
" ); +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = ""+ string ; + s += "" ; + s += ( passed ) ? "  " + PASSED + : " " + FAILED + expect + ""; + writeLineToLog( s + "" ); + return passed; +} +function err( msg, page, line ) { + writeLineToLog( "Test failed on line " + line + " with the message: " + msg ); + + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} diff --git a/tests/mozilla/ecma_2/instanceof/instanceof-001.js b/tests/mozilla/ecma_2/instanceof/instanceof-001.js new file mode 100644 index 0000000..897c2e3 --- /dev/null +++ b/tests/mozilla/ecma_2/instanceof/instanceof-001.js @@ -0,0 +1,31 @@ +/** + File Name: instanceof-1.js + ECMA Section: + Description: instanceof operator + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = ""; + var VERSION = "ECMA_2"; + var TITLE = "instanceof operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var b = new Boolean(); + + testcases[tc++] = new TestCase( SECTION, + "var b = new Boolean(); b instanceof Boolean", + true, + b instanceof Boolean ); + + testcases[tc++] = new TestCase( SECTION, + "b instanceof Object", + true, + b instanceof Object ); + + test(); diff --git a/tests/mozilla/ecma_2/instanceof/instanceof-002.js b/tests/mozilla/ecma_2/instanceof/instanceof-002.js new file mode 100644 index 0000000..d07292d --- /dev/null +++ b/tests/mozilla/ecma_2/instanceof/instanceof-002.js @@ -0,0 +1,61 @@ +/** + File Name: + ECMA Section: + Description: Call Objects + + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = ""; + var VERSION = "ECMA_2"; + var TITLE = "The Call Constructor"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var b = new Boolean(); + + testcases[tc++] = new TestCase( SECTION, + "var b = new Boolean(); b instanceof Boolean", + true, + b instanceof Boolean ); + + testcases[tc++] = new TestCase( SECTION, + "b instanceof Object", + true, + b instanceof Object ); + + testcases[tc++] = new TestCase( SECTION, + "b instanceof Array", + false, + b instanceof Array ); + + testcases[tc++] = new TestCase( SECTION, + "true instanceof Boolean", + false, + true instanceof Boolean ); + + testcases[tc++] = new TestCase( SECTION, + "Boolean instanceof Object", + true, + Boolean instanceof Object ); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/ecma_2/instanceof/instanceof-003.js b/tests/mozilla/ecma_2/instanceof/instanceof-003.js new file mode 100644 index 0000000..1b0a01b --- /dev/null +++ b/tests/mozilla/ecma_2/instanceof/instanceof-003.js @@ -0,0 +1,46 @@ +/** + File Name: instanceof-003.js + ECMA Section: + Description: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 + +js> function Foo() {} +js> theproto = {}; +[object Object] +js> Foo.prototype = theproto +[object Object] +js> theproto instanceof Foo +true + +I think this should be 'false' + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "instanceof-003"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof operator"; + var BUGNUMBER ="http://bugzilla.mozilla.org/show_bug.cgi?id=7635"; + + startTest(); + + function Foo() {}; + theproto = {}; + Foo.prototype = theproto; + + AddTestCase( + "function Foo() = {}; theproto = {}; Foo.prototype = theproto; " + + "theproto instanceof Foo", + false, + theproto instanceof Foo ); + + + var o = {}; + + AddTestCase( + "o = {}; o instanceof o", + false, + o instanceof o ); + + + test(); diff --git a/tests/mozilla/ecma_2/instanceof/regress-7635.js b/tests/mozilla/ecma_2/instanceof/regress-7635.js new file mode 100644 index 0000000..4ccb9d4 --- /dev/null +++ b/tests/mozilla/ecma_2/instanceof/regress-7635.js @@ -0,0 +1,74 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/** + * File Name: regress-7635.js + * Reference: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 + * Description: instanceof tweaks + * Author: + */ + + var SECTION = "instanceof"; // provide a document reference (ie, ECMA section) + var VERSION = "ECMA_2"; // Version of JavaScript or ECMA + var TITLE = "Regression test for Bugzilla #7635"; // Provide ECMA section title or a description + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7635"; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + /* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + + function Foo() {} + theproto = {}; + Foo.prototype = theproto + theproto instanceof Foo + + + AddTestCase( "function Foo() {}; theproto = {}; Foo.prototype = theproto; theproto instanceof Foo", + false, + theproto instanceof Foo ); + + var o = {}; + + AddTestCase( "var o = {}; o instanceof o", false, o instanceof o ); + + var f = new Function(); + + AddTestCase( "var f = new Function(); f instanceof f", false, f instanceof f ); + + + test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/tests/mozilla/ecma_2/jsref.js b/tests/mozilla/ecma_2/jsref.js new file mode 100644 index 0000000..7dc729d --- /dev/null +++ b/tests/mozilla/ecma_2/jsref.js @@ -0,0 +1,629 @@ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; +EXCLUDE = ""; +BUGNUMBER = ""; + + +TZ_DIFF = -8; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; +var DEBUG = false; + + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} +function startTest() { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_13" ) { + version ( "130" ); + } + if ( VERSION == "JS_12" ) { + version ( "120" ); + } + if ( VERSION == "JS_11" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + writeHeaderToLog( SECTION + " "+ TITLE); + testcases = new Array(); + tc = 0; + +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + writeLineToLog( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeLineToLog( string ) { + print( string + BR + CR ); +} +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() +{ + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + } + print(doneTag); + print( HR ); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} + +/** + * Type Conversion functions used by Type Conversion + * + */ + + + + /* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour + +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; + +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); +} +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { + return ( DaysInYear(y) * msPerDay ); +} +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); +} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } +} +function YearNumber( t ) { +} +function TimeFromYear( y ) { + return ( msPerDay * DayFromYear(y) ); +} +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); +} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+t+") case not covered"; + } +} +function YearFromTime( t ) { + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) + + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); +} +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); + + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } +} +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); +} +function DateFromTime( t ) { + var day = DayWithinYear(t); + var month = MonthFromTime(t); + + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); +} +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); +} + +// missing daylight savins time adjustment + +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); +} +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); +} +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +} +function msFromTime( t ) { + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); +} +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); +} +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +} +function DaylightSavingTA( t ) { + t = t - LocalTZA(); + + var dst_start = GetSecondSundayInMarch(t) + 2*msPerHour; + var dst_end = GetFirstSundayInNovember(t)+ 2*msPerHour; + + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } + + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. + + print( new Date( UTC(dst_start + LocalTZA())) ); + + return UTC(dst_start + LocalTZA()); +} + +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); + + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} +function GetLastSundayInOctober( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +// Added these two functions because DST rules changed for the US. +function GetSecondSundayInMarch( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var march = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap); + + var sundayCount = 0; + var flag = true; + for ( var second_sunday = march; flag; second_sunday += msPerDay ) + { + if (WeekDay(second_sunday) == 0) { + if(++sundayCount == 2) + flag = false; + } + } + + return second_sunday; +} +function GetFirstSundayInNovember( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var nov = TimeFromYear(year), m = 0; m < 10; m++ ) { + nov += TimeInMonth(m, leap); + } + for ( var first_sunday = nov; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + return first_sunday; +} +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var properties = new Array(); + for ( p in o ) { + properties[ properties.length ] = new Array( p, o[p] ); + } + return properties; +} +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} diff --git a/tests/mozilla/ecma_2/shell.js b/tests/mozilla/ecma_2/shell.js new file mode 100644 index 0000000..eb70069 --- /dev/null +++ b/tests/mozilla/ecma_2/shell.js @@ -0,0 +1,216 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + + +/* + * JavaScript shared functions file for running the tests in either + * stand-alone JavaScript engine. To run a test, first load this file, + * then load the test script. + */ + +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER=""; + +var TZ_DIFF = getTimeZoneDiff(); + +var DEBUG = false; + +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} +function startTest() { + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( 130 ); + } + if ( VERSION == "JS_13" ) { + version ( 130 ); + } + if ( VERSION == "JS_12" ) { + version ( 120 ); + } + if ( VERSION == "JS_11" ) { + version ( 110 ); + } + } + + + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + + writeHeaderToLog( SECTION + " "+ TITLE); + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} + +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} + +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + writeLineToLog( page + " failed with error: " + msg + " on line " + line ); + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} + +function Enumerate ( o ) { + var properties = new Array(); + for ( p in o ) { + properties[ properties.length ] = new Array( p, o[p] ); + } + return properties; +} + +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + writeLineToLog( testcases[i].description +" = " +testcases[i].actual + + " expected: "+ testcases[i].expect ); + } + } +} +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + + +/* + * Originally, the test suite used a hard-coded value TZ_DIFF = -8. + * But that was only valid for testers in the Pacific Standard Time Zone! + * We calculate the proper number dynamically for any tester. We just + * have to be careful to use a date not subject to Daylight Savings Time... +*/ +function getTimeZoneDiff() +{ + return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; +} diff --git a/tests/mozilla/ecma_2/template.js b/tests/mozilla/ecma_2/template.js new file mode 100644 index 0000000..a30cb77 --- /dev/null +++ b/tests/mozilla/ecma_2/template.js @@ -0,0 +1,39 @@ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/** + * File Name: template.js + * Reference: ** replace with bugzilla URL or document reference ** + * Description: ** replace with description of test ** + * Author: ** replace with your e-mail address ** + */ + + var SECTION = ""; // if ECMA test, provide section number + var VERSION = "ECMA_2"; // Version of JavaScript or ECMA + var TITLE = ""; // Provide ECMA section title or description + var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + + /* Calls to AddTestCase here */ + + test(); // leave this alone diff --git a/tests/mozilla/ecma_3/Array/15.4.4.3-1.js b/tests/mozilla/ecma_3/Array/15.4.4.3-1.js new file mode 100644 index 0000000..7b5fdbd --- /dev/null +++ b/tests/mozilla/ecma_3/Array/15.4.4.3-1.js @@ -0,0 +1,66 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 12 Mar 2001 +* +* +* SUMMARY: Testing Array.prototype.toLocaleString() +* See http://bugzilla.mozilla.org/show_bug.cgi?id=56883 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=58031 +* +* By ECMA3 15.4.4.3, myArray.toLocaleString() means that toLocaleString() +* should be applied to each element of the array, and the results should be +* concatenated with an implementation-specific delimiter. For example: +* +* myArray[0].toLocaleString() + ',' + myArray[1].toLocaleString() + etc. +* +* In this testcase toLocaleString is a user-defined property of each array element; +* therefore it is the function that should be invoked. This function increments a +* global variable. Therefore the end value of this variable should be myArray.length. +*/ +//------------------------------------------------------------------------------------------------- +var bug = 56883; +var summary = 'Testing Array.prototype.toLocaleString() -'; +var actual = ''; +var expect = ''; +var n = 0; +var obj = {toLocaleString: function() {n++}}; +var myArray = [obj, obj, obj]; + + +myArray.toLocaleString(); +actual = n; +expect = 3; // (see explanation above) + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/Array/15.4.4.4-001.js b/tests/mozilla/ecma_3/Array/15.4.4.4-001.js new file mode 100644 index 0000000..6d99159 --- /dev/null +++ b/tests/mozilla/ecma_3/Array/15.4.4.4-001.js @@ -0,0 +1,148 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): george@vanous.com, igor@icesoft.no, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 19 September 2002 +* SUMMARY: Testing Array.prototype.concat() +* See http://bugzilla.mozilla.org/show_bug.cgi?id=169795 +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 169795; +var summary = 'Testing Array.prototype.concat()'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var x; + + +status = inSection(1); +x = "Hello"; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(2); +x = 999; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(3); +x = /Hello/g; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(4); +x = new Error("Hello"); +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(5); +x = function() {return "Hello";}; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(6); +x = [function() {return "Hello";}]; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(7); +x = [1,2,3].concat([4,5,6]); +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(8); +x = eval('this'); +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +/* + * The next two sections are by igor@icesoft.no; see + * http://bugzilla.mozilla.org/show_bug.cgi?id=169795#c3 + */ +status = inSection(9); +x={length:0}; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(10); +x={length:2, 0:0, 1:1}; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i +* See http://bugzilla.mozilla.org/show_bug.cgi?id=101488 +* +* Without the "new" keyword, assigning arr.length = Number(n) worked. +* But with it, Rhino was giving an error "Inappropriate array length" +* and SpiderMonkey was exiting without giving any error or return value - +* +* Comments on the Rhino code by igor@icesoft.no: +* +* jsSet_length requires that the new length value should be an instance +* of Number. But according to Ecma 15.4.5.1, item 12-13, an error should +* be thrown only if ToUint32(length_value) != ToNumber(length_value) +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 101488; +var summary = 'Try assigning arr.length = new Number(n)'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var arr = []; + + +status = inSection(1); +arr = Array(); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +status = inSection(2); +arr = Array(5); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +status = inSection(3); +arr = Array(); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + +status = inSection(4); +arr = Array(5); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + + +/* + * Also try the above with the "new" keyword before Array(). + * Array() and new Array() should be equivalent, by ECMA 15.4.1.1 + */ +status = inSection(5); +arr = new Array(); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +status = inSection(6); +arr = new Array(5); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +arr = new Array(); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + +status = inSection(7); +arr = new Array(5); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function tryThis(s) +{ + try + { + eval(s); + } + catch(e) + { + // keep going + } +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i=0; i= dst_start && t < dst_end ) {return msPerHour;} + else {return 0;} + + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in PST. + // Other time zones will need to override this function. + +print( new Date( UTC(dst_start + LocalTZA())) ); +return UTC(dst_start + LocalTZA()); +} + +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); + + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} +function GetLastSundayInOctober( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +// Added these two functions because DST rules changed for the US. +function GetSecondSundayInMarch( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var march = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap); + + var sundayCount = 0; + var flag = true; + for ( var second_sunday = march; flag; second_sunday += msPerDay ) + { + if (WeekDay(second_sunday) == 0) { + if(++sundayCount == 2) + flag = false; + } + } + + return second_sunday; +} +function GetFirstSundayInNovember( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var nov = TimeFromYear(year), m = 0; m < 10; m++ ) { + nov += TimeInMonth(m, leap); + } + for ( var first_sunday = nov; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + return first_sunday; +} + + +function LocalTime( t ) +{ + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} + + +function MakeTime( hour, min, sec, ms ) +{ + if ( isNaN(hour) || isNaN(min) || isNaN(sec) || isNaN(ms) ){return Number.NaN;} + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + (sec*msPerSecond) + ms ); +} + + +function MakeDay( year, month, date ) +{ + if ( isNaN(year) || isNaN(month) || isNaN(date)) {return Number.NaN;} + + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6= month%12; + + if ( year < 1970 ) + { + for ( y = 1969; y >= year; y += sign ) + { + t += sign * TimeInYear(y); + } + } + else + { + for ( y = 1970 ; y < year; y += sign ) + { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++) + { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) {return Number.NaN;} + if ( MonthFromTime(t) != result6 ) {return Number.NaN;} + if ( DateFromTime(t) != 1 ){return Number.NaN;} + + return ( (Day(t)) + date - 1 ); +} + + +function TimeInMonth( month, leap ) +{ + // Jan 0 Feb 1 Mar 2 Apr 3 May 4 June 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec11 + + // April June September November + if ( month == 3 || month == 5 || month == 8 || month == 10 ) {return ( 30*msPerDay );} + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) {return ( 31*msPerDay );} + + // save February + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} + + +function MakeDate( day, time ) +{ + if (day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) + { + return Number.NaN; + } + + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) + { + return Number.NaN; + } + + return ( day * msPerDay ) + time; +} + + +function TimeClip( t ) +{ + if ( isNaN( t )) {return ( Number.NaN);} + if ( Math.abs( t ) > 8.64e15 ) {return ( Number.NaN);} + + return ( ToInteger( t ) ); +} + + +function ToInteger( t ) +{ + t = Number( t ); + + if ( isNaN( t )) {return ( Number.NaN);} + + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || + t == Number.NEGATIVE_INFINITY) + { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} + + +function Enumerate( o ) +{ + var p; + for ( p in o ) {print( p + ": " + o[p] );} +} + + +/* these functions are useful for running tests manually in Rhino */ + +function GetContext() +{ + return Packages.com.netscape.javascript.Context.getCurrentContext(); +} + + +function OptLevel( i ) +{ + i = Number(i); + var cx = GetContext(); + cx.setOptimizationLevel(i); +} + +/* end of Rhino functions */ + diff --git a/tests/mozilla/ecma_3/Exceptions/15.11.1.1.js b/tests/mozilla/ecma_3/Exceptions/15.11.1.1.js new file mode 100644 index 0000000..3aab137 --- /dev/null +++ b/tests/mozilla/ecma_3/Exceptions/15.11.1.1.js @@ -0,0 +1,132 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): joerg.schaible@gmx.de +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 27 Nov 2002 +* SUMMARY: Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1). +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = ''; +var summary = 'Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1)'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +function otherScope(msg) +{ + return Error(msg); +} + + +status = inSection(1); +var err1 = Error('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = otherScope('msg2'); +actual = examineThis(err2, 'msg2'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = otherScope(); +actual = examineThis(err3, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = eval("Error('msg4')"); +actual = examineThis(err4, 'msg4'); +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Searches err.toString() for err.name + ':' + err.message, + * with possible whitespace on each side of the colon sign. + * + * We allow for no colon in case err.message was not provided by the user. + * In such a case, SpiderMonkey and Rhino currently set err.message = '', + * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. + * + * If this is ever changed to a non-empty string, e.g. 'undefined', + * you may have to modify |pattern| to take that into account - + * + */ +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/Exceptions/15.11.4.4-1.js b/tests/mozilla/ecma_3/Exceptions/15.11.4.4-1.js new file mode 100644 index 0000000..ca05e7e --- /dev/null +++ b/tests/mozilla/ecma_3/Exceptions/15.11.4.4-1.js @@ -0,0 +1,169 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2001 +* the Initial Developer. All Rights Reserved. +* +* Contributors: d-russo@ti.com, pschwartau@netscape.com, joerg.schaible@gmx.de +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 22 Jan 2002 +* SUMMARY: Testing Error.prototype.toString() +* +* Revised: 25 Nov 2002 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=181909 +* +* Note that ECMA-262 3rd Edition Final, Section 15.11.4.4 states that +* Error.prototype.toString() returns an implementation-dependent string. +* Therefore any testcase on this property is somewhat arbitrary. +* +* However, d-russo@ti.com pointed out that Rhino was returning this: +* +* js> err = new Error() +* undefined: undefined +* +* js> err = new Error("msg") +* undefined: msg +* +* +* We expect Rhino to return what SpiderMonkey currently does: +* +* js> err = new Error() +* Error +* +* js> err = new Error("msg") +* Error: msg +* +* +* i.e. we expect err.toString() === err.name if err.message is not defined; +* otherwise, we expect err.toString() === err.name + ': ' + err.message. +* +* See also ECMA 15.11.4.2, 15.11.4.3 +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = '(none)'; +var summary = 'Testing Error.prototype.toString()'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +status = inSection(1); +var err1 = new Error('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = new Error(err1); +actual = examineThis(err2, err1); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = new Error(); +actual = examineThis(err3, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = new Error(EMPTY_STRING); +actual = examineThis(err4, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +// now generate a run-time error - +status = inSection(5); +try +{ + eval('1=2'); +} +catch(err5) +{ + actual = examineThis(err5, '.*'); +} +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Searches err.toString() for err.name + ':' + err.message, + * with possible whitespace on each side of the colon sign. + * + * We allow for no colon in case err.message was not provided by the user. + * In such a case, SpiderMonkey and Rhino currently set err.message = '', + * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. + * + * If this is ever changed to a non-empty string, e.g. 'undefined', + * you may have to modify |pattern| to take that into account - + * + */ +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/Exceptions/15.11.7.6-001.js b/tests/mozilla/ecma_3/Exceptions/15.11.7.6-001.js new file mode 100644 index 0000000..a8097f5 --- /dev/null +++ b/tests/mozilla/ecma_3/Exceptions/15.11.7.6-001.js @@ -0,0 +1,125 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2003 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): igor@fastmail.fm, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 14 April 2003 +* SUMMARY: Prototype of predefined error objects should be DontEnum +* See http://bugzilla.mozilla.org/show_bug.cgi?id=201989 +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 201989; +var summary = 'Prototype of predefined error objects should be DontEnum'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * Tests that |F.prototype| is not enumerable in |F| + */ +function testDontEnum(F) +{ + var proto = F.prototype; + + for (var prop in F) + { + if (F[prop] === proto) + return false; + } + return true; +} + + +var list = [ + "Error", + "ConversionError", + "EvalError", + "RangeError", + "ReferenceError", + "SyntaxError", + "TypeError", + "URIError" +]; + + +for (i in list) +{ + var F = this[list[i]]; + + // Test for |F|; e.g. Rhino defines |ConversionError| while SM does not. + if (F) + { + status = 'Testing DontEnum attribute of |' + list[i] + '.prototype|'; + actual = testDontEnum(F); + expect = true; + addThis(); + } +} + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i -1); + expect = true; + addThis(); +} + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = isReferenceError(actual); + expectedvalues[UBound] = isReferenceError(expect); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} + + +// converts a Boolean result into a textual result - +function isReferenceError(bResult) +{ + return bResult? ERR_REF_YES : ERR_REF_NO; +} diff --git a/tests/mozilla/ecma_3/Exceptions/regress-181654.js b/tests/mozilla/ecma_3/Exceptions/regress-181654.js new file mode 100644 index 0000000..d65efff --- /dev/null +++ b/tests/mozilla/ecma_3/Exceptions/regress-181654.js @@ -0,0 +1,150 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): joerg.schaible@gmx.de +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 23 Nov 2002 +* SUMMARY: Calling toString for an object derived from the Error class +* results in an TypeError (Rhino only) +* See http://bugzilla.mozilla.org/show_bug.cgi?id=181654 +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = '181654'; +var summary = 'Calling toString for an object derived from the Error class should be possible.'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +// derive MyError from Error +function MyError( msg ) +{ + this.message = msg; +} +MyError.prototype = new Error(); +MyError.prototype.name = "MyError"; + + +status = inSection(1); +var err1 = new MyError('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = new MyError(err1); +actual = examineThis(err2, err1); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = new MyError(); +actual = examineThis(err3, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = new MyError(EMPTY_STRING); +actual = examineThis(err4, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +// now generate an error - +status = inSection(5); +try +{ + throw new MyError("thrown"); +} +catch(err5) +{ + actual = examineThis(err5, "thrown"); +} +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Searches err.toString() for err.name + ':' + err.message, + * with possible whitespace on each side of the colon sign. + * + * We allow for no colon in case err.message was not provided by the user. + * In such a case, SpiderMonkey and Rhino currently set err.message = '', + * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. + * + * If this is ever changed to a non-empty string, e.g. 'undefined', + * you may have to modify |pattern| to take that into account - + * + */ +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/Exceptions/regress-181914.js b/tests/mozilla/ecma_3/Exceptions/regress-181914.js new file mode 100644 index 0000000..adf0b46 --- /dev/null +++ b/tests/mozilla/ecma_3/Exceptions/regress-181914.js @@ -0,0 +1,189 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): joerg.schaible@gmx.de, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 25 Nov 2002 +* SUMMARY: Calling a user-defined superconstructor +* See http://bugzilla.mozilla.org/show_bug.cgi?id=181914, esp. Comment 10. +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = '181914'; +var summary = 'Calling a user-defined superconstructor'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +// make a user-defined version of the Error constructor +function _Error(msg) +{ + this.message = msg; +} +_Error.prototype = new Error(); +_Error.prototype.name = '_Error'; + + +// derive MyApplyError from _Error +function MyApplyError(msg) +{ + if(this instanceof MyApplyError) + _Error.apply(this, arguments); + else + return new MyApplyError(msg); +} +MyApplyError.prototype = new _Error(); +MyApplyError.prototype.name = "MyApplyError"; + + +// derive MyCallError from _Error +function MyCallError(msg) +{ + if(this instanceof MyCallError) + _Error.call(this, msg); + else + return new MyCallError(msg); +} +MyCallError.prototype = new _Error(); +MyCallError.prototype.name = "MyCallError"; + + +function otherScope(msg) +{ + return MyApplyError(msg); +} + + +status = inSection(1); +var err1 = new MyApplyError('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = new MyCallError('msg2'); +actual = examineThis(err2, 'msg2'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = MyApplyError('msg3'); +actual = examineThis(err3, 'msg3'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = MyCallError('msg4'); +actual = examineThis(err4, 'msg4'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(5); +var err5 = otherScope('msg5'); +actual = examineThis(err5, 'msg5'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(6); +var err6 = otherScope(); +actual = examineThis(err6, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(7); +var err7 = eval("MyApplyError('msg7')"); +actual = examineThis(err7, 'msg7'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(8); +var err8; +try +{ + throw MyApplyError('msg8'); +} +catch(e) +{ + if(e instanceof Error) + err8 = e; +} +actual = examineThis(err8, 'msg8'); +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +// Searches |err.toString()| for |err.name + ':' + err.message| +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/Exceptions/regress-58946.js b/tests/mozilla/ecma_3/Exceptions/regress-58946.js new file mode 100644 index 0000000..e2fc798 --- /dev/null +++ b/tests/mozilla/ecma_3/Exceptions/regress-58946.js @@ -0,0 +1,56 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* +* +*This test arose from Bugzilla bug 58946. +*The bug was filed when we got the following error (see code below): +* +* "ReferenceError: e is not defined" +* +*There was no error if we replaced "return e" in the code below with "print(e)". +*There should be no error with "return e", either - +*/ +//------------------------------------------------------------------------------------------------- +var bug = '58946'; +var stat = 'Testing a return statement inside a catch statement inside a function'; + + +test(); + + +function test() { + enterFunc ("test"); + printBugNumber (bug); + printStatus (stat); + + + try + { + throw 'PASS'; + } + + catch(e) + { + return e; + } + + + exitFunc ("test"); +} \ No newline at end of file diff --git a/tests/mozilla/ecma_3/Exceptions/regress-95101.js b/tests/mozilla/ecma_3/Exceptions/regress-95101.js new file mode 100644 index 0000000..59b5209 --- /dev/null +++ b/tests/mozilla/ecma_3/Exceptions/regress-95101.js @@ -0,0 +1,97 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 13 August 2001 +* +* SUMMARY: Invoking an undefined function should produce a ReferenceError +* See http://bugzilla.mozilla.org/show_bug.cgi?id=95101 +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 95101; +var summary = 'Invoking an undefined function should produce a ReferenceError'; +var msgERR_REF_YES = 'ReferenceError'; +var msgERR_REF_NO = 'did NOT generate a ReferenceError'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +try +{ + xxxyyyzzz(); +} +catch (e) +{ + status = 'Section 1 of test'; + actual = e instanceof ReferenceError; + expect = true; + addThis(); + + + /* + * This test is more literal, and may one day be invalid. + * Searching for literal string "ReferenceError" in e.toString() + */ + status = 'Section 2 of test'; + var match = e.toString().search(/ReferenceError/); + actual = (match > -1); + expect = true; + addThis(); +} + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = isReferenceError(actual); + expectedvalues[UBound] = isReferenceError(expect); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} + + +// converts a Boolean result into a textual result - +function isReferenceError(bResult) +{ + return bResult? msgERR_REF_YES : msgERR_REF_NO; +} diff --git a/tests/mozilla/ecma_3/ExecutionContexts/10.1.3-1.js b/tests/mozilla/ecma_3/ExecutionContexts/10.1.3-1.js new file mode 100644 index 0000000..a29d2a4 --- /dev/null +++ b/tests/mozilla/ecma_3/ExecutionContexts/10.1.3-1.js @@ -0,0 +1,196 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 11 Feb 2002 +* SUMMARY: Testing functions having duplicate formal parameter names +* +* Note: given function f(x,x,x,x) {return x;}; f(1,2,3,4) should return 4. +* See ECMA-262 3rd Edition Final Section 10.1.3: Variable Instantiation +* +* Also see http://bugzilla.mozilla.org/show_bug.cgi?id=124900 +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 124900; +var summary = 'Testing functions having duplicate formal parameter names'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +function f1(x,x) +{ + return x; +} +status = inSection(1); +actual = f1(1,2); +expect = 2; +addThis(); + + +function f2(x,x,x) +{ + return x*x*x; +} +status = inSection(2); +actual = f2(1,2,3); +expect = 27; +addThis(); + + +function f3(x,x,x,x) +{ + return 'a' + x + 'b' + x + 'c' + x ; +} +status = inSection(3); +actual = f3(1,2,3,4); +expect = 'a4b4c4'; +addThis(); + + +/* + * If the value of the last duplicate parameter is not provided by + * the function caller, the value of this parameter is undefined + */ +function f4(x,a,b,x,z) +{ + return x; +} +status = inSection(4); +actual = f4(1,2); +expect = undefined; +addThis(); + + +/* + * f.toString() should preserve any duplicate formal parameter names that exist + */ +function f5(x,x,x,x) +{ +} +status = inSection(5); +actual = f5.toString().match(/\((.*)\)/)[1]; +actual = actual.replace(/\s/g, ''); // for definiteness, remove any white space +expect = 'x,x,x,x'; +addThis(); + + +function f6(x,x,x,x) +{ + var ret = []; + + for (var i=0; i function f\u02B1 () {} +* +* js> f\u02B1.toSource(); +* function f¦() {} +* +* js> f\u02B1.toSource().toSource(); +* (new String("function f\xB1() {}")) +* +* +* See how the high-byte information (the 02) has been lost? +* The same thing was happening with the toString() method: +* +* js> f\u02B1.toString(); +* +* function f¦() { +* } +* +* js> f\u02B1.toString().toSource(); +* (new String("\nfunction f\xB1() {\n}\n")) +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 58274; +var summary = 'Testing functions with double-byte names'; +var ERR = 'UNEXPECTED ERROR! \n'; +var ERR_MALFORMED_NAME = ERR + 'Could not find function name in: \n\n'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var sEval; +var sName; + + +sEval = "function f\u02B2() {return 42;}"; +eval(sEval); +sName = getFunctionName(f\u02B2); + +// Test function call - +status = inSection(1); +actual = f\u02B2(); +expect = 42; +addThis(); + +// Test both characters of function name - +status = inSection(2); +actual = sName[0]; +expect = sEval[9]; +addThis(); + +status = inSection(3); +actual = sName[1]; +expect = sEval[10]; +addThis(); + + + +sEval = "function f\u02B2\u0AAA () {return 84;}"; +eval(sEval); +sName = getFunctionName(f\u02B2\u0AAA); + +// Test function call - +status = inSection(4); +actual = f\u02B2\u0AAA(); +expect = 84; +addThis(); + +// Test all three characters of function name - +status = inSection(5); +actual = sName[0]; +expect = sEval[9]; +addThis(); + +status = inSection(6); +actual = sName[1]; +expect = sEval[10]; +addThis(); + +status = inSection(7); +actual = sName[2]; +expect = sEval[11]; +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Goal: test that f.toString() contains the proper function name. + * + * Note, however, f.toString() is implementation-independent. For example, + * it may begin with '\nfunction' instead of 'function'. Therefore we use + * a regexp to make sure we extract the name properly. + * + * Here we assume that f has been defined by means of a function statement, + * and not a function expression (where it wouldn't have to have a name). + * + * Rhino uses a Unicode representation for f.toString(); whereas + * SpiderMonkey uses an ASCII representation, putting escape sequences + * for non-ASCII characters. For example, if a function is called f\u02B1, + * then in Rhino the toString() method will present a 2-character Unicode + * string for its name, whereas SpiderMonkey will present a 7-character + * ASCII string for its name: the string literal 'f\u02B1'. + * + * So we force the lexer to condense the string before using it. + * This will give uniform results in Rhino and SpiderMonkey. + */ +function getFunctionName(f) +{ + var s = condenseStr(f.toString()); + var re = /\s*function\s+(\S+)\s*\(/; + var arr = s.match(re); + + if (!(arr && arr[1])) + return ERR_MALFORMED_NAME + s; + return arr[1]; +} + + +/* + * This function is the opposite of functions like escape(), which take + * Unicode characters and return escape sequences for them. Here, we force + * the lexer to turn escape sequences back into single characters. + * + * Note we can't simply do |eval(str)|, since in practice |str| will be an + * identifier somewhere in the program (e.g. a function name); thus |eval(str)| + * would return the object that the identifier represents: not what we want. + * + * So we surround |str| lexicographically with quotes to force the lexer to + * evaluate it as a string. Have to strip out any linefeeds first, however - + */ +function condenseStr(str) +{ + /* + * You won't be able to do the next step if |str| has + * any carriage returns or linefeeds in it. For example: + * + * js> eval("'" + '\nHello' + "'"); + * 1: SyntaxError: unterminated string literal: + * 1: ' + * 1: ^ + * + * So replace them with the empty string - + */ + str = str.replace(/[\r\n]/g, '') + return eval("'" + str + "'"); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i length then set lastIndex to 0 and return null. +* 7. Call [[Match]], giving it the arguments S and i. +* If [[Match]] returned failure, go to step 8; +* otherwise let r be its State result and go to step 10. +* 8. Let i = i+1. +* 9. Go to step 6. +* 10. Let e be r's endIndex value. +* 11. If the global property is true, set lastIndex to e. +* +* etc. +* +* +* So when the global flag is set, |lastIndex| is incremented every time +* there is a match; not from i to i+1, but from i to "endIndex" e: +* +* e = (index of last input character matched so far by the pattern) + 1 +* +* Thus in the example below, the first endIndex e occurs after the +* first match 'a b'. The next match will begin AFTER this, and so +* will NOT be 'b c', but rather 'c d'. Similarly, 'd e' won't be matched. +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = '(none)'; +var summary = 'Testing regexps with the global flag set'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +string = 'a b c d e'; +pattern = /\w\s\w/g; +actualmatch = string.match(pattern); +expectedmatch = ['a b','c d']; // see above explanation - +addThis(); + + +status = inSection(2); +string = '12345678'; +pattern = /\d\d\d/g; +actualmatch = string.match(pattern); +expectedmatch = ['123','456']; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/15.10.6.2-2.js b/tests/mozilla/ecma_3/RegExp/15.10.6.2-2.js new file mode 100644 index 0000000..cce4c2c --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/15.10.6.2-2.js @@ -0,0 +1,362 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 18 Feb 2002 +* SUMMARY: Testing re.exec(str) when re.lastIndex is < 0 or > str.length +* +* Case 1: If re has the global flag set, then re(str) should be null +* Case 2: If re doesn't have this set, then re(str) should be unaffected +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=76717 +* +* +* From the ECMA-262 Final spec: +* +* 15.10.6.2 RegExp.prototype.exec(string) +* Performs a regular expression match of string against the regular +* expression and returns an Array object containing the results of +* the match, or null if the string did not match. +* +* The string ToString(string) is searched for an occurrence of the +* regular expression pattern as follows: +* +* 1. Let S be the value of ToString(string). +* 2. Let length be the length of S. +* 3. Let lastIndex be the value of the lastIndex property. +* 4. Let i be the value of ToInteger(lastIndex). +* 5. If the global property is false, let i = 0. +* 6. If i < 0 or i > length then set lastIndex to 0 and return null. +* 7. Call [[Match]], giving it the arguments S and i. +* If [[Match]] returned failure, go to step 8; +* otherwise let r be its State result and go to step 10. +* 8. Let i = i+1. +* 9. Go to step 6. +* 10. Let e be r's endIndex value. +* 11. If the global property is true, set lastIndex to e. +* +* etc. +* +* +* So: +* +* A. If the global flag is not set, |lastIndex| is set to 0 +* before the match is attempted; thus the match is unaffected. +* +* B. If the global flag IS set and re.lastIndex is >= 0 and <= str.length, +* |lastIndex| is incremented every time there is a match; not from +* i to i+1, but from i to "endIndex" e: +* +* e = (index of last input character matched so far by the pattern) + 1 +* +* The match is then attempted from this position in the string (Step 7). +* +* C. When the global flag IS set and re.lastIndex is < 0 or > str.length, +* |lastIndex| is set to 0 and the match returns null. +* +* +* Note the |lastIndex| property is writeable, and may be set arbitrarily +* by the programmer - and we will do that below. +* +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 76717; +var summary = 'Testing re.exec(str) when re.lastIndex is < 0 or > str.length'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/****************************************************************************** + * + * Case 1 : when the global flag is set - + * + *****************************************************************************/ +pattern = /abc/gi; +string = 'AbcaBcabC'; + + status = inSection(1); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc'); + addThis(); + + status = inSection(2); + actualmatch = pattern.exec(string); + expectedmatch = Array('aBc'); + addThis(); + + status = inSection(3); + actualmatch = pattern.exec(string); + expectedmatch = Array('abC'); + addThis(); + + /* + * At this point |lastIndex| is > string.length, so the match should be null - + */ + status = inSection(4); + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + /* + * Now let's set |lastIndex| to -1, so the match should again be null - + */ + status = inSection(5); + pattern.lastIndex = -1; + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + /* + * Now try some edge-case values. Thanks to the work done in + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, |lastIndex| + * is now stored as a double instead of a uint32 (unsigned integer). + * + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go + * all the way up to Number.MAX_VALUE. So that's why we need cases + * between those two numbers. + */ + status = inSection(6); + pattern.lastIndex = Math.pow(2,32); + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + status = inSection(7); + pattern.lastIndex = -Math.pow(2,32); + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + status = inSection(8); + pattern.lastIndex = Math.pow(2,32) + 1; + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + status = inSection(9); + pattern.lastIndex = -(Math.pow(2,32) + 1); + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + status = inSection(10); + pattern.lastIndex = Math.pow(2,32) * 2; + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + status = inSection(11); + pattern.lastIndex = -Math.pow(2,32) * 2; + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + status = inSection(12); + pattern.lastIndex = Math.pow(2,40); + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + status = inSection(13); + pattern.lastIndex = -Math.pow(2,40); + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + status = inSection(14); + pattern.lastIndex = Number.MAX_VALUE; + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + status = inSection(15); + pattern.lastIndex = -Number.MAX_VALUE; + actualmatch = pattern.exec(string); + expectedmatch = null; + addThis(); + + + +/****************************************************************************** + * + * Case 2: repeat all the above cases WITHOUT the global flag set. + * According to EMCA. |lastIndex| should get set to 0 before the match. + * + * Therefore re.exec(str) should be unaffected; thus our expected values + * below are now DIFFERENT when |lastIndex| is < 0 or > str.length + * + *****************************************************************************/ + +pattern = /abc/i; +string = 'AbcaBcabC'; + + status = inSection(16); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc'); + addThis(); + + status = inSection(17); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc'); // NOT Array('aBc') as before - + addThis(); + + status = inSection(18); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc'); // NOT Array('abC') as before - + addThis(); + + /* + * At this point above, |lastIndex| WAS > string.length, but not here - + */ + status = inSection(19); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + /* + * Now let's set |lastIndex| to -1 + */ + status = inSection(20); + pattern.lastIndex = -1; + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + /* + * Now try some edge-case values. Thanks to the work done in + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, |lastIndex| + * is now stored as a double instead of a uint32 (unsigned integer). + * + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go + * all the way up to Number.MAX_VALUE. So that's why we need cases + * between those two numbers. + */ + status = inSection(21); + pattern.lastIndex = Math.pow(2,32); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + status = inSection(22); + pattern.lastIndex = -Math.pow(2,32); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + status = inSection(23); + pattern.lastIndex = Math.pow(2,32) + 1; + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + status = inSection(24); + pattern.lastIndex = -(Math.pow(2,32) + 1); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + status = inSection(25); + pattern.lastIndex = Math.pow(2,32) * 2; + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + status = inSection(26); + pattern.lastIndex = -Math.pow(2,32) * 2; + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + status = inSection(27); + pattern.lastIndex = Math.pow(2,40); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before -; + addThis(); + + status = inSection(28); + pattern.lastIndex = -Math.pow(2,40); + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + status = inSection(29); + pattern.lastIndex = Number.MAX_VALUE; + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + status = inSection(30); + pattern.lastIndex = -Number.MAX_VALUE; + actualmatch = pattern.exec(string); + expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/octal-001.js b/tests/mozilla/ecma_3/RegExp/octal-001.js new file mode 100644 index 0000000..34b3e34 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/octal-001.js @@ -0,0 +1,131 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 18 July 2002 +* SUMMARY: Testing octal sequences in regexps +* See http://bugzilla.mozilla.org/show_bug.cgi?id=141078 +* +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 141078; +var summary = 'Testing octal sequences in regexps'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /\240/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +/* + * In the following sections, we test the octal escape sequence '\052'. + * This is character code 42, representing the asterisk character '*'. + * The Unicode escape for it would be '\u002A', the hex escape '\x2A'. + */ +status = inSection(2); +pattern = /ab\052c/; +string = 'ab*c'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab*c'); +addThis(); + +status = inSection(3); +pattern = /ab\052*c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(4); +pattern = /ab(\052)+c/; +string = 'ab****c'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab****c', '*'); +addThis(); + +status = inSection(5); +pattern = /ab((\052)+)c/; +string = 'ab****c'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab****c', '****', '*'); +addThis(); + +status = inSection(6); +pattern = /(?:\052)c/; +string = 'ab****c'; +actualmatch = string.match(pattern); +expectedmatch = Array('*c'); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/octal-002.js b/tests/mozilla/ecma_3/RegExp/octal-002.js new file mode 100644 index 0000000..6d75e48 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/octal-002.js @@ -0,0 +1,213 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 31 July 2002 +* SUMMARY: Testing regexps containing octal escape sequences +* This is an elaboration of mozilla/js/tests/ecma_2/RegExp/octal-003.js +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=141078 +* for a reference on octal escape sequences in regexps. +* +* NOTE: +* We will use the identities '\011' === '\u0009' === '\x09' === '\t' +* +* The first is an octal escape sequence (\(0-3)OO; O an octal digit). +* See ECMA-262 Edition 2, Section 7.7.4 "String Literals". These were +* dropped in Edition 3 but we support them for backward compatibility. +* +* The second is a Unicode escape sequence (\uHHHH; H a hex digit). +* Since octal 11 = hex 9, the two escapes define the same character. +* +* The third is a hex escape sequence (\xHH; H a hex digit). +* Since hex 09 = hex 0009, this defines the same character. +* +* The fourth is the familiar escape sequence for a horizontal tab, +* defined in the ECMA spec as having Unicode value \u0009. +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 141078; +var summary = 'Testing regexps containing octal escape sequences'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/* + * Test a string containing the null character '\0' followed by the string '11' + * + * 'a' + String.fromCharCode(0) + '11'; + * + * Note we can't simply write 'a\011', because '\011' would be interpreted + * as the octal escape sequence for the tab character (see above). + * + * We should get no match from the regexp /.\011/, because it should be + * looking for the octal escape sequence \011, i.e. the tab character - + * + */ +status = inSection(1); +pattern = /.\011/; +string = 'a' + String.fromCharCode(0) + '11'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + +/* + * Try same thing with 'xx' in place of '11'. + * + * Should get a match now, because the octal escape sequence in the regexp + * has been reduced from \011 to \0, and '\0' is present in the string - + */ +status = inSection(2); +pattern = /.\0xx/; +string = 'a' + String.fromCharCode(0) + 'xx'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same thing; don't use |String.fromCharCode(0)| this time. + * There is no ambiguity in '\0xx': it is the null character + * followed by two x's, no other interpretation is possible. + */ +status = inSection(3); +pattern = /.\0xx/; +string = 'a\0xx'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * This one should produce a match. The two-character string + * 'a' + '\011' is duplicated in the pattern and test string: + */ +status = inSection(4); +pattern = /.\011/; +string = 'a\011'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same as above, only now, for the second character of the string, + * use the Unicode escape '\u0009' instead of the octal escape '\011' + */ +status = inSection(5); +pattern = /.\011/; +string = 'a\u0009'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same as above, only now for the second character of the string, + * use the hex escape '\x09' instead of the octal escape '\011' + */ +status = inSection(6); +pattern = /.\011/; +string = 'a\x09'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same as above, only now for the second character of the string, + * use the escape '\t' instead of the octal escape '\011' + */ +status = inSection(7); +pattern = /.\011/; +string = 'a\t'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Return to the string from Section 1. + * + * Unlike Section 1, use the RegExp() function to create the + * regexp pattern: null character followed by the string '11'. + * + * Since this is exactly what the string is, we should get a match - + */ +status = inSection(8); +string = 'a' + String.fromCharCode(0) + '11'; +pattern = RegExp(string); +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/perlstress-001.js b/tests/mozilla/ecma_3/RegExp/perlstress-001.js new file mode 100644 index 0000000..fd544c2 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/perlstress-001.js @@ -0,0 +1,3225 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com, rogerl@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 2002-07-07 +* SUMMARY: Testing JS RegExp engine against Perl 5 RegExp engine. +* Adjust cnLBOUND, cnUBOUND below to restrict which sections are tested. +* +* This test was created by running various patterns and strings through the +* Perl 5 RegExp engine. We saved the results below to test the JS engine. +* +* NOTE: ECMA/JS and Perl do differ on certain points. We have either commented +* out such sections altogether, or modified them to fit what we expect from JS. +* +* EXAMPLES: +* +* - In JS, regexp captures (/(a) etc./) must hold |undefined| if not used. +* See http://bugzilla.mozilla.org/show_bug.cgi?id=123437. +* By contrast, in Perl, unmatched captures hold the empty string. +* We have modified such sections accordingly. Example: + + pattern = /^([^a-z])|(\^)$/; + string = '.'; + actualmatch = string.match(pattern); + //expectedmatch = Array('.', '.', ''); <<<--- Perl + expectedmatch = Array('.', '.', undefined); <<<--- JS + addThis(); + + +* - In JS, you can't refer to a capture before it's encountered & completed +* +* - Perl supports ] & ^] inside a [], ECMA does not +* +* - ECMA does support (?: (?= and (?! operators, but doesn't support (?< etc. +* +* - ECMA doesn't support (?imsx or (?-imsx +* +* - ECMA doesn't support (?(condition) +* +* - Perl has \Z has end-of-line, ECMA doesn't +* +* - In ECMA, ^ matches only the empty string before the first character +* +* - In ECMA, $ matches only the empty string at end of input (unless multiline) +* +* - ECMA spec says that each atom in a range must be a single character +* +* - ECMA doesn't support \A +* +* - ECMA doesn't have rules for [: +* +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 85721; +var summary = 'Testing regular expression edge cases'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); +var cnLBOUND = 1; +var cnUBOUND = 1000; + + +status = inSection(1); +pattern = /abc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(2); +pattern = /abc/; +string = 'xabcy'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(3); +pattern = /abc/; +string = 'ababc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(4); +pattern = /ab*c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(5); +pattern = /ab*bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(6); +pattern = /ab*bc/; +string = 'abbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbc'); +addThis(); + +status = inSection(7); +pattern = /ab*bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(8); +pattern = /.{1}/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(9); +pattern = /.{3,4}/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbb'); +addThis(); + +status = inSection(10); +pattern = /ab{0,}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(11); +pattern = /ab+bc/; +string = 'abbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbc'); +addThis(); + +status = inSection(12); +pattern = /ab+bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(13); +pattern = /ab{1,}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(14); +pattern = /ab{1,3}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(15); +pattern = /ab{3,4}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(16); +pattern = /ab?bc/; +string = 'abbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbc'); +addThis(); + +status = inSection(17); +pattern = /ab?bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(18); +pattern = /ab{0,1}bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(19); +pattern = /ab?c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(20); +pattern = /ab{0,1}c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(21); +pattern = /^abc$/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(22); +pattern = /^abc/; +string = 'abcc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(23); +pattern = /abc$/; +string = 'aabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(24); +pattern = /^/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(25); +pattern = /$/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(26); +pattern = /a.c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(27); +pattern = /a.c/; +string = 'axc'; +actualmatch = string.match(pattern); +expectedmatch = Array('axc'); +addThis(); + +status = inSection(28); +pattern = /a.*c/; +string = 'axyzc'; +actualmatch = string.match(pattern); +expectedmatch = Array('axyzc'); +addThis(); + +status = inSection(29); +pattern = /a[bc]d/; +string = 'abd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abd'); +addThis(); + +status = inSection(30); +pattern = /a[b-d]e/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace'); +addThis(); + +status = inSection(31); +pattern = /a[b-d]/; +string = 'aac'; +actualmatch = string.match(pattern); +expectedmatch = Array('ac'); +addThis(); + +status = inSection(32); +pattern = /a[-b]/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-'); +addThis(); + +status = inSection(33); +pattern = /a[b-]/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-'); +addThis(); + +status = inSection(34); +pattern = /a]/; +string = 'a]'; +actualmatch = string.match(pattern); +expectedmatch = Array('a]'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not +pattern = /a[]]b/; +status = inSection(35); +string = 'a]b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a]b'); +addThis(); +*/ + +status = inSection(36); +pattern = /a[^bc]d/; +string = 'aed'; +actualmatch = string.match(pattern); +expectedmatch = Array('aed'); +addThis(); + +status = inSection(37); +pattern = /a[^-b]c/; +string = 'adc'; +actualmatch = string.match(pattern); +expectedmatch = Array('adc'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not +status = inSection(38); +pattern = /a[^]b]c/; +string = 'adc'; +actualmatch = string.match(pattern); +expectedmatch = Array('adc'); +addThis(); +*/ + +status = inSection(39); +pattern = /\ba\b/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(40); +pattern = /\ba\b/; +string = '-a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(41); +pattern = /\ba\b/; +string = '-a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(42); +pattern = /\By\b/; +string = 'xy'; +actualmatch = string.match(pattern); +expectedmatch = Array('y'); +addThis(); + +status = inSection(43); +pattern = /\by\B/; +string = 'yz'; +actualmatch = string.match(pattern); +expectedmatch = Array('y'); +addThis(); + +status = inSection(44); +pattern = /\By\B/; +string = 'xyz'; +actualmatch = string.match(pattern); +expectedmatch = Array('y'); +addThis(); + +status = inSection(45); +pattern = /\w/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(46); +pattern = /\W/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(47); +pattern = /a\Sb/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-b'); +addThis(); + +status = inSection(48); +pattern = /\d/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = Array('1'); +addThis(); + +status = inSection(49); +pattern = /\D/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(50); +pattern = /[\w]/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(51); +pattern = /[\W]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(52); +pattern = /a[\S]b/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-b'); +addThis(); + +status = inSection(53); +pattern = /[\d]/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = Array('1'); +addThis(); + +status = inSection(54); +pattern = /[\D]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(55); +pattern = /ab|cd/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(56); +pattern = /ab|cd/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(57); +pattern = /()ef/; +string = 'def'; +actualmatch = string.match(pattern); +expectedmatch = Array('ef', ''); +addThis(); + +status = inSection(58); +pattern = /a\(b/; +string = 'a(b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a(b'); +addThis(); + +status = inSection(59); +pattern = /a\(*b/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(60); +pattern = /a\(*b/; +string = 'a((b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a((b'); +addThis(); + +status = inSection(61); +pattern = /a\\b/; +string = 'a\\b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a\\b'); +addThis(); + +status = inSection(62); +pattern = /((a))/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a'); +addThis(); + +status = inSection(63); +pattern = /(a)b(c)/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'a', 'c'); +addThis(); + +status = inSection(64); +pattern = /a+b+c/; +string = 'aabbabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(65); +pattern = /a{1,}b{1,}c/; +string = 'aabbabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(66); +pattern = /a.+?c/; +string = 'abcabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(67); +pattern = /(a+|b)*/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(68); +pattern = /(a+|b){0,}/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(69); +pattern = /(a+|b)+/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(70); +pattern = /(a+|b){1,}/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(71); +pattern = /(a+|b)?/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a'); +addThis(); + +status = inSection(72); +pattern = /(a+|b){0,1}/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a'); +addThis(); + +status = inSection(73); +pattern = /[^ab]*/; +string = 'cde'; +actualmatch = string.match(pattern); +expectedmatch = Array('cde'); +addThis(); + +status = inSection(74); +pattern = /([abc])*d/; +string = 'abbbcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbcd', 'c'); +addThis(); + +status = inSection(75); +pattern = /([abc])*bcd/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'a'); +addThis(); + +status = inSection(76); +pattern = /a|b|c|d|e/; +string = 'e'; +actualmatch = string.match(pattern); +expectedmatch = Array('e'); +addThis(); + +status = inSection(77); +pattern = /(a|b|c|d|e)f/; +string = 'ef'; +actualmatch = string.match(pattern); +expectedmatch = Array('ef', 'e'); +addThis(); + +status = inSection(78); +pattern = /abcd*efg/; +string = 'abcdefg'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcdefg'); +addThis(); + +status = inSection(79); +pattern = /ab*/; +string = 'xabyabbbz'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(80); +pattern = /ab*/; +string = 'xayabbbz'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(81); +pattern = /(ab|cd)e/; +string = 'abcde'; +actualmatch = string.match(pattern); +expectedmatch = Array('cde', 'cd'); +addThis(); + +status = inSection(82); +pattern = /[abhgefdc]ij/; +string = 'hij'; +actualmatch = string.match(pattern); +expectedmatch = Array('hij'); +addThis(); + +status = inSection(83); +pattern = /(abc|)ef/; +string = 'abcdef'; +actualmatch = string.match(pattern); +expectedmatch = Array('ef', ''); +addThis(); + +status = inSection(84); +pattern = /(a|b)c*d/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('bcd', 'b'); +addThis(); + +status = inSection(85); +pattern = /(ab|ab*)bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'a'); +addThis(); + +status = inSection(86); +pattern = /a([bc]*)c*/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'bc'); +addThis(); + +status = inSection(87); +pattern = /a([bc]*)(c*d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'bc', 'd'); +addThis(); + +status = inSection(88); +pattern = /a([bc]+)(c*d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'bc', 'd'); +addThis(); + +status = inSection(89); +pattern = /a([bc]*)(c+d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'b', 'cd'); +addThis(); + +status = inSection(90); +pattern = /a[bcd]*dcdcde/; +string = 'adcdcde'; +actualmatch = string.match(pattern); +expectedmatch = Array('adcdcde'); +addThis(); + +status = inSection(91); +pattern = /(ab|a)b*c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'ab'); +addThis(); + +status = inSection(92); +pattern = /((a)(b)c)(d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'abc', 'a', 'b', 'd'); +addThis(); + +status = inSection(93); +pattern = /[a-zA-Z_][a-zA-Z0-9_]*/; +string = 'alpha'; +actualmatch = string.match(pattern); +expectedmatch = Array('alpha'); +addThis(); + +status = inSection(94); +pattern = /^a(bc+|b[eh])g|.h$/; +string = 'abh'; +actualmatch = string.match(pattern); +expectedmatch = Array('bh', undefined); +addThis(); + +status = inSection(95); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'effgz'; +actualmatch = string.match(pattern); +expectedmatch = Array('effgz', 'effgz', undefined); +addThis(); + +status = inSection(96); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'ij'; +actualmatch = string.match(pattern); +expectedmatch = Array('ij', 'ij', 'j'); +addThis(); + +status = inSection(97); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'reffgz'; +actualmatch = string.match(pattern); +expectedmatch = Array('effgz', 'effgz', undefined); +addThis(); + +status = inSection(98); +pattern = /((((((((((a))))))))))/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(99); +pattern = /((((((((((a))))))))))\10/; +string = 'aa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(100); +pattern = /((((((((((a))))))))))/; +string = 'a!'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(101); +pattern = /(((((((((a)))))))))/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(102); +pattern = /(.*)c(.*)/; +string = 'abcde'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcde', 'ab', 'de'); +addThis(); + +status = inSection(103); +pattern = /abcd/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd'); +addThis(); + +status = inSection(104); +pattern = /a(bc)d/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'bc'); +addThis(); + +status = inSection(105); +pattern = /a[-]?c/; +string = 'ac'; +actualmatch = string.match(pattern); +expectedmatch = Array('ac'); +addThis(); + +status = inSection(106); +pattern = /(abc)\1/; +string = 'abcabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcabc', 'abc'); +addThis(); + +status = inSection(107); +pattern = /([a-c]*)\1/; +string = 'abcabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcabc', 'abc'); +addThis(); + +status = inSection(108); +pattern = /(a)|\1/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a'); +addThis(); + +status = inSection(109); +pattern = /(([a-c])b*?\2)*/; +string = 'ababbbcbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('ababb', 'bb', 'b'); +addThis(); + +status = inSection(110); +pattern = /(([a-c])b*?\2){3}/; +string = 'ababbbcbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('ababbbcbc', 'cbc', 'c'); +addThis(); + +/* Can't refer to a capture before it's encountered & completed +status = inSection(111); +pattern = /((\3|b)\2(a)x)+/; +string = 'aaaxabaxbaaxbbax'; +actualmatch = string.match(pattern); +expectedmatch = Array('bbax', 'bbax', 'b', 'a'); +addThis(); + +status = inSection(112); +pattern = /((\3|b)\2(a)){2,}/; +string = 'bbaababbabaaaaabbaaaabba'; +actualmatch = string.match(pattern); +expectedmatch = Array('bbaaaabba', 'bba', 'b', 'a'); +addThis(); +*/ + +status = inSection(113); +pattern = /abc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(114); +pattern = /abc/i; +string = 'XABCY'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(115); +pattern = /abc/i; +string = 'ABABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(116); +pattern = /ab*c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(117); +pattern = /ab*bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(118); +pattern = /ab*bc/i; +string = 'ABBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBC'); +addThis(); + +status = inSection(119); +pattern = /ab*?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(120); +pattern = /ab{0,}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(121); +pattern = /ab+?bc/i; +string = 'ABBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBC'); +addThis(); + +status = inSection(122); +pattern = /ab+bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(123); +pattern = /ab{1,}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(124); +pattern = /ab{1,3}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(125); +pattern = /ab{3,4}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(126); +pattern = /ab??bc/i; +string = 'ABBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBC'); +addThis(); + +status = inSection(127); +pattern = /ab??bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(128); +pattern = /ab{0,1}?bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(129); +pattern = /ab??c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(130); +pattern = /ab{0,1}?c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(131); +pattern = /^abc$/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(132); +pattern = /^abc/i; +string = 'ABCC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(133); +pattern = /abc$/i; +string = 'AABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(134); +pattern = /^/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(135); +pattern = /$/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(136); +pattern = /a.c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(137); +pattern = /a.c/i; +string = 'AXC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AXC'); +addThis(); + +status = inSection(138); +pattern = /a.*?c/i; +string = 'AXYZC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AXYZC'); +addThis(); + +status = inSection(139); +pattern = /a[bc]d/i; +string = 'ABD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABD'); +addThis(); + +status = inSection(140); +pattern = /a[b-d]e/i; +string = 'ACE'; +actualmatch = string.match(pattern); +expectedmatch = Array('ACE'); +addThis(); + +status = inSection(141); +pattern = /a[b-d]/i; +string = 'AAC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AC'); +addThis(); + +status = inSection(142); +pattern = /a[-b]/i; +string = 'A-'; +actualmatch = string.match(pattern); +expectedmatch = Array('A-'); +addThis(); + +status = inSection(143); +pattern = /a[b-]/i; +string = 'A-'; +actualmatch = string.match(pattern); +expectedmatch = Array('A-'); +addThis(); + +status = inSection(144); +pattern = /a]/i; +string = 'A]'; +actualmatch = string.match(pattern); +expectedmatch = Array('A]'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not +status = inSection(145); +pattern = /a[]]b/i; +string = 'A]B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A]B'); +addThis(); +*/ + +status = inSection(146); +pattern = /a[^bc]d/i; +string = 'AED'; +actualmatch = string.match(pattern); +expectedmatch = Array('AED'); +addThis(); + +status = inSection(147); +pattern = /a[^-b]c/i; +string = 'ADC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ADC'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not +status = inSection(148); +pattern = /a[^]b]c/i; +string = 'ADC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ADC'); +addThis(); +*/ + +status = inSection(149); +pattern = /ab|cd/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(150); +pattern = /ab|cd/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(151); +pattern = /()ef/i; +string = 'DEF'; +actualmatch = string.match(pattern); +expectedmatch = Array('EF', ''); +addThis(); + +status = inSection(152); +pattern = /a\(b/i; +string = 'A(B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A(B'); +addThis(); + +status = inSection(153); +pattern = /a\(*b/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(154); +pattern = /a\(*b/i; +string = 'A((B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A((B'); +addThis(); + +status = inSection(155); +pattern = /a\\b/i; +string = 'A\\B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A\\B'); +addThis(); + +status = inSection(156); +pattern = /((a))/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A'); +addThis(); + +status = inSection(157); +pattern = /(a)b(c)/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'A', 'C'); +addThis(); + +status = inSection(158); +pattern = /a+b+c/i; +string = 'AABBABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(159); +pattern = /a{1,}b{1,}c/i; +string = 'AABBABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(160); +pattern = /a.+?c/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(161); +pattern = /a.*?c/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(162); +pattern = /a.{0,5}?c/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(163); +pattern = /(a+|b)*/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(164); +pattern = /(a+|b){0,}/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(165); +pattern = /(a+|b)+/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(166); +pattern = /(a+|b){1,}/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(167); +pattern = /(a+|b)?/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A'); +addThis(); + +status = inSection(168); +pattern = /(a+|b){0,1}/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A'); +addThis(); + +status = inSection(169); +pattern = /(a+|b){0,1}?/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('', undefined); +addThis(); + +status = inSection(170); +pattern = /[^ab]*/i; +string = 'CDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('CDE'); +addThis(); + +status = inSection(171); +pattern = /([abc])*d/i; +string = 'ABBBCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBCD', 'C'); +addThis(); + +status = inSection(172); +pattern = /([abc])*bcd/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'A'); +addThis(); + +status = inSection(173); +pattern = /a|b|c|d|e/i; +string = 'E'; +actualmatch = string.match(pattern); +expectedmatch = Array('E'); +addThis(); + +status = inSection(174); +pattern = /(a|b|c|d|e)f/i; +string = 'EF'; +actualmatch = string.match(pattern); +expectedmatch = Array('EF', 'E'); +addThis(); + +status = inSection(175); +pattern = /abcd*efg/i; +string = 'ABCDEFG'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCDEFG'); +addThis(); + +status = inSection(176); +pattern = /ab*/i; +string = 'XABYABBBZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(177); +pattern = /ab*/i; +string = 'XAYABBBZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('A'); +addThis(); + +status = inSection(178); +pattern = /(ab|cd)e/i; +string = 'ABCDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('CDE', 'CD'); +addThis(); + +status = inSection(179); +pattern = /[abhgefdc]ij/i; +string = 'HIJ'; +actualmatch = string.match(pattern); +expectedmatch = Array('HIJ'); +addThis(); + +status = inSection(180); +pattern = /(abc|)ef/i; +string = 'ABCDEF'; +actualmatch = string.match(pattern); +expectedmatch = Array('EF', ''); +addThis(); + +status = inSection(181); +pattern = /(a|b)c*d/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('BCD', 'B'); +addThis(); + +status = inSection(182); +pattern = /(ab|ab*)bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'A'); +addThis(); + +status = inSection(183); +pattern = /a([bc]*)c*/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'BC'); +addThis(); + +status = inSection(184); +pattern = /a([bc]*)(c*d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'BC', 'D'); +addThis(); + +status = inSection(185); +pattern = /a([bc]+)(c*d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'BC', 'D'); +addThis(); + +status = inSection(186); +pattern = /a([bc]*)(c+d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'B', 'CD'); +addThis(); + +status = inSection(187); +pattern = /a[bcd]*dcdcde/i; +string = 'ADCDCDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('ADCDCDE'); +addThis(); + +status = inSection(188); +pattern = /(ab|a)b*c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'AB'); +addThis(); + +status = inSection(189); +pattern = /((a)(b)c)(d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'ABC', 'A', 'B', 'D'); +addThis(); + +status = inSection(190); +pattern = /[a-zA-Z_][a-zA-Z0-9_]*/i; +string = 'ALPHA'; +actualmatch = string.match(pattern); +expectedmatch = Array('ALPHA'); +addThis(); + +status = inSection(191); +pattern = /^a(bc+|b[eh])g|.h$/i; +string = 'ABH'; +actualmatch = string.match(pattern); +expectedmatch = Array('BH', undefined); +addThis(); + +status = inSection(192); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'EFFGZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('EFFGZ', 'EFFGZ', undefined); +addThis(); + +status = inSection(193); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'IJ'; +actualmatch = string.match(pattern); +expectedmatch = Array('IJ', 'IJ', 'J'); +addThis(); + +status = inSection(194); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'REFFGZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('EFFGZ', 'EFFGZ', undefined); +addThis(); + +status = inSection(195); +pattern = /((((((((((a))))))))))/i; +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(196); +pattern = /((((((((((a))))))))))\10/i; +string = 'AA'; +actualmatch = string.match(pattern); +expectedmatch = Array('AA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(197); +pattern = /((((((((((a))))))))))/i; +string = 'A!'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(198); +pattern = /(((((((((a)))))))))/i; +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(199); +pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i; +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A'); +addThis(); + +status = inSection(200); +pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i; +string = 'C'; +actualmatch = string.match(pattern); +expectedmatch = Array('C', 'C'); +addThis(); + +status = inSection(201); +pattern = /(.*)c(.*)/i; +string = 'ABCDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCDE', 'AB', 'DE'); +addThis(); + +status = inSection(202); +pattern = /abcd/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD'); +addThis(); + +status = inSection(203); +pattern = /a(bc)d/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'BC'); +addThis(); + +status = inSection(204); +pattern = /a[-]?c/i; +string = 'AC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AC'); +addThis(); + +status = inSection(205); +pattern = /(abc)\1/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCABC', 'ABC'); +addThis(); + +status = inSection(206); +pattern = /([a-c]*)\1/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCABC', 'ABC'); +addThis(); + +status = inSection(207); +pattern = /a(?!b)./; +string = 'abad'; +actualmatch = string.match(pattern); +expectedmatch = Array('ad'); +addThis(); + +status = inSection(208); +pattern = /a(?=d)./; +string = 'abad'; +actualmatch = string.match(pattern); +expectedmatch = Array('ad'); +addThis(); + +status = inSection(209); +pattern = /a(?=c|d)./; +string = 'abad'; +actualmatch = string.match(pattern); +expectedmatch = Array('ad'); +addThis(); + +status = inSection(210); +pattern = /a(?:b|c|d)(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'e'); +addThis(); + +status = inSection(211); +pattern = /a(?:b|c|d)*(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'e'); +addThis(); + +status = inSection(212); +pattern = /a(?:b|c|d)+?(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'e'); +addThis(); + +status = inSection(213); +pattern = /a(?:b|c|d)+?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acd', 'd'); +addThis(); + +status = inSection(214); +pattern = /a(?:b|c|d)+(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(215); +pattern = /a(?:b|c|d){2}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdb', 'b'); +addThis(); + +status = inSection(216); +pattern = /a(?:b|c|d){4,5}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdb', 'b'); +addThis(); + +status = inSection(217); +pattern = /a(?:b|c|d){4,5}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcd', 'd'); +addThis(); + +// MODIFIED - ECMA has different rules for paren contents +status = inSection(218); +pattern = /((foo)|(bar))*/; +string = 'foobar'; +actualmatch = string.match(pattern); +//expectedmatch = Array('foobar', 'bar', 'foo', 'bar'); +expectedmatch = Array('foobar', 'bar', undefined, 'bar'); +addThis(); + +status = inSection(219); +pattern = /a(?:b|c|d){6,7}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(220); +pattern = /a(?:b|c|d){6,7}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(221); +pattern = /a(?:b|c|d){5,6}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(222); +pattern = /a(?:b|c|d){5,6}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdb', 'b'); +addThis(); + +status = inSection(223); +pattern = /a(?:b|c|d){5,7}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(224); +pattern = /a(?:b|c|d){5,7}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdb', 'b'); +addThis(); + +status = inSection(225); +pattern = /a(?:b|(c|e){1,2}?|d)+?(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'c', 'e'); +addThis(); + +status = inSection(226); +pattern = /^(.+)?B/; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'A'); +addThis(); + +/* MODIFIED - ECMA has different rules for paren contents */ +status = inSection(227); +pattern = /^([^a-z])|(\^)$/; +string = '.'; +actualmatch = string.match(pattern); +//expectedmatch = Array('.', '.', ''); +expectedmatch = Array('.', '.', undefined); +addThis(); + +status = inSection(228); +pattern = /^[<>]&/; +string = '<&OUT'; +actualmatch = string.match(pattern); +expectedmatch = Array('<&'); +addThis(); + +/* Can't refer to a capture before it's encountered & completed +status = inSection(229); +pattern = /^(a\1?){4}$/; +string = 'aaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaaaa', 'aaaa'); +addThis(); + +status = inSection(230); +pattern = /^(a(?(1)\1)){4}$/; +string = 'aaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaaaa', 'aaaa'); +addThis(); +*/ + +status = inSection(231); +pattern = /((a{4})+)/; +string = 'aaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa'); +addThis(); + +status = inSection(232); +pattern = /(((aa){2})+)/; +string = 'aaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa'); +addThis(); + +status = inSection(233); +pattern = /(((a{2}){2})+)/; +string = 'aaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa'); +addThis(); + +status = inSection(234); +pattern = /(?:(f)(o)(o)|(b)(a)(r))*/; +string = 'foobar'; +actualmatch = string.match(pattern); +//expectedmatch = Array('foobar', 'f', 'o', 'o', 'b', 'a', 'r'); +expectedmatch = Array('foobar', undefined, undefined, undefined, 'b', 'a', 'r'); +addThis(); + +/* ECMA supports (?: (?= and (?! but doesn't support (?< etc. +status = inSection(235); +pattern = /(?<=a)b/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('b'); +addThis(); + +status = inSection(236); +pattern = /(? +status = inSection(311); +pattern = /(?>a+)b/; +string = 'aaab'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaab'); +addThis(); +*/ + +status = inSection(312); +pattern = /([[:]+)/; +string = 'a:[b]:'; +actualmatch = string.match(pattern); +expectedmatch = Array(':[', ':['); +addThis(); + +status = inSection(313); +pattern = /([[=]+)/; +string = 'a=[b]='; +actualmatch = string.match(pattern); +expectedmatch = Array('=[', '=['); +addThis(); + +status = inSection(314); +pattern = /([[.]+)/; +string = 'a.[b].'; +actualmatch = string.match(pattern); +expectedmatch = Array('.[', '.['); +addThis(); + +/* ECMA doesn't have rules for [: +status = inSection(315); +pattern = /[a[:]b[:c]/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); +*/ + +/* ECMA doesn't support (?> +status = inSection(316); +pattern = /((?>a+)b)/; +string = 'aaab'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaab', 'aaab'); +addThis(); + +status = inSection(317); +pattern = /(?>(a+))b/; +string = 'aaab'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaab', 'aaa'); +addThis(); + +status = inSection(318); +pattern = /((?>[^()]+)|\([^()]*\))+/; +string = '((abc(ade)ufh()()x'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc(ade)ufh()()x', 'x'); +addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(319); +pattern = /\Z/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(320); +pattern = /\z/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); +*/ + +status = inSection(321); +pattern = /$/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(322); +pattern = /\Z/; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(323); +pattern = /\z/; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); +*/ + +status = inSection(324); +pattern = /$/; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(325); +pattern = /\Z/; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(326); +pattern = /\z/; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); +*/ + +status = inSection(327); +pattern = /$/; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(328); +pattern = /\Z/m; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(329); +pattern = /\z/m; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); +*/ + +status = inSection(330); +pattern = /$/m; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(331); +pattern = /\Z/m; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(332); +pattern = /\z/m; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); +*/ + +status = inSection(333); +pattern = /$/m; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(334); +pattern = /\Z/m; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(335); +pattern = /\z/m; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); +*/ + +status = inSection(336); +pattern = /$/m; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(337); +pattern = /a\Z/; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); +*/ + +/* $ only matches end of input unless multiline +status = inSection(338); +pattern = /a$/; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(339); +pattern = /a\Z/; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(340); +pattern = /a\z/; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); +*/ + +status = inSection(341); +pattern = /a$/; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(342); +pattern = /a$/m; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(343); +pattern = /a\Z/m; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); +*/ + +status = inSection(344); +pattern = /a$/m; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(345); +pattern = /a\Z/m; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(346); +pattern = /a\z/m; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); +*/ + +status = inSection(347); +pattern = /a$/m; +string = 'b\na'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(348); +pattern = /aa\Z/; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); +*/ + +/* $ only matches end of input unless multiline +status = inSection(349); +pattern = /aa$/; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(350); +pattern = /aa\Z/; +string = 'b\naa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); + +status = inSection(351); +pattern = /aa\z/; +string = 'b\naa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); +*/ + +status = inSection(352); +pattern = /aa$/; +string = 'b\naa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); + +status = inSection(353); +pattern = /aa$/m; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(354); +pattern = /aa\Z/m; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); +*/ + +status = inSection(355); +pattern = /aa$/m; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(356); +pattern = /aa\Z/m; +string = 'b\naa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); + +status = inSection(357); +pattern = /aa\z/m; +string = 'b\naa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); +*/ + +status = inSection(358); +pattern = /aa$/m; +string = 'b\naa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(359); +pattern = /ab\Z/; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); +*/ + +/* $ only matches end of input unless multiline +status = inSection(360); +pattern = /ab$/; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(361); +pattern = /ab\Z/; +string = 'b\nab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(362); +pattern = /ab\z/; +string = 'b\nab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); +*/ + +status = inSection(363); +pattern = /ab$/; +string = 'b\nab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(364); +pattern = /ab$/m; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(365); +pattern = /ab\Z/m; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); +*/ + +status = inSection(366); +pattern = /ab$/m; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(367); +pattern = /ab\Z/m; +string = 'b\nab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(368); +pattern = /ab\z/m; +string = 'b\nab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); +*/ + +status = inSection(369); +pattern = /ab$/m; +string = 'b\nab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(370); +pattern = /abb\Z/; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); +*/ + +/* $ only matches end of input unless multiline +status = inSection(371); +pattern = /abb$/; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(372); +pattern = /abb\Z/; +string = 'b\nabb'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); + +status = inSection(373); +pattern = /abb\z/; +string = 'b\nabb'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); +*/ + +status = inSection(374); +pattern = /abb$/; +string = 'b\nabb'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); + +status = inSection(375); +pattern = /abb$/m; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(376); +pattern = /abb\Z/m; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); +*/ + +status = inSection(377); +pattern = /abb$/m; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't +status = inSection(378); +pattern = /abb\Z/m; +string = 'b\nabb'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); + +status = inSection(379); +pattern = /abb\z/m; +string = 'b\nabb'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); +*/ + +status = inSection(380); +pattern = /abb$/m; +string = 'b\nabb'; +actualmatch = string.match(pattern); +expectedmatch = Array('abb'); +addThis(); + +status = inSection(381); +pattern = /(^|x)(c)/; +string = 'ca'; +actualmatch = string.match(pattern); +expectedmatch = Array('c', '', 'c'); +addThis(); + +status = inSection(382); +pattern = /foo.bart/; +string = 'foo.bart'; +actualmatch = string.match(pattern); +expectedmatch = Array('foo.bart'); +addThis(); + +status = inSection(383); +pattern = /^d[x][x][x]/m; +string = 'abcd\ndxxx'; +actualmatch = string.match(pattern); +expectedmatch = Array('dxxx'); +addThis(); + +status = inSection(384); +pattern = /tt+$/; +string = 'xxxtt'; +actualmatch = string.match(pattern); +expectedmatch = Array('tt'); +addThis(); + +/* ECMA spec says that each atom in a range must be a single character +status = inSection(385); +pattern = /([a-\d]+)/; +string = 'za-9z'; +actualmatch = string.match(pattern); +expectedmatch = Array('9', '9'); +addThis(); + +status = inSection(386); +pattern = /([\d-z]+)/; +string = 'a0-za'; +actualmatch = string.match(pattern); +expectedmatch = Array('0-z', '0-z'); +addThis(); +*/ + +/* ECMA doesn't support [: +status = inSection(387); +pattern = /([a-[:digit:]]+)/; +string = 'za-9z'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-9', 'a-9'); +addThis(); + +status = inSection(388); +pattern = /([[:digit:]-z]+)/; +string = '=0-z='; +actualmatch = string.match(pattern); +expectedmatch = Array('0-z', '0-z'); +addThis(); + +status = inSection(389); +pattern = /([[:digit:]-[:alpha:]]+)/; +string = '=0-z='; +actualmatch = string.match(pattern); +expectedmatch = Array('0-z', '0-z'); +addThis(); +*/ + +status = inSection(390); +pattern = /(\d+\.\d+)/; +string = '3.1415926'; +actualmatch = string.match(pattern); +expectedmatch = Array('3.1415926', '3.1415926'); +addThis(); + +status = inSection(391); +pattern = /\.c(pp|xx|c)?$/i; +string = 'IO.c'; +actualmatch = string.match(pattern); +expectedmatch = Array('.c', undefined); +addThis(); + +status = inSection(392); +pattern = /(\.c(pp|xx|c)?$)/i; +string = 'IO.c'; +actualmatch = string.match(pattern); +expectedmatch = Array('.c', '.c', undefined); +addThis(); + +status = inSection(393); +pattern = /(^|a)b/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'a'); +addThis(); + +status = inSection(394); +pattern = /^([ab]*?)(b)?(c)$/; +string = 'abac'; +actualmatch = string.match(pattern); +expectedmatch = Array('abac', 'aba', undefined, 'c'); +addThis(); + +status = inSection(395); +pattern = /^(?:.,){2}c/i; +string = 'a,b,c'; +actualmatch = string.match(pattern); +expectedmatch = Array('a,b,c'); +addThis(); + +status = inSection(396); +pattern = /^(.,){2}c/i; +string = 'a,b,c'; +actualmatch = string.match(pattern); +expectedmatch = Array('a,b,c', 'b,'); +addThis(); + +status = inSection(397); +pattern = /^(?:[^,]*,){2}c/; +string = 'a,b,c'; +actualmatch = string.match(pattern); +expectedmatch = Array('a,b,c'); +addThis(); + +status = inSection(398); +pattern = /^([^,]*,){2}c/; +string = 'a,b,c'; +actualmatch = string.match(pattern); +expectedmatch = Array('a,b,c', 'b,'); +addThis(); + +status = inSection(399); +pattern = /^([^,]*,){3}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(400); +pattern = /^([^,]*,){3,}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(401); +pattern = /^([^,]*,){0,3}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(402); +pattern = /^([^,]{1,3},){3}d/i; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(403); +pattern = /^([^,]{1,3},){3,}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(404); +pattern = /^([^,]{1,3},){0,3}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(405); +pattern = /^([^,]{1,},){3}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(406); +pattern = /^([^,]{1,},){3,}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(407); +pattern = /^([^,]{1,},){0,3}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(408); +pattern = /^([^,]{0,3},){3}d/i; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(409); +pattern = /^([^,]{0,3},){3,}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +status = inSection(410); +pattern = /^([^,]{0,3},){0,3}d/; +string = 'aaa,b,c,d'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaa,b,c,d', 'c,'); +addThis(); + +/* ECMA doesn't support \A +status = inSection(411); +pattern = /(?!\A)x/m; +string = 'a\nxb\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('\n'); +addThis(); +*/ + +status = inSection(412); +pattern = /^(a(b)?)+$/; +string = 'aba'; +actualmatch = string.match(pattern); +expectedmatch = Array('aba', 'a', undefined); +addThis(); + +status = inSection(413); +pattern = /^(aa(bb)?)+$/; +string = 'aabbaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aabbaa', 'aa', undefined); +addThis(); + +status = inSection(414); +pattern = /^.{9}abc.*\n/m; +string = '123\nabcabcabcabc\n'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcabcabcabc\n'); +addThis(); + +status = inSection(415); +pattern = /^(a)?a$/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', undefined); +addThis(); + +status = inSection(416); +pattern = /^(a\1?)(a\1?)(a\2?)(a\3?)$/; +string = 'aaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaa', 'a', 'aa', 'a', 'aa'); +addThis(); + +/* Can't refer to a capture before it's encountered & completed +status = inSection(417); +pattern = /^(a\1?){4}$/; +string = 'aaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaa', 'aaa'); +addThis(); +*/ + +status = inSection(418); +pattern = /^(0+)?(?:x(1))?/; +string = 'x1'; +actualmatch = string.match(pattern); +expectedmatch = Array('x1', undefined, '1'); +addThis(); + +status = inSection(419); +pattern = /^([0-9a-fA-F]+)(?:x([0-9a-fA-F]+)?)(?:x([0-9a-fA-F]+))?/; +string = '012cxx0190'; +actualmatch = string.match(pattern); +expectedmatch = Array('012cxx0190', '012c', undefined, '0190'); +addThis(); + +status = inSection(420); +pattern = /^(b+?|a){1,2}c/; +string = 'bbbac'; +actualmatch = string.match(pattern); +expectedmatch = Array('bbbac', 'a'); +addThis(); + +status = inSection(421); +pattern = /^(b+?|a){1,2}c/; +string = 'bbbbac'; +actualmatch = string.match(pattern); +expectedmatch = Array('bbbbac', 'a'); +addThis(); + +status = inSection(422); +pattern = /((?:aaaa|bbbb)cccc)?/; +string = 'aaaacccc'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaacccc', 'aaaacccc'); +addThis(); + +status = inSection(423); +pattern = /((?:aaaa|bbbb)cccc)?/; +string = 'bbbbcccc'; +actualmatch = string.match(pattern); +expectedmatch = Array('bbbbcccc', 'bbbbcccc'); +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + if(omitCurrentSection()) + return; + + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function omitCurrentSection() +{ + try + { + // current section number is in global status variable + var n = status.match(/(\d+)/)[1]; + return ((n < cnLBOUND) || (n > cnUBOUND)); + } + catch(e) + { + return false; + } +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/perlstress-002.js b/tests/mozilla/ecma_3/RegExp/perlstress-002.js new file mode 100644 index 0000000..44cfbb5 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/perlstress-002.js @@ -0,0 +1,1837 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com, rogerl@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 2002-07-07 +* SUMMARY: Testing JS RegExp engine against Perl 5 RegExp engine. +* Adjust cnLBOUND, cnUBOUND below to restrict which sections are tested. +* +* This test was created by running various patterns and strings through the +* Perl 5 RegExp engine. We saved the results below to test the JS engine. +* +* Each of the examples below is a negative test; that is, each produces a +* null match in Perl. Thus we set |expectedmatch| = |null| in each section. +* +* NOTE: ECMA/JS and Perl do differ on certain points. We have either commented +* out such sections altogether, or modified them to fit what we expect from JS. +* +* EXAMPLES: +* +* - ECMA does support (?: (?= and (?! operators, but doesn't support (?< etc. +* +* - ECMA doesn't support (?(condition) +* +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 85721; +var summary = 'Testing regular expression edge cases'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); +var cnLBOUND = 0; +var cnUBOUND = 1000; + + +status = inSection(1); +pattern = /abc/; +string = 'xbc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(2); +pattern = /abc/; +string = 'axc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(3); +pattern = /abc/; +string = 'abx'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(4); +pattern = /ab+bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(5); +pattern = /ab+bc/; +string = 'abq'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(6); +pattern = /ab{1,}bc/; +string = 'abq'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(7); +pattern = /ab{4,5}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(8); +pattern = /ab?bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(9); +pattern = /^abc$/; +string = 'abcc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(10); +pattern = /^abc$/; +string = 'aabc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(11); +pattern = /abc$/; +string = 'aabcd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(12); +pattern = /a.*c/; +string = 'axyzd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(13); +pattern = /a[bc]d/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(14); +pattern = /a[b-d]e/; +string = 'abd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(15); +pattern = /a[^bc]d/; +string = 'abd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(16); +pattern = /a[^-b]c/; +string = 'a-c'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(17); +pattern = /a[^]b]c/; +string = 'a]c'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(18); +pattern = /\by\b/; +string = 'xy'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(19); +pattern = /\by\b/; +string = 'yz'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(20); +pattern = /\by\b/; +string = 'xyz'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(21); +pattern = /\Ba\B/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(22); +pattern = /\Ba\B/; +string = '-a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(23); +pattern = /\Ba\B/; +string = '-a-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(24); +pattern = /\w/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(25); +pattern = /\W/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(26); +pattern = /a\sb/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(27); +pattern = /\d/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(28); +pattern = /\D/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(29); +pattern = /[\w]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(30); +pattern = /[\W]/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(31); +pattern = /a[\s]b/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(32); +pattern = /[\d]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(33); +pattern = /[\D]/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(34); +pattern = /$b/; +string = 'b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(35); +pattern = /^(ab|cd)e/; +string = 'abcde'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(36); +pattern = /a[bcd]+dcdcde/; +string = 'adcdcde'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(37); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'effg'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(38); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'bcdd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(39); +pattern = /[k]/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +// MODIFIED - ECMA has different rules for paren contents. +status = inSection(40); +pattern = /(a)|\1/; +string = 'x'; +actualmatch = string.match(pattern); +//expectedmatch = null; +expectedmatch = Array("", undefined); +addThis(); + +// MODIFIED - ECMA has different rules for paren contents. +status = inSection(41); +pattern = /((\3|b)\2(a)x)+/; +string = 'aaxabxbaxbbx'; +actualmatch = string.match(pattern); +//expectedmatch = null; +expectedmatch = Array("ax", "ax", "", "a"); +addThis(); + +status = inSection(42); +pattern = /abc/i; +string = 'XBC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(43); +pattern = /abc/i; +string = 'AXC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(44); +pattern = /abc/i; +string = 'ABX'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(45); +pattern = /ab+bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(46); +pattern = /ab+bc/i; +string = 'ABQ'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(47); +pattern = /ab{1,}bc/i; +string = 'ABQ'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(48); +pattern = /ab{4,5}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(49); +pattern = /ab??bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(50); +pattern = /^abc$/i; +string = 'ABCC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(51); +pattern = /^abc$/i; +string = 'AABC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(52); +pattern = /a.*c/i; +string = 'AXYZD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(53); +pattern = /a[bc]d/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(54); +pattern = /a[b-d]e/i; +string = 'ABD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(55); +pattern = /a[^bc]d/i; +string = 'ABD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(56); +pattern = /a[^-b]c/i; +string = 'A-C'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(57); +pattern = /a[^]b]c/i; +string = 'A]C'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(58); +pattern = /$b/i; +string = 'B'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(59); +pattern = /^(ab|cd)e/i; +string = 'ABCDE'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(60); +pattern = /a[bcd]+dcdcde/i; +string = 'ADCDCDE'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(61); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'EFFG'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(62); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'BCDD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(63); +pattern = /[k]/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(64); +pattern = /^(a\1?){4}$/; +string = 'aaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(65); +pattern = /^(a\1?){4}$/; +string = 'aaaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +/* ECMA doesn't support (?( +status = inSection(66); +pattern = /^(a(?(1)\1)){4}$/; +string = 'aaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(67); +pattern = /^(a(?(1)\1)){4}$/; +string = 'aaaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); +*/ + +/* ECMA doesn't support (?< +status = inSection(68); +pattern = /(?<=a)b/; +string = 'cb'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(69); +pattern = /(?<=a)b/; +string = 'b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(70); +pattern = /(?a+)ab/; +string = 'aaab'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(106); +pattern = /a\Z/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(107); +pattern = /a\z/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(108); +pattern = /a$/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(109); +pattern = /a\z/; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(110); +pattern = /a\z/m; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(111); +pattern = /a\z/m; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(112); +pattern = /aa\Z/; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(113); +pattern = /aa\z/; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(114); +pattern = /aa$/; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(115); +pattern = /aa\z/; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(116); +pattern = /aa\z/m; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(117); +pattern = /aa\z/m; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(118); +pattern = /aa\Z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(119); +pattern = /aa\z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(120); +pattern = /aa$/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(121); +pattern = /aa\Z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(122); +pattern = /aa\z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(123); +pattern = /aa$/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(124); +pattern = /aa\Z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(125); +pattern = /aa\z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(126); +pattern = /aa$/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(127); +pattern = /aa\Z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(128); +pattern = /aa\z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(129); +pattern = /aa$/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(130); +pattern = /aa\Z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(131); +pattern = /aa\z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(132); +pattern = /aa$/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(133); +pattern = /aa\Z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(134); +pattern = /aa\z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(135); +pattern = /aa$/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(136); +pattern = /aa\Z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(137); +pattern = /aa\z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(138); +pattern = /aa$/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(139); +pattern = /aa\Z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(140); +pattern = /aa\z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(141); +pattern = /aa$/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(142); +pattern = /aa\Z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(143); +pattern = /aa\z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(144); +pattern = /aa$/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(145); +pattern = /aa\Z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(146); +pattern = /aa\z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(147); +pattern = /aa$/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(148); +pattern = /aa\Z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(149); +pattern = /aa\z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(150); +pattern = /aa$/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(151); +pattern = /aa\Z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(152); +pattern = /aa\z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(153); +pattern = /aa$/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(154); +pattern = /ab\Z/; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(155); +pattern = /ab\z/; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(156); +pattern = /ab$/; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(157); +pattern = /ab\z/; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(158); +pattern = /ab\z/m; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(159); +pattern = /ab\z/m; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(160); +pattern = /ab\Z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(161); +pattern = /ab\z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(162); +pattern = /ab$/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(163); +pattern = /ab\Z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(164); +pattern = /ab\z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(165); +pattern = /ab$/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(166); +pattern = /ab\Z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(167); +pattern = /ab\z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(168); +pattern = /ab$/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(169); +pattern = /ab\Z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(170); +pattern = /ab\z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(171); +pattern = /ab$/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(172); +pattern = /ab\Z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(173); +pattern = /ab\z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(174); +pattern = /ab$/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(175); +pattern = /ab\Z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(176); +pattern = /ab\z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(177); +pattern = /ab$/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(178); +pattern = /ab\Z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(179); +pattern = /ab\z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(180); +pattern = /ab$/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(181); +pattern = /ab\Z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(182); +pattern = /ab\z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(183); +pattern = /ab$/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(184); +pattern = /ab\Z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(185); +pattern = /ab\z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(186); +pattern = /ab$/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(187); +pattern = /ab\Z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(188); +pattern = /ab\z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(189); +pattern = /ab$/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(190); +pattern = /ab\Z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(191); +pattern = /ab\z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(192); +pattern = /ab$/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(193); +pattern = /ab\Z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(194); +pattern = /ab\z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(195); +pattern = /ab$/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(196); +pattern = /abb\Z/; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(197); +pattern = /abb\z/; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(198); +pattern = /abb$/; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(199); +pattern = /abb\z/; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(200); +pattern = /abb\z/m; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(201); +pattern = /abb\z/m; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(202); +pattern = /abb\Z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(203); +pattern = /abb\z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(204); +pattern = /abb$/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(205); +pattern = /abb\Z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(206); +pattern = /abb\z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(207); +pattern = /abb$/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(208); +pattern = /abb\Z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(209); +pattern = /abb\z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(210); +pattern = /abb$/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(211); +pattern = /abb\Z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(212); +pattern = /abb\z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(213); +pattern = /abb$/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(214); +pattern = /abb\Z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(215); +pattern = /abb\z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(216); +pattern = /abb$/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(217); +pattern = /abb\Z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(218); +pattern = /abb\z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(219); +pattern = /abb$/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(220); +pattern = /abb\Z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(221); +pattern = /abb\z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(222); +pattern = /abb$/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(223); +pattern = /abb\Z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(224); +pattern = /abb\z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(225); +pattern = /abb$/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(226); +pattern = /abb\Z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(227); +pattern = /abb\z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(228); +pattern = /abb$/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(229); +pattern = /abb\Z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(230); +pattern = /abb\z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(231); +pattern = /abb$/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(232); +pattern = /abb\Z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(233); +pattern = /abb\z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(234); +pattern = /abb$/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(235); +pattern = /abb\Z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(236); +pattern = /abb\z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(237); +pattern = /abb$/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(238); +pattern = /a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/; +string = 'x'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(239); +pattern = /\GX.*X/; +string = 'aaaXbX'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(240); +pattern = /\.c(pp|xx|c)?$/i; +string = 'Changes'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(241); +pattern = /^([a-z]:)/; +string = 'C:/'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(242); +pattern = /(\w)?(abc)\1b/; +string = 'abcab'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +/* ECMA doesn't support (?( +status = inSection(243); +pattern = /^(a)?(?(1)a|b)+$/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); +*/ + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + if(omitCurrentSection()) + return; + + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function omitCurrentSection() +{ + try + { + // current section number is in global status variable + var n = status.match(/(\d+)/)[1]; + return ((n < cnLBOUND) || (n > cnUBOUND)); + } + catch(e) + { + return false; + } +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-100199.js b/tests/mozilla/ecma_3/RegExp/regress-100199.js new file mode 100644 index 0000000..8380499 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-100199.js @@ -0,0 +1,286 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 17 September 2001 +* +* SUMMARY: Regression test for Bugzilla bug 100199 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=100199 +* +* The empty character class [] is a valid RegExp construct: the condition +* that a given character belong to a set containing no characters. As such, +* it can never be met and is always FALSE. Similarly, [^] is a condition +* that matches any given character and is always TRUE. +* +* Neither one of these conditions should cause syntax errors in a RegExp. +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 100199; +var summary = '[], [^] are valid RegExp conditions. Should not cause errors -'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /[]/; + string = 'abc'; + status = inSection(1); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = ''; + status = inSection(2); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = '['; + status = inSection(3); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = '/'; + status = inSection(4); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = '['; + status = inSection(5); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = ']'; + status = inSection(6); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = '[]'; + status = inSection(7); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = '[ ]'; + status = inSection(8); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = ']['; + status = inSection(9); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + +pattern = /a[]/; + string = 'abc'; + status = inSection(10); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = ''; + status = inSection(11); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = 'a['; + status = inSection(12); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = 'a[]'; + status = inSection(13); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = '['; + status = inSection(14); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = ']'; + status = inSection(15); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = '[]'; + status = inSection(16); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = '[ ]'; + status = inSection(17); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + string = ']['; + status = inSection(18); + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + +pattern = /[^]/; + string = 'abc'; + status = inSection(19); + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + + string = ''; + status = inSection(20); + actualmatch = string.match(pattern); + expectedmatch = null; //there are no characters to test against the condition + addThis(); + + string = '\/'; + status = inSection(21); + actualmatch = string.match(pattern); + expectedmatch = Array('/'); + addThis(); + + string = '\['; + status = inSection(22); + actualmatch = string.match(pattern); + expectedmatch = Array('['); + addThis(); + + string = '['; + status = inSection(23); + actualmatch = string.match(pattern); + expectedmatch = Array('['); + addThis(); + + string = ']'; + status = inSection(24); + actualmatch = string.match(pattern); + expectedmatch = Array(']'); + addThis(); + + string = '[]'; + status = inSection(25); + actualmatch = string.match(pattern); + expectedmatch = Array('['); + addThis(); + + string = '[ ]'; + status = inSection(26); + actualmatch = string.match(pattern); + expectedmatch = Array('['); + addThis(); + + string = ']['; + status = inSection(27); + actualmatch = string.match(pattern); + expectedmatch = Array(']'); + addThis(); + + +pattern = /a[^]/; + string = 'abc'; + status = inSection(28); + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + + string = ''; + status = inSection(29); + actualmatch = string.match(pattern); + expectedmatch = null; //there are no characters to test against the condition + addThis(); + + string = 'a['; + status = inSection(30); + actualmatch = string.match(pattern); + expectedmatch = Array('a['); + addThis(); + + string = 'a]'; + status = inSection(31); + actualmatch = string.match(pattern); + expectedmatch = Array('a]'); + addThis(); + + string = 'a[]'; + status = inSection(32); + actualmatch = string.match(pattern); + expectedmatch = Array('a['); + addThis(); + + string = 'a[ ]'; + status = inSection(33); + actualmatch = string.match(pattern); + expectedmatch = Array('a['); + addThis(); + + string = 'a]['; + status = inSection(34); + actualmatch = string.match(pattern); + expectedmatch = Array('a]'); + addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-103087.js b/tests/mozilla/ecma_3/RegExp/regress-103087.js new file mode 100644 index 0000000..8cfc662 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-103087.js @@ -0,0 +1,155 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): bedney@technicalpursuit.com, pschwartau@netscape.com +* Date: 04 October 2001 +* +* SUMMARY: Arose from Bugzilla bug 103087: +* "The RegExp MarkupSPE in demo crashes Mozilla" +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=103087 +* The SpiderMonkey shell crashed on some of these regexps. +* +* The reported crash was on i=24 below ('MarkupSPE' regexp) +* I crashed on that, and also on i=43 ('XML_SPE' regexp) +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 103087; +var summary = "Testing that we don't crash on any of these regexps -"; +var re = ''; +var lm = ''; +var lc = ''; +var rc = ''; + + +// the regexps are built in pieces - +var NameStrt = "[A-Za-z_:]|[^\\x00-\\x7F]"; +var NameChar = "[A-Za-z0-9_:.-]|[^\\x00-\\x7F]"; +var Name = "(" + NameStrt + ")(" + NameChar + ")*"; +var TextSE = "[^<]+"; +var UntilHyphen = "[^-]*-"; +var Until2Hyphens = UntilHyphen + "([^-]" + UntilHyphen + ")*-"; +var CommentCE = Until2Hyphens + ">?"; +var UntilRSBs = "[^]]*]([^]]+])*]+"; +var CDATA_CE = UntilRSBs + "([^]>]" + UntilRSBs + ")*>"; +var S = "[ \\n\\t\\r]+"; +var QuoteSE = '"[^"]' + "*" + '"' + "|'[^']*'"; +var DT_IdentSE = S + Name + "(" + S + "(" + Name + "|" + QuoteSE + "))*"; +var MarkupDeclCE = "([^]\"'><]+|" + QuoteSE + ")*>"; +var S1 = "[\\n\\r\\t ]"; +var UntilQMs = "[^?]*\\?+"; +var PI_Tail = "\\?>|" + S1 + UntilQMs + "([^>?]" + UntilQMs + ")*>"; +var DT_ItemSE = "<(!(--" + Until2Hyphens + ">|[^-]" + MarkupDeclCE + ")|\\?" + Name + "(" + PI_Tail + "))|%" + Name + ";|" + S; +var DocTypeCE = DT_IdentSE + "(" + S + ")?(\\[(" + DT_ItemSE + ")*](" + S + ")?)?>?"; +var DeclCE = "--(" + CommentCE + ")?|\\[CDATA\\[(" + CDATA_CE + ")?|DOCTYPE(" + DocTypeCE + ")?"; +var PI_CE = Name + "(" + PI_Tail + ")?"; +var EndTagCE = Name + "(" + S + ")?>?"; +var AttValSE = '"[^<"]' + "*" + '"' + "|'[^<']*'"; +var ElemTagCE = Name + "(" + S + Name + "(" + S + ")?=(" + S + ")?(" + AttValSE + "))*(" + S + ")?/?>?"; +var MarkupSPE = "<(!(" + DeclCE + ")?|\\?(" + PI_CE + ")?|/(" + EndTagCE + ")?|(" + ElemTagCE + ")?)"; +var XML_SPE = TextSE + "|" + MarkupSPE; +var CommentRE = "'; +s += ''; +s += ''; +s += ''; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += 'Click here to skip to main content.'; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += ''; +s += '
'; +s += '
CNN.com'; +s += ' '; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ''; +s += ''; +s += '
'; +s += '
'; +s += ''; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
SEARCH
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
  The Web  CNN.com   
enhanced by Google
'; +s += '
'; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += ' '; +s += ' '; +s += ''; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
'; +s += '
SERVICES
 
 
 
SEARCH
'; +s += ''; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
WebCNN.com
enhanced by Google
'; +s += ''; +s += ''; +s += ''; +s += '
'; +s += ''; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
Updated: 05:53 p.m. EDT (2153 GMT) June 12, 2003
'; +s += '
'; +s += ''; +s += ''; +s += ' '; +s += ' Oscar-winner Peck dies'; +s += ''; +s += '
'; +s += '

Oscar-winner Peck dies

'; +s += '

'; +s += 'Actor Gregory Peck, who won an Oscar for his portrayal of upstanding lawyer Atticus Finch in 1962s "To Kill a Mockingbird," has died at age 87. Peck was best known for roles of dignified statesmen and people who followed a strong code of ethics. But he also could play against type. All told, Peck was nominated for five Academy Awards.'; +s += '

'; +s += '

'; +s += ' FULL STORY'; +s += '

'; +s += ''; +s += ''; +s += ''; +s += '• Video: premium content A leading mans leading man
'; +s += ''; +s += ''; +s += ''; +s += ' '; +s += '• Interactive: Gregory Peck through the years
'; +s += ''; +s += ' '; +s += '• Gregory Peck filmographyexternal link
'; +s += ''; +s += ' '; +s += '• Pecks Finch chararcter AFIs top heroexternal link
'; +s += '
'; +s += ''; +s += ''; +s += '
'; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += '
'; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
MORE TOP STORIES Hot Stories
'; +s += '
'; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ' '; +s += ''; +s += '
'; +s += ''; +s += ''; +s += '
'; +s += ''; +s += ''; +s += ''; +s += ' '; +s += '
'; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += ' '; +s += ' '; +s += '
'; +s += ' CNNRADIO'; +s += '
Listen to latest updates'; +s += '
'; +s += ''; +s += '
'; +s += ' '; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
VIDEOMORE VIDEO
'; +s += ' Soldier broke dozens of hearts over e-mail
'; +s += ' premium content PLAY VIDEO
'; +s += '
'; +s += ' '; +s += '
'; +s += ' '; +s += '
'; +s += ''; +s += ''; +s += '
'; +s += ''; +s += ''; +s += ''; +s += '
'; +s += '
'; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
ON THE SCENEmore reports
'; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ''; +s += ''; +s += ' '; +s += '
Jeffrey Toobin: "It takes guts" for Peterson defense to subpoena judge over wiretap issue.'; +s += 'Full Storyimage
'; +s += '
'; +s += '
'; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
BUSINESS'; +s += '  at CNN/Money  Business News
'; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
STOCK/FUND QUOTES:
enter symbol
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
sponsored by:Click Here
'; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += ' '; +s += '
MARKETS: '; +s += ''; +s += '4:30pm ET, 6/12
DJIA+13.309196.50+ 0.14%
NAS+ 7.601653.62+ 0.46%
S&P+ 1.03998.51+ 0.10%
'; +s += '
'; +s += ''; +s += '
'; +s += ''; +s += ''; +s += '
'; +s += ''; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += '
'; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
MORE REAL TVMore Entertainment
'; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += ' '; +s += ' Go ahead, follow me
'; +s += 'New reality series and the movie debut of "Idol" finalists'; +s += '
Go ahead, follow me
'; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ' '; +s += '
'; +s += ''; +s += '
'; +s += '
'; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
GIFT IDEASBusiness News
'; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += ''; +s += ''; +s += 'CNN/Money: Fathers Day
'; +s += 'Smaller is better --from digital cameras to iPod'; +s += '
Fathers Day
'; +s += '
'; +s += '
'; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '

U.S. News:
'; +s += ''; +s += ' '; +s += '• Miami police link 4 rapes to serial rapist
'; +s += ''; +s += ' '; +s += '• Woman mistaken for fugitive jailed
'; +s += ''; +s += ' '; +s += '• Pregnant woman impaled on mic stand
'; +s += '
World News:
'; +s += ''; +s += ' '; +s += '• NATO reshapes for new era
'; +s += ''; +s += ' '; +s += '• U.N. reviews Bunia peace force
'; +s += ''; +s += ''; +s += ''; +s += '• TIME.com: Saddams curtain trailexternal link
'; +s += '
Sci-Tech News:
'; +s += ''; +s += ' '; +s += '• Another reason to throw out your VCR
'; +s += ''; +s += ' '; +s += '• Flat screen TV prices dropping
'; +s += '
Entertainment News:
'; +s += ''; +s += ' '; +s += '• CNN hires Soledad OBrien for "AM"
'; +s += ''; +s += ' '; +s += '• Dating show star let go by law firm
'; +s += '
Politics News:
'; +s += ''; +s += ' '; +s += '• Schwarzenegger on California politics
'; +s += ''; +s += ' '; +s += '• House approves extension on child tax credit
'; +s += '
Law News:
'; +s += ''; +s += ' '; +s += '• Court bars cash advances to plaintiffs
'; +s += ''; +s += ' '; +s += '• Lawsuit against Jackson settled
'; +s += '
Health News:
'; +s += ''; +s += ' '; +s += '• Monkeypox spreading person-to-person?
'; +s += ''; +s += ' '; +s += '• A full body X-ray in 13 seconds
'; +s += '
Space News:
'; +s += ''; +s += ' '; +s += '• Hydrogen fuel may disturb ozone layer
'; +s += ''; +s += ' '; +s += '• New threat found for shuttle launches
'; +s += '
Travel News:
'; +s += ''; +s += ' '; +s += '• Walking America from coast to coast
'; +s += ''; +s += ' '; +s += '• Airline execs not seeing sunny skies yet
'; +s += '
Education News:
'; +s += ''; +s += ' '; +s += '• Arab students seek prom balance
'; +s += ''; +s += ' '; +s += '• Public schools turn to upscale fundraising
'; +s += '
Sports News:
Business News:
'; +s += '• Here come the "Duppies"
'; +s += '• Oracle beats estimates
'; +s += '
'; +s += '
'; +s += '
'; +s += ' '; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
WATCH CNN TV
On CNN TV
'; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += '
American Morning, 7 a.m. ETAmerican Morning (7 a.m. ET): Tomorrow, singer Carnie Wilson talks about her new book, "Im Still Hungry."'; +s += '
'; +s += ''; +s += ''; +s += ''; +s += '
'; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
ANALYSIS
U.S. News
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += 'Fight It, Martha'; +s += ''; +s += ''; +s += 'NYTimes: Fight It, Martha
'; +s += 'William Safire: I hope Martha Stewart beats this bum rap'; +s += ''; +s += ''; +s += ''; +s += ''; +s += '
'; +s += '
'; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
OFFBEAT
more offbeat
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += 'Waiting list'; +s += ' '; +s += ' Waiting list
'; +s += 'Chinas "smart sperm" bank needs donors'; +s += '
'; +s += '
'; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
 WEATHER
Get your hometown weather on the home page! Enter city name or U.S. Zip Code:
Or select location from a list
'; +s += ''; +s += ''; +s += ''; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
Quick Vote'; +s += ''; +s += 'Click Here'; +s += '
'; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += '
Should an international peacekeeping force be sent to the Mideast?
Yes'; +s += '
No'; +s += '
'; +s += ''; +s += '
VIEW RESULTS
'; +s += ''; +s += '
'; +s += ''; +s += '
'; +s += '
'; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += '
From our Partners'; +s += '  External site icon
'; +s += 'Time:
  Subscribe to TIME  

'; +s += 'CNNsi.com:
'; +s += '• Marty Burns: Nets pull out all stops
'; +s += '• Michael Farber: Sens look good for "04
'; +s += '• Tim Layden: NFL or bust for Neuheisel
'; +s += '
'; +s += '
  Subscribe to Sports Illustrated  
'; +s += '

'; +s += 'New York Times:
  Get 50% OFF the NY Times  
'; +s += '
'; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += ''; +s += ''; +s += '
'; +s += ''; +s += '
'; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ''; +s += ' '; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
International Edition
CNN TVCNN InternationalHeadline NewsTranscriptsPreferencesAbout CNN.com
'; +s += ''; +s += '
'; +s += ''; +s += ''; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
'; +s += '© 2003 Cable News Network LP, LLLP.
'; +s += 'An AOL Time Warner Company. All Rights Reserved.
'; +s += 'Terms under which this service is provided to you.
'; +s += 'Read our privacy guidelines. Contact us.'; +s += '
'; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += ' '; +s += '
external link
All external sites will open in a new browser.
'; +s += ' CNN.com does not endorse external sites.
'; +s += ''; +s += '
 Premium content icon Denotes premium content.
'; +s += ''; +s += '
'; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ' '; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; +s += ''; + +return s; +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-209919.js b/tests/mozilla/ecma_3/RegExp/regress-209919.js new file mode 100644 index 0000000..e1bb76c --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-209919.js @@ -0,0 +1,169 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2003 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): sagdjb@softwareag.com, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 19 June 2003 +* SUMMARY: Testing regexp submatches with quantifiers +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=209919 +* +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 209919; +var summary = 'Testing regexp submatches with quantifiers'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/* + * Waldemar: "ECMA-262 15.10.2.5, third algorithm, step 2.1 states that + * once the minimum repeat count (which is 0 for *, 1 for +, etc.) has + * been satisfied, an atom being repeated must not match the empty string." + * + * In this example, the minimum repeat count is 0, so the last thing the + * capturing parens is permitted to contain is the 'a'. It may NOT go on + * to capture the '' at the $ position of 'a', even though '' satifies + * the condition b* + * + */ +status = inSection(1); +string = 'a'; +pattern = /(a|b*)*/; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'a'); +addThis(); + + +/* + * In this example, the minimum repeat count is 5, so the capturing parens + * captures the 'a', then goes on to capture the '' at the $ position of 'a' + * 4 times before it has to stop. Therefore the last thing it contains is ''. + */ +status = inSection(2); +string = 'a'; +pattern = /(a|b*){5,}/; +actualmatch = string.match(pattern); +expectedmatch = Array(string, ''); +addThis(); + + +/* + * Reduction of the above examples to contain only the condition b* + * inside the capturing parens. This can be even harder to grasp! + * + * The global match is the '' at the ^ position of 'a', but the parens + * is NOT permitted to capture it since the minimum repeat count is 0! + */ +status = inSection(3); +string = 'a'; +pattern = /(b*)*/; +actualmatch = string.match(pattern); +expectedmatch = Array('', undefined); +addThis(); + + +/* + * Here we have used the + quantifier (repeat count 1) outside the parens. + * Therefore the parens must capture at least once before stopping, so it + * does capture the '' this time - + */ +status = inSection(4); +string = 'a'; +pattern = /(b*)+/; +actualmatch = string.match(pattern); +expectedmatch = Array('', ''); +addThis(); + + +/* + * More complex examples - + */ +pattern = /^\-?(\d{1,}|\.{0,})*(\,\d{1,})?$/; + + status = inSection(5); + string = '100.00'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, '00', undefined); + addThis(); + + status = inSection(6); + string = '100,00'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, '100', ',00'); + addThis(); + + status = inSection(7); + string = '1.000,00'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, '000', ',00'); + addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-216591.js b/tests/mozilla/ecma_3/RegExp/regress-216591.js new file mode 100644 index 0000000..cc86d73 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-216591.js @@ -0,0 +1,112 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2003 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): okin7@yahoo.fr, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 19 August 2003 +* SUMMARY: Regexp conformance test +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=216591 +* +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 216591; +var summary = 'Regexp conformance test'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +string = 'a {result.data.DATA} b'; +pattern = /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/i; +actualmatch = string.match(pattern); +expectedmatch = Array('{result.data.DATA}', 'result.data.', 'data.', 'DATA'); +addThis(); + +/* + * Add a global flag to the regexp. In Perl 5, this gives the same results as above. Compare: + * + * [ ] perl -e '"a {result.data.DATA} b" =~ /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/i; print("$&, $1, $2, $3");' + * {result.data.DATA}, result.data., data., DATA + * + * [ ] perl -e '"a {result.data.DATA} b" =~ /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/gi; print("$&, $1, $2, $3");' + * {result.data.DATA}, result.data., data., DATA + * + * + * But in JavaScript, there will no longer be any sub-captures: + */ +status = inSection(2); +string = 'a {result.data.DATA} b'; +pattern = /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/gi; +actualmatch = string.match(pattern); +expectedmatch = Array('{result.data.DATA}'); +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-220367-001.js b/tests/mozilla/ecma_3/RegExp/regress-220367-001.js new file mode 100644 index 0000000..e6a767e --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-220367-001.js @@ -0,0 +1,99 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2003 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): igor@fastmail.fm, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 26 September 2003 +* SUMMARY: Regexp conformance test +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=220367 +* +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 220367; +var summary = 'Regexp conformance test'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +string = 'a'; +pattern = /(a)|(b)/; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'a', undefined); +addThis(); + +status = inSection(2); +string = 'b'; +pattern = /(a)|(b)/; +actualmatch = string.match(pattern); +expectedmatch = Array(string, undefined, 'b'); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-220367-002.js b/tests/mozilla/ecma_3/RegExp/regress-220367-002.js new file mode 100644 index 0000000..62eec23 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-220367-002.js @@ -0,0 +1,107 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2003 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): igor@fastmail.fm, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 26 September 2003 +* SUMMARY: Regexp conformance test +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=220367 +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 220367; +var summary = 'Regexp conformance test'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + +var re = /(a)|(b)/; + +re.test('a'); + status = inSection(1); + actual = RegExp.$1; + expect = 'a'; + addThis(); + + status = inSection(2); + actual = RegExp.$2; + expect = ''; + addThis(); + +re.test('b'); + status = inSection(3); + actual = RegExp.$1; + expect = ''; + addThis(); + + status = inSection(4); + actual = RegExp.$2; + expect = 'b'; + addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i][^<>]*[^\/])>|<([^\/<>])>/; +string = '

Some
test

'; +actualmatch = string.match(pattern); +expectedmatch = Array('

', undefined, 'p'); +addThis(); + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-57572.js b/tests/mozilla/ecma_3/RegExp/regress-57572.js new file mode 100644 index 0000000..de9834a --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-57572.js @@ -0,0 +1,129 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 28 December 2000 +* +* SUMMARY: Testing regular expressions containing the ? character. +* Arose from Bugzilla bug 57572: "RegExp with ? matches incorrectly" +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=57572 +* +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 57572; +var summary = 'Testing regular expressions containing "?"'; +var cnEmptyString = ''; var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /(\S+)?(.*)/; +string = 'Test this'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Test', ' this'); //single space in front of 'this' +addThis(); + +status = inSection(2); +pattern = /(\S+)? ?(.*)/; //single space between the ? characters +string= 'Test this'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Test', 'this'); //NO space in front of 'this' +addThis(); + +status = inSection(3); +pattern = /(\S+)?(.*)/; +string = 'Stupid phrase, with six - (short) words'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Stupid', ' phrase, with six - (short) words'); //single space in front of 'phrase' +addThis(); + +status = inSection(4); +pattern = /(\S+)? ?(.*)/; //single space between the ? characters +string = 'Stupid phrase, with six - (short) words'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Stupid', 'phrase, with six - (short) words'); //NO space in front of 'phrase' +addThis(); + + +// let's add an extra back-reference this time - three instead of two - +status = inSection(5); +pattern = /(\S+)?( ?)(.*)/; //single space before second ? character +string = 'Stupid phrase, with six - (short) words'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Stupid', cnSingleSpace, 'phrase, with six - (short) words'); +addThis(); + +status = inSection(6); +pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character +string = 'AAABBB'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AAABB', cnEmptyString, 'B'); +addThis(); + +status = inSection(7); +pattern = /(\S+)?(!?)(.*)/; +string = 'WOW !!! !!!'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'WOW', cnEmptyString, ' !!! !!!'); +addThis(); + +status = inSection(8); +pattern = /(.+)?(!?)(!+)/; +string = 'WOW !!! !!!'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'WOW !!! !!', cnEmptyString, '!'); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-57631.js b/tests/mozilla/ecma_3/RegExp/regress-57631.js new file mode 100644 index 0000000..1917ed4 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-57631.js @@ -0,0 +1,128 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 26 November 2000 +* +* +* SUMMARY: This test arose from Bugzilla bug 57631: +* "RegExp with invalid pattern or invalid flag causes segfault" +* +* Either error should throw an exception of type SyntaxError, +* and we check to see that it does... +*/ +//------------------------------------------------------------------------------------------------- +var bug = '57631'; +var summary = 'Testing new RegExp(pattern,flag) with illegal pattern or flag'; +var statprefix = 'Testing for error creating illegal RegExp object on pattern '; +var statsuffix = 'and flag '; +var cnSUCCESS = 'SyntaxError'; +var cnFAILURE = 'not a SyntaxError'; +var singlequote = "'"; +var i = -1; var j = -1; var s = ''; var f = ''; +var obj = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var legalpatterns = new Array(); var illegalpatterns = new Array(); +var legalflags = new Array(); var illegalflags = new Array(); + + +// valid regular expressions to try - +legalpatterns[0] = ''; +legalpatterns[1] = 'abc'; +legalpatterns[2] = '(.*)(3-1)\s\w'; +legalpatterns[3] = '(.*)(...)\\s\\w'; +legalpatterns[4] = '[^A-Za-z0-9_]'; +legalpatterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// invalid regular expressions to try - +illegalpatterns[0] = '()'; +illegalpatterns[1] = '(a'; +illegalpatterns[2] = '( ]'; +illegalpatterns[3] = '\d{s}'; + +// valid flags to try - +legalflags[0] = 'i'; +legalflags[1] = 'g'; +legalflags[2] = 'm'; +legalflags[3] = undefined; + +// invalid flags to try - +illegalflags[0] = 'a'; +illegalflags[1] = 123; +illegalflags[2] = new RegExp(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + testIllegalRegExps(legalpatterns, illegalflags); + testIllegalRegExps(illegalpatterns, legalflags); + testIllegalRegExps(illegalpatterns, illegalflags); + + exitFunc ('test'); +} + + +// This function will only be called where all the patterns are illegal, or all the flags +function testIllegalRegExps(patterns, flags) +{ + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + + try + { + // This should cause an exception if either s or f is illegal - + eval('obj = new RegExp(s, f);'); + } + catch(e) + { + // We expect to get a SyntaxError - test for this: + actual = (e instanceof SyntaxError)? cnSUCCESS : cnFAILURE; + expect = cnSUCCESS; + reportCompare(expect, actual, status); + } + } + } +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + statsuffix + quote(flag)); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} \ No newline at end of file diff --git a/tests/mozilla/ecma_3/RegExp/regress-67773.js b/tests/mozilla/ecma_3/RegExp/regress-67773.js new file mode 100644 index 0000000..e399050 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-67773.js @@ -0,0 +1,190 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 06 February 2001 +* +* SUMMARY: Arose from Bugzilla bug 67773: +* "Regular subexpressions followed by + failing to run to completion" +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=67773 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 +*/ +//------------------------------------------------------------------------------------------------- +var i = 0; +var bug = 67773; +var summary = 'Testing regular subexpressions followed by ? or +\n'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character + status = inSection(1); + string = 'AAABBB AAABBB '; //single space at middle and at end - + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + status = inSection(2); + string = 'AAABBB BBB'; //single space in the middle + actualmatch = string.match(pattern); + expectedmatch = Array(string, 'AAABBB', cnSingleSpace, 'BBB'); + addThis(); + + status = inSection(3); + string = 'AAABBB AAABBB'; //single space in the middle + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + +pattern = /^(A+B)+$/; + status = inSection(4); + string = 'AABAAB'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, 'AAB'); + addThis(); + + status = inSection(5); + string = 'ABAABAAAAAAB'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, 'AAAAAAB'); + addThis(); + + status = inSection(6); + string = 'ABAABAABAB'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, 'AB'); + addThis(); + + status = inSection(7); + string = 'ABAABAABABB'; + actualmatch = string.match(pattern); + expectedmatch = null; // because string doesn't match at end + addThis(); + + +pattern = /^(A+1)+$/; + status = inSection(8); + string = 'AA1AA1'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, 'AA1'); + addThis(); + + +pattern = /^(\w+\-)+$/; + status = inSection(9); + string = ''; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + status = inSection(10); + string = 'bla-'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, string); + addThis(); + + status = inSection(11); + string = 'bla-bla'; // hyphen missing at end - + actualmatch = string.match(pattern); + expectedmatch = null; //because string doesn't match at end + addThis(); + + status = inSection(12); + string = 'bla-bla-'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, 'bla-'); + addThis(); + + +pattern = /^(\S+)+(A+)$/; + status = inSection(13); + string = 'asdldflkjAAA'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, 'asdldflkjAA', 'A'); + addThis(); + + status = inSection(14); + string = 'asdldflkj AAA'; // space in middle + actualmatch = string.match(pattern); + expectedmatch = null; //because of the space + addThis(); + + +pattern = /^(\S+)+(\d+)$/; + status = inSection(15); + string = 'asdldflkj122211'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, 'asdldflkj12221', '1'); + addThis(); + + status = inSection(16); + string = 'asdldflkj1111111aaa1'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, 'asdldflkj1111111aaa', '1'); + addThis(); + + +/* + * This one comes from Stephen Ostermiller. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 + */ +pattern = /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)+$/; + status = inSection(17); + string = 'some.host.tld'; + actualmatch = string.match(pattern); + expectedmatch = Array(string, '.tld', '.'); + addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-72964.js b/tests/mozilla/ecma_3/RegExp/regress-72964.js new file mode 100644 index 0000000..5965313 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-72964.js @@ -0,0 +1,100 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 2001-07-17 +* +* SUMMARY: Regression test for Bugzilla bug 72964: +* "String method for pattern matching failed for Chinese Simplified (GB2312)" +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=72964 +*/ +//----------------------------------------------------------------------------- +var i = 0; +var bug = 72964; +var summary = 'Testing regular expressions containing non-Latin1 characters'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /[\S]+/; + // 4 low Unicode chars = Latin1; whole string should match + status = inSection(1); + string = '\u00BF\u00CD\u00BB\u00A7'; + actualmatch = string.match(pattern); + expectedmatch = Array(string); + addThis(); + + // Now put a space in the middle; first half of string should match + status = inSection(2); + string = '\u00BF\u00CD \u00BB\u00A7'; + actualmatch = string.match(pattern); + expectedmatch = Array('\u00BF\u00CD'); + addThis(); + + + // 4 high Unicode chars = non-Latin1; whole string should match + status = inSection(3); + string = '\u4e00\uac00\u4e03\u4e00'; + actualmatch = string.match(pattern); + expectedmatch = Array(string); + addThis(); + + // Now put a space in the middle; first half of string should match + status = inSection(4); + string = '\u4e00\uac00 \u4e03\u4e00'; + actualmatch = string.match(pattern); + expectedmatch = Array('\u4e00\uac00'); + addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-76683.js b/tests/mozilla/ecma_3/RegExp/regress-76683.js new file mode 100644 index 0000000..59b95b9 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-76683.js @@ -0,0 +1,93 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 01 May 2001 +* +* SUMMARY: Regression test for Bugzilla bug 76683 on Rhino: +* "RegExp regression (NullPointerException)" +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=76683 +*/ +//------------------------------------------------------------------------------------------------- +var i = 0; +var bug = 76683; +var summary = 'Regression test for Bugzilla bug 76683'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/* + * Rhino (2001-04-19) crashed on the 3rd regular expression below. + * It didn't matter what the string was. No problem in SpiderMonkey - + */ +string = 'abc'; + status = inSection(1); + pattern = /()|(<([\$\w:\.\-]+)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))/; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + status = inSection(2); + pattern = /()|(<(tagPattern)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))/; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + // This was the one causing a Rhino crash - + status = inSection(3); + pattern = /()|(<(tagPattern)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))|(<\/tagPattern[^>]*>)/; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-78156.js b/tests/mozilla/ecma_3/RegExp/regress-78156.js new file mode 100644 index 0000000..08947ce --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-78156.js @@ -0,0 +1,102 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 06 February 2001 +* +* SUMMARY: Arose from Bugzilla bug 78156: +* "m flag of regular expression does not work with $" +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=78156 +* +* The m flag means a regular expression should search strings +* across multiple lines, i.e. across '\n', '\r'. +*/ +//------------------------------------------------------------------------------------------------- +var i = 0; +var bug = 78156; +var summary = 'Testing regular expressions with ^, $, and the m flag -'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + +/* + * All patterns have an m flag; all strings are multiline. + * Looking for digit characters at beginning/end of lines. + */ + +string = 'aaa\n789\r\nccc\r\n345'; + status = inSection(1); + pattern = /^\d/gm; + actualmatch = string.match(pattern); + expectedmatch = ['7','3']; + addThis(); + + status = inSection(2); + pattern = /\d$/gm; + actualmatch = string.match(pattern); + expectedmatch = ['9','5']; + addThis(); + +string = 'aaa\n789\r\nccc\r\nddd'; + status = inSection(3); + pattern = /^\d/gm; + actualmatch = string.match(pattern); + expectedmatch = ['7']; + addThis(); + + status = inSection(4); + pattern = /\d$/gm; + actualmatch = string.match(pattern); + expectedmatch = ['9']; + addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-85721.js b/tests/mozilla/ecma_3/RegExp/regress-85721.js new file mode 100644 index 0000000..41f5bc0 --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-85721.js @@ -0,0 +1,271 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): rogerl@netscape.com, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 14 Feb 2002 +* SUMMARY: Performance: Regexp performance degraded from 4.7 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=85721 +* +* Adjust this testcase if necessary. The FAST constant defines +* an upper bound in milliseconds for any execution to take. +* +*/ +//----------------------------------------------------------------------------- +var bug = 85721; +var summary = 'Performance: execution of regular expression'; +var FAST = 100; // execution should be 100 ms or less to pass the test +var MSG_FAST = 'Execution took less than ' + FAST + ' ms'; +var MSG_SLOW = 'Execution took '; +var MSG_MS = ' ms'; +var str = ''; +var re = ''; +var status = ''; +var actual = ''; +var expect= ''; + +printBugNumber (bug); +printStatus (summary); + + +function elapsedTime(startTime) +{ + return new Date() - startTime; +} + + +function isThisFast(ms) +{ + if (ms <= FAST) + return MSG_FAST; + return MSG_SLOW + ms + MSG_MS; +} + + + +/* + * The first regexp. We'll test for performance (Section 1) and accuracy (Section 2). + */ +str=' www.m.com drive.class\nfoo goo '; +re = /\s*\s*([^\r\n]*?)\s*<\/sql:url>\s*\s*([^\r\n]*?)\s*<\/sql:driver>\s*(\s*\s*([^\r\n]*?)\s*<\/sql:userId>\s*)?\s*(\s*\s*([^\r\n]*?)\s*<\/sql:password>\s*)?\s*<\/sql:connection>/; +expect = Array(" www.m.com drive.class\nfoo goo ","conn1","www.m.com","drive.class","foo ","foo","goo ","goo"); + +/* + * Check performance - + */ +status = inSection(1); +var start = new Date(); +var result = re.exec(str); +actual = elapsedTime(start); +reportCompare(isThisFast(FAST), isThisFast(actual), status); + +/* + * Check accuracy - + */ +status = inSection(2); +testRegExp([status], [re], [str], [result], [expect]); + + + +/* + * The second regexp (HUGE!). We'll test for performance (Section 3) and accuracy (Section 4). + * It comes from the O'Reilly book "Mastering Regular Expressions" by Jeffrey Friedl, Appendix B + */ + +//# Some things for avoiding backslashitis later on. +$esc = '\\\\'; +$Period = '\.'; +$space = '\040'; $tab = '\t'; +$OpenBR = '\\['; $CloseBR = '\\]'; +$OpenParen = '\\('; $CloseParen = '\\)'; +$NonASCII = '\x80-\xff'; $ctrl = '\000-\037'; +$CRlist = '\n\015'; //# note: this should really be only \015. +// Items 19, 20, 21 +$qtext = '[^' + $esc + $NonASCII + $CRlist + '\"]'; // # for within "..." +$dtext = '[^' + $esc + $NonASCII + $CRlist + $OpenBR + $CloseBR + ']'; // # for within [...] +$quoted_pair = $esc + '[^' + $NonASCII + ']'; // # an escaped character + +//############################################################################## +//# Items 22 and 23, comment. +//# Impossible to do properly with a regex, I make do by allowing at most one level of nesting. +$ctext = '[^' + $esc + $NonASCII + $CRlist + '()]'; + +//# $Cnested matches one non-nested comment. +//# It is unrolled, with normal of $ctext, special of $quoted_pair. +$Cnested = + $OpenParen + // # ( + $ctext + '*' + // # normal* + '(?:' + $quoted_pair + $ctext + '*)*' + // # (special normal*)* + $CloseParen; // # ) + + +//# $comment allows one level of nested parentheses +//# It is unrolled, with normal of $ctext, special of ($quoted_pair|$Cnested) +$comment = + $OpenParen + // # ( + $ctext + '*' + // # normal* + '(?:' + // # ( + '(?:' + $quoted_pair + '|' + $Cnested + ')' + // # special + $ctext + '*' + // # normal* + ')*' + // # )* + $CloseParen; // # ) + + +//############################################################################## +//# $X is optional whitespace/comments. +$X = + '[' + $space + $tab + ']*' + // # Nab whitespace. + '(?:' + $comment + '[' + $space + $tab + ']*)*'; // # If comment found, allow more spaces. + + +//# Item 10: atom +$atom_char = '[^(' + $space + '<>\@,;:\".' + $esc + $OpenBR + $CloseBR + $ctrl + $NonASCII + ']'; +$atom = + $atom_char + '+' + // # some number of atom characters... + '(?!' + $atom_char + ')'; // # ..not followed by something that could be part of an atom + +// # Item 11: doublequoted string, unrolled. +$quoted_str = + '\"' + // # " + $qtext + '*' + // # normal + '(?:' + $quoted_pair + $qtext + '*)*' + // # ( special normal* )* + '\"'; // # " + +//# Item 7: word is an atom or quoted string +$word = + '(?:' + + $atom + // # Atom + '|' + // # or + $quoted_str + // # Quoted string + ')' + +//# Item 12: domain-ref is just an atom +$domain_ref = $atom; + +//# Item 13: domain-literal is like a quoted string, but [...] instead of "..." +$domain_lit = + $OpenBR + // # [ + '(?:' + $dtext + '|' + $quoted_pair + ')*' + // # stuff + $CloseBR; // # ] + +// # Item 9: sub-domain is a domain-ref or domain-literal +$sub_domain = + '(?:' + + $domain_ref + + '|' + + $domain_lit + + ')' + + $X; // # optional trailing comments + +// # Item 6: domain is a list of subdomains separated by dots. +$domain = + $sub_domain + + '(?:' + + $Period + $X + $sub_domain + + ')*'; + +//# Item 8: a route. A bunch of "@ $domain" separated by commas, followed by a colon. +$route = + '\@' + $X + $domain + + '(?:,' + $X + '\@' + $X + $domain + ')*' + // # additional domains + ':' + + $X; // # optional trailing comments + +//# Item 6: local-part is a bunch of $word separated by periods +$local_part = + $word + $X + '(?:' + + $Period + $X + $word + $X + // # additional words + ')*'; + +// # Item 2: addr-spec is local@domain +$addr_spec = + $local_part + '\@' + $X + $domain; + +//# Item 4: route-addr is +$route_addr = + '<' + $X + // # < + '(?:' + $route + ')?' + // # optional route + $addr_spec + // # address spec + '>'; // # > + +//# Item 3: phrase........ +$phrase_ctrl = '\000-\010\012-\037'; // # like ctrl, but without tab + +//# Like atom-char, but without listing space, and uses phrase_ctrl. +//# Since the class is negated, this matches the same as atom-char plus space and tab +$phrase_char = + '[^()<>\@,;:\".' + $esc + $OpenBR + $CloseBR + $NonASCII + $phrase_ctrl + ']'; + +// # We've worked it so that $word, $comment, and $quoted_str to not consume trailing $X +// # because we take care of it manually. +$phrase = + $word + // # leading word + $phrase_char + '*' + // # "normal" atoms and/or spaces + '(?:' + + '(?:' + $comment + '|' + $quoted_str + ')' + // # "special" comment or quoted string + $phrase_char + '*' + // # more "normal" + ')*'; + +// ## Item #1: mailbox is an addr_spec or a phrase/route_addr +$mailbox = + $X + // # optional leading comment + '(?:' + + $phrase + $route_addr + // # name and address + '|' + // # or + $addr_spec + // # address + ')'; + + +//########################################################################### + + +re = new RegExp($mailbox, "g"); +str = 'Jeffy<"That Tall Guy"@ora.com (this address is no longer active)>'; +expect = Array('Jeffy<"That Tall Guy"@ora.com (this address is no longer active)>'); + +/* + * Check performance - + */ +status = inSection(3); +var start = new Date(); +var result = re.exec(str); +actual = elapsedTime(start); +reportCompare(isThisFast(FAST), isThisFast(actual), status); + +/* + * Check accuracy - + */ +status = inSection(4); +testRegExp([status], [re], [str], [result], [expect]); diff --git a/tests/mozilla/ecma_3/RegExp/regress-87231.js b/tests/mozilla/ecma_3/RegExp/regress-87231.js new file mode 100644 index 0000000..7fde4ff --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-87231.js @@ -0,0 +1,124 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 22 June 2001 +* +* SUMMARY: Regression test for Bugzilla bug 87231: +* "Regular expression /(A)?(A.*)/ picks 'A' twice" +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=87231 +* Key case: +* +* pattern = /^(A)?(A.*)$/; +* string = 'A'; +* expectedmatch = Array('A', '', 'A'); +* +* +* We expect the 1st subexpression (A)? NOT to consume the single 'A'. +* Recall that "?" means "match 0 or 1 times". Here, it should NOT do +* greedy matching: it should match 0 times instead of 1. This allows +* the 2nd subexpression to make the only match it can: the single 'A'. +* Such "altruism" is the only way there can be a successful global match... +*/ +//------------------------------------------------------------------------------------------------- +var i = 0; +var bug = 87231; +var cnEmptyString = ''; +var summary = 'Testing regular expression /(A)?(A.*)/'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /^(A)?(A.*)$/; + status = inSection(1); + string = 'AAA'; + actualmatch = string.match(pattern); + expectedmatch = Array('AAA', 'A', 'AA'); + addThis(); + + status = inSection(2); + string = 'AA'; + actualmatch = string.match(pattern); + expectedmatch = Array('AA', 'A', 'A'); + addThis(); + + status = inSection(3); + string = 'A'; + actualmatch = string.match(pattern); + expectedmatch = Array('A', undefined, 'A'); // 'altruistic' case: see above + addThis(); + + +pattern = /(A)?(A.*)/; +var strL = 'zxcasd;fl\\\ ^'; +var strR = 'aaAAaaaf;lrlrzs'; + + status = inSection(4); + string = strL + 'AAA' + strR; + actualmatch = string.match(pattern); + expectedmatch = Array('AAA' + strR, 'A', 'AA' + strR); + addThis(); + + status = inSection(5); + string = strL + 'AA' + strR; + actualmatch = string.match(pattern); + expectedmatch = Array('AA' + strR, 'A', 'A' + strR); + addThis(); + + status = inSection(6); + string = strL + 'A' + strR; + actualmatch = string.match(pattern); + expectedmatch = Array('A' + strR, undefined, 'A' + strR); // 'altruistic' case: see above + addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/RegExp/regress-98306.js b/tests/mozilla/ecma_3/RegExp/regress-98306.js new file mode 100644 index 0000000..e812ebf --- /dev/null +++ b/tests/mozilla/ecma_3/RegExp/regress-98306.js @@ -0,0 +1,77 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): jrgm@netscape.com, pschwartau@netscape.com +* Date: 04 September 2001 +* +* SUMMARY: Regression test for Bugzilla bug 98306 +* "JS parser crashes in ParseAtom for script using Regexp()" +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=98306 +*/ +//----------------------------------------------------------------------------- +var bug = 98306; +var summary = "Testing that we don't crash on this code -"; +var cnUBOUND = 10; +var re; +var s; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + s = '"Hello".match(/[/]/)'; + tryThis(s); + + s = 're = /[/'; + tryThis(s); + + s = 're = /[/]/'; + tryThis(s); + + s = 're = /[//]/'; + tryThis(s); + + exitFunc ('test'); +} + + +// Try to provoke a crash - +function tryThis(sCode) +{ + // sometimes more than one attempt is necessary - + for (var i=0; i 'aaZaa' + expect = strJim.replace(new RegExp(strA), strB); // expect 'aa$aaZ' + reportCompare(expect, actual, status); + + + * + * Note: 'Zabc' is the result we expect for 'abc'.replace('', 'Z'). + * + * The string '' is supposed to be equivalent to new RegExp('') = //. + * The regexp // means we should match the "empty string" conceived of + * at the beginning boundary of the word, before the first character. + * + status = 'Section F of test'; + strA = cnEmptyString; + actual = str.replace(strA, strB); + expect = 'Zabc'; + reportCompare(expect, actual, status); + + status = 'Section G of test'; + strA = cnEmptyString; + actual = str.replace(strA, strB); + expect = str.replace(new RegExp(strA), strB); + reportCompare(expect, actual, status); + +************************* END OF INCORRECT CASES ****************************/ + + +////////////////////////// OK, LET'S START OVER ////////////////////////////// + + status = 'Section 1 of test'; + actual = 'abc'.replace('a', 'Z'); + expect = 'Zbc'; + reportCompare(expect, actual, status); + + status = 'Section 2 of test'; + actual = 'abc'.replace('b', 'Z'); + expect = 'aZc'; + reportCompare(expect, actual, status); + + status = 'Section 3 of test'; + actual = 'abc'.replace(undefined, 'Z'); + expect = 'abc'; // String(undefined) == 'undefined'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 4 of test'; + actual = 'abc'.replace(null, 'Z'); + expect = 'abc'; // String(null) == 'null'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 5 of test'; + actual = 'abc'.replace(true, 'Z'); + expect = 'abc'; // String(true) == 'true'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 6 of test'; + actual = 'abc'.replace(false, 'Z'); + expect = 'abc'; // String(false) == 'false'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 7 of test'; + actual = 'aa$aa'.replace('$', 'Z'); + expect = 'aaZaa'; // NOT 'aa$aaZ' as in ECMA Final Draft; see above + reportCompare(expect, actual, status); + + status = 'Section 8 of test'; + actual = 'abc'.replace('.*', 'Z'); + expect = 'abc'; // not 'Z' as in EMCA Final Draft + reportCompare(expect, actual, status); + + status = 'Section 9 of test'; + actual = 'abc'.replace('', 'Z'); + expect = 'Zabc'; // Still expect 'Zabc' for this + reportCompare(expect, actual, status); + + exitFunc ('test'); +} diff --git a/tests/mozilla/ecma_3/Unicode/uc-001-n.js b/tests/mozilla/ecma_3/Unicode/uc-001-n.js new file mode 100644 index 0000000..6527c16 --- /dev/null +++ b/tests/mozilla/ecma_3/Unicode/uc-001-n.js @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode Characters 1C-1F negative test."); + printBugNumber (23612); + + reportCompare ("error", eval ("'no'\u001C+' error'"), + "Unicode whitespace test (1C.)"); + reportCompare ("error", eval ("'no'\u001D+' error'"), + "Unicode whitespace test (1D.)"); + reportCompare ("error", eval ("'no'\u001E+' error'"), + "Unicode whitespace test (1E.)"); + reportCompare ("error", eval ("'no'\u001F+' error'"), + "Unicode whitespace test (1F.)"); + + exitFunc ("test"); +} diff --git a/tests/mozilla/ecma_3/Unicode/uc-001.js b/tests/mozilla/ecma_3/Unicode/uc-001.js new file mode 100644 index 0000000..470e8bc --- /dev/null +++ b/tests/mozilla/ecma_3/Unicode/uc-001.js @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode format-control character (Category Cf) test."); + printBugNumber (23610); + + reportCompare ("no error", eval('"no\u200E error"'), + "Unicode format-control character test (Category Cf.)"); + + exitFunc ("test"); +} diff --git a/tests/mozilla/ecma_3/Unicode/uc-002-n.js b/tests/mozilla/ecma_3/Unicode/uc-002-n.js new file mode 100644 index 0000000..9c54a26 --- /dev/null +++ b/tests/mozilla/ecma_3/Unicode/uc-002-n.js @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Non-character escapes in identifiers negative test."); + printBugNumber (23607); + + reportCompare ("error", eval("\u0020 = 5"), + "Non-character escapes in identifiers negative test."); + + exitFunc ("test"); +} diff --git a/tests/mozilla/ecma_3/Unicode/uc-002.js b/tests/mozilla/ecma_3/Unicode/uc-002.js new file mode 100644 index 0000000..3b05d83 --- /dev/null +++ b/tests/mozilla/ecma_3/Unicode/uc-002.js @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode non-breaking space character test."); + printBugNumber (23613); + + reportCompare ("no error", eval("'no'\u00A0+ ' error'"), + "Unicode non-breaking space character test."); + + var str = "\u00A0foo"; + reportCompare (0, str.search(/^\sfoo$/), + "Unicode non-breaking space character regexp test."); + + exitFunc ("test"); +} diff --git a/tests/mozilla/ecma_3/Unicode/uc-003.js b/tests/mozilla/ecma_3/Unicode/uc-003.js new file mode 100644 index 0000000..7004cf4 --- /dev/null +++ b/tests/mozilla/ecma_3/Unicode/uc-003.js @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + enterFunc ("test"); + + var \u0041 = 5; + var A\u03B2 = 15; + var c\u0061se = 25; + + printStatus ("Escapes in identifiers test."); + printBugNumber (23608); + printBugNumber (23607); + + reportCompare (5, eval("\u0041"), + "Escaped ASCII Identifier test."); + reportCompare (6, eval("++\u0041"), + "Escaped ASCII Identifier test"); + reportCompare (15, eval("A\u03B2"), + "Escaped non-ASCII Identifier test"); + reportCompare (16, eval("++A\u03B2"), + "Escaped non-ASCII Identifier test"); + reportCompare (25, eval("c\\u00" + "61se"), + "Escaped keyword Identifier test"); + reportCompare (26, eval("++c\\u00" + "61se"), + "Escaped keyword Identifier test"); + + exitFunc ("test"); +} diff --git a/tests/mozilla/ecma_3/Unicode/uc-004.js b/tests/mozilla/ecma_3/Unicode/uc-004.js new file mode 100644 index 0000000..2518124 --- /dev/null +++ b/tests/mozilla/ecma_3/Unicode/uc-004.js @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode Characters 1C-1F with regexps test."); + printBugNumber (23612); + + var ary = ["\u001Cfoo", "\u001Dfoo", "\u001Efoo", "\u001Ffoo"]; + + for (var i in ary) + { + reportCompare (0, ary[Number(i)].search(/^\Sfoo$/), + "Unicode characters 1C-1F in regexps, ary[" + + i + "] did not match \\S test (it should not.)"); + reportCompare (-1, ary[Number(i)].search(/^\sfoo$/), + "Unicode characters 1C-1F in regexps, ary[" + + i + "] matched \\s test (it should not.)"); + } + + exitFunc ("test"); +} diff --git a/tests/mozilla/ecma_3/Unicode/uc-005.js b/tests/mozilla/ecma_3/Unicode/uc-005.js new file mode 100644 index 0000000..5b1be03 --- /dev/null +++ b/tests/mozilla/ecma_3/Unicode/uc-005.js @@ -0,0 +1,271 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): rogerl@netscape.com, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 15 July 2002 +* SUMMARY: Testing identifiers with double-byte names +* See http://bugzilla.mozilla.org/show_bug.cgi?id=58274 +* +* Here is a sample of the problem: +* +* js> function f\u02B1 () {} +* +* js> f\u02B1.toSource(); +* function f¦() {} +* +* js> f\u02B1.toSource().toSource(); +* (new String("function f\xB1() {}")) +* +* +* See how the high-byte information (the 02) has been lost? +* The same thing was happening with the toString() method: +* +* js> f\u02B1.toString(); +* +* function f¦() { +* } +* +* js> f\u02B1.toString().toSource(); +* (new String("\nfunction f\xB1() {\n}\n")) +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 58274; +var summary = 'Testing identifiers with double-byte names'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * Define a function that uses double-byte identifiers in + * "every possible way" + * + * Then recover each double-byte identifier via f.toString(). + * To make this easier, put a 'Z' token before every one. + * + * Our eval string will be: + * + * sEval = "function Z\u02b1(Z\u02b2, b) { + * try { Z\u02b3 : var Z\u02b4 = Z\u02b1; } + * catch (Z\u02b5) { for (var Z\u02b6 in Z\u02b5) + * {for (1; 1<0; Z\u02b7++) {new Array()[Z\u02b6] = 1;} };} }"; + * + * It will be helpful to build this string in stages: + */ +var s0 = 'function Z'; +var s1 = '\u02b1(Z'; +var s2 = '\u02b2, b) {try { Z'; +var s3 = '\u02b3 : var Z'; +var s4 = '\u02b4 = Z'; +var s5 = '\u02b1; } catch (Z' +var s6 = '\u02b5) { for (var Z'; +var s7 = '\u02b6 in Z'; +var s8 = '\u02b5){for (1; 1<0; Z'; +var s9 = '\u02b7++) {new Array()[Z'; +var s10 = '\u02b6] = 1;} };} }'; + + +/* + * Concatenate these and eval() to create the function Z\u02b1 + */ +var sEval = s0 + s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10; +eval(sEval); + + +/* + * Recover all the double-byte identifiers via Z\u02b1.toString(). + * We'll recover the 1st one as arrID[1], the 2nd one as arrID[2], + * and so on ... + */ +var arrID = getIdentifiers(Z\u02b1); + + +/* + * Now check that we got back what we put in - + */ +status = inSection(1); +actual = arrID[1]; +expect = s1.charAt(0); +addThis(); + +status = inSection(2); +actual = arrID[2]; +expect = s2.charAt(0); +addThis(); + +status = inSection(3); +actual = arrID[3]; +expect = s3.charAt(0); +addThis(); + +status = inSection(4); +actual = arrID[4]; +expect = s4.charAt(0); +addThis(); + +status = inSection(5); +actual = arrID[5]; +expect = s5.charAt(0); +addThis(); + +status = inSection(6); +actual = arrID[6]; +expect = s6.charAt(0); +addThis(); + +status = inSection(7); +actual = arrID[7]; +expect = s7.charAt(0); +addThis(); + +status = inSection(8); +actual = arrID[8]; +expect = s8.charAt(0); +addThis(); + +status = inSection(9); +actual = arrID[9]; +expect = s9.charAt(0); +addThis(); + +status = inSection(10); +actual = arrID[10]; +expect = s10.charAt(0); +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Goal: recover the double-byte identifiers from f.toString() + * by getting the very next character after each 'Z' token. + * + * The return value will be an array |arr| indexed such that + * |arr[1]| is the 1st identifier, |arr[2]| the 2nd, and so on. + * + * Note, however, f.toString() is implementation-independent. + * For example, it may begin with '\nfunction' instead of 'function'. + * + * Rhino uses a Unicode representation for f.toString(); whereas + * SpiderMonkey uses an ASCII representation, putting escape sequences + * for non-ASCII characters. For example, if a function is called f\u02B1, + * then in Rhino the toString() method will present a 2-character Unicode + * string for its name, whereas SpiderMonkey will present a 7-character + * ASCII string for its name: the string literal 'f\u02B1'. + * + * So we force the lexer to condense the string before we use it. + * This will give uniform results in Rhino and SpiderMonkey. + */ +function getIdentifiers(f) +{ + var str = condenseStr(f.toString()); + var arr = str.split('Z'); + + /* + * The identifiers are the 1st char of each split substring + * EXCEPT the first one, which is just ('\n' +) 'function '. + * + * Thus note the 1st identifier will be stored in |arr[1]|, + * the 2nd one in |arr[2]|, etc., making the indexing easy - + */ + for (i in arr) + arr[i] = arr[i].charAt(0); + return arr; +} + + +/* + * This function is the opposite of a functions like escape(), which take + * Unicode characters and return escape sequences for them. Here, we force + * the lexer to turn escape sequences back into single characters. + * + * Note we can't simply do |eval(str)|, since in practice |str| will be an + * identifier somewhere in the program (e.g. a function name); thus |eval(str)| + * would return the object that the identifier represents: not what we want. + * + * So we surround |str| lexicographically with quotes to force the lexer to + * evaluate it as a string. Have to strip out any linefeeds first, however - + */ +function condenseStr(str) +{ + /* + * You won't be able to do the next step if |str| has + * any carriage returns or linefeeds in it. For example: + * + * js> eval("'" + '\nHello' + "'"); + * 1: SyntaxError: unterminated string literal: + * 1: ' + * 1: ^ + * + * So replace them with the empty string - + */ + str = str.replace(/[\r\n]/g, '') + return eval("'" + str + "'") +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i +Test results, kjs + + + +

Test results, kjs


+

+Test List: All tests
+Skip List: (none)
+1135 test(s) selected, 1127 test(s) completed, 52 failures reported (4.61% failed)
+Engine command line: /symroots/Development/testkjs
+OS type: Darwin dkilzer.apple.com 9.1.0 Darwin Kernel Version 9.1.0: Wed Oct 31 17:48:21 PDT 2007; root:xnu-1228.0.2~1/RELEASE_PPC Power Macintosh
+Testcase execution time: 4 minutes, 34 seconds.
+Tests completed on Sat Jan 5 15:45:34 2008.

+[ Failure Details | Retest List | Test Selection Page ]
+


+ +

Failure Details


+
Testcase ecma/TypeConversion/9.3.1-3.js failed
+ [ Next Failure | Top of Page ]
+
+Failure messages were:
+- "-0x123456789abcde8" = NaN FAILED! expected: 81985529216486880
+- "-0x123456789abcde8" = NaN FAILED! expected: 81985529216486880
+-"\u20001234\u2001" = NaN FAILED! expected: -1234
+

+
Testcase ecma_2/Exceptions/function-001.js failed Bug Number 10278
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+eval("function f(){}function g(){}") (threw no exception thrown = fail FAILED! expected: pass
+

+
Testcase ecma_3/Date/15.9.5.7.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+(Wed Dec 31 1969 16:00:00 GMT-0800 (PST)).toLocaleTimeString() = 4:00:00 PM PST FAILED! expected: 16:00:00
+(Wed Dec 31 1969 08:00:00 GMT-0800 (PST)).toLocaleTimeString() = 8:00:00 AM PST FAILED! expected: 08:00:00
+(Sun Dec 31 1899 16:00:00 GMT-0800 (PST)).toLocaleTimeString() = 5:00:00 PM PDT FAILED! expected: 16:00:00
+(Mon Jan 01 1900 00:00:00 GMT-0800 (PST)).toLocaleTimeString() = 1:00:00 AM PDT FAILED! expected: 00:00:00
+(Fri Dec 31 1999 16:00:00 GMT-0800 (PST)).toLocaleTimeString() = 4:00:00 PM PST FAILED! expected: 16:00:00
+(Sat Jan 01 2000 00:00:00 GMT-0800 (PST)).toLocaleTimeString() = 12:00:00 AM PST FAILED! expected: 00:00:00
+(Mon Feb 28 2000 16:00:00 GMT-0800 (PST)).toLocaleTimeString() = 4:00:00 PM PST FAILED! expected: 16:00:00
+(Mon Feb 28 2000 15:59:59 GMT-0800 (PST)).toLocaleTimeString() = 3:59:59 PM PST FAILED! expected: 15:59:59
+(Tue Feb 29 2000 00:00:00 GMT-0800 (PST)).toLocaleTimeString() = 12:00:00 AM PST FAILED! expected: 00:00:00
+(Sat Jan 05 2008 15:44:42 GMT-0800 (PST)).toLocaleTimeString() = 3:44:42 PM PST FAILED! expected: 15:44:42
+(Sat Jan 05 2008 23:44:42 GMT-0800 (PST)).toLocaleTimeString() = 11:44:42 PM PST FAILED! expected: 23:44:42
+(Fri Dec 31 2004 16:00:00 GMT-0800 (PST)).toLocaleTimeString() = 4:00:00 PM PST FAILED! expected: 16:00:00
+(Fri Dec 31 2004 15:59:59 GMT-0800 (PST)).toLocaleTimeString() = 3:59:59 PM PST FAILED! expected: 15:59:59
+(Sat Jan 01 2005 00:00:00 GMT-0800 (PST)).toLocaleTimeString() = 12:00:00 AM PST FAILED! expected: 00:00:00
+

+
Testcase ecma_3/FunExpr/fe-001.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase ecma_3/RegExp/15.10.2-1.js failed Bug Number (none)
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: RegExp conformance test
+Failure messages were:
+FAILED!: [reported from test()] Section 7 of test -
+FAILED!: [reported from test()] regexp = /(z)((a+)?(b+)?(c))*/
+FAILED!: [reported from test()] string = 'zaacbbbcac'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["zaacbbbcac", "z", "ac", "a", , "c"]
+FAILED!: [reported from test()] Actual: ["zaacbbbcac", "z", "ac", "a", "bbb", "c"]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 8 of test -
+FAILED!: [reported from test()] regexp = /(a*)*/
+FAILED!: [reported from test()] string = 'b'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["", , ]
+FAILED!: [reported from test()] Actual: ["", ""]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 12 of test -
+FAILED!: [reported from test()] regexp = /(.*?)a(?!(a+)b\2c)\2(.*)/
+FAILED!: [reported from test()] string = 'baaabaac'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["baaabaac", "ba", , "abaac"]
+FAILED!: [reported from test()] Actual: ["baaabaac", "ba", "aa", "abaac"]
+FAILED!: [reported from test()]
+

+
Testcase ecma_3/RegExp/perlstress-001.js failed Bug Number 85721
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: Testing regular expression edge cases
+Failure messages were:
+FAILED!: [reported from test()] Section 218 of test -
+FAILED!: [reported from test()] regexp = /((foo)|(bar))*/
+FAILED!: [reported from test()] string = 'foobar'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["foobar", "bar", , "bar"]
+FAILED!: [reported from test()] Actual: ["foobar", "bar", "foo", "bar"]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 234 of test -
+FAILED!: [reported from test()] regexp = /(?:(f)(o)(o)|(b)(a)(r))*/
+FAILED!: [reported from test()] string = 'foobar'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["foobar", , , , "b", "a", "r"]
+FAILED!: [reported from test()] Actual: ["foobar", "f", "o", "o", "b", "a", "r"]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 241 of test -
+FAILED!: [reported from test()] regexp = /^(?:b|a(?=(.)))*\1/
+FAILED!: [reported from test()] string = 'abc'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["ab", , ]
+FAILED!: [reported from test()] Actual: ["ab", "b"]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 412 of test -
+FAILED!: [reported from test()] regexp = /^(a(b)?)+$/
+FAILED!: [reported from test()] string = 'aba'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["aba", "a", , ]
+FAILED!: [reported from test()] Actual: ["aba", "a", "b"]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 413 of test -
+FAILED!: [reported from test()] regexp = /^(aa(bb)?)+$/
+FAILED!: [reported from test()] string = 'aabbaa'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["aabbaa", "aa", , ]
+FAILED!: [reported from test()] Actual: ["aabbaa", "aa", "bb"]
+FAILED!: [reported from test()]
+

+
Testcase ecma_3/RegExp/regress-209919.js failed Bug Number 209919
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: Testing regexp submatches with quantifiers
+Failure messages were:
+FAILED!: [reported from test()] Section 1 of test -
+FAILED!: [reported from test()] regexp = /(a|b*)*/
+FAILED!: [reported from test()] string = 'a'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["a", "a"]
+FAILED!: [reported from test()] Actual: ["a", ""]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 3 of test -
+FAILED!: [reported from test()] regexp = /(b*)*/
+FAILED!: [reported from test()] string = 'a'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["", , ]
+FAILED!: [reported from test()] Actual: ["", ""]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 5 of test -
+FAILED!: [reported from test()] regexp = /^\-?(\d{1,}|\.{0,})*(\,\d{1,})?$/
+FAILED!: [reported from test()] string = '100.00'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["100.00", "00", , ]
+FAILED!: [reported from test()] Actual: ["100.00", "", , ]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 6 of test -
+FAILED!: [reported from test()] regexp = /^\-?(\d{1,}|\.{0,})*(\,\d{1,})?$/
+FAILED!: [reported from test()] string = '100,00'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["100,00", "100", ",00"]
+FAILED!: [reported from test()] Actual: ["100,00", "", ",00"]
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 7 of test -
+FAILED!: [reported from test()] regexp = /^\-?(\d{1,}|\.{0,})*(\,\d{1,})?$/
+FAILED!: [reported from test()] string = '1.000,00'
+FAILED!: [reported from test()] ERROR !!! regexp failed to give expected match array:
+FAILED!: [reported from test()] Expect: ["1.000,00", "000", ",00"]
+FAILED!: [reported from test()] Actual: ["1.000,00", "", ",00"]
+FAILED!: [reported from test()]
+

+
Testcase ecma_3/Statements/regress-194364.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+[40229] ./ecma_3/Statements/regress-194364.js line 1: SyntaxError: Parse error
+

+
Testcase ecma_3/Unicode/uc-001.js failed Bug Number 23610
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: Unicode format-control character (Category Cf) test.
+Failure messages were:
+FAILED!: [reported from test()] Unicode format-control character test (Category Cf.)
+FAILED!: [reported from test()] Expected value 'no error', Actual value 'no‎ error'
+FAILED!: [reported from test()]
+

+
Testcase ecma_3/Unicode/uc-002.js failed Bug Number 23613
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: Unicode non-breaking space character test.
+Failure messages were:
+FAILED!: [reported from test()] Unicode non-breaking space character regexp test.
+FAILED!: [reported from test()] Expected value '0', Actual value '-1'
+FAILED!: [reported from test()]
+

+
Testcase js1_2/Objects/toString-001.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+var o = new Object(); o.toString() = [object Object] FAILED! expected: {}
+o = {}; o.toString() = [object Object] FAILED! expected: {}
+o = { name:"object", length:0, value:"hello" }; o.toString() = false FAILED! expected: true
+

+
Testcase js1_2/function/Function_object.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+f.name = undefined FAILED! expected: a_test_function
+f.arity = undefined FAILED! expected: 3
+(new Function()).name = undefined FAILED! expected: anonymous
+} FAILED! expected:
+

+
Testcase js1_2/function/function-001-n.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 3, got 0
+Testcase terminated with signal 0
+Complete testcase output was:
+function-001.js functions not separated by semicolons are errors in version 120 and higher
+eval("function f(){}function g(){}") = undefined FAILED! expected: error
+

+
Testcase js1_2/function/tostring-1.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+

+
Testcase js1_2/function/tostring-2.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+} FAILED! expected:
+

+
Testcase js1_2/operator/equality.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+(new String('x') == 'x') = true FAILED! expected: false
+('x' == new String('x')) = true FAILED! expected: false
+

+
Testcase js1_2/regexp/RegExp_lastIndex.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+re=/x./g; re.lastIndex=4; re.exec('xyabcdxa') = xa FAILED! expected: ["xa"]
+re.exec('xyabcdef') = xy FAILED! expected: ["xy"]
+

+
Testcase js1_2/regexp/RegExp_multiline.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+(multiline == true) '123\n456'.match(/^4../) = null FAILED! expected: 456
+(multiline == true) 'a11\na22\na23\na24'.match(/^a../g) = a11 FAILED! expected: a11,a22,a23,a24
+(multiline == true) '123\n456'.match(/.3$/) = null FAILED! expected: 23
+(multiline == true) 'a11\na22\na23\na24'.match(/a..$/g) = a24 FAILED! expected: a11,a22,a23,a24
+(multiline == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) = a24 FAILED! expected: a11,a22,a23,a24
+

+
Testcase js1_2/regexp/RegExp_multiline_as_array.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+(['$*'] == true) '123\n456'.match(/^4../) = null FAILED! expected: 456
+(['$*'] == true) 'a11\na22\na23\na24'.match(/^a../g) = a11 FAILED! expected: a11,a22,a23,a24
+(['$*'] == true) '123\n456'.match(/.3$/) = null FAILED! expected: 23
+(['$*'] == true) 'a11\na22\na23\na24'.match(/a..$/g) = a24 FAILED! expected: a11,a22,a23,a24
+(['$*'] == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) = a24 FAILED! expected: a11,a22,a23,a24
+

+
Testcase js1_2/regexp/beginLine.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+123xyz'.match(new RegExp('^\d+')) = null FAILED! expected: 123
+

+
Testcase js1_2/regexp/endLine.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+xyz'.match(new RegExp('\d+$')) = null FAILED! expected: 890
+

+
Testcase js1_2/regexp/string_split.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+'abc'.split(/[a-z]/) = ,,, FAILED! expected: ,,
+'abc'.split(/[a-z]/) = ,,, FAILED! expected: ,,
+'abc'.split(new RegExp('[a-z]')) = ,,, FAILED! expected: ,,
+'abc'.split(new RegExp('[a-z]')) = ,,, FAILED! expected: ,,
+

+
Testcase js1_2/version120/boolean-001.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+
+Failure messages were:
+new Boolean(false) = true FAILED! expected: false
+

+
Testcase js1_2/version120/regress-99663.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: Regression test for Bugzilla bug 99663
+Failure messages were:
+Section 1 of test - got Error: Can't find variable: it FAILED! expected: a "read-only" error
+Section 2 of test - got Error: Can't find variable: it FAILED! expected: a "read-only" error
+Section 3 of test - got Error: Can't find variable: it FAILED! expected: a "read-only" error
+

+
Testcase js1_3/Script/function-001-n.js failed Bug Number 10278
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 3, got 0
+Testcase terminated with signal 0
+Complete testcase output was:
+BUGNUMBER: 10278
+function-001.js functions not separated by semicolons are errors in version 120 and higher
+eval("function f(){}function g(){}") = undefined FAILED! expected: error
+

+
Testcase js1_3/Script/script-001.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+script-001 NativeScript
+[40334] ./js1_3/Script/script-001.js line 133: ReferenceError: Can't find variable: Script
+

+
Testcase js1_3/regress/function-001-n.js failed Bug Number 10278
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 3, got 0
+Testcase terminated with signal 0
+Complete testcase output was:
+BUGNUMBER: 10278
+function-001.js functions not separated by semicolons are errors in version 120 and higher
+eval("function f(){}function g(){}") = undefined FAILED! expected: error
+

+
Testcase js1_5/Exceptions/catchguard-001.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase js1_5/Exceptions/catchguard-002.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase js1_5/Exceptions/catchguard-003.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase js1_5/Exceptions/errstack-001.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+[40379] ./js1_5/Exceptions/errstack-001.js line 247: TypeError: Undefined value
+

+
Testcase js1_5/Exceptions/regress-50447.js failed Bug Number 50447
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+BUGNUMBER: 50447
+STATUS: Test (non-ECMA) Error object properties fileName, lineNumber
+[40380] ./js1_5/Exceptions/regress-50447.js line 65: TypeError: Undefined value
+

+
Testcase js1_5/GetSet/getset-001.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase js1_5/GetSet/getset-002.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase js1_5/GetSet/getset-003.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase js1_5/Object/regress-90596-001.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+[40395] ./js1_5/Object/regress-90596-001.js line 48: TypeError: Value undefined (result of expression obj.toSource) is not object.
+

+
Testcase js1_5/Object/regress-90596-002.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+[40396] ./js1_5/Object/regress-90596-002.js line 48: ReferenceError: Can't find variable: uneval
+

+
Testcase js1_5/Object/regress-96284-001.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+[40398] ./js1_5/Object/regress-96284-001.js line 49: TypeError: Value undefined (result of expression obj1.toSource) is not object.
+

+
Testcase js1_5/Object/regress-96284-002.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+[40399] ./js1_5/Object/regress-96284-002.js line 49: ReferenceError: Can't find variable: uneval
+

+
Testcase js1_5/Regress/regress-44009.js failed Bug Number 44009
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+BUGNUMBER: 44009
+STATUS: Testing that we don't crash on obj.toSource()
+[40404] ./js1_5/Regress/regress-44009.js line 60: TypeError: Value undefined (result of expression obj.toSource) is not object.
+

+
Testcase js1_5/Regress/regress-68498-003.js failed Bug Number 68498
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: Testing calling obj.eval(str)
+Failure messages were:
+FAILED!: [reported from test()] Testing calling obj.eval(str); currently at expect[1] within test -
+FAILED!: [reported from test()] Type mismatch, expected type number, actual type boolean
+FAILED!: [reported from test()] Expected value '43', Actual value 'false'
+FAILED!: [reported from test()]
+

+
Testcase js1_5/Regress/regress-103602.js failed Bug Number 103602
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: Reassignment to a const is NOT an error per ECMA
+Failure messages were:
+FAILED!: [reported from test()] Section 1 of test -
+FAILED!: [reported from test()] Expected value '', Actual value 'Redeclaration of a const FAILED to cause an error'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 3 of test -
+FAILED!: [reported from test()] Expected value '1', Actual value '2'
+FAILED!: [reported from test()]
+

+
Testcase js1_5/Regress/regress-104077.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase js1_5/Regress/regress-127557.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+[40431] ./js1_5/Regress/regress-127557.js line 75: ReferenceError: Can't find variable: clone
+

+
Testcase js1_5/Regress/regress-172699.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+[40440] ./js1_5/Regress/regress-172699.js line 61: URIError: URI error
+

+
Testcase js1_5/Regress/regress-179524.js failed Bug Number 179524
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: Don't crash on extraneous arguments to str.match(), etc.
+Failure messages were:
+FAILED!: [reported from test()] Section 14 of test -
+FAILED!: [reported from test()] Expected value 'A', Actual value 'a'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 15 of test -
+FAILED!: [reported from test()] Expected value 'A,a', Actual value 'a'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 17 of test -
+FAILED!: [reported from test()] Expected value 'A', Actual value 'a'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 18 of test -
+FAILED!: [reported from test()] Expected value 'A,a', Actual value 'a'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 20 of test -
+FAILED!: [reported from test()] Expected value 'SHOULD HAVE FALLEN INTO CATCH-BLOCK!', Actual value 'a'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 22 of test -
+FAILED!: [reported from test()] Expected value '0', Actual value '4'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 23 of test -
+FAILED!: [reported from test()] Expected value '0', Actual value '4'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 25 of test -
+FAILED!: [reported from test()] Expected value '0', Actual value '4'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 26 of test -
+FAILED!: [reported from test()] Expected value '0', Actual value '4'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 28 of test -
+FAILED!: [reported from test()] Type mismatch, expected type string, actual type number
+FAILED!: [reported from test()] Expected value 'SHOULD HAVE FALLEN INTO CATCH-BLOCK!', Actual value '4'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 30 of test -
+FAILED!: [reported from test()] Expected value 'ZBC abc', Actual value 'ABC Zbc'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 31 of test -
+FAILED!: [reported from test()] Expected value 'ZBC Zbc', Actual value 'ABC Zbc'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 33 of test -
+FAILED!: [reported from test()] Expected value 'ZBC abc', Actual value 'ABC Zbc'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 34 of test -
+FAILED!: [reported from test()] Expected value 'ZBC Zbc', Actual value 'ABC Zbc'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Section 36 of test -
+FAILED!: [reported from test()] Expected value 'SHOULD HAVE FALLEN INTO CATCH-BLOCK!', Actual value 'ABC Zbc'
+FAILED!: [reported from test()]
+

+
Testcase js1_5/Scope/regress-220584.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+[40465] ./js1_5/Scope/regress-220584.js line 56: ReferenceError: Can't find variable: Script
+

+
Testcase js1_5/Scope/scope-001.js failed Bug Number 53268
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: Testing scope after changing obj.__proto__
+Failure messages were:
+FAILED!: [reported from test()] Step 1: setting obj.__proto__ = global object
+FAILED!: [reported from test()] Expected value '5', Actual value '1'
+FAILED!: [reported from test()]
+FAILED!: [reported from test()] Step 2: setting obj.__proto__ = null
+FAILED!: [reported from test()] Type mismatch, expected type undefined, actual type number
+FAILED!: [reported from test()] Expected value 'undefined', Actual value '1'
+FAILED!: [reported from test()]
+

+
Testcase js1_6/Regress/regress-301574.js failed Bug Number 301574
+ [ Previous Failure | Next Failure | Top of Page ]
+STATUS: E4X should be enabled even when e4x=1 not specified
+Failure messages were:
+FAILED!: E4X should be enabled even when e4x=1 not specified: XML()
+FAILED!: Expected value 'No error', Actual value 'error: ReferenceError: Can't find variable: XML'
+FAILED!:
+FAILED!: E4X should be enabled even when e4x=1 not specified: XMLList()
+FAILED!: Expected value 'No error', Actual value 'error: ReferenceError: Can't find variable: XML'
+FAILED!:
+

+
Testcase js1_6/Regress/regress-309242.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase js1_6/Regress/regress-314887.js failed
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+Testcase produced no output!

+
Testcase js1_6/String/regress-306591.js failed Bug Number 306591
+ [ Previous Failure | Next Failure | Top of Page ]
+Expected exit code 0, got 3
+Testcase terminated with signal 0
+Complete testcase output was:
+BUGNUMBER: 306591
+STATUS: String static methods
+STATUS: See https://bugzilla.mozilla.org/show_bug.cgi?id=304828
+[40487] ./js1_6/String/regress-306591.js line 48: TypeError: Value undefined (result of expression String.split) is not object.
+

+
+[ Top of Page | Top of Failures ]
+
+
+
+

Retest List


+# Retest List, kjs, generated Sat Jan 5 15:45:34 2008. +# Original test base was: All tests. +# 1127 of 1135 test(s) were completed, 52 failures reported. +ecma/TypeConversion/9.3.1-3.js +ecma_2/Exceptions/function-001.js +ecma_3/Date/15.9.5.7.js +ecma_3/FunExpr/fe-001.js +ecma_3/RegExp/15.10.2-1.js +ecma_3/RegExp/perlstress-001.js +ecma_3/RegExp/regress-209919.js +ecma_3/Statements/regress-194364.js +ecma_3/Unicode/uc-001.js +ecma_3/Unicode/uc-002.js +js1_2/Objects/toString-001.js +js1_2/function/Function_object.js +js1_2/function/function-001-n.js +js1_2/function/tostring-1.js +js1_2/function/tostring-2.js +js1_2/operator/equality.js +js1_2/regexp/RegExp_lastIndex.js +js1_2/regexp/RegExp_multiline.js +js1_2/regexp/RegExp_multiline_as_array.js +js1_2/regexp/beginLine.js +js1_2/regexp/endLine.js +js1_2/regexp/string_split.js +js1_2/version120/boolean-001.js +js1_2/version120/regress-99663.js +js1_3/Script/function-001-n.js +js1_3/Script/script-001.js +js1_3/regress/function-001-n.js +js1_5/Exceptions/catchguard-001.js +js1_5/Exceptions/catchguard-002.js +js1_5/Exceptions/catchguard-003.js +js1_5/Exceptions/errstack-001.js +js1_5/Exceptions/regress-50447.js +js1_5/GetSet/getset-001.js +js1_5/GetSet/getset-002.js +js1_5/GetSet/getset-003.js +js1_5/Object/regress-90596-001.js +js1_5/Object/regress-90596-002.js +js1_5/Object/regress-96284-001.js +js1_5/Object/regress-96284-002.js +js1_5/Regress/regress-44009.js +js1_5/Regress/regress-68498-003.js +js1_5/Regress/regress-103602.js +js1_5/Regress/regress-104077.js +js1_5/Regress/regress-127557.js +js1_5/Regress/regress-172699.js +js1_5/Regress/regress-179524.js +js1_5/Scope/regress-220584.js +js1_5/Scope/scope-001.js +js1_6/Regress/regress-301574.js +js1_6/Regress/regress-309242.js +js1_6/Regress/regress-314887.js +js1_6/String/regress-306591.js \ No newline at end of file diff --git a/tests/mozilla/importList.html b/tests/mozilla/importList.html new file mode 100644 index 0000000..f9f167f --- /dev/null +++ b/tests/mozilla/importList.html @@ -0,0 +1,69 @@ + + + + Import Test List + + + + + +
+
+ +  Clear all selections berofe import.
+ + +
+ +
+
+ + +Last modified: Wed Nov 17 14:18:42 PST 1999 + + + diff --git a/tests/mozilla/js1_1/browser.js b/tests/mozilla/js1_1/browser.js new file mode 100644 index 0000000..5bbdf7c --- /dev/null +++ b/tests/mozilla/js1_1/browser.js @@ -0,0 +1,80 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * + * + * + */ + +onerror = err; + +function startTest() { + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function writeLineToLog( string ) { + document.write( string + "
\n"); +} +function writeHeaderToLog( string ) { + document.write( "

" + string + "

" ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } + document.write( "
" ); +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = ""+ string ; + s += "" ; + s += ( passed ) ? "  " + PASSED + : " " + FAILED + expect + ""; + writeLineToLog( s + "" ); + return passed; +} +function err( msg, page, line ) { + writeLineToLog( "Test failed with the message: " + msg ); + + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} diff --git a/tests/mozilla/js1_1/jsref.js b/tests/mozilla/js1_1/jsref.js new file mode 100644 index 0000000..05fcdc8 --- /dev/null +++ b/tests/mozilla/js1_1/jsref.js @@ -0,0 +1,170 @@ +var completed = false; +var testcases; + +var BUGNUMBER=""; +var EXCLUDE = ""; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +version( 110 ); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); +} +function startTest() { +/* + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). +*/ +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { +// s += NBSP; + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + writeLineToLog( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeLineToLog( string ) { + print( string + BR + CR ); +} +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() { + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + } + print(doneTag); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} diff --git a/tests/mozilla/js1_1/regress/function-001.js b/tests/mozilla/js1_1/regress/function-001.js new file mode 100644 index 0000000..2a08b31 --- /dev/null +++ b/tests/mozilla/js1_1/regress/function-001.js @@ -0,0 +1,76 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: boolean-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232 + * + * eval("function f(){}function g(){}") at top level is an error for JS1.2 + and above (missing ; between named function expressions), but declares f + and g as functions below 1.2. + * + * Fails to produce error regardless of version: + * js> version(100) +120 +js> eval("function f(){}function g(){}") +js> version(120); +100 +js> eval("function f(){}function g(){}") +js> + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "boolean-001.js"; + var VERSION = "JS1_1"; + var TITLE = "functions not separated by semicolons are not errors in version 110 "; + var BUGNUMBER="99232"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + result = "passed"; + + testcases[tc++] = new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\")", + void 0, + eval("function f(){}function g(){}") ); + + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_1/shell.js b/tests/mozilla/js1_1/shell.js new file mode 100644 index 0000000..191e8e7 --- /dev/null +++ b/tests/mozilla/js1_1/shell.js @@ -0,0 +1,143 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; + +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + + this.passed = getTestCaseResult( this.expect, this.actual ); +} +function startTest() { + version(110); + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +/* + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. + */ + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +/* end of print functions */ + +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } +} diff --git a/tests/mozilla/js1_2/Array/array_split_1.js b/tests/mozilla/js1_2/Array/array_split_1.js new file mode 100644 index 0000000..4076111 --- /dev/null +++ b/tests/mozilla/js1_2/Array/array_split_1.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: array_split_1.js + ECMA Section: Array.split() + Description: + + These are tests from free perl suite. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "Free Perl"; + var VERSION = "JS1_2"; + var TITLE = "Array.split()"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + testcases[tc++] = new TestCase( SECTION, + "('a,b,c'.split(',')).length", + 3, + ('a,b,c'.split(',')).length ); + + testcases[tc++] = new TestCase( SECTION, + "('a,b'.split(',')).length", + 2, + ('a,b'.split(',')).length ); + + testcases[tc++] = new TestCase( SECTION, + "('a'.split(',')).length", + 1, + ('a'.split(',')).length ); + +/* + * Mozilla deviates from ECMA by never splitting an empty string by any separator + * string into a non-empty array (an array of length 1 that contains the empty string). + * But Internet Explorer does not do this, so we won't do it in JavaScriptCore either. + */ + testcases[tc++] = new TestCase( SECTION, + "(''.split(',')).length", + 1, + (''.split(',')).length ); + + + + + test(); diff --git a/tests/mozilla/js1_2/Array/general1.js b/tests/mozilla/js1_2/Array/general1.js new file mode 100644 index 0000000..7762ec4 --- /dev/null +++ b/tests/mozilla/js1_2/Array/general1.js @@ -0,0 +1,62 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: general1.js + Description: 'This tests out some of the functionality on methods on the Array objects' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String:push,unshift,shift'; + + writeHeaderToLog('Executing script: general1.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + var array1 = []; + + array1.push(123); //array1 = [123] + array1.push("dog"); //array1 = [123,dog] + array1.push(-99); //array1 = [123,dog,-99] + array1.push("cat"); //array1 = [123,dog,-99,cat] + testcases[count++] = new TestCase( SECTION, "array1.pop()", array1.pop(),'cat'); + //array1 = [123,dog,-99] + array1.push("mouse"); //array1 = [123,dog,-99,mouse] + testcases[count++] = new TestCase( SECTION, "array1.shift()", array1.shift(),123); + //array1 = [dog,-99,mouse] + array1.unshift(96); //array1 = [96,dog,-99,mouse] + testcases[count++] = new TestCase( SECTION, "state of array", String([96,"dog",-99,"mouse"]), String(array1)); + testcases[count++] = new TestCase( SECTION, "array1.length", array1.length,4); + array1.shift(); //array1 = [dog,-99,mouse] + array1.shift(); //array1 = [-99,mouse] + array1.shift(); //array1 = [mouse] + testcases[count++] = new TestCase( SECTION, "array1.shift()", array1.shift(),"mouse"); + testcases[count++] = new TestCase( SECTION, "array1.shift()", "undefined", String(array1.shift())); + + test(); + diff --git a/tests/mozilla/js1_2/Array/general2.js b/tests/mozilla/js1_2/Array/general2.js new file mode 100644 index 0000000..afa4529 --- /dev/null +++ b/tests/mozilla/js1_2/Array/general2.js @@ -0,0 +1,78 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: general2.js + Description: 'This tests out some of the functionality on methods on the Array objects' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String:push,splice,concat,unshift,sort'; + + writeHeaderToLog('Executing script: general2.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + array1 = new Array(); + array2 = []; + size = 10; + + // this for loop populates array1 and array2 as follows: + // array1 = [0,1,2,3,4,....,size - 2,size - 1] + // array2 = [size - 1, size - 2,...,4,3,2,1,0] + for (var i = 0; i < size; i++) + { + array1.push(i); + array2.push(size - 1 - i); + } + + // the following for loop reverses the order of array1 so + // that it should be similarly ordered to array2 + for (i = array1.length; i > 0; i--) + { + array3 = array1.slice(1,i); + array1.splice(1,i-1); + array1 = array3.concat(array1); + } + + // the following for loop reverses the order of array1 + // and array2 + for (i = 0; i < size; i++) + { + array1.push(array1.shift()); + array2.unshift(array2.pop()); + } + + testcases[count++] = new TestCase( SECTION, "Array.push,pop,shift,unshift,slice,splice", true,String(array1) == String(array2)); + array1.sort(); + array2.sort(); + testcases[count++] = new TestCase( SECTION, "Array.sort", true,String(array1) == String(array2)); + + test(); + diff --git a/tests/mozilla/js1_2/Array/slice.js b/tests/mozilla/js1_2/Array/slice.js new file mode 100644 index 0000000..7b9c55d --- /dev/null +++ b/tests/mozilla/js1_2/Array/slice.js @@ -0,0 +1,123 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: slice.js + Description: 'This tests out some of the functionality on methods on the Array objects' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String:slice'; + + writeHeaderToLog('Executing script: slice.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + function mySlice(a, from, to) + { + var from2 = from; + var to2 = to; + var returnArray = []; + var i; + + if (from2 < 0) from2 = a.length + from; + if (to2 < 0) to2 = a.length + to; + + if ((to2 > from2)&&(to2 > 0)&&(from2 < a.length)) + { + if (from2 < 0) from2 = 0; + if (to2 > a.length) to2 = a.length; + + for (i = from2; i < to2; ++i) returnArray.push(a[i]); + } + return returnArray; + } + + // This function tests the slice command on an Array + // passed in. The arguments passed into slice range in + // value from -5 to the length of the array + 4. Every + // combination of the two arguments is tested. The expected + // result of the slice(...) method is calculated and + // compared to the actual result from the slice(...) method. + // If the Arrays are not similar false is returned. + function exhaustiveSliceTest(testname, a) + { + var x = 0; + var y = 0; + var errorMessage; + var reason = ""; + var passed = true; + + for (x = -(2 + a.length); x <= (2 + a.length); x++) + for (y = (2 + a.length); y >= -(2 + a.length); y--) + { + var b = a.slice(x,y); + var c = mySlice(a,x,y); + + if (String(b) != String(c)) + { + errorMessage = + "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + + " test: " + "a.slice(" + x + "," + y + ")\n" + + " a: " + String(a) + "\n" + + " actual result: " + String(b) + "\n" + + " expected result: " + String(c) + "\n"; + writeHeaderToLog(errorMessage); + reason = reason + errorMessage; + passed = false; + } + } + var testCase = new TestCase(SECTION, testname, true, passed); + if (passed == false) + testCase.reason = reason; + return testCase; + } + + var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; + var b = [1,2,3,4,5,6,7,8,9,0]; + + testcases[count++] = exhaustiveSliceTest("exhaustive slice test 1", a); + testcases[count++] = exhaustiveSliceTest("exhaustive slice test 2", b); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/Array/splice1.js b/tests/mozilla/js1_2/Array/splice1.js new file mode 100644 index 0000000..b2164f4 --- /dev/null +++ b/tests/mozilla/js1_2/Array/splice1.js @@ -0,0 +1,152 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: splice1.js + Description: 'Tests Array.splice(x,y) w/no var args' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String:splice 1'; + var BUGNUMBER="123795"; + + writeHeaderToLog('Executing script: splice1.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + function mySplice(testArray, splicedArray, first, len, elements) + { + var removedArray = []; + var adjustedFirst = first; + var adjustedLen = len; + + if (adjustedFirst < 0) adjustedFirst = testArray.length + first; + if (adjustedFirst < 0) adjustedFirst = 0; + + if (adjustedLen < 0) adjustedLen = 0; + + for (i = 0; (i < adjustedFirst)&&(i < testArray.length); ++i) + splicedArray.push(testArray[i]); + + if (adjustedFirst < testArray.length) + for (i = adjustedFirst; (i < adjustedFirst + adjustedLen) && + (i < testArray.length); ++i) + { + removedArray.push(testArray[i]); + } + + for (i = 0; i < elements.length; i++) splicedArray.push(elements[i]); + + for (i = adjustedFirst + adjustedLen; i < testArray.length; i++) + splicedArray.push(testArray[i]); + + return removedArray; + } + + function exhaustiveSpliceTest(testname, testArray) + { + var errorMessage; + var passed = true; + var reason = ""; + + for (var first = -(testArray.length+2); first <= 2 + testArray.length; first++) + { + var actualSpliced = []; + var expectedSpliced = []; + var actualRemoved = []; + var expectedRemoved = []; + + for (var len = 0; len < testArray.length + 2; len++) + { + actualSpliced = []; + expectedSpliced = []; + + for (var i = 0; i < testArray.length; ++i) + actualSpliced.push(testArray[i]); + + actualRemoved = actualSpliced.splice(first,len); + expectedRemoved = mySplice(testArray,expectedSpliced,first,len,[]); + + var adjustedFirst = first; + if (adjustedFirst < 0) adjustedFirst = testArray.length + first; + if (adjustedFirst < 0) adjustedFirst = 0; + + if ( (String(actualSpliced) != String(expectedSpliced)) + ||(String(actualRemoved) != String(expectedRemoved))) + { + if ( (String(actualSpliced) == String(expectedSpliced)) + &&(String(actualRemoved) != String(expectedRemoved)) ) + { + if ( (expectedRemoved.length == 1) + &&(String(actualRemoved) == String(expectedRemoved[0]))) continue; + if ( expectedRemoved.length == 0 && actualRemoved == void 0) continue; + } + + errorMessage = + "ERROR: 'TEST FAILED'\n" + + " test: " + "a.splice(" + first + "," + len + ",-97,new String('test arg'),[],9.8)\n" + + " a: " + String(testArray) + "\n" + + " actual spliced: " + String(actualSpliced) + "\n" + + " expected spliced: " + String(expectedSpliced) + "\n" + + " actual removed: " + String(actualRemoved) + "\n" + + " expected removed: " + String(expectedRemoved) + "\n"; + writeHeaderToLog(errorMessage); + reason = reason + errorMessage; + passed = false; + } + } + } + var testcase = new TestCase( SECTION, testname, true, passed); + if (!passed) + testcase.reason = reason; + return testcase; + } + + var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; + var b = [1,2,3,4,5,6,7,8,9,0]; + + testcases[count++] = exhaustiveSpliceTest("exhaustive splice w/no optional args 1",a); + testcases[count++] = exhaustiveSpliceTest("exhaustive splice w/no optional args 1",b); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/Array/splice2.js b/tests/mozilla/js1_2/Array/splice2.js new file mode 100644 index 0000000..30861a5 --- /dev/null +++ b/tests/mozilla/js1_2/Array/splice2.js @@ -0,0 +1,150 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: splice2.js + Description: 'Tests Array.splice(x,y) w/4 var args' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String:splice 2'; + var BUGNUMBER="123795"; + + writeHeaderToLog('Executing script: splice2.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + function mySplice(testArray, splicedArray, first, len, elements) + { + var removedArray = []; + var adjustedFirst = first; + var adjustedLen = len; + + if (adjustedFirst < 0) adjustedFirst = testArray.length + first; + if (adjustedFirst < 0) adjustedFirst = 0; + + if (adjustedLen < 0) adjustedLen = 0; + + for (i = 0; (i < adjustedFirst)&&(i < testArray.length); ++i) + splicedArray.push(testArray[i]); + + if (adjustedFirst < testArray.length) + for (i = adjustedFirst; (i < adjustedFirst + adjustedLen) && (i < testArray.length); ++i) + removedArray.push(testArray[i]); + + for (i = 0; i < elements.length; i++) splicedArray.push(elements[i]); + + for (i = adjustedFirst + adjustedLen; i < testArray.length; i++) + splicedArray.push(testArray[i]); + + return removedArray; + } + + function exhaustiveSpliceTestWithArgs(testname, testArray) + { + var passed = true; + var errorMessage; + var reason = ""; + for (var first = -(testArray.length+2); first <= 2 + testArray.length; first++) + { + var actualSpliced = []; + var expectedSpliced = []; + var actualRemoved = []; + var expectedRemoved = []; + + for (var len = 0; len < testArray.length + 2; len++) + { + actualSpliced = []; + expectedSpliced = []; + + for (var i = 0; i < testArray.length; ++i) + actualSpliced.push(testArray[i]); + + actualRemoved = actualSpliced.splice(first,len,-97,new String("test arg"),[],9.8); + expectedRemoved = mySplice(testArray,expectedSpliced,first,len,[-97,new String("test arg"),[],9.8]); + + var adjustedFirst = first; + if (adjustedFirst < 0) adjustedFirst = testArray.length + first; + if (adjustedFirst < 0) adjustedFirst = 0; + + + if ( (String(actualSpliced) != String(expectedSpliced)) + ||(String(actualRemoved) != String(expectedRemoved))) + { + if ( (String(actualSpliced) == String(expectedSpliced)) + &&(String(actualRemoved) != String(expectedRemoved)) ) + { + + if ( (expectedRemoved.length == 1) + &&(String(actualRemoved) == String(expectedRemoved[0]))) continue; + if ( expectedRemoved.length == 0 && actualRemoved == void 0 ) continue; + } + + errorMessage = + "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + + " test: " + "a.splice(" + first + "," + len + ",-97,new String('test arg'),[],9.8)\n" + + " a: " + String(testArray) + "\n" + + " actual spliced: " + String(actualSpliced) + "\n" + + " expected spliced: " + String(expectedSpliced) + "\n" + + " actual removed: " + String(actualRemoved) + "\n" + + " expected removed: " + String(expectedRemoved); + reason = reason + errorMessage; + writeHeaderToLog(errorMessage); + passed = false; + } + } + } + var testcase = new TestCase(SECTION, testname, true, passed); + if (!passed) testcase.reason = reason; + return testcase; + } + + + var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; + var b = [1,2,3,4,5,6,7,8,9,0]; + + testcases[count++] = exhaustiveSpliceTestWithArgs("exhaustive splice w/2 optional args 1",a); + testcases[count++] = exhaustiveSpliceTestWithArgs("exhaustive splice w/2 optional args 2",b); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/Array/tostring_1.js b/tests/mozilla/js1_2/Array/tostring_1.js new file mode 100644 index 0000000..453d8ab --- /dev/null +++ b/tests/mozilla/js1_2/Array/tostring_1.js @@ -0,0 +1,138 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: tostring_1.js + ECMA Section: Array.toString() + Description: + + This checks the ToString value of Array objects under JavaScript 1.2. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "JS1_2"; + var VERSION = "JS1_2"; + startTest(); + var TITLE = "Array.toString()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var a = new Array(); + + var VERSION = 0; + + /* This test assumes that if version() exists, it can set the JavaScript + * interpreter to an arbitrary version. To prevent unhandled exceptions in + * other tests, testkjs implements version() as a stub function, but + * JavaScriptCore doesn't support setting the JavaScript engine's version. + + * Commenting out the following lines forces the test to expect JavaScript + * 1.5 results. + + * If JavaScriptCore changes to support versioning, this test should split + * into a 1.2 test in js1_2/ and a 1.5 test in js1_5/. + */ + + /* + if ( typeof version == "function" ) { + version(120); + VERSION = "120"; + } else { + function version() { return 0; }; + } + */ + + testcases[tc++] = new TestCase ( SECTION, + "var a = new Array(); a.toString()", + ( VERSION == "120" ? "[]" : "" ), + a.toString() ); + + a[0] = void 0; + + testcases[tc++] = new TestCase ( SECTION, + "a[0] = void 0; a.toString()", + ( VERSION == "120" ? "[, ]" : "" ), + a.toString() ); + + + testcases[tc++] = new TestCase( SECTION, + "a.length", + 1, + a.length ); + + a[1] = void 0; + + testcases[tc++] = new TestCase( SECTION, + "a[1] = void 0; a.toString()", + ( VERSION == "120" ? "[, , ]" : "," ), + a.toString() ); + + a[1] = "hi"; + + testcases[tc++] = new TestCase( SECTION, + "a[1] = \"hi\"; a.toString()", + ( VERSION == "120" ? "[, \"hi\"]" : ",hi" ), + a.toString() ); + + a[2] = void 0; + + testcases[tc++] = new TestCase( SECTION, + "a[2] = void 0; a.toString()", + ( VERSION == "120" ?"[, \"hi\", , ]":",hi,"), + a.toString() ); + + var b = new Array(1000); + var bstring = ""; + for ( blen=0; blen<999; blen++) { + bstring += ","; + } + + + testcases[tc++] = new TestCase ( SECTION, + "var b = new Array(1000); b.toString()", + ( VERSION == "120" ? "[1000]" : bstring ), + b.toString() ); + + + testcases[tc++] = new TestCase( SECTION, + "b.length", + ( VERSION == "120" ? 1 : 1000 ), + b.length ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_2/Array/tostring_2.js b/tests/mozilla/js1_2/Array/tostring_2.js new file mode 100644 index 0000000..ae9542b --- /dev/null +++ b/tests/mozilla/js1_2/Array/tostring_2.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: tostring_2.js + Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=114564 + Description: toString in version 120 + + + Author: christine@netscape.com + Date: 15 June 1998 +*/ + + var SECTION = "Array/tostring_2.js"; + var VERSION = "JS_12"; + startTest(); + var TITLE = "Array.toString"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var a = []; + + var VERSION = 0; + + /* This test assumes that if version() exists, it can set the JavaScript + * interpreter to an arbitrary version. To prevent unhandled exceptions in + * other tests, testkjs implements version() as a stub function, but + * JavaScriptCore doesn't support setting the JavaScript engine's version. + + * Commenting out the following lines forces the test to expect JavaScript + * 1.5 results. + + * If JavaScriptCore changes to support versioning, this test should split + * into a 1.2 test in js1_2/ and a 1.5 test in js1_5/. + */ + + /* + if ( typeof version == "function" ) { + writeLineToLog("version 120"); + version(120); + VERSION = "120"; + } else { + function version() { return 0; }; + } + */ + + testcases[tc++] = new TestCase ( SECTION, + "a.toString()", + ( VERSION == "120" ? "[]" : "" ), + a.toString() ); + + testcases[tc++] = new TestCase ( SECTION, + "String( a )", + ( VERSION == "120" ? "[]" : "" ), + String( a ) ); + + testcases[tc++] = new TestCase ( SECTION, + "a +''", + ( VERSION == "120" ? "[]" : "" ), + a+"" ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_2/Objects/toString-001.js b/tests/mozilla/js1_2/Objects/toString-001.js new file mode 100644 index 0000000..33976bd --- /dev/null +++ b/tests/mozilla/js1_2/Objects/toString-001.js @@ -0,0 +1,117 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: toString_1.js + ECMA Section: Object.toString() + Description: + + This checks the ToString value of Object objects under JavaScript 1.2. + + In JavaScript 1.2, Object.toString() + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "JS1_2"; + var VERSION = "JS1_2"; + startTest(); + var TITLE = "Object.toString()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var o = new Object(); + + testcases[testcases.length] = new TestCase( SECTION, + "var o = new Object(); o.toString()", + "{}", + o.toString() ); + + o = {}; + + testcases[testcases.length] = new TestCase( SECTION, + "o = {}; o.toString()", + "{}", + o.toString() ); + + o = { name:"object", length:0, value:"hello" } + + testcases[testcases.length] = new TestCase( SECTION, + "o = { name:\"object\", length:0, value:\"hello\" }; o.toString()", + true, + checkObjectToString(o.toString(), ['name:"object"', 'length:0', + 'value:"hello"'])); + + o = { name:"object", length:0, value:"hello", + toString:new Function( "return this.value+''" ) } + + testcases[testcases.length] = new TestCase( SECTION, + "o = { name:\"object\", length:0, value:\"hello\", "+ + "toString:new Function( \"return this.value+''\" ) }; o.toString()", + "hello", + o.toString() ); + + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +/** + * checkObjectToString + * + * In JS1.2, Object.prototype.toString returns a representation of the + * object's properties as a string. However, the order of the properties + * in the resulting string is not specified. This function compares the + * resulting string with an array of strings to make sure that the + * resulting string is some permutation of the strings in the array. + */ +function checkObjectToString(s, a) { + var m = /^\{(.*)\}$/(s); + if (!m) + return false; // should begin and end with curly brackets + var a2 = m[1].split(", "); + if (a.length != a2.length) + return false; // should be same length + a.sort(); + a2.sort(); + for (var i=0; i < a.length; i++) { + if (a[i] != a2[i]) + return false; // should have identical elements + } + return true; +} + diff --git a/tests/mozilla/js1_2/String/charCodeAt.js b/tests/mozilla/js1_2/String/charCodeAt.js new file mode 100644 index 0000000..ec4a7a2 --- /dev/null +++ b/tests/mozilla/js1_2/String/charCodeAt.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: charCodeAt.js + Description: 'This tests new String object method: charCodeAt' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String:charCodeAt'; + + writeHeaderToLog('Executing script: charCodeAt.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + var aString = new String("tEs5"); + + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt(-2)", NaN, aString.charCodeAt(-2)); + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt(-1)", NaN, aString.charCodeAt(-1)); + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 0)", 116, aString.charCodeAt( 0)); + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 1)", 69, aString.charCodeAt( 1)); + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 2)", 115, aString.charCodeAt( 2)); + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 3)", 53, aString.charCodeAt( 3)); + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 4)", NaN, aString.charCodeAt( 4)); + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 5)", NaN, aString.charCodeAt( 5)); + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( Infinity)", NaN, aString.charCodeAt( Infinity)); + testcases[count++] = new TestCase( SECTION, "aString.charCodeAt(-Infinity)", NaN, aString.charCodeAt(-Infinity)); + //testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( )", 116, aString.charCodeAt( )); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/String/concat.js b/tests/mozilla/js1_2/String/concat.js new file mode 100644 index 0000000..725abb7 --- /dev/null +++ b/tests/mozilla/js1_2/String/concat.js @@ -0,0 +1,96 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: concat.js + Description: 'This tests the new String object method: concat' + + Author: NickLerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String:concat'; + + writeHeaderToLog('Executing script: concat.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + var aString = new String("test string"); + var bString = new String(" another "); + + testcases[count++] = new TestCase( SECTION, "aString.concat(' more')", "test string more", aString.concat(' more').toString()); + testcases[count++] = new TestCase( SECTION, "aString.concat(bString)", "test string another ", aString.concat(bString).toString()); + testcases[count++] = new TestCase( SECTION, "aString ", "test string", aString.toString()); + testcases[count++] = new TestCase( SECTION, "bString ", " another ", bString.toString()); + testcases[count++] = new TestCase( SECTION, "aString.concat(345) ", "test string345", aString.concat(345).toString()); + testcases[count++] = new TestCase( SECTION, "aString.concat(true) ", "test stringtrue", aString.concat(true).toString()); + testcases[count++] = new TestCase( SECTION, "aString.concat(null) ", "test stringnull", aString.concat(null).toString()); + /* + http://bugs.webkit.org/show_bug.cgi?id=11545#c3 + According to ECMA 15.5.4.6, the argument of concat should send to ToString and + convert into a string value (not String object). So these arguments will be + convert into '' and '1,2,3' under ECMA-262v3, not the js1.2 expected '[]' and + '[1,2,3]' + */ + //testcases[count++] = new TestCase( SECTION, "aString.concat([]) ", "test string[]", aString.concat([]).toString()); + //testcases[count++] = new TestCase( SECTION, "aString.concat([1,2,3])", "test string[1, 2, 3]", aString.concat([1,2,3]).toString()); + + testcases[count++] = new TestCase( SECTION, "'abcde'.concat(' more')", "abcde more", 'abcde'.concat(' more').toString()); + testcases[count++] = new TestCase( SECTION, "'abcde'.concat(bString)", "abcde another ", 'abcde'.concat(bString).toString()); + testcases[count++] = new TestCase( SECTION, "'abcde' ", "abcde", 'abcde'); + testcases[count++] = new TestCase( SECTION, "'abcde'.concat(345) ", "abcde345", 'abcde'.concat(345).toString()); + testcases[count++] = new TestCase( SECTION, "'abcde'.concat(true) ", "abcdetrue", 'abcde'.concat(true).toString()); + testcases[count++] = new TestCase( SECTION, "'abcde'.concat(null) ", "abcdenull", 'abcde'.concat(null).toString()); + /* + http://bugs.webkit.org/show_bug.cgi?id=11545#c3 + According to ECMA 15.5.4.6, the argument of concat should send to ToString and + convert into a string value (not String object). So these arguments will be + convert into '' and '1,2,3' under ECMA-262v3, not the js1.2 expected '[]' and + '[1,2,3]' + */ + //testcases[count++] = new TestCase( SECTION, "'abcde'.concat([]) ", "abcde[]", 'abcde'.concat([]).toString()); + //testcases[count++] = new TestCase( SECTION, "'abcde'.concat([1,2,3])", "abcde[1, 2, 3]", 'abcde'.concat([1,2,3]).toString()); + + //what should this do: + testcases[count++] = new TestCase( SECTION, "'abcde'.concat() ", "abcde", 'abcde'.concat().toString()); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/String/match.js b/tests/mozilla/js1_2/String/match.js new file mode 100644 index 0000000..6c4efb4 --- /dev/null +++ b/tests/mozilla/js1_2/String/match.js @@ -0,0 +1,62 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: match.js + Description: 'This tests the new String object method: match' + + Author: NickLerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String:match'; + + writeHeaderToLog('Executing script: match.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + var aString = new String("this is a test string"); + + testcases[count++] = new TestCase( SECTION, "aString.match(/is.*test/) ", String(["is is a test"]), String(aString.match(/is.*test/))); + testcases[count++] = new TestCase( SECTION, "aString.match(/s.*s/) ", String(["s is a test s"]), String(aString.match(/s.*s/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/String/slice.js b/tests/mozilla/js1_2/String/slice.js new file mode 100644 index 0000000..f0e901e --- /dev/null +++ b/tests/mozilla/js1_2/String/slice.js @@ -0,0 +1,123 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: slice.js + Description: 'This tests the String object method: slice' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String.slice'; + + writeHeaderToLog('Executing script: slice.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + function myStringSlice(a, from, to) + { + var from2 = from; + var to2 = to; + var returnString = new String(""); + var i; + + if (from2 < 0) from2 = a.length + from; + if (to2 < 0) to2 = a.length + to; + + if ((to2 > from2)&&(to2 > 0)&&(from2 < a.length)) + { + if (from2 < 0) from2 = 0; + if (to2 > a.length) to2 = a.length; + + for (i = from2; i < to2; ++i) returnString += a.charAt(i); + } + return returnString; + } + + // This function tests the slice command on a String + // passed in. The arguments passed into slice range in + // value from -5 to the length of the array + 4. Every + // combination of the two arguments is tested. The expected + // result of the slice(...) method is calculated and + // compared to the actual result from the slice(...) method. + // If the Strings are not similar false is returned. + function exhaustiveStringSliceTest(testname, a) + { + var x = 0; + var y = 0; + var errorMessage; + var reason = ""; + var passed = true; + + for (x = -(2 + a.length); x <= (2 + a.length); x++) + for (y = (2 + a.length); y >= -(2 + a.length); y--) + { + var b = a.slice(x,y); + var c = myStringSlice(a,x,y); + + if (String(b) != String(c)) + { + errorMessage = + "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + + " test: " + "a.slice(" + x + "," + y + ")\n" + + " a: " + String(a) + "\n" + + " actual result: " + String(b) + "\n" + + " expected result: " + String(c) + "\n"; + writeHeaderToLog(errorMessage); + reason = reason + errorMessage; + passed = false; + } + } + var testCase = new TestCase(SECTION, testname, true, passed); + if (passed == false) + testCase.reason = reason; + return testCase; + } + + var a = new String("abcdefghijklmnopqrstuvwxyz1234567890"); + var b = new String("this is a test string"); + + testcases[count++] = exhaustiveStringSliceTest("exhaustive String.slice test 1", a); + testcases[count++] = exhaustiveStringSliceTest("exhaustive String.slice test 2", b); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/browser.js b/tests/mozilla/js1_2/browser.js new file mode 100644 index 0000000..8b298a0 --- /dev/null +++ b/tests/mozilla/js1_2/browser.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * + * + * + */ + +onerror = err; + +var GLOBAL = "[object Window]"; + +function startTest() { + writeHeaderToLog( SECTION + " "+ TITLE); + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function writeLineToLog( string ) { + document.write( string + "
\n"); +} +function writeHeaderToLog( string ) { + document.write( "

" + string + "

" ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } + document.write( "
" ); +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = ""+ string ; + s += "" ; + s += ( passed ) ? "  " + PASSED + : " " + FAILED + expect + ""; + writeLineToLog( s + "" ); + return passed; +} +function err ( msg, page, line ) { + writeLineToLog( "Test " + page + " failed on line " + line +" with the message: " + msg ); + + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} diff --git a/tests/mozilla/js1_2/function/Function_object.js b/tests/mozilla/js1_2/function/Function_object.js new file mode 100644 index 0000000..1dec16a --- /dev/null +++ b/tests/mozilla/js1_2/function/Function_object.js @@ -0,0 +1,85 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: Function_object.js + Description: 'Testing Function objects' + + Author: Nick Lerissa + Date: April 17, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'functions: Function_object'; + + writeHeaderToLog('Executing script: Function_object.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + function a_test_function(a,b,c) + { + return a + b + c; + } + + f = a_test_function; + + + testcases[count++] = new TestCase( SECTION, "f.name", + 'a_test_function', f.name); + + testcases[count++] = new TestCase( SECTION, "f.length", + 3, f.length); + + testcases[count++] = new TestCase( SECTION, "f.arity", + 3, f.arity); + + testcases[count++] = new TestCase( SECTION, "f(2,3,4)", + 9, f(2,3,4)); + + var fnName = version() == 120 ? '' : 'anonymous'; + + testcases[count++] = new TestCase( SECTION, "(new Function()).name", + fnName, (new Function()).name); + + testcases[count++] = new TestCase( SECTION, "(new Function()).toString()", + '\nfunction ' + fnName + '() {\n}\n', (new Function()).toString()); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/function/Number.js b/tests/mozilla/js1_2/function/Number.js new file mode 100644 index 0000000..9586f78 --- /dev/null +++ b/tests/mozilla/js1_2/function/Number.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: Number.js + Description: 'This tests the function Number(Object)' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'functions: Number'; + var BUGNUMBER="123435"; + + writeHeaderToLog('Executing script: Number.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + date = new Date(2200); + + testcases[count++] = new TestCase( SECTION, "Number(new Date(2200)) ", + 2200, (Number(date))); + testcases[count++] = new TestCase( SECTION, "Number(true) ", + 1, (Number(true))); + testcases[count++] = new TestCase( SECTION, "Number(false) ", + 0, (Number(false))); + testcases[count++] = new TestCase( SECTION, "Number('124') ", + 124, (Number('124'))); + testcases[count++] = new TestCase( SECTION, "Number('1.23') ", + 1.23, (Number('1.23'))); + testcases[count++] = new TestCase( SECTION, "Number({p:1}) ", + NaN, (Number({p:1}))); + testcases[count++] = new TestCase( SECTION, "Number(null) ", + 0, (Number(null))); + testcases[count++] = new TestCase( SECTION, "Number(-45) ", + -45, (Number(-45))); + + // http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123435 + // under js1.2, Number([1,2,3]) should return 3. + + /* + http://bugs.webkit.org/show_bug.cgi?id=11545#c4 + According to ECMA 9.3, when input type was Object, should call + ToPrimitive(input arg, hint Number) first, and than ToNumber() later. However, + ToPrimitive() will use [[DefaultValue]](hint) rule when input Type was Object + (ECMA 8.6.2.6). So the input [1,2,3] will applied [[DefaultValue]](hint) rule + with hint Number, and it looks like this: + + toString(valuOf([1,2,3])) => toString(1,2,3) => '1,2,3' + + Than ToNumber('1,2,3') results NaN based on ECMA 9.3.1: If the grammar cannot + interpret the string as an expansion of StringNumericLiteral, then the result + of ToNumber is NaN. + */ + + //testcases[count++] = new TestCase( SECTION, "Number([1,2,3]) ", + // 3, (Number([1,2,3]))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/function/String.js b/tests/mozilla/js1_2/function/String.js new file mode 100644 index 0000000..724c392 --- /dev/null +++ b/tests/mozilla/js1_2/function/String.js @@ -0,0 +1,99 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: String.js + Description: 'This tests the function String(Object)' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'functions: String'; + + writeHeaderToLog('Executing script: String.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + testcases[count++] = new TestCase( SECTION, "String(true) ", + 'true', (String(true))); + testcases[count++] = new TestCase( SECTION, "String(false) ", + 'false', (String(false))); + testcases[count++] = new TestCase( SECTION, "String(-124) ", + '-124', (String(-124))); + testcases[count++] = new TestCase( SECTION, "String(1.23) ", + '1.23', (String(1.23))); + /* + http://bugs.webkit.org/show_bug.cgi?id=11545#c5 + According to ECMA 9.8, when input type of String object argument was Object, we + should applied ToPrimitive(input arg, hint String) first, and later ToString(). + And just like previous one, ToPrimitive() will use [[DefaultValue]](hint) + with hint String to convert the input (toString() below uses the rule in ECMA 15.2.4.2): + + valueOf(toString({p:1}) => valueOf('[object Object]') => '[object Object]' + + And ToString() called after ToPrimitive(), so the correct result would be: + + [object Object] + */ + //testcases[count++] = new TestCase( SECTION, "String({p:1}) ", + // '{p:1}', (String({p:1}))); + testcases[count++] = new TestCase( SECTION, "String(null) ", + 'null', (String(null))); + /* + http://bugs.webkit.org/show_bug.cgi?id=11545#c5 + According to ECMA 9.8, when input type of String object argument was Object, we + should applied ToPrimitive(input arg, hint String) first, and later ToString(). + And just like previous one, ToPrimitive() will use [[DefaultValue]](hint) + with hint String to convert the input (toString() below uses the rule in ECMA 15.2.4.2): + + valueOf(toString([1,2,3])) => valueOf('1,2,3') => '1,2,3' + + And ToString() called after ToPrimitive(), so the correct result would be: + + 1,2,3 + */ + //testcases[count++] = new TestCase( SECTION, "String([1,2,3]) ", + // '[1, 2, 3]', (String([1,2,3]))); + + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/function/definition-1.js b/tests/mozilla/js1_2/function/definition-1.js new file mode 100644 index 0000000..6daea71 --- /dev/null +++ b/tests/mozilla/js1_2/function/definition-1.js @@ -0,0 +1,73 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: definition-1.js + Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=111284 + Description: Regression test for declaring functions. + + Author: christine@netscape.com + Date: 15 June 1998 +*/ + + var SECTION = "function/definition-1.js"; + var VERSION = "JS_12"; + startTest(); + var TITLE = "Regression test for 111284"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + f1 = function() { return "passed!" } + + function f2() { f3 = function() { return "passed!" }; return f3(); } + + testcases[tc++] = new TestCase( SECTION, + 'f1 = function() { return "passed!" }; f1()', + "passed!", + f1() ); + + testcases[tc++] = new TestCase( SECTION, + 'function f2() { f3 = function { return "passed!" }; return f3() }; f2()', + "passed!", + f2() ); + + testcases[tc++] = new TestCase( SECTION, + 'f3()', + "passed!", + f3() ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_2/function/function-001-n.js b/tests/mozilla/js1_2/function/function-001-n.js new file mode 100644 index 0000000..5ae01a9 --- /dev/null +++ b/tests/mozilla/js1_2/function/function-001-n.js @@ -0,0 +1,74 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: boolean-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232 + * + * eval("function f(){}function g(){}") at top level is an error for JS1.2 + * and above (missing ; between named function expressions), but declares f + * and g as functions below 1.2. + * + * Fails to produce error regardless of version: + * js> version(100) + * 120 + * js> eval("function f(){}function g(){}") + * js> version(120); + * 100 + * js> eval("function f(){}function g(){}") + * js> + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "function-001.js"; + var VERSION = "JS1_1"; + startTest(); + var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; + var BUGNUMBER="99232"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\")", + "error", + eval("function f(){}function g(){}") ); + + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_2/function/length.js b/tests/mozilla/js1_2/function/length.js new file mode 100644 index 0000000..aae30d5 --- /dev/null +++ b/tests/mozilla/js1_2/function/length.js @@ -0,0 +1,93 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: 15.3.5.1.js + ECMA Section: Function.length + Description: + + The value of the length property is usually an integer that indicates the + "typical" number of arguments expected by the function. However, the + language permits the function to be invoked with some other number of + arguments. The behavior of a function when invoked on a number of arguments + other than the number specified by its length property depends on the function. + + This checks the pre-ecma behavior Function.length. + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204 + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "function/length.js"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function.length"; + var BUGNUMBER="104204"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var f = new Function( "a","b", "c", "return f.length"); + + if ( version() <= 120 ) { + + testcases[tc++] = new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f()', + 0, + f() ); + + testcases[tc++] = new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', + 5, + f(1,2,3,4,5) ); + } else { + + testcases[tc++] = new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f()', + 3, + f() ); + + testcases[tc++] = new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', + 3, + f(1,2,3,4,5) ); + + + } + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_2/function/nesting-1.js b/tests/mozilla/js1_2/function/nesting-1.js new file mode 100644 index 0000000..391f926 --- /dev/null +++ b/tests/mozilla/js1_2/function/nesting-1.js @@ -0,0 +1,61 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: nesting-1.js + Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122040 + Description: Regression test for a nested function + + Author: christine@netscape.com + Date: 15 June 1998 +*/ + + var SECTION = "function/nesting-1.js"; + var VERSION = "JS_12"; + startTest(); + var TITLE = "Regression test for 122040"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + function f(a) {function g(b) {return a+b;}; return g;}; f(7) + + testcases[tc++] = new TestCase( SECTION, + 'function f(a) {function g(b) {return a+b;}; return g;}; typeof f(7)', + "function", + typeof f(7) ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_2/function/nesting.js b/tests/mozilla/js1_2/function/nesting.js new file mode 100644 index 0000000..b626da5 --- /dev/null +++ b/tests/mozilla/js1_2/function/nesting.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: nesting.js + Description: 'This tests the nesting of functions' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'functions: nesting'; + + writeHeaderToLog('Executing script: nesting.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + function outer_func(x) + { + var y = "outer"; + + testcases[count++] = new TestCase( SECTION, "outer:x ", + 1111, x); + testcases[count++] = new TestCase( SECTION, "outer:y ", + 'outer', y); + function inner_func(x) + { + var y = "inner"; + testcases[count++] = new TestCase( SECTION, "inner:x ", + 2222, x); + testcases[count++] = new TestCase( SECTION, "inner:y ", + 'inner', y); + }; + + inner_func(2222); + testcases[count++] = new TestCase( SECTION, "outer:x ", + 1111, x); + testcases[count++] = new TestCase( SECTION, "outer:y ", + 'outer', y); + } + + outer_func(1111); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/function/regexparg-1.js b/tests/mozilla/js1_2/function/regexparg-1.js new file mode 100644 index 0000000..b01825c --- /dev/null +++ b/tests/mozilla/js1_2/function/regexparg-1.js @@ -0,0 +1,98 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: regexparg-1.js + Description: + + Regression test for + http://scopus/bugsplat/show_bug.cgi?id=122787 + Passing a regular expression as the first constructor argument fails + + Author: christine@netscape.com + Date: 15 June 1998 +*/ + + var SECTION = "JS_1.2"; + var VERSION = "JS_1.2"; + startTest(); + var TITLE = "The variable statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + function f(x) {return x;} + + x = f(/abc/); + + testcases[tc++] = new TestCase( SECTION, + "function f(x) {return x;}; f()", + void 0, + f() ); + + testcases[tc++] = new TestCase( SECTION, + "f(\"hi\")", + "hi", + f("hi") ); + + testcases[tc++] = new TestCase( SECTION, + "new f(/abc/) +''", + "/abc/", + new f(/abc/) +"" ); + + testcases[tc++] = new TestCase( SECTION, + "f(/abc/)+'')", + "/abc/", + f(/abc/) +''); + + testcases[tc++] = new TestCase( SECTION, + "typeof f(/abc/)", + "function", + typeof f(/abc/) ); + + testcases[tc++] = new TestCase( SECTION, + "typeof new f(/abc/)", + "function", + typeof new f(/abc/) ); + + testcases[tc++] = new TestCase( SECTION, + "x = new f(/abc/); x(\"hi\")", + null, + x("hi") ); + + + // js> x() + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_2/function/regexparg-2-n.js b/tests/mozilla/js1_2/function/regexparg-2-n.js new file mode 100644 index 0000000..e8bf951 --- /dev/null +++ b/tests/mozilla/js1_2/function/regexparg-2-n.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: regexparg-1.js + Description: + + Regression test for + http://scopus/bugsplat/show_bug.cgi?id=122787 + Passing a regular expression as the first constructor argument fails + + Author: christine@netscape.com + Date: 15 June 1998 +*/ + + var SECTION = "JS_1.2"; + var VERSION = "JS_1.2"; + startTest(); + var TITLE = "The variable statment"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + function f(x) {return x;} + + x = f(/abc/); + + testcases[tc++] = new TestCase( SECTION, + "function f(x) {return x;}; x = f(/abc/); x()", + "error", + x() ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_2/function/tostring-1.js b/tests/mozilla/js1_2/function/tostring-1.js new file mode 100644 index 0000000..d532d65 --- /dev/null +++ b/tests/mozilla/js1_2/function/tostring-1.js @@ -0,0 +1,143 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: tostring-1.js + Section: Function.toString + Description: + + Since the behavior of Function.toString() is implementation-dependent, + toString tests for function are not in the ECMA suite. + + Currently, an attempt to parse the toString output for some functions + and verify that the result is something reasonable. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "tostring-1"; + var VERSION = "JS1_2"; + startTest(); + var TITLE = "Function.toString()"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var tab = " "; + + t1 = new TestFunction( "stub", "value", tab + "return value;" ); + + t2 = new TestFunction( "ToString", "object", tab+"return object + \"\";" ); + + t3 = new TestFunction( "Add", "a, b, c, d, e", tab +"var s = a + b + c + d + e;\n" + + tab + "return s;" ); + + t4 = new TestFunction( "noop", "value" ); + + t5 = new TestFunction( "anonymous", "", tab+"return \"hello!\";" ); + + var f = new Function( "return \"hello!\""); + + testcases[tc++] = new TestCase( SECTION, + "stub.toString()", + t1.valueOf(), + stub.toString() ); + + testcases[tc++] = new TestCase( SECTION, + "ToString.toString()", + t2.valueOf(), + ToString.toString() ); + + testcases[tc++] = new TestCase( SECTION, + "Add.toString()", + t3.valueOf(), + Add.toString() ); + + testcases[tc++] = new TestCase( SECTION, + "noop.toString()", + t4.toString(), + noop.toString() ); + + testcases[tc++] = new TestCase( SECTION, + "f.toString()", + t5.toString(), + f.toString() ); + test(); + +function noop( value ) { +} +function Add( a, b, c, d, e ) { + var s = a + b + c + d + e; + return s; +} +function stub( value ) { + return value; +} +function ToString( object ) { + return object + ""; +} + +function ToBoolean( value ) { + if ( value == 0 || value == NaN || value == false ) { + return false; + } else { + return true; + } +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function TestFunction( name, args, body ) { + if ( name == "anonymous" && version() == 120 ) { + name = ""; + } + + this.name = name; + this.arguments = args.toString(); + this.body = body; + + /* the format of Function.toString() in JavaScript 1.2 is: + /n + function name ( arguments ) { + body + } + */ + this.value = "\nfunction " + (name ? name : "" )+ + "("+args+") {\n"+ (( body ) ? body +"\n" : "") + "}\n"; + + this.toString = new Function( "return this.value" ); + this.valueOf = new Function( "return this.value" ); + return this; +} diff --git a/tests/mozilla/js1_2/function/tostring-2.js b/tests/mozilla/js1_2/function/tostring-2.js new file mode 100644 index 0000000..146764d --- /dev/null +++ b/tests/mozilla/js1_2/function/tostring-2.js @@ -0,0 +1,185 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: tostring-1.js + Section: Function.toString + Description: + + Since the behavior of Function.toString() is implementation-dependent, + toString tests for function are not in the ECMA suite. + + Currently, an attempt to parse the toString output for some functions + and verify that the result is something reasonable. + + This verifies + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99212 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "tostring-2"; + var VERSION = "JS1_2"; + startTest(); + var TITLE = "Function.toString()"; + var BUGNUMBER="123444"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var tab = " "; + + +var equals = new TestFunction( "Equals", "a, b", tab+ "return a == b;" ); +function Equals (a, b) { + return a == b; +} + +var reallyequals = new TestFunction( "ReallyEquals", "a, b", + ( version() <= 120 ) ? tab +"return a == b;" : tab +"return a === b;" ); +function ReallyEquals( a, b ) { + return a === b; +} + +var doesntequal = new TestFunction( "DoesntEqual", "a, b", tab + "return a != b;" ); +function DoesntEqual( a, b ) { + return a != b; +} + +var reallydoesntequal = new TestFunction( "ReallyDoesntEqual", "a, b", + ( version() <= 120 ) ? tab +"return a != b;" : tab +"return a !== b;" ); +function ReallyDoesntEqual( a, b ) { + return a !== b; +} + +var testor = new TestFunction( "TestOr", "a", tab+"if (a == null || a == void 0) {\n"+ + tab +tab+"return 0;\n"+tab+"} else {\n"+tab+tab+"return a;\n"+tab+"}" ); +function TestOr( a ) { + if ( a == null || a == void 0 ) + return 0; + else + return a; +} + +var testand = new TestFunction( "TestAnd", "a", tab+"if (a != null && a != void 0) {\n"+ + tab+tab+"return a;\n" + tab+ "} else {\n"+tab+tab+"return 0;\n"+tab+"}" ); +function TestAnd( a ) { + if ( a != null && a != void 0 ) + return a; + else + return 0; +} + +var or = new TestFunction( "Or", "a, b", tab + "return a | b;" ); +function Or( a, b ) { + return a | b; +} + +var and = new TestFunction( "And", "a, b", tab + "return a & b;" ); +function And( a, b ) { + return a & b; +} + +var xor = new TestFunction( "XOr", "a, b", tab + "return a ^ b;" ); +function XOr( a, b ) { + return a ^ b; +} + + testcases[testcases.length] = new TestCase( SECTION, + "Equals.toString()", + equals.valueOf(), + Equals.toString() ); + + testcases[testcases.length] = new TestCase( SECTION, + "ReallyEquals.toString()", + reallyequals.valueOf(), + ReallyEquals.toString() ); + + testcases[testcases.length] = new TestCase( SECTION, + "DoesntEqual.toString()", + doesntequal.valueOf(), + DoesntEqual.toString() ); + + testcases[testcases.length] = new TestCase( SECTION, + "ReallyDoesntEqual.toString()", + reallydoesntequal.valueOf(), + ReallyDoesntEqual.toString() ); + + testcases[testcases.length] = new TestCase( SECTION, + "TestOr.toString()", + testor.valueOf(), + TestOr.toString() ); + + testcases[testcases.length] = new TestCase( SECTION, + "TestAnd.toString()", + testand.valueOf(), + TestAnd.toString() ); + + testcases[testcases.length] = new TestCase( SECTION, + "Or.toString()", + or.valueOf(), + Or.toString() ); + + testcases[testcases.length] = new TestCase( SECTION, + "And.toString()", + and.valueOf(), + And.toString() ); + + testcases[testcases.length] = new TestCase( SECTION, + "XOr.toString()", + xor.valueOf(), + XOr.toString() ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function TestFunction( name, args, body ) { + this.name = name; + this.arguments = args.toString(); + this.body = body; + + /* the format of Function.toString() in JavaScript 1.2 is: + /n + function name ( arguments ) { + body + } + */ + this.value = "\nfunction " + (name ? name : "anonymous" )+ + "("+args+") {\n"+ (( body ) ? body +"\n" : "") + "}\n"; + + this.toString = new Function( "return this.value" ); + this.valueOf = new Function( "return this.value" ); + return this; +} diff --git a/tests/mozilla/js1_2/jsref.js b/tests/mozilla/js1_2/jsref.js new file mode 100644 index 0000000..3ecb4c1 --- /dev/null +++ b/tests/mozilla/js1_2/jsref.js @@ -0,0 +1,215 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; +EXCLUDE = ""; + +/* + * constant strings + */ +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +var DEBUG = false; + +version("120"); +/* + * change this for date tests if you're not in PST + */ + +TZ_DIFF = -8; +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); +} +function startTest() { + version(120); + + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + // print out bugnumber + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; + +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +/* + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. + */ + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +/* end of print functions */ + + +function stopTest() { + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + } + print(doneTag); + gc(); +} + +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} +function Enumerate ( o ) { + var p; + for ( p in o ) { + print( p +": " + o[p] ); + } +} +function GetContext() { + return Packages.com.netscape.javascript.Context.getCurrentContext(); +} +function OptLevel( i ) { + i = Number(i); + var cx = GetContext(); + cx.setOptimizationLevel(i); +} diff --git a/tests/mozilla/js1_2/operator/equality.js b/tests/mozilla/js1_2/operator/equality.js new file mode 100644 index 0000000..855b5a8 --- /dev/null +++ b/tests/mozilla/js1_2/operator/equality.js @@ -0,0 +1,72 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: equality.js + Description: 'This tests the operator ==' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'operator "=="'; + + writeHeaderToLog('Executing script: equality.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + // the following two tests are incorrect + //testcases[count++] = new TestCase( SECTION, "(new String('') == new String('')) ", + // true, (new String('') == new String(''))); + + //testcases[count++] = new TestCase( SECTION, "(new Boolean(true) == new Boolean(true)) ", + // true, (new Boolean(true) == new Boolean(true))); + + testcases[count++] = new TestCase( SECTION, "(new String('x') == 'x') ", + false, (new String('x') == 'x')); + + testcases[count++] = new TestCase( SECTION, "('x' == new String('x')) ", + false, ('x' == new String('x'))); + + + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/operator/strictEquality.js b/tests/mozilla/js1_2/operator/strictEquality.js new file mode 100644 index 0000000..0f8acea --- /dev/null +++ b/tests/mozilla/js1_2/operator/strictEquality.js @@ -0,0 +1,92 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: strictEquality.js + Description: 'This tests the operator ===' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'operator "==="'; + + writeHeaderToLog('Executing script: strictEquality.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + testcases[count++] = new TestCase( SECTION, "('8' === 8) ", + false, ('8' === 8)); + + testcases[count++] = new TestCase( SECTION, "(8 === 8) ", + true, (8 === 8)); + + testcases[count++] = new TestCase( SECTION, "(8 === true) ", + false, (8 === true)); + + testcases[count++] = new TestCase( SECTION, "(new String('') === new String('')) ", + false, (new String('') === new String(''))); + + testcases[count++] = new TestCase( SECTION, "(new Boolean(true) === new Boolean(true))", + false, (new Boolean(true) === new Boolean(true))); + + var anObject = { one:1 , two:2 }; + + testcases[count++] = new TestCase( SECTION, "(anObject === anObject) ", + true, (anObject === anObject)); + + testcases[count++] = new TestCase( SECTION, "(anObject === { one:1 , two:2 }) ", + false, (anObject === { one:1 , two:2 })); + + testcases[count++] = new TestCase( SECTION, "({ one:1 , two:2 } === anObject) ", + false, ({ one:1 , two:2 } === anObject)); + + testcases[count++] = new TestCase( SECTION, "(null === null) ", + true, (null === null)); + + testcases[count++] = new TestCase( SECTION, "(null === 0) ", + false, (null === 0)); + + testcases[count++] = new TestCase( SECTION, "(true === !false) ", + true, (true === !false)); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/regexp/RegExp_dollar_number.js b/tests/mozilla/js1_2/regexp/RegExp_dollar_number.js new file mode 100644 index 0000000..58f9264 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_dollar_number.js @@ -0,0 +1,108 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_dollar_number.js + Description: 'Tests RegExps $1, ..., $9 properties' + + Author: Nick Lerissa + Date: March 12, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: $1, ..., $9'; + var BUGNUMBER="123802"; + + writeHeaderToLog('Executing script: RegExp_dollar_number.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$1 + 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$1", + 'abcdefghi', RegExp.$1); + + // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$2 + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$2", + 'bcdefgh', RegExp.$2); + + // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$3 + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$3", + 'cdefg', RegExp.$3); + + // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$4 + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$4", + 'def', RegExp.$4); + + // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$5 + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$5", + 'e', RegExp.$5); + + // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$6 + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$6", + '', RegExp.$6); + + var a_to_z = 'abcdefghijklmnopqrstuvwxyz'; + var regexp1 = /(a)b(c)d(e)f(g)h(i)j(k)l(m)n(o)p(q)r(s)t(u)v(w)x(y)z/ + // 'abcdefghijklmnopqrstuvwxyz'.match(/(a)b(c)d(e)f(g)h(i)j(k)l(m)n(o)p(q)r(s)t(u)v(w)x(y)z/); RegExp.$1 + a_to_z.match(regexp1); + + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$1", + 'a', RegExp.$1); + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$2", + 'c', RegExp.$2); + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$3", + 'e', RegExp.$3); + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$4", + 'g', RegExp.$4); + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$5", + 'i', RegExp.$5); + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$6", + 'k', RegExp.$6); + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$7", + 'm', RegExp.$7); + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$8", + 'o', RegExp.$8); + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$9", + 'q', RegExp.$9); +/* + testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$10", + 's', RegExp.$10); +*/ + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_input.js b/tests/mozilla/js1_2/regexp/RegExp_input.js new file mode 100644 index 0000000..01c145c --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_input.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_input.js + Description: 'Tests RegExps input property' + + Author: Nick Lerissa + Date: March 13, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: input'; + + writeHeaderToLog('Executing script: RegExp_input.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + RegExp.input = "abcd12357efg"; + + // RegExp.input = "abcd12357efg"; RegExp.input + RegExp.input = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; RegExp.input", + "abcd12357efg", RegExp.input); + + // RegExp.input = "abcd12357efg"; /\d+/.exec('2345') + RegExp.input = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.exec('2345')", + String(["2345"]), String(/\d+/.exec('2345'))); + + // RegExp.input = "abcd12357efg"; /\d+/.exec() + RegExp.input = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.exec()", + String(["12357"]), String(/\d+/.exec())); + + // RegExp.input = "abcd12357efg"; /[h-z]+/.exec() + RegExp.input = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /[h-z]+/.exec()", + null, /[h-z]+/.exec()); + + // RegExp.input = "abcd12357efg"; /\d+/.test('2345') + RegExp.input = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.test('2345')", + true, /\d+/.test('2345')); + + // RegExp.input = "abcd12357efg"; /\d+/.test() + RegExp.input = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.test()", + true, /\d+/.test()); + + // RegExp.input = "abcd12357efg"; (new RegExp('d+')).test() + RegExp.input = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; (new RegExp('d+')).test()", + true, (new RegExp('d+')).test()); + + // RegExp.input = "abcd12357efg"; /[h-z]+/.test() + RegExp.input = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /[h-z]+/.test()", + false, /[h-z]+/.test()); + + // RegExp.input = "abcd12357efg"; (new RegExp('[h-z]+')).test() + RegExp.input = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; (new RegExp('[h-z]+')).test()", + false, (new RegExp('[h-z]+')).test()); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_input_as_array.js b/tests/mozilla/js1_2/regexp/RegExp_input_as_array.js new file mode 100644 index 0000000..a1ed113 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_input_as_array.js @@ -0,0 +1,102 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_input_as_array.js + Description: 'Tests RegExps $_ property (same tests as RegExp_input.js but using $_)' + + Author: Nick Lerissa + Date: March 13, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: input'; + + writeHeaderToLog('Executing script: RegExp_input.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + RegExp['$_'] = "abcd12357efg"; + + // RegExp['$_'] = "abcd12357efg"; RegExp['$_'] + RegExp['$_'] = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; RegExp['$_']", + "abcd12357efg", RegExp['$_']); + + // RegExp['$_'] = "abcd12357efg"; /\d+/.exec('2345') + RegExp['$_'] = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.exec('2345')", + String(["2345"]), String(/\d+/.exec('2345'))); + + // RegExp['$_'] = "abcd12357efg"; /\d+/.exec() + RegExp['$_'] = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.exec()", + String(["12357"]), String(/\d+/.exec())); + + // RegExp['$_'] = "abcd12357efg"; /[h-z]+/.exec() + RegExp['$_'] = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /[h-z]+/.exec()", + null, /[h-z]+/.exec()); + + // RegExp['$_'] = "abcd12357efg"; /\d+/.test('2345') + RegExp['$_'] = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.test('2345')", + true, /\d+/.test('2345')); + + // RegExp['$_'] = "abcd12357efg"; /\d+/.test() + RegExp['$_'] = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.test()", + true, /\d+/.test()); + + // RegExp['$_'] = "abcd12357efg"; /[h-z]+/.test() + RegExp['$_'] = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /[h-z]+/.test()", + false, /[h-z]+/.test()); + + // RegExp['$_'] = "abcd12357efg"; (new RegExp('\d+')).test() + RegExp['$_'] = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; (new RegExp('\d+')).test()", + true, (new RegExp('\d+')).test()); + + // RegExp['$_'] = "abcd12357efg"; (new RegExp('[h-z]+')).test() + RegExp['$_'] = "abcd12357efg"; + testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; (new RegExp('[h-z]+')).test()", + false, (new RegExp('[h-z]+')).test()); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_lastIndex.js b/tests/mozilla/js1_2/regexp/RegExp_lastIndex.js new file mode 100644 index 0000000..b48836f --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_lastIndex.js @@ -0,0 +1,83 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_lastIndex.js + Description: 'Tests RegExps lastIndex property' + + Author: Nick Lerissa + Date: March 17, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: lastIndex'; + var BUGNUMBER="123802"; + + writeHeaderToLog('Executing script: RegExp_lastIndex.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // re=/x./g; re.lastIndex=4; re.exec('xyabcdxa'); + re=/x./g; + re.lastIndex=4; + testcases[count++] = new TestCase ( SECTION, "re=/x./g; re.lastIndex=4; re.exec('xyabcdxa')", + '["xa"]', String(re.exec('xyabcdxa'))); + + // re.lastIndex + testcases[count++] = new TestCase ( SECTION, "re.lastIndex", + 8, re.lastIndex); + + // re.exec('xyabcdef'); + testcases[count++] = new TestCase ( SECTION, "re.exec('xyabcdef')", + null, re.exec('xyabcdef')); + + // re.lastIndex + testcases[count++] = new TestCase ( SECTION, "re.lastIndex", + 0, re.lastIndex); + + // re.exec('xyabcdef'); + testcases[count++] = new TestCase ( SECTION, "re.exec('xyabcdef')", + '["xy"]', String(re.exec('xyabcdef'))); + + // re.lastIndex=30; re.exec('123xaxbxc456'); + re.lastIndex=30; + testcases[count++] = new TestCase ( SECTION, "re.lastIndex=30; re.exec('123xaxbxc456')", + null, re.exec('123xaxbxc456')); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_lastMatch.js b/tests/mozilla/js1_2/regexp/RegExp_lastMatch.js new file mode 100644 index 0000000..2b0c72d --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_lastMatch.js @@ -0,0 +1,85 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_lastMatch.js + Description: 'Tests RegExps lastMatch property' + + Author: Nick Lerissa + Date: March 12, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: lastMatch'; + + writeHeaderToLog('Executing script: RegExp_lastMatch.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'foo'.match(/foo/); RegExp.lastMatch + 'foo'.match(/foo/); + testcases[count++] = new TestCase ( SECTION, "'foo'.match(/foo/); RegExp.lastMatch", + 'foo', RegExp.lastMatch); + + // 'foo'.match(new RegExp('foo')); RegExp.lastMatch + 'foo'.match(new RegExp('foo')); + testcases[count++] = new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp.lastMatch", + 'foo', RegExp.lastMatch); + + // 'xxx'.match(/bar/); RegExp.lastMatch + 'xxx'.match(/bar/); + testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp.lastMatch", + 'foo', RegExp.lastMatch); + + // 'xxx'.match(/$/); RegExp.lastMatch + 'xxx'.match(/$/); + testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/$/); RegExp.lastMatch", + '', RegExp.lastMatch); + + // 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch + 'abcdefg'.match(/^..(cd)[a-z]+/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch", + 'abcdefg', RegExp.lastMatch); + + // 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp.lastMatch + 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); + testcases[count++] = new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp.lastMatch", + 'abcdefgabcdefg', RegExp.lastMatch); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_lastMatch_as_array.js b/tests/mozilla/js1_2/regexp/RegExp_lastMatch_as_array.js new file mode 100644 index 0000000..b59b2c2 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_lastMatch_as_array.js @@ -0,0 +1,85 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_lastMatch_as_array.js + Description: 'Tests RegExps $& property (same tests as RegExp_lastMatch.js but using $&)' + + Author: Nick Lerissa + Date: March 13, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: $&'; + + writeHeaderToLog('Executing script: RegExp_lastMatch_as_array.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'foo'.match(/foo/); RegExp['$&'] + 'foo'.match(/foo/); + testcases[count++] = new TestCase ( SECTION, "'foo'.match(/foo/); RegExp['$&']", + 'foo', RegExp['$&']); + + // 'foo'.match(new RegExp('foo')); RegExp['$&'] + 'foo'.match(new RegExp('foo')); + testcases[count++] = new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp['$&']", + 'foo', RegExp['$&']); + + // 'xxx'.match(/bar/); RegExp['$&'] + 'xxx'.match(/bar/); + testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp['$&']", + 'foo', RegExp['$&']); + + // 'xxx'.match(/$/); RegExp['$&'] + 'xxx'.match(/$/); + testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/$/); RegExp['$&']", + '', RegExp['$&']); + + // 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&'] + 'abcdefg'.match(/^..(cd)[a-z]+/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']", + 'abcdefg', RegExp['$&']); + + // 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp['$&'] + 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); + testcases[count++] = new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp['$&']", + 'abcdefgabcdefg', RegExp['$&']); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_lastParen.js b/tests/mozilla/js1_2/regexp/RegExp_lastParen.js new file mode 100644 index 0000000..1dd0791 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_lastParen.js @@ -0,0 +1,100 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_lastParen.js + Description: 'Tests RegExps lastParen property' + + Author: Nick Lerissa + Date: March 12, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: lastParen'; + + writeHeaderToLog('Executing script: RegExp_lastParen.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcd'.match(/(abc)d/); RegExp.lastParen + 'abcd'.match(/(abc)d/); + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(abc)d/); RegExp.lastParen", + 'abc', RegExp.lastParen); + + // 'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen + 'abcd'.match(new RegExp('(abc)d')); + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen", + 'abc', RegExp.lastParen); + + // 'abcd'.match(/(bcd)e/); RegExp.lastParen + 'abcd'.match(/(bcd)e/); + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(bcd)e/); RegExp.lastParen", + 'abc', RegExp.lastParen); + + // 'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen + 'abcdefg'.match(/(a(b(c(d)e)f)g)/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen", + 'd', RegExp.lastParen); + + // 'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen + 'abcdefg'.match(/(a(b)c)(d(e)f)/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen", + 'e', RegExp.lastParen); + + // 'abcdefg'.match(/(^)abc/); RegExp.lastParen + 'abcdefg'.match(/(^)abc/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^)abc/); RegExp.lastParen", + '', RegExp.lastParen); + + // 'abcdefg'.match(/(^a)bc/); RegExp.lastParen + 'abcdefg'.match(/(^a)bc/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^a)bc/); RegExp.lastParen", + 'a', RegExp.lastParen); + + // 'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen + 'abcdefg'.match(new RegExp('(^a)bc')); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen", + 'a', RegExp.lastParen); + + // 'abcdefg'.match(/bc/); RegExp.lastParen + 'abcdefg'.match(/bc/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/bc/); RegExp.lastParen", + '', RegExp.lastParen); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_lastParen_as_array.js b/tests/mozilla/js1_2/regexp/RegExp_lastParen_as_array.js new file mode 100644 index 0000000..d8dcd52 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_lastParen_as_array.js @@ -0,0 +1,100 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_lastParen_as_array.js + Description: 'Tests RegExps $+ property (same tests as RegExp_lastParen.js but using $+)' + + Author: Nick Lerissa + Date: March 13, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: $+'; + + writeHeaderToLog('Executing script: RegExp_lastParen_as_array.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcd'.match(/(abc)d/); RegExp['$+'] + 'abcd'.match(/(abc)d/); + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(abc)d/); RegExp['$+']", + 'abc', RegExp['$+']); + + // 'abcd'.match(/(bcd)e/); RegExp['$+'] + 'abcd'.match(/(bcd)e/); + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(bcd)e/); RegExp['$+']", + 'abc', RegExp['$+']); + + // 'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp['$+'] + 'abcdefg'.match(/(a(b(c(d)e)f)g)/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp['$+']", + 'd', RegExp['$+']); + + // 'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); RegExp['$+'] + 'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); RegExp['$+']", + 'd', RegExp['$+']); + + // 'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp['$+'] + 'abcdefg'.match(/(a(b)c)(d(e)f)/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp['$+']", + 'e', RegExp['$+']); + + // 'abcdefg'.match(/(^)abc/); RegExp['$+'] + 'abcdefg'.match(/(^)abc/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^)abc/); RegExp['$+']", + '', RegExp['$+']); + + // 'abcdefg'.match(/(^a)bc/); RegExp['$+'] + 'abcdefg'.match(/(^a)bc/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^a)bc/); RegExp['$+']", + 'a', RegExp['$+']); + + // 'abcdefg'.match(new RegExp('(^a)bc')); RegExp['$+'] + 'abcdefg'.match(new RegExp('(^a)bc')); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(^a)bc')); RegExp['$+']", + 'a', RegExp['$+']); + + // 'abcdefg'.match(/bc/); RegExp['$+'] + 'abcdefg'.match(/bc/); + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/bc/); RegExp['$+']", + '', RegExp['$+']); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_leftContext.js b/tests/mozilla/js1_2/regexp/RegExp_leftContext.js new file mode 100644 index 0000000..025915a --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_leftContext.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_leftContext.js + Description: 'Tests RegExps leftContext property' + + Author: Nick Lerissa + Date: March 12, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: leftContext'; + + writeHeaderToLog('Executing script: RegExp_leftContext.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abc123xyz'.match(/123/); RegExp.leftContext + 'abc123xyz'.match(/123/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp.leftContext", + 'abc', RegExp.leftContext); + + // 'abc123xyz'.match(/456/); RegExp.leftContext + 'abc123xyz'.match(/456/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp.leftContext", + 'abc', RegExp.leftContext); + + // 'abc123xyz'.match(/abc123xyz/); RegExp.leftContext + 'abc123xyz'.match(/abc123xyz/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp.leftContext", + '', RegExp.leftContext); + + // 'xxxx'.match(/$/); RegExp.leftContext + 'xxxx'.match(/$/); + testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp.leftContext", + 'xxxx', RegExp.leftContext); + + // 'test'.match(/^/); RegExp.leftContext + 'test'.match(/^/); + testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp.leftContext", + '', RegExp.leftContext); + + // 'xxxx'.match(new RegExp('$')); RegExp.leftContext + 'xxxx'.match(new RegExp('$')); + testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp.leftContext", + 'xxxx', RegExp.leftContext); + + // 'test'.match(new RegExp('^')); RegExp.leftContext + 'test'.match(new RegExp('^')); + testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp.leftContext", + '', RegExp.leftContext); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_leftContext_as_array.js b/tests/mozilla/js1_2/regexp/RegExp_leftContext_as_array.js new file mode 100644 index 0000000..5a86b4f --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_leftContext_as_array.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_leftContext_as_array.js + Description: 'Tests RegExps leftContext property (same tests as RegExp_leftContext.js but using $`)' + + Author: Nick Lerissa + Date: March 12, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: $`'; + + writeHeaderToLog('Executing script: RegExp_leftContext_as_array.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abc123xyz'.match(/123/); RegExp['$`'] + 'abc123xyz'.match(/123/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp['$`']", + 'abc', RegExp['$`']); + + // 'abc123xyz'.match(/456/); RegExp['$`'] + 'abc123xyz'.match(/456/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp['$`']", + 'abc', RegExp['$`']); + + // 'abc123xyz'.match(/abc123xyz/); RegExp['$`'] + 'abc123xyz'.match(/abc123xyz/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp['$`']", + '', RegExp['$`']); + + // 'xxxx'.match(/$/); RegExp['$`'] + 'xxxx'.match(/$/); + testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp['$`']", + 'xxxx', RegExp['$`']); + + // 'test'.match(/^/); RegExp['$`'] + 'test'.match(/^/); + testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp['$`']", + '', RegExp['$`']); + + // 'xxxx'.match(new RegExp('$')); RegExp['$`'] + 'xxxx'.match(new RegExp('$')); + testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp['$`']", + 'xxxx', RegExp['$`']); + + // 'test'.match(new RegExp('^')); RegExp['$`'] + 'test'.match(new RegExp('^')); + testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp['$`']", + '', RegExp['$`']); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_multiline.js b/tests/mozilla/js1_2/regexp/RegExp_multiline.js new file mode 100644 index 0000000..be22261 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_multiline.js @@ -0,0 +1,129 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_multiline.js + Description: 'Tests RegExps multiline property' + + Author: Nick Lerissa + Date: March 12, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: multiline'; + + writeHeaderToLog('Executing script: RegExp_multiline.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // First we do a series of tests with RegExp.multiline set to false (default value) + // Following this we do the same tests with RegExp.multiline set true(**). + // RegExp.multiline + testcases[count++] = new TestCase ( SECTION, "RegExp.multiline", + false, RegExp.multiline); + + // (multiline == false) '123\n456'.match(/^4../) + testcases[count++] = new TestCase ( SECTION, "(multiline == false) '123\\n456'.match(/^4../)", + null, '123\n456'.match(/^4../)); + + // (multiline == false) 'a11\na22\na23\na24'.match(/^a../g) + testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(/^a../g)", + String(['a11']), String('a11\na22\na23\na24'.match(/^a../g))); + + // (multiline == false) 'a11\na22'.match(/^.+^./) + testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\na22'.match(/^.+^./)", + null, 'a11\na22'.match(/^.+^./)); + + // (multiline == false) '123\n456'.match(/.3$/) + testcases[count++] = new TestCase ( SECTION, "(multiline == false) '123\\n456'.match(/.3$/)", + null, '123\n456'.match(/.3$/)); + + // (multiline == false) 'a11\na22\na23\na24'.match(/a..$/g) + testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)", + String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g))); + + // (multiline == false) 'abc\ndef'.match(/c$...$/) + testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'abc\ndef'.match(/c$...$/)", + null, 'abc\ndef'.match(/c$...$/)); + + // (multiline == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) + testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", + String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); + + // (multiline == false) 'abc\ndef'.match(new RegExp('c$...$')) + testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'abc\ndef'.match(new RegExp('c$...$'))", + null, 'abc\ndef'.match(new RegExp('c$...$'))); + + // **Now we do the tests with RegExp.multiline set to true + // RegExp.multiline = true; RegExp.multiline + RegExp.multiline = true; + testcases[count++] = new TestCase ( SECTION, "RegExp.multiline = true; RegExp.multiline", + true, RegExp.multiline); + + // (multiline == true) '123\n456'.match(/^4../) + testcases[count++] = new TestCase ( SECTION, "(multiline == true) '123\\n456'.match(/^4../)", + String(['456']), String('123\n456'.match(/^4../))); + + // (multiline == true) 'a11\na22\na23\na24'.match(/^a../g) + testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(/^a../g)", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g))); + + // (multiline == true) 'a11\na22'.match(/^.+^./) + //testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\na22'.match(/^.+^./)", + // String(['a11\na']), String('a11\na22'.match(/^.+^./))); + + // (multiline == true) '123\n456'.match(/.3$/) + testcases[count++] = new TestCase ( SECTION, "(multiline == true) '123\\n456'.match(/.3$/)", + String(['23']), String('123\n456'.match(/.3$/))); + + // (multiline == true) 'a11\na22\na23\na24'.match(/a..$/g) + testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g))); + + // (multiline == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) + testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); + + // (multiline == true) 'abc\ndef'.match(/c$....$/) + //testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'abc\ndef'.match(/c$.+$/)", + // 'c\ndef', String('abc\ndef'.match(/c$.+$/))); + + RegExp.multiline = false; + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_multiline_as_array.js b/tests/mozilla/js1_2/regexp/RegExp_multiline_as_array.js new file mode 100644 index 0000000..690653f --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_multiline_as_array.js @@ -0,0 +1,129 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_multiline_as_array.js + Description: 'Tests RegExps $* property (same tests as RegExp_multiline.js but using $*)' + + Author: Nick Lerissa + Date: March 13, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: $*'; + + writeHeaderToLog('Executing script: RegExp_multiline_as_array.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // First we do a series of tests with RegExp['$*'] set to false (default value) + // Following this we do the same tests with RegExp['$*'] set true(**). + // RegExp['$*'] + testcases[count++] = new TestCase ( SECTION, "RegExp['$*']", + false, RegExp['$*']); + + // (['$*'] == false) '123\n456'.match(/^4../) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/^4../)", + null, '123\n456'.match(/^4../)); + + // (['$*'] == false) 'a11\na22\na23\na24'.match(/^a../g) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/^a../g)", + String(['a11']), String('a11\na22\na23\na24'.match(/^a../g))); + + // (['$*'] == false) 'a11\na22'.match(/^.+^./) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\na22'.match(/^.+^./)", + null, 'a11\na22'.match(/^.+^./)); + + // (['$*'] == false) '123\n456'.match(/.3$/) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/.3$/)", + null, '123\n456'.match(/.3$/)); + + // (['$*'] == false) 'a11\na22\na23\na24'.match(/a..$/g) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)", + String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g))); + + // (['$*'] == false) 'abc\ndef'.match(/c$...$/) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(/c$...$/)", + null, 'abc\ndef'.match(/c$...$/)); + + // (['$*'] == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", + String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); + + // (['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$')) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$'))", + null, 'abc\ndef'.match(new RegExp('c$...$'))); + + // **Now we do the tests with RegExp['$*'] set to true + // RegExp['$*'] = true; RegExp['$*'] + RegExp['$*'] = true; + testcases[count++] = new TestCase ( SECTION, "RegExp['$*'] = true; RegExp['$*']", + true, RegExp['$*']); + + // (['$*'] == true) '123\n456'.match(/^4../) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/^4../)", + String(['456']), String('123\n456'.match(/^4../))); + + // (['$*'] == true) 'a11\na22\na23\na24'.match(/^a../g) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/^a../g)", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g))); + + // (['$*'] == true) 'a11\na22'.match(/^.+^./) + //testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\na22'.match(/^.+^./)", + // String(['a11\na']), String('a11\na22'.match(/^.+^./))); + + // (['$*'] == true) '123\n456'.match(/.3$/) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/.3$/)", + String(['23']), String('123\n456'.match(/.3$/))); + + // (['$*'] == true) 'a11\na22\na23\na24'.match(/a..$/g) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g))); + + // (['$*'] == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) + testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); + + // (['$*'] == true) 'abc\ndef'.match(/c$....$/) + //testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'abc\ndef'.match(/c$.+$/)", + // 'c\ndef', String('abc\ndef'.match(/c$.+$/))); + + RegExp['$*'] = false; + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_object.js b/tests/mozilla/js1_2/regexp/RegExp_object.js new file mode 100644 index 0000000..6bf2353 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_object.js @@ -0,0 +1,88 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_object.js + Description: 'Tests regular expressions creating RexExp Objects' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: object'; + + writeHeaderToLog('Executing script: RegExp_object.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + var SSN_pattern = new RegExp("\\d{3}-\\d{2}-\\d{4}"); + + // testing SSN pattern + testcases[count++] = new TestCase ( SECTION, "'Test SSN is 123-34-4567'.match(SSN_pattern))", + String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern))); + + // testing SSN pattern + testcases[count++] = new TestCase ( SECTION, "'Test SSN is 123-34-4567'.match(SSN_pattern))", + String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern))); + + var PHONE_pattern = new RegExp("\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})"); + // testing PHONE pattern + testcases[count++] = new TestCase ( SECTION, "'Our phone number is (408)345-2345.'.match(PHONE_pattern))", + String(["(408)345-2345","408","345","2345"]), String('Our phone number is (408)345-2345.'.match(PHONE_pattern))); + + // testing PHONE pattern + testcases[count++] = new TestCase ( SECTION, "'The phone number is 408-345-2345!'.match(PHONE_pattern))", + String(["408-345-2345","408","345","2345"]), String('The phone number is 408-345-2345!'.match(PHONE_pattern))); + + // testing PHONE pattern + testcases[count++] = new TestCase ( SECTION, "String(PHONE_pattern.toString())", + "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/", String(PHONE_pattern.toString())); + + // testing conversion to String + testcases[count++] = new TestCase ( SECTION, "PHONE_pattern + ' is the string'", + "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/ is the string",PHONE_pattern + ' is the string'); + + // testing conversion to int + testcases[count++] = new TestCase ( SECTION, "SSN_pattern - 8", + NaN,SSN_pattern - 8); + + var testPattern = new RegExp("(\\d+)45(\\d+)90"); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_rightContext.js b/tests/mozilla/js1_2/regexp/RegExp_rightContext.js new file mode 100644 index 0000000..ede5e21 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_rightContext.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_rightContext.js + Description: 'Tests RegExps rightContext property' + + Author: Nick Lerissa + Date: March 12, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: rightContext'; + + writeHeaderToLog('Executing script: RegExp_rightContext.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abc123xyz'.match(/123/); RegExp.rightContext + 'abc123xyz'.match(/123/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp.rightContext", + 'xyz', RegExp.rightContext); + + // 'abc123xyz'.match(/456/); RegExp.rightContext + 'abc123xyz'.match(/456/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp.rightContext", + 'xyz', RegExp.rightContext); + + // 'abc123xyz'.match(/abc123xyz/); RegExp.rightContext + 'abc123xyz'.match(/abc123xyz/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp.rightContext", + '', RegExp.rightContext); + + // 'xxxx'.match(/$/); RegExp.rightContext + 'xxxx'.match(/$/); + testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp.rightContext", + '', RegExp.rightContext); + + // 'test'.match(/^/); RegExp.rightContext + 'test'.match(/^/); + testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp.rightContext", + 'test', RegExp.rightContext); + + // 'xxxx'.match(new RegExp('$')); RegExp.rightContext + 'xxxx'.match(new RegExp('$')); + testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp.rightContext", + '', RegExp.rightContext); + + // 'test'.match(new RegExp('^')); RegExp.rightContext + 'test'.match(new RegExp('^')); + testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp.rightContext", + 'test', RegExp.rightContext); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/RegExp_rightContext_as_array.js b/tests/mozilla/js1_2/regexp/RegExp_rightContext_as_array.js new file mode 100644 index 0000000..e182774 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/RegExp_rightContext_as_array.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: RegExp_rightContext_as_array.js + Description: 'Tests RegExps $\' property (same tests as RegExp_rightContext.js but using $\)' + + Author: Nick Lerissa + Date: March 12, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: $\''; + + writeHeaderToLog('Executing script: RegExp_rightContext.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abc123xyz'.match(/123/); RegExp['$\''] + 'abc123xyz'.match(/123/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp['$\'']", + 'xyz', RegExp['$\'']); + + // 'abc123xyz'.match(/456/); RegExp['$\''] + 'abc123xyz'.match(/456/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp['$\'']", + 'xyz', RegExp['$\'']); + + // 'abc123xyz'.match(/abc123xyz/); RegExp['$\''] + 'abc123xyz'.match(/abc123xyz/); + testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp['$\'']", + '', RegExp['$\'']); + + // 'xxxx'.match(/$/); RegExp['$\''] + 'xxxx'.match(/$/); + testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp['$\'']", + '', RegExp['$\'']); + + // 'test'.match(/^/); RegExp['$\''] + 'test'.match(/^/); + testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp['$\'']", + 'test', RegExp['$\'']); + + // 'xxxx'.match(new RegExp('$')); RegExp['$\''] + 'xxxx'.match(new RegExp('$')); + testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp['$\'']", + '', RegExp['$\'']); + + // 'test'.match(new RegExp('^')); RegExp['$\''] + 'test'.match(new RegExp('^')); + testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp['$\'']", + 'test', RegExp['$\'']); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/alphanumeric.js b/tests/mozilla/js1_2/regexp/alphanumeric.js new file mode 100644 index 0000000..36f5280 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/alphanumeric.js @@ -0,0 +1,129 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: alphanumeric.js + Description: 'Tests regular expressions with \w and \W special characters' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: \\w and \\W'; + + writeHeaderToLog('Executing script: alphanumeric.js'); + writeHeaderToLog( SECTION + " " + TITLE); + + var count = 0; + var testcases = new Array(); + + var non_alphanumeric = "~`!@#$%^&*()-+={[}]|\\:;'<,>./?\f\n\r\t\v " + '"'; + var alphanumeric = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + + // be sure all alphanumerics are matched by \w + testcases[count++] = new TestCase ( SECTION, + "'" + alphanumeric + "'.match(new RegExp('\\w+'))", + String([alphanumeric]), String(alphanumeric.match(new RegExp('\\w+')))); + + // be sure all non-alphanumerics are matched by \W + testcases[count++] = new TestCase ( SECTION, + "'" + non_alphanumeric + "'.match(new RegExp('\\W+'))", + String([non_alphanumeric]), String(non_alphanumeric.match(new RegExp('\\W+')))); + + // be sure all non-alphanumerics are not matched by \w + testcases[count++] = new TestCase ( SECTION, + "'" + non_alphanumeric + "'.match(new RegExp('\\w'))", + null, non_alphanumeric.match(new RegExp('\\w'))); + + // be sure all alphanumerics are not matched by \W + testcases[count++] = new TestCase ( SECTION, + "'" + alphanumeric + "'.match(new RegExp('\\W'))", + null, alphanumeric.match(new RegExp('\\W'))); + + var s = non_alphanumeric + alphanumeric; + + // be sure all alphanumerics are matched by \w + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\w+'))", + String([alphanumeric]), String(s.match(new RegExp('\\w+')))); + + s = alphanumeric + non_alphanumeric; + + // be sure all non-alphanumerics are matched by \W + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\W+'))", + String([non_alphanumeric]), String(s.match(new RegExp('\\W+')))); + + // be sure all alphanumerics are matched by \w (using literals) + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(/\w+/)", + String([alphanumeric]), String(s.match(/\w+/))); + + s = alphanumeric + non_alphanumeric; + + // be sure all non-alphanumerics are matched by \W (using literals) + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(/\W+/)", + String([non_alphanumeric]), String(s.match(/\W+/))); + + s = 'abcd*&^%$$'; + // be sure the following test behaves consistently + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(/(\w+)...(\W+)/)", + String([s , 'abcd' , '%$$']), String(s.match(/(\w+)...(\W+)/))); + + var i; + + // be sure all alphanumeric characters match individually + for (i = 0; i < alphanumeric.length; ++i) + { + s = '#$' + alphanumeric[i] + '%^'; + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\w'))", + String([alphanumeric[i]]), String(s.match(new RegExp('\\w')))); + } + // be sure all non_alphanumeric characters match individually + for (i = 0; i < non_alphanumeric.length; ++i) + { + s = 'sd' + non_alphanumeric[i] + String((i+10) * (i+10) - 2 * (i+10)); + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\W'))", + String([non_alphanumeric[i]]), String(s.match(new RegExp('\\W')))); + } + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/asterisk.js b/tests/mozilla/js1_2/regexp/asterisk.js new file mode 100644 index 0000000..dfa8343 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/asterisk.js @@ -0,0 +1,105 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: asterisk.js + Description: 'Tests regular expressions containing *' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: *'; + + writeHeaderToLog('Executing script: aterisk.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcddddefg'.match(new RegExp('d*')) + testcases[count++] = new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('d*'))", + String([""]), String('abcddddefg'.match(new RegExp('d*')))); + + // 'abcddddefg'.match(new RegExp('cd*')) + testcases[count++] = new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('cd*'))", + String(["cdddd"]), String('abcddddefg'.match(new RegExp('cd*')))); + + // 'abcdefg'.match(new RegExp('cx*d')) + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('cx*d'))", + String(["cd"]), String('abcdefg'.match(new RegExp('cx*d')))); + + // 'xxxxxxx'.match(new RegExp('(x*)(x+)')) + testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x*)(x+)'))", + String(["xxxxxxx","xxxxxx","x"]), String('xxxxxxx'.match(new RegExp('(x*)(x+)')))); + + // '1234567890'.match(new RegExp('(\\d*)(\\d+)')) + testcases[count++] = new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)(\\d+)'))", + String(["1234567890","123456789","0"]), + String('1234567890'.match(new RegExp('(\\d*)(\\d+)')))); + + // '1234567890'.match(new RegExp('(\\d*)\\d(\\d+)')) + testcases[count++] = new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))", + String(["1234567890","12345678","0"]), + String('1234567890'.match(new RegExp('(\\d*)\\d(\\d+)')))); + + // 'xxxxxxx'.match(new RegExp('(x+)(x*)')) + testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x+)(x*)'))", + String(["xxxxxxx","xxxxxxx",""]), String('xxxxxxx'.match(new RegExp('(x+)(x*)')))); + + // 'xxxxxxyyyyyy'.match(new RegExp('x*y+$')) + testcases[count++] = new TestCase ( SECTION, "'xxxxxxyyyyyy'.match(new RegExp('x*y+$'))", + String(["xxxxxxyyyyyy"]), String('xxxxxxyyyyyy'.match(new RegExp('x*y+$')))); + + // 'abcdef'.match(/[\d]*[\s]*bc./) + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/[\\d]*[\\s]*bc./)", + String(["bcd"]), String('abcdef'.match(/[\d]*[\s]*bc./))); + + // 'abcdef'.match(/bc..[\d]*[\s]*/) + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/bc..[\\d]*[\\s]*/)", + String(["bcde"]), String('abcdef'.match(/bc..[\d]*[\s]*/))); + + // 'a1b2c3'.match(/.*/) + testcases[count++] = new TestCase ( SECTION, "'a1b2c3'.match(/.*/)", + String(["a1b2c3"]), String('a1b2c3'.match(/.*/))); + + // 'a0.b2.c3'.match(/[xyz]*1/) + testcases[count++] = new TestCase ( SECTION, "'a0.b2.c3'.match(/[xyz]*1/)", + null, 'a0.b2.c3'.match(/[xyz]*1/)); + +function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/backslash.js b/tests/mozilla/js1_2/regexp/backslash.js new file mode 100644 index 0000000..61c5d61 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/backslash.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: backslash.js + Description: 'Tests regular expressions containing \' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: \\'; + + writeHeaderToLog('Executing script: backslash.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcde'.match(new RegExp('\e')) + testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('\e'))", + String(["e"]), String('abcde'.match(new RegExp('\e')))); + + // 'ab\\cde'.match(new RegExp('\\\\')) + testcases[count++] = new TestCase ( SECTION, "'ab\\cde'.match(new RegExp('\\\\'))", + String(["\\"]), String('ab\\cde'.match(new RegExp('\\\\')))); + + // 'ab\\cde'.match(/\\/) (using literal) + testcases[count++] = new TestCase ( SECTION, "'ab\\cde'.match(/\\\\/)", + String(["\\"]), String('ab\\cde'.match(/\\/))); + + // 'before ^$*+?.()|{}[] after'.match(new RegExp('\^\$\*\+\?\.\(\)\|\{\}\[\]')) + testcases[count++] = new TestCase ( SECTION, + "'before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]'))", + String(["^$*+?.()|{}[]"]), + String('before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]')))); + + // 'before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/) (using literal) + testcases[count++] = new TestCase ( SECTION, + "'before ^$*+?.()|{}[] after'.match(/\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]/)", + String(["^$*+?.()|{}[]"]), + String('before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/backspace.js b/tests/mozilla/js1_2/regexp/backspace.js new file mode 100644 index 0000000..bd3c064 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/backspace.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: backspace.js + Description: 'Tests regular expressions containing [\b]' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: [\b]'; + + writeHeaderToLog('Executing script: backspace.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abc\bdef'.match(new RegExp('.[\b].')) + testcases[count++] = new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('.[\\b].'))", + String(["c\bd"]), String('abc\bdef'.match(new RegExp('.[\\b].')))); + + // 'abc\\bdef'.match(new RegExp('.[\b].')) + testcases[count++] = new TestCase ( SECTION, "'abc\\bdef'.match(new RegExp('.[\\b].'))", + null, 'abc\\bdef'.match(new RegExp('.[\\b].'))); + + // 'abc\b\b\bdef'.match(new RegExp('c[\b]{3}d')) + testcases[count++] = new TestCase ( SECTION, "'abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d'))", + String(["c\b\b\bd"]), String('abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d')))); + + // 'abc\bdef'.match(new RegExp('[^\\[\b\\]]+')) + testcases[count++] = new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('[^\\[\\b\\]]+'))", + String(["abc"]), String('abc\bdef'.match(new RegExp('[^\\[\\b\\]]+')))); + + // 'abcdef'.match(new RegExp('[^\\[\b\\]]+')) + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('[^\\[\\b\\]]+'))", + String(["abcdef"]), String('abcdef'.match(new RegExp('[^\\[\\b\\]]+')))); + + // 'abcdef'.match(/[^\[\b\]]+/) + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/[^\\[\\b\\]]+/)", + String(["abcdef"]), String('abcdef'.match(/[^\[\b\]]+/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/beginLine.js b/tests/mozilla/js1_2/regexp/beginLine.js new file mode 100644 index 0000000..c5ccbdc --- /dev/null +++ b/tests/mozilla/js1_2/regexp/beginLine.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: beginLine.js + Description: 'Tests regular expressions containing ^' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: ^'; + + writeHeaderToLog('Executing script: beginLine.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcde'.match(new RegExp('^ab')) + testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('^ab'))", + String(["ab"]), String('abcde'.match(new RegExp('^ab')))); + + // 'ab\ncde'.match(new RegExp('^..^e')) + testcases[count++] = new TestCase ( SECTION, "'ab\ncde'.match(new RegExp('^..^e'))", + null, 'ab\ncde'.match(new RegExp('^..^e'))); + + // 'yyyyy'.match(new RegExp('^xxx')) + testcases[count++] = new TestCase ( SECTION, "'yyyyy'.match(new RegExp('^xxx'))", + null, 'yyyyy'.match(new RegExp('^xxx'))); + + // '^^^x'.match(new RegExp('^\\^+')) + testcases[count++] = new TestCase ( SECTION, "'^^^x'.match(new RegExp('^\\^+'))", + String(['^^^']), String('^^^x'.match(new RegExp('^\\^+')))); + + // '^^^x'.match(/^\^+/) + testcases[count++] = new TestCase ( SECTION, "'^^^x'.match(/^\\^+/)", + String(['^^^']), String('^^^x'.match(/^\^+/))); + + RegExp.multiline = true; + // 'abc\n123xyz'.match(new RegExp('^\d+')) + testcases[count++] = new TestCase ( SECTION, "'abc\n123xyz'.match(new RegExp('^\\d+'))", + String(['123']), String('abc\n123xyz'.match(new RegExp('^\\d+')))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/character_class.js b/tests/mozilla/js1_2/regexp/character_class.js new file mode 100644 index 0000000..da0b59e --- /dev/null +++ b/tests/mozilla/js1_2/regexp/character_class.js @@ -0,0 +1,107 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: character_class.js + Description: 'Tests regular expressions containing []' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: []'; + + writeHeaderToLog('Executing script: character_class.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcde'.match(new RegExp('ab[ercst]de')) + testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('ab[ercst]de'))", + String(["abcde"]), String('abcde'.match(new RegExp('ab[ercst]de')))); + + // 'abcde'.match(new RegExp('ab[erst]de')) + testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('ab[erst]de'))", + null, 'abcde'.match(new RegExp('ab[erst]de'))); + + // 'abcdefghijkl'.match(new RegExp('[d-h]+')) + testcases[count++] = new TestCase ( SECTION, "'abcdefghijkl'.match(new RegExp('[d-h]+'))", + String(["defgh"]), String('abcdefghijkl'.match(new RegExp('[d-h]+')))); + + // 'abc6defghijkl'.match(new RegExp('[1234567].{2}')) + testcases[count++] = new TestCase ( SECTION, "'abc6defghijkl'.match(new RegExp('[1234567].{2}'))", + String(["6de"]), String('abc6defghijkl'.match(new RegExp('[1234567].{2}')))); + + // '\n\n\abc324234\n'.match(new RegExp('[a-c\d]+')) + testcases[count++] = new TestCase ( SECTION, "'\n\n\abc324234\n'.match(new RegExp('[a-c\\d]+'))", + String(["abc324234"]), String('\n\n\abc324234\n'.match(new RegExp('[a-c\\d]+')))); + + // 'abc'.match(new RegExp('ab[.]?c')) + testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('ab[.]?c'))", + String(["abc"]), String('abc'.match(new RegExp('ab[.]?c')))); + + // 'abc'.match(new RegExp('a[b]c')) + testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('a[b]c'))", + String(["abc"]), String('abc'.match(new RegExp('a[b]c')))); + + // 'a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]')) + testcases[count++] = new TestCase ( SECTION, "'a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]'))", + String(["def"]), String('a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]')))); + + // '123*&$abc'.match(new RegExp('[*&$]{3}')) + testcases[count++] = new TestCase ( SECTION, "'123*&$abc'.match(new RegExp('[*&$]{3}'))", + String(["*&$"]), String('123*&$abc'.match(new RegExp('[*&$]{3}')))); + + // 'abc'.match(new RegExp('a[^1-9]c')) + testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('a[^1-9]c'))", + String(["abc"]), String('abc'.match(new RegExp('a[^1-9]c')))); + + // 'abc'.match(new RegExp('a[^b]c')) + testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('a[^b]c'))", + null, 'abc'.match(new RegExp('a[^b]c'))); + + // 'abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}')) + testcases[count++] = new TestCase ( SECTION, "'abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}'))", + String(["%&*@"]), String('abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}')))); + + // 'abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/) + testcases[count++] = new TestCase ( SECTION, "'abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/)", + String(["%&*@"]), String('abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/compile.js b/tests/mozilla/js1_2/regexp/compile.js new file mode 100644 index 0000000..973fff2 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/compile.js @@ -0,0 +1,94 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: compile.js + Description: 'Tests regular expressions method compile' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: compile'; + + writeHeaderToLog('Executing script: compile.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + var regularExpression = new RegExp(); + + regularExpression.compile("[0-9]{3}x[0-9]{4}","i"); + + testcases[count++] = new TestCase ( SECTION, + "(compile '[0-9]{3}x[0-9]{4}','i')", + String(["456X7890"]), String('234X456X7890'.match(regularExpression))); + + testcases[count++] = new TestCase ( SECTION, + "source of (compile '[0-9]{3}x[0-9]{4}','i')", + "[0-9]{3}x[0-9]{4}", regularExpression.source); + + testcases[count++] = new TestCase ( SECTION, + "global of (compile '[0-9]{3}x[0-9]{4}','i')", + false, regularExpression.global); + + testcases[count++] = new TestCase ( SECTION, + "ignoreCase of (compile '[0-9]{3}x[0-9]{4}','i')", + true, regularExpression.ignoreCase); + + regularExpression.compile("[0-9]{3}X[0-9]{3}","g"); + + testcases[count++] = new TestCase ( SECTION, + "(compile '[0-9]{3}X[0-9]{3}','g')", + String(["234X456"]), String('234X456X7890'.match(regularExpression))); + + testcases[count++] = new TestCase ( SECTION, + "source of (compile '[0-9]{3}X[0-9]{3}','g')", + "[0-9]{3}X[0-9]{3}", regularExpression.source); + + testcases[count++] = new TestCase ( SECTION, + "global of (compile '[0-9]{3}X[0-9]{3}','g')", + true, regularExpression.global); + + testcases[count++] = new TestCase ( SECTION, + "ignoreCase of (compile '[0-9]{3}X[0-9]{3}','g')", + false, regularExpression.ignoreCase); + + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/control_characters.js b/tests/mozilla/js1_2/regexp/control_characters.js new file mode 100644 index 0000000..fb54a7f --- /dev/null +++ b/tests/mozilla/js1_2/regexp/control_characters.js @@ -0,0 +1,71 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: control_characters.js + Description: 'Tests regular expressions containing .' + + Author: Nick Lerissa + Date: April 8, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: .'; + var BUGNUMBER="123802"; + + writeHeaderToLog('Executing script: control_characters.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'àOÐ ê:i¢Ø'.match(new RegExp('.+')) + testcases[count++] = new TestCase ( SECTION, "'àOÐ ê:i¢Ø'.match(new RegExp('.+'))", + String(['àOÐ ê:i¢Ø']), String('àOÐ ê:i¢Ø'.match(new RegExp('.+')))); + + // string1.match(new RegExp(string1)) + var string1 = 'àOÐ ê:i¢Ø'; + testcases[count++] = new TestCase ( SECTION, "string1 = " + string1 + " string1.match(string1)", + String([string1]), String(string1.match(string1))); + + string1 = ""; + for (var i = 0; i < 32; i++) + string1 += String.fromCharCode(i); + testcases[count++] = new TestCase ( SECTION, "string1 = " + string1 + " string1.match(string1)", + String([string1]), String(string1.match(string1))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/digit.js b/tests/mozilla/js1_2/regexp/digit.js new file mode 100644 index 0000000..d476823 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/digit.js @@ -0,0 +1,119 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: digit.js + Description: 'Tests regular expressions containing \d' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: \\d'; + + writeHeaderToLog('Executing script: digit.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + var non_digits = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\f\n\r\t\v~`!@#$%^&*()-+={[}]|\\:;'<,>./? " + '"'; + + var digits = "1234567890"; + + // be sure all digits are matched by \d + testcases[count++] = new TestCase ( SECTION, + "'" + digits + "'.match(new RegExp('\\d+'))", + String([digits]), String(digits.match(new RegExp('\\d+')))); + + // be sure all non-digits are matched by \D + testcases[count++] = new TestCase ( SECTION, + "'" + non_digits + "'.match(new RegExp('\\D+'))", + String([non_digits]), String(non_digits.match(new RegExp('\\D+')))); + + // be sure all non-digits are not matched by \d + testcases[count++] = new TestCase ( SECTION, + "'" + non_digits + "'.match(new RegExp('\\d'))", + null, non_digits.match(new RegExp('\\d'))); + + // be sure all digits are not matched by \D + testcases[count++] = new TestCase ( SECTION, + "'" + digits + "'.match(new RegExp('\\D'))", + null, digits.match(new RegExp('\\D'))); + + var s = non_digits + digits; + + // be sure all digits are matched by \d + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\d+'))", + String([digits]), String(s.match(new RegExp('\\d+')))); + + var s = digits + non_digits; + + // be sure all non-digits are matched by \D + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\D+'))", + String([non_digits]), String(s.match(new RegExp('\\D+')))); + + var i; + + // be sure all digits match individually + for (i = 0; i < digits.length; ++i) + { + s = 'ab' + digits[i] + 'cd'; + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\d'))", + String([digits[i]]), String(s.match(new RegExp('\\d')))); + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(/\\d/)", + String([digits[i]]), String(s.match(/\d/))); + } + // be sure all non_digits match individually + for (i = 0; i < non_digits.length; ++i) + { + s = '12' + non_digits[i] + '34'; + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\D'))", + String([non_digits[i]]), String(s.match(new RegExp('\\D')))); + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(/\\D/)", + String([non_digits[i]]), String(s.match(/\D/))); + } + + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/dot.js b/tests/mozilla/js1_2/regexp/dot.js new file mode 100644 index 0000000..1e9bbab --- /dev/null +++ b/tests/mozilla/js1_2/regexp/dot.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: dot.js + Description: 'Tests regular expressions containing .' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: .'; + + writeHeaderToLog('Executing script: dot.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcde'.match(new RegExp('ab.de')) + testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('ab.de'))", + String(["abcde"]), String('abcde'.match(new RegExp('ab.de')))); + + // 'line 1\nline 2'.match(new RegExp('.+')) + testcases[count++] = new TestCase ( SECTION, "'line 1\nline 2'.match(new RegExp('.+'))", + String(["line 1"]), String('line 1\nline 2'.match(new RegExp('.+')))); + + // 'this is a test'.match(new RegExp('.*a.*')) + testcases[count++] = new TestCase ( SECTION, "'this is a test'.match(new RegExp('.*a.*'))", + String(["this is a test"]), String('this is a test'.match(new RegExp('.*a.*')))); + + // 'this is a *&^%$# test'.match(new RegExp('.+')) + testcases[count++] = new TestCase ( SECTION, "'this is a *&^%$# test'.match(new RegExp('.+'))", + String(["this is a *&^%$# test"]), String('this is a *&^%$# test'.match(new RegExp('.+')))); + + // '....'.match(new RegExp('.+')) + testcases[count++] = new TestCase ( SECTION, "'....'.match(new RegExp('.+'))", + String(["...."]), String('....'.match(new RegExp('.+')))); + + // 'abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+')) + testcases[count++] = new TestCase ( SECTION, "'abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+'))", + String(["abcdefghijklmnopqrstuvwxyz"]), String('abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+')))); + + // 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+')) + testcases[count++] = new TestCase ( SECTION, "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+'))", + String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+')))); + + // '`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+')) + testcases[count++] = new TestCase ( SECTION, "'`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+'))", + String(["`1234567890-=~!@#$%^&*()_+"]), String('`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+')))); + + // '|\\[{]};:"\',<>.?/'.match(new RegExp('.+')) + testcases[count++] = new TestCase ( SECTION, "'|\\[{]};:\"\',<>.?/'.match(new RegExp('.+'))", + String(["|\\[{]};:\"\',<>.?/"]), String('|\\[{]};:\"\',<>.?/'.match(new RegExp('.+')))); + + // '|\\[{]};:"\',<>.?/'.match(/.+/) + testcases[count++] = new TestCase ( SECTION, "'|\\[{]};:\"\',<>.?/'.match(/.+/)", + String(["|\\[{]};:\"\',<>.?/"]), String('|\\[{]};:\"\',<>.?/'.match(/.+/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/endLine.js b/tests/mozilla/js1_2/regexp/endLine.js new file mode 100644 index 0000000..655d6ec --- /dev/null +++ b/tests/mozilla/js1_2/regexp/endLine.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: endLine.js + Description: 'Tests regular expressions containing $' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: $'; + + writeHeaderToLog('Executing script: endLine.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcde'.match(new RegExp('de$')) + testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('de$'))", + String(["de"]), String('abcde'.match(new RegExp('de$')))); + + // 'ab\ncde'.match(new RegExp('..$e$')) + testcases[count++] = new TestCase ( SECTION, "'ab\ncde'.match(new RegExp('..$e$'))", + null, 'ab\ncde'.match(new RegExp('..$e$'))); + + // 'yyyyy'.match(new RegExp('xxx$')) + testcases[count++] = new TestCase ( SECTION, "'yyyyy'.match(new RegExp('xxx$'))", + null, 'yyyyy'.match(new RegExp('xxx$'))); + + // 'a$$$'.match(new RegExp('\\$+$')) + testcases[count++] = new TestCase ( SECTION, "'a$$$'.match(new RegExp('\\$+$'))", + String(['$$$']), String('a$$$'.match(new RegExp('\\$+$')))); + + // 'a$$$'.match(/\$+$/) + testcases[count++] = new TestCase ( SECTION, "'a$$$'.match(/\\$+$/)", + String(['$$$']), String('a$$$'.match(/\$+$/))); + + RegExp.multiline = true; + // 'abc\n123xyz890\nxyz'.match(new RegExp('\d+$')) + testcases[count++] = new TestCase ( SECTION, "'abc\n123xyz890\nxyz'.match(new RegExp('\\d+$'))", + String(['890']), String('abc\n123xyz890\nxyz'.match(new RegExp('\\d+$')))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/everything.js b/tests/mozilla/js1_2/regexp/everything.js new file mode 100644 index 0000000..1cb6acb --- /dev/null +++ b/tests/mozilla/js1_2/regexp/everything.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: everything.js + Description: 'Tests regular expressions' + + Author: Nick Lerissa + Date: March 24, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp'; + + writeHeaderToLog('Executing script: everything.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'Sally and Fred are sure to come.'.match(/^[a-z\s]*/i) + testcases[count++] = new TestCase ( SECTION, "'Sally and Fred are sure to come'.match(/^[a-z\\s]*/i)", + String(["Sally and Fred are sure to come"]), String('Sally and Fred are sure to come'.match(/^[a-z\s]*/i))); + + // 'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$')) + testcases[count++] = new TestCase ( SECTION, "'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))", + String(["test123W+xyz","xyz"]), String('test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$')))); + + // 'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/) + testcases[count++] = new TestCase ( SECTION, "'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)", + String(["12365 number two 9898","12365","9898"]), String('number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/))); + + var simpleSentence = /(\s?[^\!\?\.]+[\!\?\.])+/; + // 'See Spot run.'.match(simpleSentence) + testcases[count++] = new TestCase ( SECTION, "'See Spot run.'.match(simpleSentence)", + String(["See Spot run.","See Spot run."]), String('See Spot run.'.match(simpleSentence))); + + // 'I like it. What's up? I said NO!'.match(simpleSentence) + testcases[count++] = new TestCase ( SECTION, "'I like it. What's up? I said NO!'.match(simpleSentence)", + String(["I like it. What's up? I said NO!",' I said NO!']), String('I like it. What\'s up? I said NO!'.match(simpleSentence))); + + // 'the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/) + testcases[count++] = new TestCase ( SECTION, "'the quick brown fox jumped over the lazy dogs'.match(/((\\w+)\\s*)+/)", + String(['the quick brown fox jumped over the lazy dogs','dogs','dogs']),String('the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/exec.js b/tests/mozilla/js1_2/regexp/exec.js new file mode 100644 index 0000000..f1a9d8b --- /dev/null +++ b/tests/mozilla/js1_2/regexp/exec.js @@ -0,0 +1,77 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: exec.js + Description: 'Tests regular expressions exec compile' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: exec'; + + writeHeaderToLog('Executing script: exec.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + testcases[count++] = new TestCase ( SECTION, + "/[0-9]{3}/.exec('23 2 34 678 9 09')", + String(["678"]), String(/[0-9]{3}/.exec('23 2 34 678 9 09'))); + + testcases[count++] = new TestCase ( SECTION, + "/3.{4}8/.exec('23 2 34 678 9 09')", + String(["34 678"]), String(/3.{4}8/.exec('23 2 34 678 9 09'))); + + var re = new RegExp('3.{4}8'); + testcases[count++] = new TestCase ( SECTION, + "re.exec('23 2 34 678 9 09')", + String(["34 678"]), String(re.exec('23 2 34 678 9 09'))); + + testcases[count++] = new TestCase ( SECTION, + "(/3.{4}8/.exec('23 2 34 678 9 09').length", + 1, (/3.{4}8/.exec('23 2 34 678 9 09')).length); + + re = new RegExp('3.{4}8'); + testcases[count++] = new TestCase ( SECTION, + "(re.exec('23 2 34 678 9 09').length", + 1, (re.exec('23 2 34 678 9 09')).length); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/flags.js b/tests/mozilla/js1_2/regexp/flags.js new file mode 100644 index 0000000..5c25c8f --- /dev/null +++ b/tests/mozilla/js1_2/regexp/flags.js @@ -0,0 +1,84 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: regexp.js + Description: 'Tests regular expressions using flags "i" and "g"' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'regular expression flags with flags "i" and "g"'; + + writeHeaderToLog('Executing script: flags.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // testing optional flag 'i' + testcases[count++] = new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(/fghijk/i)", + String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(/fghijk/i))); + + testcases[count++] = new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(new RegExp('fghijk','i'))", + String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(new RegExp("fghijk","i")))); + + // testing optional flag 'g' + testcases[count++] = new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(/x./g)", + String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(/x./g))); + + testcases[count++] = new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(new RegExp('x.','g'))", + String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(new RegExp('x.','g')))); + + // testing optional flags 'g' and 'i' + testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./gi)", + String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./gi))); + + testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','gi'))", + String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','gi')))); + + testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./ig)", + String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./ig))); + + testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','ig'))", + String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','ig')))); + + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/regexp/global.js b/tests/mozilla/js1_2/regexp/global.js new file mode 100644 index 0000000..ce43520 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/global.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: global.js + Description: 'Tests RegExp attribute global' + + Author: Nick Lerissa + Date: March 13, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: global'; + + writeHeaderToLog('Executing script: global.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // /xyz/g.global + testcases[count++] = new TestCase ( SECTION, "/xyz/g.global", + true, /xyz/g.global); + + // /xyz/.global + testcases[count++] = new TestCase ( SECTION, "/xyz/.global", + false, /xyz/.global); + + // '123 456 789'.match(/\d+/g) + testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(/\\d+/g)", + String(["123","456","789"]), String('123 456 789'.match(/\d+/g))); + + // '123 456 789'.match(/(\d+)/g) + testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(/(\\d+)/g)", + String(["123","456","789"]), String('123 456 789'.match(/(\d+)/g))); + + // '123 456 789'.match(/\d+/) + testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(/\\d+/)", + String(["123"]), String('123 456 789'.match(/\d+/))); + + // (new RegExp('[a-z]','g')).global + testcases[count++] = new TestCase ( SECTION, "(new RegExp('[a-z]','g')).global", + true, (new RegExp('[a-z]','g')).global); + + // (new RegExp('[a-z]','i')).global + testcases[count++] = new TestCase ( SECTION, "(new RegExp('[a-z]','i')).global", + false, (new RegExp('[a-z]','i')).global); + + // '123 456 789'.match(new RegExp('\\d+','g')) + testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','g'))", + String(["123","456","789"]), String('123 456 789'.match(new RegExp('\\d+','g')))); + + // '123 456 789'.match(new RegExp('(\\d+)','g')) + testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(new RegExp('(\\\\d+)','g'))", + String(["123","456","789"]), String('123 456 789'.match(new RegExp('(\\d+)','g')))); + + // '123 456 789'.match(new RegExp('\\d+','i')) + testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','i'))", + String(["123"]), String('123 456 789'.match(new RegExp('\\d+','i')))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/hexadecimal.js b/tests/mozilla/js1_2/regexp/hexadecimal.js new file mode 100644 index 0000000..8f68c9a --- /dev/null +++ b/tests/mozilla/js1_2/regexp/hexadecimal.js @@ -0,0 +1,108 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: hexadecimal.js + Description: 'Tests regular expressions containing \ ' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: \x# (hex) '; + + writeHeaderToLog('Executing script: hexadecimal.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + var testPattern = '\\x41\\x42\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4A\\x4B\\x4C\\x4D\\x4E\\x4F\\x50\\x51\\x52\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5A'; + + var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern)))); + + testPattern = '\\x61\\x62\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6A\\x6B\\x6C\\x6D\\x6E\\x6F\\x70\\x71\\x72\\x73\\x74\\x75\\x76\\x77\\x78\\x79\\x7A'; + + testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern)))); + + testPattern = '\\x20\\x21\\x22\\x23\\x24\\x25\\x26\\x27\\x28\\x29\\x2A\\x2B\\x2C\\x2D\\x2E\\x2F\\x30\\x31\\x32\\x33'; + + testString = "abc !\"#$%&'()*+,-./0123ZBC"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern)))); + + testPattern = '\\x34\\x35\\x36\\x37\\x38\\x39\\x3A\\x3B\\x3C\\x3D\\x3E\\x3F\\x40'; + + testString = "123456789:;<=>?@ABC"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern)))); + + testPattern = '\\x7B\\x7C\\x7D\\x7E'; + + testString = "1234{|}~ABC"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["{|}~"]), String(testString.match(new RegExp(testPattern)))); + + testcases[count++] = new TestCase ( SECTION, + "'canthisbeFOUND'.match(new RegExp('[A-\\x5A]+'))", + String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\x5A]+')))); + + testcases[count++] = new TestCase ( SECTION, + "'canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+'))", + String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+')))); + + testcases[count++] = new TestCase ( SECTION, + "'canthisbeFOUND'.match(/[\\x61-\\x7A]+/)", + String(["canthisbe"]), String('canthisbeFOUND'.match(/[\x61-\x7A]+/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/ignoreCase.js b/tests/mozilla/js1_2/regexp/ignoreCase.js new file mode 100644 index 0000000..fec4d2c --- /dev/null +++ b/tests/mozilla/js1_2/regexp/ignoreCase.js @@ -0,0 +1,111 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: ignoreCase.js + Description: 'Tests RegExp attribute ignoreCase' + + Author: Nick Lerissa + Date: March 13, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: ignoreCase'; + + writeHeaderToLog('Executing script: ignoreCase.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // /xyz/i.ignoreCase + testcases[count++] = new TestCase ( SECTION, "/xyz/i.ignoreCase", + true, /xyz/i.ignoreCase); + + // /xyz/.ignoreCase + testcases[count++] = new TestCase ( SECTION, "/xyz/.ignoreCase", + false, /xyz/.ignoreCase); + + // 'ABC def ghi'.match(/[a-z]+/ig) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/ig)", + String(["ABC","def","ghi"]), String('ABC def ghi'.match(/[a-z]+/ig))); + + // 'ABC def ghi'.match(/[a-z]+/i) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/i)", + String(["ABC"]), String('ABC def ghi'.match(/[a-z]+/i))); + + // 'ABC def ghi'.match(/([a-z]+)/ig) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/([a-z]+)/ig)", + String(["ABC","def","ghi"]), String('ABC def ghi'.match(/([a-z]+)/ig))); + + // 'ABC def ghi'.match(/([a-z]+)/i) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/([a-z]+)/i)", + String(["ABC","ABC"]), String('ABC def ghi'.match(/([a-z]+)/i))); + + // 'ABC def ghi'.match(/[a-z]+/) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/)", + String(["def"]), String('ABC def ghi'.match(/[a-z]+/))); + + // (new RegExp('xyz','i')).ignoreCase + testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz','i')).ignoreCase", + true, (new RegExp('xyz','i')).ignoreCase); + + // (new RegExp('xyz')).ignoreCase + testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz')).ignoreCase", + false, (new RegExp('xyz')).ignoreCase); + + // 'ABC def ghi'.match(new RegExp('[a-z]+','ig')) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+','ig'))", + String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('[a-z]+','ig')))); + + // 'ABC def ghi'.match(new RegExp('[a-z]+','i')) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+','i'))", + String(["ABC"]), String('ABC def ghi'.match(new RegExp('[a-z]+','i')))); + + // 'ABC def ghi'.match(new RegExp('([a-z]+)','ig')) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('([a-z]+)','ig'))", + String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','ig')))); + + // 'ABC def ghi'.match(new RegExp('([a-z]+)','i')) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('([a-z]+)','i'))", + String(["ABC","ABC"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','i')))); + + // 'ABC def ghi'.match(new RegExp('[a-z]+')) + testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+'))", + String(["def"]), String('ABC def ghi'.match(new RegExp('[a-z]+')))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/interval.js b/tests/mozilla/js1_2/regexp/interval.js new file mode 100644 index 0000000..7e80777 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/interval.js @@ -0,0 +1,115 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: interval.js + Description: 'Tests regular expressions containing {}' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: {}'; + + writeHeaderToLog('Executing script: interval.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c')) + testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c'))", + String(["bbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c')))); + + // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}')) + testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}'))", + null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}'))); + + // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c')) + testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c'))", + String(["bbbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c')))); + + // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c')) + testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c'))", + null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c'))); + + // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c')) + testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c'))", + String(["bbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c')))); + + // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c')) + testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c'))", + null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c'))); + + // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c')) + testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c'))", + String(["bbbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c')))); + + // 'aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c')) + testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c'))", + String(["bc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c')))); + + // 'weirwerdf'.match(new RegExp('.{0,93}')) + testcases[count++] = new TestCase ( SECTION, "'weirwerdf'.match(new RegExp('.{0,93}'))", + String(["weirwerdf"]), String('weirwerdf'.match(new RegExp('.{0,93}')))); + + // 'wqe456646dsff'.match(new RegExp('\d{1,}')) + testcases[count++] = new TestCase ( SECTION, "'wqe456646dsff'.match(new RegExp('\\d{1,}'))", + String(["456646"]), String('wqe456646dsff'.match(new RegExp('\\d{1,}')))); + + // '123123'.match(new RegExp('(123){1,}')) + testcases[count++] = new TestCase ( SECTION, "'123123'.match(new RegExp('(123){1,}'))", + String(["123123","123"]), String('123123'.match(new RegExp('(123){1,}')))); + + // '123123x123'.match(new RegExp('(123){1,}x\1')) + testcases[count++] = new TestCase ( SECTION, "'123123x123'.match(new RegExp('(123){1,}x\\1'))", + String(["123123x123","123"]), String('123123x123'.match(new RegExp('(123){1,}x\\1')))); + + // '123123x123'.match(/(123){1,}x\1/) + testcases[count++] = new TestCase ( SECTION, "'123123x123'.match(/(123){1,}x\\1/)", + String(["123123x123","123"]), String('123123x123'.match(/(123){1,}x\1/))); + + // 'xxxxxxx'.match(new RegExp('x{1,2}x{1,}')) + testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('x{1,2}x{1,}'))", + String(["xxxxxxx"]), String('xxxxxxx'.match(new RegExp('x{1,2}x{1,}')))); + + // 'xxxxxxx'.match(/x{1,2}x{1,}/) + testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(/x{1,2}x{1,}/)", + String(["xxxxxxx"]), String('xxxxxxx'.match(/x{1,2}x{1,}/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/octal.js b/tests/mozilla/js1_2/regexp/octal.js new file mode 100644 index 0000000..2fe6588 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/octal.js @@ -0,0 +1,108 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: octal.js + Description: 'Tests regular expressions containing \ ' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: \# (octal) '; + + writeHeaderToLog('Executing script: octal.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + var testPattern = '\\101\\102\\103\\104\\105\\106\\107\\110\\111\\112\\113\\114\\115\\116\\117\\120\\121\\122\\123\\124\\125\\126\\127\\130\\131\\132'; + + var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern)))); + + testPattern = '\\141\\142\\143\\144\\145\\146\\147\\150\\151\\152\\153\\154\\155\\156\\157\\160\\161\\162\\163\\164\\165\\166\\167\\170\\171\\172'; + + testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern)))); + + testPattern = '\\40\\41\\42\\43\\44\\45\\46\\47\\50\\51\\52\\53\\54\\55\\56\\57\\60\\61\\62\\63'; + + testString = "abc !\"#$%&'()*+,-./0123ZBC"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern)))); + + testPattern = '\\64\\65\\66\\67\\70\\71\\72\\73\\74\\75\\76\\77\\100'; + + testString = "123456789:;<=>?@ABC"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern)))); + + testPattern = '\\173\\174\\175\\176'; + + testString = "1234{|}~ABC"; + + testcases[count++] = new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["{|}~"]), String(testString.match(new RegExp(testPattern)))); + + testcases[count++] = new TestCase ( SECTION, + "'canthisbeFOUND'.match(new RegExp('[A-\\132]+'))", + String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\132]+')))); + + testcases[count++] = new TestCase ( SECTION, + "'canthisbeFOUND'.match(new RegExp('[\\141-\\172]+'))", + String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\141-\\172]+')))); + + testcases[count++] = new TestCase ( SECTION, + "'canthisbeFOUND'.match(/[\\141-\\172]+/)", + String(["canthisbe"]), String('canthisbeFOUND'.match(/[\141-\172]+/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/parentheses.js b/tests/mozilla/js1_2/regexp/parentheses.js new file mode 100644 index 0000000..6fe1948 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/parentheses.js @@ -0,0 +1,107 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: parentheses.js + Description: 'Tests regular expressions containing ()' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: ()'; + + writeHeaderToLog('Executing script: parentheses.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abc'.match(new RegExp('(abc)')) + testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('(abc)'))", + String(["abc","abc"]), String('abc'.match(new RegExp('(abc)')))); + + // 'abcdefg'.match(new RegExp('a(bc)d(ef)g')) + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('a(bc)d(ef)g'))", + String(["abcdefg","bc","ef"]), String('abcdefg'.match(new RegExp('a(bc)d(ef)g')))); + + // 'abcdefg'.match(new RegExp('(.{3})(.{4})')) + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(.{3})(.{4})'))", + String(["abcdefg","abc","defg"]), String('abcdefg'.match(new RegExp('(.{3})(.{4})')))); + + // 'aabcdaabcd'.match(new RegExp('(aa)bcd\1')) + testcases[count++] = new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(aa)bcd\\1'))", + String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(aa)bcd\\1')))); + + // 'aabcdaabcd'.match(new RegExp('(aa).+\1')) + testcases[count++] = new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(aa).+\\1'))", + String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(aa).+\\1')))); + + // 'aabcdaabcd'.match(new RegExp('(.{2}).+\1')) + testcases[count++] = new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(.{2}).+\\1'))", + String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(.{2}).+\\1')))); + + // '123456123456'.match(new RegExp('(\d{3})(\d{3})\1\2')) + testcases[count++] = new TestCase ( SECTION, "'123456123456'.match(new RegExp('(\\d{3})(\\d{3})\\1\\2'))", + String(["123456123456","123","456"]), String('123456123456'.match(new RegExp('(\\d{3})(\\d{3})\\1\\2')))); + + // 'abcdefg'.match(new RegExp('a(..(..)..)')) + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('a(..(..)..)'))", + String(["abcdefg","bcdefg","de"]), String('abcdefg'.match(new RegExp('a(..(..)..)')))); + + // 'abcdefg'.match(/a(..(..)..)/) + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/a(..(..)..)/)", + String(["abcdefg","bcdefg","de"]), String('abcdefg'.match(/a(..(..)..)/))); + + // 'xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))')) + testcases[count++] = new TestCase ( SECTION, "'xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))'))", + String(["abcdef","abc","bc","c","def","ef","f"]), String('xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))')))); + + // 'xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\2\5')) + testcases[count++] = new TestCase ( SECTION, "'xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\\2\\5'))", + String(["abcdefbcef","abc","bc","c","def","ef","f"]), String('xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\\2\\5')))); + + // 'abcd'.match(new RegExp('a(.?)b\1c\1d\1')) + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('a(.?)b\\1c\\1d\\1'))", + String(["abcd",""]), String('abcd'.match(new RegExp('a(.?)b\\1c\\1d\\1')))); + + // 'abcd'.match(/a(.?)b\1c\1d\1/) + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/a(.?)b\\1c\\1d\\1/)", + String(["abcd",""]), String('abcd'.match(/a(.?)b\1c\1d\1/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/plus.js b/tests/mozilla/js1_2/regexp/plus.js new file mode 100644 index 0000000..f3e44ea --- /dev/null +++ b/tests/mozilla/js1_2/regexp/plus.js @@ -0,0 +1,87 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: plus.js + Description: 'Tests regular expressions containing +' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: +'; + + writeHeaderToLog('Executing script: plus.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcdddddefg'.match(new RegExp('d+')) + testcases[count++] = new TestCase ( SECTION, "'abcdddddefg'.match(new RegExp('d+'))", + String(["ddddd"]), String('abcdddddefg'.match(new RegExp('d+')))); + + // 'abcdefg'.match(new RegExp('o+')) + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('o+'))", + null, 'abcdefg'.match(new RegExp('o+'))); + + // 'abcdefg'.match(new RegExp('d+')) + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('d+'))", + String(['d']), String('abcdefg'.match(new RegExp('d+')))); + + // 'abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)')) + testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)'))", + String(["bbbbbbb","bbbbb","b","b"]), String('abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)')))); + + // 'abbbbbbbc'.match(new RegExp('(b+)(b*)')) + testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('(b+)(b*)'))", + String(["bbbbbbb","bbbbbbb",""]), String('abbbbbbbc'.match(new RegExp('(b+)(b*)')))); + + // 'abbbbbbbc'.match(new RegExp('b*b+')) + testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('b*b+'))", + String(['bbbbbbb']), String('abbbbbbbc'.match(new RegExp('b*b+')))); + + // 'abbbbbbbc'.match(/(b+)(b*)/) + testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(/(b+)(b*)/)", + String(["bbbbbbb","bbbbbbb",""]), String('abbbbbbbc'.match(/(b+)(b*)/))); + + // 'abbbbbbbc'.match(new RegExp('b*b+')) + testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(/b*b+/)", + String(['bbbbbbb']), String('abbbbbbbc'.match(/b*b+/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/question_mark.js b/tests/mozilla/js1_2/regexp/question_mark.js new file mode 100644 index 0000000..f17cd0b --- /dev/null +++ b/tests/mozilla/js1_2/regexp/question_mark.js @@ -0,0 +1,99 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: question_mark.js + Description: 'Tests regular expressions containing ?' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: ?'; + + writeHeaderToLog('Executing script: question_mark.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcdef'.match(new RegExp('cd?e')) + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('cd?e'))", + String(["cde"]), String('abcdef'.match(new RegExp('cd?e')))); + + // 'abcdef'.match(new RegExp('cdx?e')) + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('cdx?e'))", + String(["cde"]), String('abcdef'.match(new RegExp('cdx?e')))); + + // 'pqrstuvw'.match(new RegExp('o?pqrst')) + testcases[count++] = new TestCase ( SECTION, "'pqrstuvw'.match(new RegExp('o?pqrst'))", + String(["pqrst"]), String('pqrstuvw'.match(new RegExp('o?pqrst')))); + + // 'abcd'.match(new RegExp('x?y?z?')) + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('x?y?z?'))", + String([""]), String('abcd'.match(new RegExp('x?y?z?')))); + + // 'abcd'.match(new RegExp('x?ay?bz?c')) + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('x?ay?bz?c'))", + String(["abc"]), String('abcd'.match(new RegExp('x?ay?bz?c')))); + + // 'abcd'.match(/x?ay?bz?c/) + testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/x?ay?bz?c/)", + String(["abc"]), String('abcd'.match(/x?ay?bz?c/))); + + // 'abbbbc'.match(new RegExp('b?b?b?b')) + testcases[count++] = new TestCase ( SECTION, "'abbbbc'.match(new RegExp('b?b?b?b'))", + String(["bbbb"]), String('abbbbc'.match(new RegExp('b?b?b?b')))); + + // '123az789'.match(new RegExp('ab?c?d?x?y?z')) + testcases[count++] = new TestCase ( SECTION, "'123az789'.match(new RegExp('ab?c?d?x?y?z'))", + String(["az"]), String('123az789'.match(new RegExp('ab?c?d?x?y?z')))); + + // '123az789'.match(/ab?c?d?x?y?z/) + testcases[count++] = new TestCase ( SECTION, "'123az789'.match(/ab?c?d?x?y?z/)", + String(["az"]), String('123az789'.match(/ab?c?d?x?y?z/))); + + // '?????'.match(new RegExp('\\??\\??\\??\\??\\??')) + testcases[count++] = new TestCase ( SECTION, "'?????'.match(new RegExp('\\??\\??\\??\\??\\??'))", + String(["?????"]), String('?????'.match(new RegExp('\\??\\??\\??\\??\\??')))); + + // 'test'.match(new RegExp('.?.?.?.?.?.?.?')) + testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('.?.?.?.?.?.?.?'))", + String(["test"]), String('test'.match(new RegExp('.?.?.?.?.?.?.?')))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/regress-6359.js b/tests/mozilla/js1_2/regexp/regress-6359.js new file mode 100644 index 0000000..20ac50f --- /dev/null +++ b/tests/mozilla/js1_2/regexp/regress-6359.js @@ -0,0 +1,68 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/** + * File Name: regress-6359.js + * Reference: ** replace with bugzilla URL or document reference ** + * Description: ** replace with description of test ** + * Author: ** replace with your e-mail address ** + */ + + var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) + var VERSION = "ECMA_2"; // Version of JavaScript or ECMA + var TITLE = "Regression test for bugzilla # 6359"; // Provide ECMA section title or a description + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=6359"; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + /* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + + AddTestCase( '/(a*)b\1+/("baaac").length', + 2, + /(a*)b\1+/("baaac").length ); + + AddTestCase( '/(a*)b\1+/("baaac")[0]', + "b", + /(a*)b\1+/("baaac")[0]); + + AddTestCase( '/(a*)b\1+/("baaac")[1]', + "", + /(a*)b\1+/("baaac")[1]); + + + test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/tests/mozilla/js1_2/regexp/regress-9141.js b/tests/mozilla/js1_2/regexp/regress-9141.js new file mode 100644 index 0000000..3601bcf --- /dev/null +++ b/tests/mozilla/js1_2/regexp/regress-9141.js @@ -0,0 +1,86 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/** + * File Name: regress-9141.js + * Reference: "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; + * Description: + * From waldemar@netscape.com: + * + * The following page crashes the system: + * + * + * + * + * + * + * + * + */ + + var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) + var VERSION = "ECMA_2"; // Version of JavaScript or ECMA + var TITLE = "Regression test for bugzilla # 9141"; // Provide ECMA section title or a description + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + /* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + + var s = "x"; + for (var i = 0; i != 13; i++) s += s; + var a = /(?:xx|x)*/(s); + var b = /(xx|x)*/(s); + + AddTestCase( "var s = 'x'; for (var i = 0; i != 13; i++) s += s; " + + "a = /(?:xx|x)*/(s); a.length", + 1, + a.length ); + + AddTestCase( "var b = /(xx|x)*/(s); b.length", + 2, + b.length ); + + test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/tests/mozilla/js1_2/regexp/simple_form.js b/tests/mozilla/js1_2/regexp/simple_form.js new file mode 100644 index 0000000..e369c3e --- /dev/null +++ b/tests/mozilla/js1_2/regexp/simple_form.js @@ -0,0 +1,90 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: simple_form.js + Description: 'Tests regular expressions using simple form: re(...)' + + Author: Nick Lerissa + Date: March 19, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: simple form'; + + writeHeaderToLog('Executing script: simple_form.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + testcases[count++] = new TestCase ( SECTION, + "/[0-9]{3}/('23 2 34 678 9 09')", + String(["678"]), String(/[0-9]{3}/('23 2 34 678 9 09'))); + + testcases[count++] = new TestCase ( SECTION, + "/3.{4}8/('23 2 34 678 9 09')", + String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09'))); + + testcases[count++] = new TestCase ( SECTION, + "(/3.{4}8/('23 2 34 678 9 09').length", + 1, (/3.{4}8/('23 2 34 678 9 09')).length); + + var re = /[0-9]{3}/; + testcases[count++] = new TestCase ( SECTION, + "re('23 2 34 678 9 09')", + String(["678"]), String(re('23 2 34 678 9 09'))); + + re = /3.{4}8/; + testcases[count++] = new TestCase ( SECTION, + "re('23 2 34 678 9 09')", + String(["34 678"]), String(re('23 2 34 678 9 09'))); + + testcases[count++] = new TestCase ( SECTION, + "/3.{4}8/('23 2 34 678 9 09')", + String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09'))); + + re =/3.{4}8/; + testcases[count++] = new TestCase ( SECTION, + "(re('23 2 34 678 9 09').length", + 1, (re('23 2 34 678 9 09')).length); + + testcases[count++] = new TestCase ( SECTION, + "(/3.{4}8/('23 2 34 678 9 09').length", + 1, (/3.{4}8/('23 2 34 678 9 09')).length); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/source.js b/tests/mozilla/js1_2/regexp/source.js new file mode 100644 index 0000000..589d2b9 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/source.js @@ -0,0 +1,87 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: source.js + Description: 'Tests RegExp attribute source' + + Author: Nick Lerissa + Date: March 13, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: source'; + + writeHeaderToLog('Executing script: source.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // /xyz/g.source + testcases[count++] = new TestCase ( SECTION, "/xyz/g.source", + "xyz", /xyz/g.source); + + // /xyz/.source + testcases[count++] = new TestCase ( SECTION, "/xyz/.source", + "xyz", /xyz/.source); + + // /abc\\def/.source + testcases[count++] = new TestCase ( SECTION, "/abc\\\\def/.source", + "abc\\\\def", /abc\\def/.source); + + // /abc[\b]def/.source + testcases[count++] = new TestCase ( SECTION, "/abc[\\b]def/.source", + "abc[\\b]def", /abc[\b]def/.source); + + // (new RegExp('xyz')).source + testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz')).source", + "xyz", (new RegExp('xyz')).source); + + // (new RegExp('xyz','g')).source + testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz','g')).source", + "xyz", (new RegExp('xyz','g')).source); + + // (new RegExp('abc\\\\def')).source + testcases[count++] = new TestCase ( SECTION, "(new RegExp('abc\\\\\\\\def')).source", + "abc\\\\def", (new RegExp('abc\\\\def')).source); + + // (new RegExp('abc[\\b]def')).source + testcases[count++] = new TestCase ( SECTION, "(new RegExp('abc[\\\\b]def')).source", + "abc[\\b]def", (new RegExp('abc[\\b]def')).source); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/special_characters.js b/tests/mozilla/js1_2/regexp/special_characters.js new file mode 100644 index 0000000..8675980 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/special_characters.js @@ -0,0 +1,157 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: special_characters.js + Description: 'Tests regular expressions containing special characters' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: special_charaters'; + + writeHeaderToLog('Executing script: special_characters.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // testing backslash '\' + testcases[count++] = new TestCase ( SECTION, "'^abcdefghi'.match(/\^abc/)", String(["^abc"]), String('^abcdefghi'.match(/\^abc/))); + + // testing beginning of line '^' + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/^abc/)", String(["abc"]), String('abcdefghi'.match(/^abc/))); + + // testing end of line '$' + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/fghi$/)", String(["ghi"]), String('abcdefghi'.match(/ghi$/))); + + // testing repeat '*' + testcases[count++] = new TestCase ( SECTION, "'eeeefghi'.match(/e*/)", String(["eeee"]), String('eeeefghi'.match(/e*/))); + + // testing repeat 1 or more times '+' + testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e+/)", String(["eeee"]), String('abcdeeeefghi'.match(/e+/))); + + // testing repeat 0 or 1 time '?' + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/abc?de/)", String(["abcde"]), String('abcdefghi'.match(/abc?de/))); + + // testing any character '.' + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/c.e/)", String(["cde"]), String('abcdefghi'.match(/c.e/))); + + // testing remembering () + testcases[count++] = new TestCase ( SECTION, "'abcewirjskjdabciewjsdf'.match(/(abc).+\\1'/)", + String(["abcewirjskjdabc","abc"]), String('abcewirjskjdabciewjsdf'.match(/(abc).+\1/))); + + // testing or match '|' + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/xyz|def/)", String(["def"]), String('abcdefghi'.match(/xyz|def/))); + + // testing repeat n {n} + testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{3}/)", String(["eee"]), String('abcdeeeefghi'.match(/e{3}/))); + + // testing min repeat n {n,} + testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{3,}/)", String(["eeee"]), String('abcdeeeefghi'.match(/e{3,}/))); + + // testing min/max repeat {min, max} + testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{2,8}/)", String(["eeee"]), String('abcdeeeefghi'.match(/e{2,8}/))); + + // testing any in set [abc...] + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/cd[xey]fgh/)", String(["cdefgh"]), String('abcdefghi'.match(/cd[xey]fgh/))); + + // testing any in set [a-z] + testcases[count++] = new TestCase ( SECTION, "'netscape inc'.match(/t[r-v]ca/)", String(["tsca"]), String('netscape inc'.match(/t[r-v]ca/))); + + // testing any not in set [^abc...] + testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/cd[^xy]fgh/)", String(["cdefgh"]), String('abcdefghi'.match(/cd[^xy]fgh/))); + + // testing any not in set [^a-z] + testcases[count++] = new TestCase ( SECTION, "'netscape inc'.match(/t[^a-c]ca/)", String(["tsca"]), String('netscape inc'.match(/t[^a-c]ca/))); + + // testing backspace [\b] + testcases[count++] = new TestCase ( SECTION, "'this is b\ba test'.match(/is b[\b]a test/)", + String(["is b\ba test"]), String('this is b\ba test'.match(/is b[\b]a test/))); + + // testing word boundary \b + testcases[count++] = new TestCase ( SECTION, "'today is now - day is not now'.match(/\bday.*now/)", + String(["day is not now"]), String('today is now - day is not now'.match(/\bday.*now/))); + + // control characters??? + + // testing any digit \d + testcases[count++] = new TestCase ( SECTION, "'a dog - 1 dog'.match(/\d dog/)", String(["1 dog"]), String('a dog - 1 dog'.match(/\d dog/))); + + // testing any non digit \d + testcases[count++] = new TestCase ( SECTION, "'a dog - 1 dog'.match(/\D dog/)", String(["a dog"]), String('a dog - 1 dog'.match(/\D dog/))); + + // testing form feed '\f' + testcases[count++] = new TestCase ( SECTION, "'a b a\fb'.match(/a\fb/)", String(["a\fb"]), String('a b a\fb'.match(/a\fb/))); + + // testing line feed '\n' + testcases[count++] = new TestCase ( SECTION, "'a b a\nb'.match(/a\nb/)", String(["a\nb"]), String('a b a\nb'.match(/a\nb/))); + + // testing carriage return '\r' + testcases[count++] = new TestCase ( SECTION, "'a b a\rb'.match(/a\rb/)", String(["a\rb"]), String('a b a\rb'.match(/a\rb/))); + + // testing whitespace '\s' + testcases[count++] = new TestCase ( SECTION, "'xa\f\n\r\t\vbz'.match(/a\s+b/)", String(["a\f\n\r\t\vb"]), String('xa\f\n\r\t\vbz'.match(/a\s+b/))); + + // testing non whitespace '\S' + testcases[count++] = new TestCase ( SECTION, "'a\tb a b a-b'.match(/a\Sb/)", String(["a-b"]), String('a\tb a b a-b'.match(/a\Sb/))); + + // testing tab '\t' + testcases[count++] = new TestCase ( SECTION, "'a\t\tb a b'.match(/a\t{2}/)", String(["a\t\t"]), String('a\t\tb a b'.match(/a\t{2}/))); + + // testing vertical tab '\v' + testcases[count++] = new TestCase ( SECTION, "'a\v\vb a b'.match(/a\v{2}/)", String(["a\v\v"]), String('a\v\vb a b'.match(/a\v{2}/))); + + // testing alphnumeric characters '\w' + testcases[count++] = new TestCase ( SECTION, "'%AZaz09_$'.match(/\w+/)", String(["AZaz09_"]), String('%AZaz09_$'.match(/\w+/))); + + // testing non alphnumeric characters '\W' + testcases[count++] = new TestCase ( SECTION, "'azx$%#@*4534'.match(/\W+/)", String(["$%#@*"]), String('azx$%#@*4534'.match(/\W+/))); + + // testing back references '\' + testcases[count++] = new TestCase ( SECTION, "'test'.match(/(t)es\\1/)", String(["test","t"]), String('test'.match(/(t)es\1/))); + + // testing hex excaping with '\' + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/\x63\x64/)", String(["cd"]), String('abcdef'.match(/\x63\x64/))); + + // testing oct excaping with '\' + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/\\143\\144/)", String(["cd"]), String('abcdef'.match(/\143\144/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/regexp/string_replace.js b/tests/mozilla/js1_2/regexp/string_replace.js new file mode 100644 index 0000000..b95ddf3 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/string_replace.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: string_replace.js + Description: 'Tests the replace method on Strings using regular expressions' + + Author: Nick Lerissa + Date: March 11, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String: replace'; + + writeHeaderToLog('Executing script: string_replace.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'adddb'.replace(/ddd/,"XX") + testcases[count++] = new TestCase ( SECTION, "'adddb'.replace(/ddd/,'XX')", + "aXXb", 'adddb'.replace(/ddd/,'XX')); + + // 'adddb'.replace(/eee/,"XX") + testcases[count++] = new TestCase ( SECTION, "'adddb'.replace(/eee/,'XX')", + 'adddb', 'adddb'.replace(/eee/,'XX')); + + // '34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**') + testcases[count++] = new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')", + "34 56 ** 12", '34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')); + + // '34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX') + testcases[count++] = new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')", + "34 56 78b 12", '34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')); + + // 'original'.replace(new RegExp(),'XX') + testcases[count++] = new TestCase ( SECTION, "'original'.replace(new RegExp(),'XX')", + "XXoriginal", 'original'.replace(new RegExp(),'XX')); + + // 'qwe ert x\t\n 345654AB'.replace(new RegExp('x\s*\d+(..)$'),'****') + testcases[count++] = new TestCase ( SECTION, "'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****')", + "qwe ert ****", 'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****')); + + +function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/string_search.js b/tests/mozilla/js1_2/regexp/string_search.js new file mode 100644 index 0000000..8d229c6 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/string_search.js @@ -0,0 +1,87 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: string_search.js + Description: 'Tests the search method on Strings using regular expressions' + + Author: Nick Lerissa + Date: March 12, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String: search'; + + writeHeaderToLog('Executing script: string_search.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abcdefg'.search(/d/) + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.search(/d/)", + 3, 'abcdefg'.search(/d/)); + + // 'abcdefg'.search(/x/) + testcases[count++] = new TestCase ( SECTION, "'abcdefg'.search(/x/)", + -1, 'abcdefg'.search(/x/)); + + // 'abcdefg123456hijklmn'.search(/\d+/) + testcases[count++] = new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(/\d+/)", + 7, 'abcdefg123456hijklmn'.search(/\d+/)); + + // 'abcdefg123456hijklmn'.search(new RegExp()) + testcases[count++] = new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(new RegExp())", + 0, 'abcdefg123456hijklmn'.search(new RegExp())); + + // 'abc'.search(new RegExp('$')) + testcases[count++] = new TestCase ( SECTION, "'abc'.search(new RegExp('$'))", + 3, 'abc'.search(new RegExp('$'))); + + // 'abc'.search(new RegExp('^')) + testcases[count++] = new TestCase ( SECTION, "'abc'.search(new RegExp('^'))", + 0, 'abc'.search(new RegExp('^'))); + + // 'abc1'.search(/.\d/) + testcases[count++] = new TestCase ( SECTION, "'abc1'.search(/.\d/)", + 2, 'abc1'.search(/.\d/)); + + // 'abc1'.search(/\d{2}/) + testcases[count++] = new TestCase ( SECTION, "'abc1'.search(/\d{2}/)", + -1, 'abc1'.search(/\d{2}/)); + +function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/string_split.js b/tests/mozilla/js1_2/regexp/string_split.js new file mode 100644 index 0000000..f824998 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/string_split.js @@ -0,0 +1,91 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: string_split.js + Description: 'Tests the split method on Strings using regular expressions' + + Author: Nick Lerissa + Date: March 11, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'String: split'; + + writeHeaderToLog('Executing script: string_split.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'a b c de f'.split(/\s/) + testcases[count++] = new TestCase ( SECTION, "'a b c de f'.split(/\s/)", + String(["a","b","c","de","f"]), String('a b c de f'.split(/\s/))); + + // 'a b c de f'.split(/\s/,3) + testcases[count++] = new TestCase ( SECTION, "'a b c de f'.split(/\s/,3)", + String(["a","b","c"]), String('a b c de f'.split(/\s/,3))); + + // 'a b c de f'.split(/X/) + testcases[count++] = new TestCase ( SECTION, "'a b c de f'.split(/X/)", + String(["a b c de f"]), String('a b c de f'.split(/X/))); + + // 'dfe23iu 34 =+65--'.split(/\d+/) + testcases[count++] = new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(/\d+/)", + String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(/\d+/))); + + // 'dfe23iu 34 =+65--'.split(new RegExp('\d+')) + testcases[count++] = new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(new RegExp('\\d+'))", + String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(new RegExp('\\d+')))); + + // 'abc'.split(/[a-z]/) + testcases[count++] = new TestCase ( SECTION, "'abc'.split(/[a-z]/)", + String(["","",""]), String('abc'.split(/[a-z]/))); + + // 'abc'.split(/[a-z]/) + testcases[count++] = new TestCase ( SECTION, "'abc'.split(/[a-z]/)", + String(["","",""]), String('abc'.split(/[a-z]/))); + + // 'abc'.split(new RegExp('[a-z]')) + testcases[count++] = new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))", + String(["","",""]), String('abc'.split(new RegExp('[a-z]')))); + + // 'abc'.split(new RegExp('[a-z]')) + testcases[count++] = new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))", + String(["","",""]), String('abc'.split(new RegExp('[a-z]')))); + +function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/test.js b/tests/mozilla/js1_2/regexp/test.js new file mode 100644 index 0000000..2325af1 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/test.js @@ -0,0 +1,87 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: test.js + Description: 'Tests regular expressions method compile' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: test'; + + writeHeaderToLog('Executing script: test.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + testcases[count++] = new TestCase ( SECTION, + "/[0-9]{3}/.test('23 2 34 678 9 09')", + true, /[0-9]{3}/.test('23 2 34 678 9 09')); + + testcases[count++] = new TestCase ( SECTION, + "/[0-9]{3}/.test('23 2 34 78 9 09')", + false, /[0-9]{3}/.test('23 2 34 78 9 09')); + + testcases[count++] = new TestCase ( SECTION, + "/\w+ \w+ \w+/.test('do a test')", + true, /\w+ \w+ \w+/.test("do a test")); + + testcases[count++] = new TestCase ( SECTION, + "/\w+ \w+ \w+/.test('a test')", + false, /\w+ \w+ \w+/.test("a test")); + + testcases[count++] = new TestCase ( SECTION, + "(new RegExp('[0-9]{3}')).test('23 2 34 678 9 09')", + true, (new RegExp('[0-9]{3}')).test('23 2 34 678 9 09')); + + testcases[count++] = new TestCase ( SECTION, + "(new RegExp('[0-9]{3}')).test('23 2 34 78 9 09')", + false, (new RegExp('[0-9]{3}')).test('23 2 34 78 9 09')); + + testcases[count++] = new TestCase ( SECTION, + "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('do a test')", + true, (new RegExp('\\w+ \\w+ \\w+')).test("do a test")); + + testcases[count++] = new TestCase ( SECTION, + "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('a test')", + false, (new RegExp('\\w+ \\w+ \\w+')).test("a test")); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/toString.js b/tests/mozilla/js1_2/regexp/toString.js new file mode 100644 index 0000000..554b934 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/toString.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: toString.js + Description: 'Tests RegExp method toString' + + Author: Nick Lerissa + Date: March 13, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: toString'; + + writeHeaderToLog('Executing script: toString.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // var re = new RegExp(); re.toString() + var re = new RegExp(); + testcases[count++] = new TestCase ( SECTION, "var re = new RegExp(); re.toString()", + '//', re.toString()); + + // re = /.+/; re.toString(); + re = /.+/; + testcases[count++] = new TestCase ( SECTION, "re = /.+/; re.toString()", + '/.+/', re.toString()); + + // re = /test/gi; re.toString() + re = /test/gi; + testcases[count++] = new TestCase ( SECTION, "re = /test/gi; re.toString()", + '/test/gi', re.toString()); + + // re = /test2/ig; re.toString() + re = /test2/ig; + testcases[count++] = new TestCase ( SECTION, "re = /test2/ig; re.toString()", + '/test2/gi', re.toString()); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/vertical_bar.js b/tests/mozilla/js1_2/regexp/vertical_bar.js new file mode 100644 index 0000000..39b428a --- /dev/null +++ b/tests/mozilla/js1_2/regexp/vertical_bar.js @@ -0,0 +1,95 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: vertical_bar.js + Description: 'Tests regular expressions containing |' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: |'; + + writeHeaderToLog('Executing script: vertical_bar.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'abc'.match(new RegExp('xyz|abc')) + testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|abc'))", + String(["abc"]), String('abc'.match(new RegExp('xyz|abc')))); + + // 'this is a test'.match(new RegExp('quiz|exam|test|homework')) + testcases[count++] = new TestCase ( SECTION, "'this is a test'.match(new RegExp('quiz|exam|test|homework'))", + String(["test"]), String('this is a test'.match(new RegExp('quiz|exam|test|homework')))); + + // 'abc'.match(new RegExp('xyz|...')) + testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|...'))", + String(["abc"]), String('abc'.match(new RegExp('xyz|...')))); + + // 'abc'.match(new RegExp('(.)..|abc')) + testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('(.)..|abc'))", + String(["abc","a"]), String('abc'.match(new RegExp('(.)..|abc')))); + + // 'color: grey'.match(new RegExp('.+: gr(a|e)y')) + testcases[count++] = new TestCase ( SECTION, "'color: grey'.match(new RegExp('.+: gr(a|e)y'))", + String(["color: grey","e"]), String('color: grey'.match(new RegExp('.+: gr(a|e)y')))); + + // 'no match'.match(new RegExp('red|white|blue')) + testcases[count++] = new TestCase ( SECTION, "'no match'.match(new RegExp('red|white|blue'))", + null, 'no match'.match(new RegExp('red|white|blue'))); + + // 'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)')) + testcases[count++] = new TestCase ( SECTION, "'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))", + String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)')))); + + // 'abcdef'.match(new RegExp('abc|bcd|cde|def')) + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('abc|bcd|cde|def'))", + String(["abc"]), String('abcdef'.match(new RegExp('abc|bcd|cde|def')))); + + // 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/) + testcases[count++] = new TestCase ( SECTION, "'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)", + String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/))); + + // 'abcdef'.match(/abc|bcd|cde|def/) + testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/abc|bcd|cde|def/)", + String(["abc"]), String('abcdef'.match(/abc|bcd|cde|def/))); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/whitespace.js b/tests/mozilla/js1_2/regexp/whitespace.js new file mode 100644 index 0000000..40c78c3 --- /dev/null +++ b/tests/mozilla/js1_2/regexp/whitespace.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: whitespace.js + Description: 'Tests regular expressions containing \f\n\r\t\v\s\S\ ' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: \\f\\n\\r\\t\\v\\s\\S '; + + writeHeaderToLog('Executing script: whitespace.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + var non_whitespace = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()-+={[}]|\\:;'<,>./?1234567890" + '"'; + var whitespace = "\f\n\r\t\v "; + + // be sure all whitespace is matched by \s + testcases[count++] = new TestCase ( SECTION, + "'" + whitespace + "'.match(new RegExp('\\s+'))", + String([whitespace]), String(whitespace.match(new RegExp('\\s+')))); + + // be sure all non-whitespace is matched by \S + testcases[count++] = new TestCase ( SECTION, + "'" + non_whitespace + "'.match(new RegExp('\\S+'))", + String([non_whitespace]), String(non_whitespace.match(new RegExp('\\S+')))); + + // be sure all non-whitespace is not matched by \s + testcases[count++] = new TestCase ( SECTION, + "'" + non_whitespace + "'.match(new RegExp('\\s'))", + null, non_whitespace.match(new RegExp('\\s'))); + + // be sure all whitespace is not matched by \S + testcases[count++] = new TestCase ( SECTION, + "'" + whitespace + "'.match(new RegExp('\\S'))", + null, whitespace.match(new RegExp('\\S'))); + + var s = non_whitespace + whitespace; + + // be sure all digits are matched by \s + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\s+'))", + String([whitespace]), String(s.match(new RegExp('\\s+')))); + + s = whitespace + non_whitespace; + + // be sure all non-whitespace are matched by \S + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\S+'))", + String([non_whitespace]), String(s.match(new RegExp('\\S+')))); + + // '1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+')) + testcases[count++] = new TestCase ( SECTION, "'1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+'))", + String(["find me"]), String('1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+')))); + + var i; + + // be sure all whitespace characters match individually + for (i = 0; i < whitespace.length; ++i) + { + s = 'ab' + whitespace[i] + 'cd'; + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\\\s'))", + String([whitespace[i]]), String(s.match(new RegExp('\\s')))); + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(/\s/)", + String([whitespace[i]]), String(s.match(/\s/))); + } + // be sure all non_whitespace characters match individually + for (i = 0; i < non_whitespace.length; ++i) + { + s = ' ' + non_whitespace[i] + ' '; + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\\\S'))", + String([non_whitespace[i]]), String(s.match(new RegExp('\\S')))); + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(/\S/)", + String([non_whitespace[i]]), String(s.match(/\S/))); + } + + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regexp/word_boundary.js b/tests/mozilla/js1_2/regexp/word_boundary.js new file mode 100644 index 0000000..581499c --- /dev/null +++ b/tests/mozilla/js1_2/regexp/word_boundary.js @@ -0,0 +1,119 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: word_boundary.js + Description: 'Tests regular expressions containing \b and \B' + + Author: Nick Lerissa + Date: March 10, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'RegExp: \\b and \\B'; + + writeHeaderToLog('Executing script: word_boundary.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // 'cowboy boyish boy'.match(new RegExp('\bboy\b')) + testcases[count++] = new TestCase ( SECTION, "'cowboy boyish boy'.match(new RegExp('\\bboy\\b'))", + String(["boy"]), String('cowboy boyish boy'.match(new RegExp('\\bboy\\b')))); + + var boundary_characters = "\f\n\r\t\v~`!@#$%^&*()-+={[}]|\\:;'<,>./? " + '"'; + var non_boundary_characters = '1234567890_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + var s = ''; + var i; + + // testing whether all boundary characters are matched when they should be + for (i = 0; i < boundary_characters.length; ++i) + { + s = '123ab' + boundary_characters.charAt(i) + '123c' + boundary_characters.charAt(i); + + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\b123[a-z]\\b'))", + String(["123c"]), String(s.match(new RegExp('\\b123[a-z]\\b')))); + } + + // testing whether all non-boundary characters are matched when they should be + for (i = 0; i < non_boundary_characters.length; ++i) + { + s = '123ab' + non_boundary_characters.charAt(i) + '123c' + non_boundary_characters.charAt(i); + + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\B123[a-z]\\B'))", + String(["123c"]), String(s.match(new RegExp('\\B123[a-z]\\B')))); + } + + s = ''; + + // testing whether all boundary characters are not matched when they should not be + for (i = 0; i < boundary_characters.length; ++i) + { + s += boundary_characters[i] + "a" + i + "b"; + } + s += "xa1111bx"; + + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\Ba\\d+b\\B'))", + String(["a1111b"]), String(s.match(new RegExp('\\Ba\\d+b\\B')))); + + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(/\\Ba\\d+b\\B/)", + String(["a1111b"]), String(s.match(/\Ba\d+b\B/))); + + s = ''; + + // testing whether all non-boundary characters are not matched when they should not be + for (i = 0; i < non_boundary_characters.length; ++i) + { + s += non_boundary_characters[i] + "a" + i + "b"; + } + s += "(a1111b)"; + + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\ba\\d+b\\b'))", + String(["a1111b"]), String(s.match(new RegExp('\\ba\\d+b\\b')))); + + testcases[count++] = new TestCase ( SECTION, + "'" + s + "'.match(/\\ba\\d+b\\b/)", + String(["a1111b"]), String(s.match(/\ba\d+b\b/))); + + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/regress/regress-144834.js b/tests/mozilla/js1_2/regress/regress-144834.js new file mode 100644 index 0000000..cfbfc1b --- /dev/null +++ b/tests/mozilla/js1_2/regress/regress-144834.js @@ -0,0 +1,76 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): bzbarsky@mit.edu, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 05 July 2002 +* SUMMARY: Testing local var having same name as switch label inside function +* +* The code below crashed while compiling in JS1.1 or JS1.2 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=144834 +* +*/ +//----------------------------------------------------------------------------- +var bug = 144834; +var summary = 'Local var having same name as switch label inside function'; + +print(bug); +print(summary); + + +function RedrawSched() +{ + var MinBound; + + switch (i) + { + case MinBound : + } +} + + +/* + * Also try eval scope - + */ +var s = ''; +s += 'function RedrawSched()'; +s += '{'; +s += ' var MinBound;'; +s += ''; +s += ' switch (i)'; +s += ' {'; +s += ' case MinBound :'; +s += ' }'; +s += '}'; +eval(s); diff --git a/tests/mozilla/js1_2/regress/regress-7703.js b/tests/mozilla/js1_2/regress/regress-7703.js new file mode 100644 index 0000000..7808d9b --- /dev/null +++ b/tests/mozilla/js1_2/regress/regress-7703.js @@ -0,0 +1,83 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/** + * File Name: regress-7703.js + * Reference: "http://bugzilla.mozilla.org/show_bug.cgi?id=7703"; + * Description: See the text of the bugnumber above + */ + + var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) + var VERSION = "JS1_2"; // Version of JavaScript or ECMA + var TITLE = "Regression test for bugzilla # 7703"; // Provide ECMA section title or a description + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7703"; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + /* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + + types = []; + function inspect(object) { + for (prop in object) { + var x = object[prop]; + types[types.length] = (typeof x); + } + } + + var o = {a: 1, b: 2}; + inspect(o); + + AddTestCase( "inspect(o),length", 2, types.length ); + AddTestCase( "inspect(o)[0]", "number", types[0] ); + AddTestCase( "inspect(o)[1]", "number", types[1] ); + + types_2 = []; + + function inspect_again(object) { + for (prop in object) { + types_2[types_2.length] = (typeof object[prop]); + } + } + + inspect_again(o); + AddTestCase( "inspect_again(o),length", 2, types.length ); + AddTestCase( "inspect_again(o)[0]", "number", types[0] ); + AddTestCase( "inspect_again(o)[1]", "number", types[1] ); + + + test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/tests/mozilla/js1_2/shell.js b/tests/mozilla/js1_2/shell.js new file mode 100644 index 0000000..ba57d61 --- /dev/null +++ b/tests/mozilla/js1_2/shell.js @@ -0,0 +1,147 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +var completed = false; +var testcases; + +var SECTION = ""; +var VERSION = ""; +var BUGNUMBER = ""; + +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +startTest(); + + version(120); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + + this.passed = getTestCaseResult( this.expect, this.actual ); +} +function startTest() { + version(120); + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +/* + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. + */ + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +/* end of print functions */ + +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } +} diff --git a/tests/mozilla/js1_2/statements/break.js b/tests/mozilla/js1_2/statements/break.js new file mode 100644 index 0000000..ffe177d --- /dev/null +++ b/tests/mozilla/js1_2/statements/break.js @@ -0,0 +1,162 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: break.js + Description: 'Tests the break statement' + + Author: Nick Lerissa + Date: March 18, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'statements: break'; + + writeHeaderToLog("Executing script: break.js"); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + var i,j; + + for (i = 0; i < 1000; i++) + { + if (i == 100) break; + } + + // 'breaking out of "for" loop' + testcases[count++] = new TestCase ( SECTION, 'breaking out of "for" loop', + 100, i); + + j = 2000; + + out1: + for (i = 0; i < 1000; i++) + { + if (i == 100) + { + out2: + for (j = 0; j < 1000; j++) + { + if (j == 500) break out1; + } + j = 2001; + } + j = 2002; + } + + // 'breaking out of a "for" loop with a "label"' + testcases[count++] = new TestCase ( SECTION, 'breaking out of a "for" loop with a "label"', + 500, j); + + i = 0; + + while (i < 1000) + { + if (i == 100) break; + i++; + } + + // 'breaking out of a "while" loop' + testcases[count++] = new TestCase ( SECTION, 'breaking out of a "while" loop', + 100, i ); + + + j = 2000; + i = 0; + + out3: + while (i < 1000) + { + if (i == 100) + { + j = 0; + out4: + while (j < 1000) + { + if (j == 500) break out3; + j++; + } + j = 2001; + } + j = 2002; + i++; + } + + // 'breaking out of a "while" loop with a "label"' + testcases[count++] = new TestCase ( SECTION, 'breaking out of a "while" loop with a "label"', + 500, j); + + i = 0; + + do + { + if (i == 100) break; + i++; + } while (i < 1000); + + // 'breaking out of a "do" loop' + testcases[count++] = new TestCase ( SECTION, 'breaking out of a "do" loop', + 100, i ); + + j = 2000; + i = 0; + + out5: + do + { + if (i == 100) + { + j = 0; + out6: + do + { + if (j == 500) break out5; + j++; + }while (j < 1000); + j = 2001; + } + j = 2002; + i++; + }while (i < 1000); + + // 'breaking out of a "do" loop with a "label"' + testcases[count++] = new TestCase ( SECTION, 'breaking out of a "do" loop with a "label"', + 500, j); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/statements/continue.js b/tests/mozilla/js1_2/statements/continue.js new file mode 100644 index 0000000..e27b9df --- /dev/null +++ b/tests/mozilla/js1_2/statements/continue.js @@ -0,0 +1,175 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: continue.js + Description: 'Tests the continue statement' + + Author: Nick Lerissa + Date: March 18, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'statements: continue'; + + writeHeaderToLog("Executing script: continue.js"); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + var i,j; + + j = 0; + for (i = 0; i < 200; i++) + { + if (i == 100) + continue; + j++; + } + + // '"continue" in a "for" loop' + testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop', + 199, j); + + + j = 0; + out1: + for (i = 0; i < 1000; i++) + { + if (i == 100) + { + out2: + for (var k = 0; k < 1000; k++) + { + if (k == 500) continue out1; + } + j = 3000; + } + j++; + } + + // '"continue" in a "for" loop with a "label"' + testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop with a "label"', + 999, j); + + i = 0; + j = 1; + + while (i != j) + { + i++; + if (i == 100) continue; + j++; + } + + // '"continue" in a "while" loop' + testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop', + 100, j ); + + j = 0; + i = 0; + out3: + while (i < 1000) + { + if (i == 100) + { + var k = 0; + out4: + while (k < 1000) + { + if (k == 500) + { + i++; + continue out3; + } + k++; + } + j = 3000; + } + j++; + i++; + } + + // '"continue" in a "while" loop with a "label"' + testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop with a "label"', + 999, j); + + i = 0; + j = 1; + + do + { + i++; + if (i == 100) continue; + j++; + } while (i != j); + + + // '"continue" in a "do" loop' + testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop', + 100, j ); + + j = 0; + i = 0; + out5: + do + { + if (i == 100) + { + var k = 0; + out6: + do + { + if (k == 500) + { + i++; + continue out5; + } + k++; + }while (k < 1000); + j = 3000; + } + j++; + i++; + }while (i < 1000); + + // '"continue" in a "do" loop with a "label"' + testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop with a "label"', + 999, j); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/statements/do_while.js b/tests/mozilla/js1_2/statements/do_while.js new file mode 100644 index 0000000..d54ac78 --- /dev/null +++ b/tests/mozilla/js1_2/statements/do_while.js @@ -0,0 +1,68 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: do_while.js + Description: 'This tests the new do_while loop' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'statements: do_while'; + + writeHeaderToLog('Executing script: do_while.js'); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + + var done = false; + var x = 0; + do + { + if (x++ == 3) done = true; + } while (!done); + + testcases[count++] = new TestCase( SECTION, "do_while ", + 4, x); + + //load('d:/javascript/tests/output/statements/do_while.js') + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); + diff --git a/tests/mozilla/js1_2/statements/switch.js b/tests/mozilla/js1_2/statements/switch.js new file mode 100644 index 0000000..f6678c5 --- /dev/null +++ b/tests/mozilla/js1_2/statements/switch.js @@ -0,0 +1,127 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: switch.js + Description: 'Tests the switch statement' + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696 + + Author: Nick Lerissa + Date: March 19, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'statements: switch'; + var BUGNUMBER="323696"; + + writeHeaderToLog("Executing script: switch.js"); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + var var1 = "match string"; + var match1 = false; + var match2 = false; + var match3 = false; + + switch (var1) + { + case "match string": + match1 = true; + case "bad string 1": + match2 = true; + break; + case "bad string 2": + match3 = true; + } + + testcases[count++] = new TestCase ( SECTION, 'switch statement', + true, match1); + + testcases[count++] = new TestCase ( SECTION, 'switch statement', + true, match2); + + testcases[count++] = new TestCase ( SECTION, 'switch statement', + false, match3); + + var var2 = 3; + + var match1 = false; + var match2 = false; + var match3 = false; + var match4 = false; + var match5 = false; + + switch (var2) + { + case 1: +/* switch (var1) + { + case "foo": + match1 = true; + break; + case 3: + match2 = true; + break; + }*/ + match3 = true; + break; + case 2: + match4 = true; + break; + case 3: + match5 = true; + break; + } + testcases[count++] = new TestCase ( SECTION, 'switch statement', + false, match1); + + testcases[count++] = new TestCase ( SECTION, 'switch statement', + false, match2); + + testcases[count++] = new TestCase ( SECTION, 'switch statement', + false, match3); + + testcases[count++] = new TestCase ( SECTION, 'switch statement', + false, match4); + + testcases[count++] = new TestCase ( SECTION, 'switch statement', + true, match5); + + function test() + { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } + + test(); diff --git a/tests/mozilla/js1_2/statements/switch2.js b/tests/mozilla/js1_2/statements/switch2.js new file mode 100644 index 0000000..5d35f8c --- /dev/null +++ b/tests/mozilla/js1_2/statements/switch2.js @@ -0,0 +1,188 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + Filename: switch2.js + Description: 'Tests the switch statement' + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696 + + Author: Norris Boyd + Date: July 31, 1998 +*/ + + var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; + var VERSION = 'no version'; + startTest(); + var TITLE = 'statements: switch'; + var BUGNUMBER="323626"; + + writeHeaderToLog("Executing script: switch2.js"); + writeHeaderToLog( SECTION + " "+ TITLE); + + var count = 0; + var testcases = new Array(); + + // test defaults not at the end; regression test for a bug that + // nearly made it into 4.06 + function f0(i) { + switch(i) { + default: + case "a": + case "b": + return "ab*" + case "c": + return "c"; + case "d": + return "d"; + } + return ""; + } + testcases[count++] = new TestCase(SECTION, 'switch statement', + f0("a"), "ab*"); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f0("b"), "ab*"); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f0("*"), "ab*"); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f0("c"), "c"); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f0("d"), "d"); + + function f1(i) { + switch(i) { + case "a": + case "b": + default: + return "ab*" + case "c": + return "c"; + case "d": + return "d"; + } + return ""; + } + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f1("a"), "ab*"); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f1("b"), "ab*"); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f1("*"), "ab*"); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f1("c"), "c"); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f1("d"), "d"); + + // Switch on integer; will use TABLESWITCH opcode in C engine + function f2(i) { + switch (i) { + case 0: + case 1: + return 1; + case 2: + return 2; + } + // with no default, control will fall through + return 3; + } + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f2(0), 1); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f2(1), 1); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f2(2), 2); + + testcases[count++] = new TestCase(SECTION, 'switch statement', + f2(3), 3); + + // empty switch: make sure expression is evaluated + var se = 0; + switch (se = 1) { + } + testcases[count++] = new TestCase(SECTION, 'switch statement', + se, 1); + + // only default + se = 0; + switch (se) { + default: + se = 1; + } + testcases[count++] = new TestCase(SECTION, 'switch statement', + se, 1); + + // in loop, break should only break out of switch + se = 0; + for (var i=0; i < 2; i++) { + switch (i) { + case 0: + case 1: + break; + } + se = 1; + } + testcases[count++] = new TestCase(SECTION, 'switch statement', + se, 1); + + // test "fall through" + se = 0; + i = 0; + switch (i) { + case 0: + se++; + /* fall through */ + case 1: + se++; + break; + } + testcases[count++] = new TestCase(SECTION, 'switch statement', + se, 2); + + test(); + + // Needed: tests for evaluation time of case expressions. + // This issue was under debate at ECMA, so postponing for now. + + function test() { + writeLineToLog("hi"); + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); + } diff --git a/tests/mozilla/js1_2/version120/boolean-001.js b/tests/mozilla/js1_2/version120/boolean-001.js new file mode 100644 index 0000000..55fafe4 --- /dev/null +++ b/tests/mozilla/js1_2/version120/boolean-001.js @@ -0,0 +1,73 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: boolean-001.js + * Description: + * + * In JavaScript 1.2, new Boolean(false) evaluates to false. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "boolean-001.js"; + var VERSION = "JS1_2"; + startTest(); + var TITLE = "new Boolean(false) should evaluate to false"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + BooleanTest( "new Boolean(true)", new Boolean(true), true ); + BooleanTest( "new Boolean(false)", new Boolean(false), false ); + BooleanTest( "true", true, true ); + BooleanTest( "false", false, false ); + + test(); + +function BooleanTest( string, object, expect ) { + if ( object ) { + result = true; + } else { + result = false; + } + + testcases[tc++] = new TestCase( + SECTION, + string, + expect, + result ); +} + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_2/version120/regress-99663.js b/tests/mozilla/js1_2/version120/regress-99663.js new file mode 100644 index 0000000..75131ee --- /dev/null +++ b/tests/mozilla/js1_2/version120/regress-99663.js @@ -0,0 +1,172 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): brendan@mozilla.org, pschwartau@netscape.com +* Date: 09 October 2001 +* +* SUMMARY: Regression test for Bugzilla bug 99663 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=99663 +* +******************************************************************************* +******************************************************************************* +* ESSENTIAL!: this test should contain, or be loaded after, a call to +* +* version(120); +* +* Only JS version 1.2 or less has the behavior we're expecting here - +* +* Brendan: "The JS_SetVersion stickiness is necessary for tests such as +* this one to work properly. I think the existing js/tests have been lucky +* in dodging the buggy way that JS_SetVersion's effect can be undone by +* function return." +* +* Note: it is the function statements for f1(), etc. that MUST be compiled +* in JS version 1.2 or less for the test to pass - +* +******************************************************************************* +******************************************************************************* +* +* +* NOTE: the test uses the |it| object of SpiderMonkey; don't run it in Rhino - +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 99663; +var summary = 'Regression test for Bugzilla bug 99663'; +/* + * This testcase expects error messages containing + * the phrase 'read-only' or something similar - + */ +var READONLY = /read\s*-?\s*only/; +var READONLY_TRUE = 'a "read-only" error'; +var READONLY_FALSE = 'Error: '; +var FAILURE = 'NO ERROR WAS GENERATED!'; +var status = ''; +var actual = ''; +var expect= ''; +var statusitems = []; +var expectedvalues = []; +var actualvalues = []; + + +/* + * These MUST be compiled in JS1.2 or less for the test to work - see above + */ +function f1() +{ + with (it) + { + for (rdonly in this); + } +} + + +function f2() +{ + for (it.rdonly in this); +} + + +function f3(s) +{ + for (it[s] in this); +} + + + +/* + * Begin testing by capturing actual vs. expected values. + * Initialize to FAILURE; this will get reset if all goes well - + */ +actual = FAILURE; +try +{ + f1(); +} +catch(e) +{ + actual = readOnly(e.message); +} +expect= READONLY_TRUE; +status = 'Section 1 of test - got ' + actual; +addThis(); + + +actual = FAILURE; +try +{ + f2(); +} +catch(e) +{ + actual = readOnly(e.message); +} +expect= READONLY_TRUE; +status = 'Section 2 of test - got ' + actual; +addThis(); + + +actual = FAILURE; +try +{ + f3('rdonly'); +} +catch(e) +{ + actual = readOnly(e.message); +} +expect= READONLY_TRUE; +status = 'Section 3 of test - got ' + actual; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function readOnly(msg) +{ + if (msg.match(READONLY)) + return READONLY_TRUE; + return READONLY_FALSE + msg; +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + writeLineToLog ('Bug Number ' + bug); + writeLineToLog ('STATUS: ' + summary); + + for (var i=0; i version(100) + * 120 + * js> eval("function f(){}function g(){}") + * js> version(120); + * 100 + * js> eval("function f(){}function g(){}") + * js> + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "function-001.js"; + var VERSION = "JS_1.3"; + var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; + var BUGNUMBER="10278"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\")", + "error", + eval("function f(){}function g(){}") ); + + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/Script/function-002.js b/tests/mozilla/js1_3/Script/function-002.js new file mode 100644 index 0000000..d3d1d85 --- /dev/null +++ b/tests/mozilla/js1_3/Script/function-002.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: function-002.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=249579 + + function definitions in conditional statements should be allowed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "function-002"; + var VERSION = "JS1_3"; + var TITLE = "Regression test for 249579"; + var BUGNUMBER="249579"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( + SECTION, + "0?function(){}:0", + 0, + 0?function(){}:0 ); + + + bar = true; + foo = bar ? function () { return true; } : function() { return false; }; + + testcases[tc++] = new TestCase( + SECTION, + "bar = true; foo = bar ? function () { return true; } : function() { return false; }; foo()", + true, + foo() ); + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/Script/in-001.js b/tests/mozilla/js1_3/Script/in-001.js new file mode 100644 index 0000000..d9d76fe --- /dev/null +++ b/tests/mozilla/js1_3/Script/in-001.js @@ -0,0 +1,52 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: in-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=196109 + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "in-001"; + var VERSION = "JS1_3"; + var TITLE = "Regression test for 196109"; + var BUGNUMBER="196109"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + o = {}; + o.foo = 'sil'; + + testcases[tc++] = new TestCase( + SECTION, + "\"foo\" in o", + true, + "foo" in o ); + + test(); diff --git a/tests/mozilla/js1_3/Script/new-001.js b/tests/mozilla/js1_3/Script/new-001.js new file mode 100644 index 0000000..2868eca --- /dev/null +++ b/tests/mozilla/js1_3/Script/new-001.js @@ -0,0 +1,120 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: new-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=76103 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "new-001"; + var VERSION = "JS1_3"; + var TITLE = "new-001"; + var BUGNUMBER="31567"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + function Test_One (x) { + this.v = x+1; + return x*2 + } + + function Test_Two( x, y ) { + this.v = x; + return y; + } + + testcases[tc++] = new TestCase( + SECTION, + "Test_One(18)", + 36, + Test_One(18) ); + + testcases[tc++] = new TestCase( + SECTION, + "new Test_One(18)", + "[object Object]", + new Test_One(18) +"" ); + + testcases[tc++] = new TestCase( + SECTION, + "new Test_One(18).v", + 19, + new Test_One(18).v ); + + testcases[tc++] = new TestCase( + SECTION, + "Test_Two(2,7)", + 7, + Test_Two(2,7) ); + + testcases[tc++] = new TestCase( + SECTION, + "new Test_Two(2,7)", + "[object Object]", + new Test_Two(2,7) +"" ); + + testcases[tc++] = new TestCase( + SECTION, + "new Test_Two(2,7).v", + 2, + new Test_Two(2,7).v ); + + testcases[tc++] = new TestCase( + SECTION, + "new (Function)(\"x\", \"return x+3\")(5,6)", + 8, + new (Function)("x","return x+3")(5,6) ); + + testcases[tc++] = new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123)", + "83", + new new Test_Two(String, 2).v(0123) +""); + + testcases[tc++] = new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123).length", + 2, + new new Test_Two(String, 2).v(0123).length ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/Script/script-001.js b/tests/mozilla/js1_3/Script/script-001.js new file mode 100644 index 0000000..5e7ec89 --- /dev/null +++ b/tests/mozilla/js1_3/Script/script-001.js @@ -0,0 +1,159 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: script-001.js + Section: + Description: new NativeScript object + + +js> parseInt(123,"hi") +123 +js> parseInt(123, "blah") +123 +js> s +js: s is not defined +js> s = new Script + +undefined; + + +js> s = new Script() + +undefined; + + +js> s.getJSClass +js> s.getJSClass = Object.prototype.toString +function toString() { + [native code] +} + +js> s.getJSClass() +[object Script] +js> s.compile( "return 3+4" ) +js: JavaScript exception: javax.javascript.EvaluatorException: " s.compile( "3+4" ) + +3 + 4; + + +js> typeof s +function +js> s() +Jit failure! +invalid opcode: 1 +Jit Pass1 Failure! +javax/javascript/gen/c13 initScript (Ljavax/javascript/Scriptable;)V +An internal JIT error has occurred. Please report this with .class +jit-bugs@itools.symantec.com + +7 +js> s.compile("3+4") + +3 + 4; + + +js> s() +Jit failure! +invalid opcode: 1 +Jit Pass1 Failure! +javax/javascript/gen/c17 initScript (Ljavax/javascript/Scriptable;)V +An internal JIT error has occurred. Please report this with .class +jit-bugs@itools.symantec.com + +7 +js> quit() + +C:\src\ns_priv\js\tests\ecma>shell + +C:\src\ns_priv\js\tests\ecma>java -classpath c:\cafe\java\JavaScope; +:\src\ns_priv\js\tests javax.javascript.examples.Shell +Symantec Java! JustInTime Compiler Version 210.054 for JDK 1.1.2 +Copyright (C) 1996-97 Symantec Corporation + +js> s = new Script("3+4") + +3 + 4; + + +js> s() +7 +js> s2 = new Script(); + +undefined; + + +js> s.compile( "3+4") + +3 + 4; + + +js> s() +Jit failure! +invalid opcode: 1 +Jit Pass1 Failure! +javax/javascript/gen/c7 initScript (Ljavax/javascript/Scriptable;)V +An internal JIT error has occurred. Please report this with .class +jit-bugs@itools.symantec.com + +7 +js> quit() + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "script-001"; + var VERSION = "JS1_3"; + var TITLE = "NativeScript"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var s = new Script(); + s.getJSClass = Object.prototype.toString; + + testcases[tc++] = new TestCase( SECTION, + "var s = new Script(); typeof s", + "function", + typeof s ); + + testcases[tc++] = new TestCase( SECTION, + "s.getJSClass()", + "[object Script]", + s.getJSClass() ); + + test(); +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/Script/switch-001.js b/tests/mozilla/js1_3/Script/switch-001.js new file mode 100644 index 0000000..b3f71d7 --- /dev/null +++ b/tests/mozilla/js1_3/Script/switch-001.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: switch-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315767 + + Verify that switches do not use strict equality in + versions of JavaScript < 1.4 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "switch-001"; + var VERSION = "JS1_3"; + var TITLE = "switch-001"; + var BUGNUMBER="315767"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + result = "fail: did not enter switch"; + + switch (true) { + case 1: + result = "fail: for backwards compatibility, version 130 use strict equality"; + break; + case true: + result = "pass"; + break; + default: + result = "fail: evaluated default statement"; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch / case should use strict equality in version of JS < 1.4", + "pass", + result ); + + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/inherit/proto_1.js b/tests/mozilla/js1_3/inherit/proto_1.js new file mode 100644 index 0000000..1d9915e --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_1.js @@ -0,0 +1,166 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_1.js + Section: + Description: new PrototypeObject + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_1"; + var VERSION = "JS1_3"; + var TITLE = "new PrototypeObject"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee () { + this.name = ""; + this.dept = "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee () { + this.projects = new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer () { + this.dept = "engineering"; + this.machine = ""; +} +Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + var jim = new Employee(); + + testcases[tc++] = new TestCase( SECTION, + "jim = new Employee(); jim.name", + "", + jim.name ); + + + testcases[tc++] = new TestCase( SECTION, + "jim = new Employee(); jim.dept", + "general", + jim.dept ); + + var sally = new Manager(); + + testcases[tc++] = new TestCase( SECTION, + "sally = new Manager(); sally.name", + "", + sally.name ); + testcases[tc++] = new TestCase( SECTION, + "sally = new Manager(); sally.dept", + "general", + sally.dept ); + + testcases[tc++] = new TestCase( SECTION, + "sally = new Manager(); sally.reports.length", + 0, + sally.reports.length ); + + testcases[tc++] = new TestCase( SECTION, + "sally = new Manager(); typeof sally.reports", + "object", + typeof sally.reports ); + + var fred = new SalesPerson(); + + testcases[tc++] = new TestCase( SECTION, + "fred = new SalesPerson(); fred.name", + "", + fred.name ); + + testcases[tc++] = new TestCase( SECTION, + "fred = new SalesPerson(); fred.dept", + "sales", + fred.dept ); + + testcases[tc++] = new TestCase( SECTION, + "fred = new SalesPerson(); fred.quota", + 100, + fred.quota ); + + testcases[tc++] = new TestCase( SECTION, + "fred = new SalesPerson(); fred.projects.length", + 0, + fred.projects.length ); + + var jane = new Engineer(); + + testcases[tc++] = new TestCase( SECTION, + "jane = new Engineer(); jane.name", + "", + jane.name ); + + testcases[tc++] = new TestCase( SECTION, + "jane = new Engineer(); jane.dept", + "engineering", + jane.dept ); + + testcases[tc++] = new TestCase( SECTION, + "jane = new Engineer(); jane.projects.length", + 0, + jane.projects.length ); + + testcases[tc++] = new TestCase( SECTION, + "jane = new Engineer(); jane.machine", + "", + jane.machine ); + + + test(); \ No newline at end of file diff --git a/tests/mozilla/js1_3/inherit/proto_10.js b/tests/mozilla/js1_3/inherit/proto_10.js new file mode 100644 index 0000000..e6d1b9a --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_10.js @@ -0,0 +1,152 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_10.js + Section: + Description: Determining Instance Relationships + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_10"; + var VERSION = "JS1_3"; + var TITLE = "Determining Instance Relationships"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function InstanceOf( object, constructor ) { + while ( object != null ) { + if ( object == constructor.prototype ) { + return true; + } + object = object.__proto__; + } + return false; +} +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} + +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + var pat = new Engineer() + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__ == WorkerBee.prototype", + true, + pat.__proto__.__proto__ == WorkerBee.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__ == Employee.prototype", + true, + pat.__proto__.__proto__.__proto__ == Employee.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", + true, + pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", + true, + pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); + + + testcases[tc++] = new TestCase( SECTION, + "InstanceOf( pat, Engineer )", + true, + InstanceOf( pat, Engineer ) ); + + testcases[tc++] = new TestCase( SECTION, + "InstanceOf( pat, WorkerBee )", + true, + InstanceOf( pat, WorkerBee ) ); + + testcases[tc++] = new TestCase( SECTION, + "InstanceOf( pat, Employee )", + true, + InstanceOf( pat, Employee ) ); + + testcases[tc++] = new TestCase( SECTION, + "InstanceOf( pat, Object )", + true, + InstanceOf( pat, Object ) ); + + testcases[tc++] = new TestCase( SECTION, + "InstanceOf( pat, SalesPerson )", + false, + InstanceOf ( pat, SalesPerson ) ); + test(); diff --git a/tests/mozilla/js1_3/inherit/proto_11.js b/tests/mozilla/js1_3/inherit/proto_11.js new file mode 100644 index 0000000..4e92b9b --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_11.js @@ -0,0 +1,115 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_11.js + Section: + Description: Global Information in Constructors + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_11"; + var VERSION = "JS1_3"; + var TITLE = "Global Information in Constructors"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + var idCounter = 1; + + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; + this.id = idCounter++; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + var pat = new Employee( "Toonces, Pat", "Tech Pubs" ) + var terry = new Employee( "O'Sherry Terry", "Marketing" ); + + var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" ); + + testcases[tc++] = new TestCase( SECTION, + "pat.id", + 5, + pat.id ); + + testcases[tc++] = new TestCase( SECTION, + "terry.id", + 6, + terry.id ); + + testcases[tc++] = new TestCase( SECTION, + "les.id", + 7, + les.id ); + + + test(); + diff --git a/tests/mozilla/js1_3/inherit/proto_12.js b/tests/mozilla/js1_3/inherit/proto_12.js new file mode 100644 index 0000000..93081a0 --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_12.js @@ -0,0 +1,142 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_12.js + Section: + Description: new PrototypeObject + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + No Multiple Inheritance + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_12"; + var VERSION = "JS1_3"; + var TITLE = "No Multiple Inheritance"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; + this.id = idCounter++; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Hobbyist( hobby ) { + this.hobby = hobby || "yodeling"; +} + +function Engineer ( name, projs, machine, hobby ) { + this.base1 = WorkerBee; + this.base1( name, "engineering", projs ) + + this.base2 = Hobbyist; + this.base2( hobby ); + + this.projects = projs || new Array(); + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + var idCounter = 1; + + var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" ); + + Hobbyist.prototype.equipment = [ "horn", "mountain", "goat" ]; + + testcases[tc++] = new TestCase( SECTION, + "les.name", + "Morris, Les", + les.name ); + + testcases[tc++] = new TestCase( SECTION, + "les.dept", + "engineering", + les.dept ); + + Array.prototype.getClass = Object.prototype.toString; + + testcases[tc++] = new TestCase( SECTION, + "les.projects.getClass()", + "[object Array]", + les.projects.getClass() ); + + testcases[tc++] = new TestCase( SECTION, + "les.projects[0]", + "JavaScript", + les.projects[0] ); + + testcases[tc++] = new TestCase( SECTION, + "les.machine", + "indy", + les.machine ); + + testcases[tc++] = new TestCase( SECTION, + "les.hobby", + "yodeling", + les.hobby ); + + testcases[tc++] = new TestCase( SECTION, + "les.equpment", + void 0, + les.equipment ); + + test(); diff --git a/tests/mozilla/js1_3/inherit/proto_2.js b/tests/mozilla/js1_3/inherit/proto_2.js new file mode 100644 index 0000000..1300ed3 --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_2.js @@ -0,0 +1,122 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_2.js + Section: + Description: new PrototypeObject + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_2"; + var VERSION = "JS1_3"; + var TITLE = "new PrototypeObject"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee () { + this.name = ""; + this.dept = "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee () { + this.projects = new Array(); +} + +WorkerBee.prototype = new Employee; + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee; + +function Engineer () { + this.dept = "engineering"; + this.machine = ""; +} +Engineer.prototype = new WorkerBee; + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + + var employee = new Employee(); + var manager = new Manager(); + var workerbee = new WorkerBee(); + var salesperson = new SalesPerson(); + var engineer = new Engineer(); + + testcases[tc++] = new TestCase( SECTION, + "employee.__proto__ == Employee.prototype", + true, + employee.__proto__ == Employee.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "manager.__proto__ == Manager.prototype", + true, + manager.__proto__ == Manager.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "workerbee.__proto__ == WorkerBee.prototype", + true, + workerbee.__proto__ == WorkerBee.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "salesperson.__proto__ == SalesPerson.prototype", + true, + salesperson.__proto__ == SalesPerson.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "engineer.__proto__ == Engineer.prototype", + true, + engineer.__proto__ == Engineer.prototype ); + + test(); + diff --git a/tests/mozilla/js1_3/inherit/proto_3.js b/tests/mozilla/js1_3/inherit/proto_3.js new file mode 100644 index 0000000..61fa033 --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_3.js @@ -0,0 +1,103 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_3.js + Section: + Description: Adding properties to an instance + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_3"; + var VERSION = "JS1_3"; + var TITLE = "Adding properties to an Instance"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee () { + this.name = ""; + this.dept = "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee () { + this.projects = new Array(); +} + +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer () { + this.dept = "engineering"; + this.machine = ""; +} +Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + var jim = new Employee(); + var pat = new Employee(); + + jim.bonus = 300; + + testcases[tc++] = new TestCase( SECTION, + "jim = new Employee(); jim.bonus = 300; jim.bonus", + 300, + jim.bonus ); + + + testcases[tc++] = new TestCase( SECTION, + "pat = new Employee(); pat.bonus", + void 0, + pat.bonus ); + test(); diff --git a/tests/mozilla/js1_3/inherit/proto_4.js b/tests/mozilla/js1_3/inherit/proto_4.js new file mode 100644 index 0000000..2006f76 --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_4.js @@ -0,0 +1,156 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_4.js + Section: + Description: new PrototypeObject + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + If you add a property to an object in the prototype chain, instances of + objects that derive from that prototype should inherit that property, even + if they were instatiated after the property was added to the prototype object. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_3"; + var VERSION = "JS1_3"; + var TITLE = "Adding properties to the prototype"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee () { + this.name = ""; + this.dept = "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee () { + this.projects = new Array(); +} + +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer () { + this.dept = "engineering"; + this.machine = ""; +} +Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + + var jim = new Employee(); + var terry = new Engineer(); + var sean = new SalesPerson(); + var wally = new Manager(); + + Employee.prototype.specialty = "none"; + + var pat = new Employee(); + var leslie = new Engineer(); + var bubbles = new SalesPerson(); + var furry = new Manager(); + + Engineer.prototype.specialty = "code"; + + var chris = new Engineer(); + + + testcases[tc++] = new TestCase( SECTION, + "jim = new Employee(); jim.specialty", + "none", + jim.specialty ); + + testcases[tc++] = new TestCase( SECTION, + "terry = new Engineer(); terry.specialty", + "code", + terry.specialty ); + + testcases[tc++] = new TestCase( SECTION, + "sean = new SalesPerson(); sean.specialty", + "none", + sean.specialty ); + + testcases[tc++] = new TestCase( SECTION, + "wally = new Manager(); wally.specialty", + "none", + wally.specialty ); + + testcases[tc++] = new TestCase( SECTION, + "furry = new Manager(); furry.specialty", + "none", + furry.specialty ); + + testcases[tc++] = new TestCase( SECTION, + "pat = new Employee(); pat.specialty", + "none", + pat.specialty ); + + testcases[tc++] = new TestCase( SECTION, + "leslie = new Engineer(); leslie.specialty", + "code", + leslie.specialty ); + + testcases[tc++] = new TestCase( SECTION, + "bubbles = new SalesPerson(); bubbles.specialty", + "none", + bubbles.specialty ); + + + testcases[tc++] = new TestCase( SECTION, + "chris = new Employee(); chris.specialty", + "code", + chris.specialty ); + test(); diff --git a/tests/mozilla/js1_3/inherit/proto_5.js b/tests/mozilla/js1_3/inherit/proto_5.js new file mode 100644 index 0000000..4c84d33 --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_5.js @@ -0,0 +1,146 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_5.js + Section: + Description: Logical OR || in Constructors + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + This tests the logical OR opererator || syntax in constructors. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_5"; + var VERSION = "JS1_3"; + var TITLE = "Logical OR || in Constructors"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( projs ) { + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( machine ) { + this.dept = "engineering"; + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + + + var pat = new Engineer( "indy" ); + + var les = new Engineer(); + + testcases[tc++] = new TestCase( SECTION, + "var pat = new Engineer(\"indy\"); pat.name", + "", + pat.name ); + + testcases[tc++] = new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects.length", + 0, + pat.projects.length ); + + testcases[tc++] = new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "var les = new Engineer(); les.name", + "", + les.name ); + + testcases[tc++] = new TestCase( SECTION, + "les.dept", + "engineering", + les.dept ); + + testcases[tc++] = new TestCase( SECTION, + "les.projects.length", + 0, + les.projects.length ); + + testcases[tc++] = new TestCase( SECTION, + "les.machine", + "", + les.machine ); + + testcases[tc++] = new TestCase( SECTION, + "les.__proto__ == Engineer.prototype", + true, + les.__proto__ == Engineer.prototype ); + + + test(); \ No newline at end of file diff --git a/tests/mozilla/js1_3/inherit/proto_6.js b/tests/mozilla/js1_3/inherit/proto_6.js new file mode 100644 index 0000000..15d4bdd --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_6.js @@ -0,0 +1,171 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_6.js + Section: + Description: Logical OR || in constructors + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + This tests the logical OR opererator || syntax in constructors. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_6"; + var VERSION = "JS1_3"; + var TITLE = "Logical OR || in constructors"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} + +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + + var pat = new Engineer( "Toonces, Pat", + ["SpiderMonkey", "Rhino"], + "indy" ); + + var les = new WorkerBee( "Morris, Les", + "Training", + ["Hippo"] ) + + var terry = new Employee( "Boomberi, Terry", + "Marketing" ); + + // Pat, the Engineer + + testcases[tc++] = new TestCase( SECTION, + "pat.name", + "Toonces, Pat", + pat.name ); + + testcases[tc++] = new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects.length", + 2, + pat.projects.length ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects[0]", + "SpiderMonkey", + pat.projects[0] ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects[1]", + "Rhino", + pat.projects[1] ); + + testcases[tc++] = new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); + + + // Les, the WorkerBee + + testcases[tc++] = new TestCase( SECTION, + "les.name", + "Morris, Les", + les.name ); + + testcases[tc++] = new TestCase( SECTION, + "les.dept", + "Training", + les.dept ); + + testcases[tc++] = new TestCase( SECTION, + "les.projects.length", + 1, + les.projects.length ); + + testcases[tc++] = new TestCase( SECTION, + "les.projects[0]", + "Hippo", + les.projects[0] ); + + // Terry, the Employee + testcases[tc++] = new TestCase( SECTION, + "terry.name", + "Boomberi, Terry", + terry.name ); + + testcases[tc++] = new TestCase( SECTION, + "terry.dept", + "Marketing", + terry.dept ); + test(); + diff --git a/tests/mozilla/js1_3/inherit/proto_7.js b/tests/mozilla/js1_3/inherit/proto_7.js new file mode 100644 index 0000000..207fa17 --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_7.js @@ -0,0 +1,125 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_7.js + Section: + Description: Adding Properties to the Prototype Object + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + This tests + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_6"; + var VERSION = "JS1_3"; + var TITLE = "Adding properties to the Prototype Object"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +// Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + var pat = new Engineer( "Toonces, Pat", + ["SpiderMonkey", "Rhino"], + "indy" ); + + Employee.prototype.specialty = "none"; + + + // Pat, the Engineer + + testcases[tc++] = new TestCase( SECTION, + "pat.name", + "Toonces, Pat", + pat.name ); + + testcases[tc++] = new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects.length", + 2, + pat.projects.length ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects[0]", + "SpiderMonkey", + pat.projects[0] ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects[1]", + "Rhino", + pat.projects[1] ); + + testcases[tc++] = new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); + + testcases[tc++] = new TestCase( SECTION, + "pat.specialty", + void 0, + pat.specialty ); + + test(); diff --git a/tests/mozilla/js1_3/inherit/proto_8.js b/tests/mozilla/js1_3/inherit/proto_8.js new file mode 100644 index 0000000..fa92d70 --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_8.js @@ -0,0 +1,123 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_8.js + Section: + Description: Adding Properties to the Prototype Object + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_8"; + var VERSION = "JS1_3"; + var TITLE = "Adding Properties to the Prototype Object"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + var pat = new Engineer( "Toonces, Pat", + ["SpiderMonkey", "Rhino"], + "indy" ); + + Employee.prototype.specialty = "none"; + + + // Pat, the Engineer + + testcases[tc++] = new TestCase( SECTION, + "pat.name", + "Toonces, Pat", + pat.name ); + + testcases[tc++] = new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects.length", + 2, + pat.projects.length ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects[0]", + "SpiderMonkey", + pat.projects[0] ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects[1]", + "Rhino", + pat.projects[1] ); + + testcases[tc++] = new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); + + testcases[tc++] = new TestCase( SECTION, + "pat.specialty", + "none", + pat.specialty ); + + test(); diff --git a/tests/mozilla/js1_3/inherit/proto_9.js b/tests/mozilla/js1_3/inherit/proto_9.js new file mode 100644 index 0000000..93989ca --- /dev/null +++ b/tests/mozilla/js1_3/inherit/proto_9.js @@ -0,0 +1,101 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: proto_9.js + Section: + Description: Local versus Inherited Values + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + This tests + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "proto_9"; + var VERSION = "JS1_3"; + var TITLE = "Local versus Inherited Values"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} +function WorkerBee ( name, dept, projs ) { + this.projects = new Array(); +} +WorkerBee.prototype = new Employee(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + var pat = new WorkerBee() + + Employee.prototype.specialty = "none"; + Employee.prototype.name = "Unknown"; + + Array.prototype.getClass = Object.prototype.toString; + + // Pat, the WorkerBee + + testcases[tc++] = new TestCase( SECTION, + "pat.name", + "", + pat.name ); + + testcases[tc++] = new TestCase( SECTION, + "pat.dept", + "general", + pat.dept ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects.getClass", + "[object Array]", + pat.projects.getClass() ); + + testcases[tc++] = new TestCase( SECTION, + "pat.projects.length", + 0, + pat.projects.length ); + + test(); \ No newline at end of file diff --git a/tests/mozilla/js1_3/jsref.js b/tests/mozilla/js1_3/jsref.js new file mode 100644 index 0000000..dd611a7 --- /dev/null +++ b/tests/mozilla/js1_3/jsref.js @@ -0,0 +1,198 @@ +var completed = false; +var testcases; + +SECTION = ""; +VERSION = ""; + +BUGNUMBER =""; +var EXCLUDE = ""; + +TZ_DIFF = -8; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; +var DEBUG = false; + +version(130); + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} +function startTest() { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + writeLineToLog( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeLineToLog( string ) { + print( string + BR + CR ); +} +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() +{ + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + } + print(doneTag); + + print( HR ); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} + +function Enumerate ( o ) { + var p; + for ( p in o ) { + writeLineToLog( p +": " + o[p] ); + } +} diff --git a/tests/mozilla/js1_3/regress/delete-001.js b/tests/mozilla/js1_3/regress/delete-001.js new file mode 100644 index 0000000..e2f4332 --- /dev/null +++ b/tests/mozilla/js1_3/regress/delete-001.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: delete-001.js + Section: regress + Description: + + Regression test for + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=108736 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "JS1_2"; + var VERSION = "JS1_2"; + var TITLE = "The variable statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // delete all properties of the global object + // per ecma, this does not affect variables in the global object declared + // with var or functions + + for ( p in this ) { + delete p; + } + + var result =""; + + for ( p in this ) { + result += String( p ); + } + + // not too picky here... just want to make sure we didn't crash or something + + testcases[testcases.length] = new TestCase( SECTION, + "delete all properties of the global object", + "PASSED", + result == "" ? "FAILED" : "PASSED" ); + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/regress/function-001-n.js b/tests/mozilla/js1_3/regress/function-001-n.js new file mode 100644 index 0000000..5b4add0 --- /dev/null +++ b/tests/mozilla/js1_3/regress/function-001-n.js @@ -0,0 +1,74 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: boolean-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232 + * + * eval("function f(){}function g(){}") at top level is an error for JS1.2 + * and above (missing ; between named function expressions), but declares f + * and g as functions below 1.2. + * + * Fails to produce error regardless of version: + * js> version(100) + * 120 + * js> eval("function f(){}function g(){}") + * js> version(120); + * 100 + * js> eval("function f(){}function g(){}") + * js> + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "function-001.js"; + var VERSION = "JS_1.3"; + var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; + var BUGNUMBER="10278"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\")", + "error", + eval("function f(){}function g(){}") ); + + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/regress/function-002.js b/tests/mozilla/js1_3/regress/function-002.js new file mode 100644 index 0000000..d3d1d85 --- /dev/null +++ b/tests/mozilla/js1_3/regress/function-002.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: function-002.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=249579 + + function definitions in conditional statements should be allowed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "function-002"; + var VERSION = "JS1_3"; + var TITLE = "Regression test for 249579"; + var BUGNUMBER="249579"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( + SECTION, + "0?function(){}:0", + 0, + 0?function(){}:0 ); + + + bar = true; + foo = bar ? function () { return true; } : function() { return false; }; + + testcases[tc++] = new TestCase( + SECTION, + "bar = true; foo = bar ? function () { return true; } : function() { return false; }; foo()", + true, + foo() ); + + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/regress/in-001.js b/tests/mozilla/js1_3/regress/in-001.js new file mode 100644 index 0000000..f524870 --- /dev/null +++ b/tests/mozilla/js1_3/regress/in-001.js @@ -0,0 +1,66 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: in-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=196109 + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "in-001"; + var VERSION = "JS1_3"; + var TITLE = "Regression test for 196109"; + var BUGNUMBER="196109"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + o = {}; + o.foo = 'sil'; + + testcases[tc++] = new TestCase( + SECTION, + "\"foo\" in o", + true, + "foo" in o ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/regress/new-001.js b/tests/mozilla/js1_3/regress/new-001.js new file mode 100644 index 0000000..2868eca --- /dev/null +++ b/tests/mozilla/js1_3/regress/new-001.js @@ -0,0 +1,120 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: new-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=76103 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "new-001"; + var VERSION = "JS1_3"; + var TITLE = "new-001"; + var BUGNUMBER="31567"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + function Test_One (x) { + this.v = x+1; + return x*2 + } + + function Test_Two( x, y ) { + this.v = x; + return y; + } + + testcases[tc++] = new TestCase( + SECTION, + "Test_One(18)", + 36, + Test_One(18) ); + + testcases[tc++] = new TestCase( + SECTION, + "new Test_One(18)", + "[object Object]", + new Test_One(18) +"" ); + + testcases[tc++] = new TestCase( + SECTION, + "new Test_One(18).v", + 19, + new Test_One(18).v ); + + testcases[tc++] = new TestCase( + SECTION, + "Test_Two(2,7)", + 7, + Test_Two(2,7) ); + + testcases[tc++] = new TestCase( + SECTION, + "new Test_Two(2,7)", + "[object Object]", + new Test_Two(2,7) +"" ); + + testcases[tc++] = new TestCase( + SECTION, + "new Test_Two(2,7).v", + 2, + new Test_Two(2,7).v ); + + testcases[tc++] = new TestCase( + SECTION, + "new (Function)(\"x\", \"return x+3\")(5,6)", + 8, + new (Function)("x","return x+3")(5,6) ); + + testcases[tc++] = new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123)", + "83", + new new Test_Two(String, 2).v(0123) +""); + + testcases[tc++] = new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123).length", + 2, + new new Test_Two(String, 2).v(0123).length ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/regress/switch-001.js b/tests/mozilla/js1_3/regress/switch-001.js new file mode 100644 index 0000000..47d8a44 --- /dev/null +++ b/tests/mozilla/js1_3/regress/switch-001.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + File Name: switch-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315767 + + Verify that switches do not use strict equality in + versions of JavaScript < 1.4. It's now been decided that + we won't put in version switches, so all switches will + be ECMA. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "switch-001"; + var VERSION = "JS1_3"; + var TITLE = "switch-001"; + var BUGNUMBER="315767"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + result = "fail: did not enter switch"; + + switch (true) { + case 1: + result = "fail: version 130 should force strict equality"; + break; + case true: + result = "pass"; + break; + default: + result = "fail: evaluated default statement"; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch / case should use strict equality in version of JS < 1.4", + "pass", + result ); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_3/shell.js b/tests/mozilla/js1_3/shell.js new file mode 100644 index 0000000..dc0ec4e --- /dev/null +++ b/tests/mozilla/js1_3/shell.js @@ -0,0 +1,163 @@ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; +DEBUG = false; + +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} +function startTest() { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( 130 ); + } + if ( VERSION == "JS_1.3" ) { + version ( 130 ); + } + if ( VERSION == "JS_1.2" ) { + version ( 120 ); + } + if ( VERSION == "JS_1.1" ) { + version ( 110 ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + writeLineToLog( s + FONT_ + B_ + TT_ ); + + return passed; +} +/* + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. + */ + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +/* end of print functions */ + +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } +} diff --git a/tests/mozilla/js1_3/template.js b/tests/mozilla/js1_3/template.js new file mode 100644 index 0000000..1958832 --- /dev/null +++ b/tests/mozilla/js1_3/template.js @@ -0,0 +1,44 @@ +/** + File Name: switch_1.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315767 + + Verify that switches do not use strict equality in + versions of JavaScript < 1.4 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +// onerror = err; + + var SECTION = "script_1; + var VERSION = "JS1_3"; + var TITLE = "NativeScript"; + var BUGNUMBER="31567"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + testcases[tc++] = new TestCase( SECTION, + + + test(); +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/tests/mozilla/js1_4/Eval/eval-001.js b/tests/mozilla/js1_4/Eval/eval-001.js new file mode 100644 index 0000000..38f9d04 --- /dev/null +++ b/tests/mozilla/js1_4/Eval/eval-001.js @@ -0,0 +1,75 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: eval-001.js + * Original Description: (SEE REVISED DESCRIPTION FURTHER BELOW) + * + * The global eval function may not be accessed indirectly and then called. + * This feature will continue to work in JavaScript 1.3 but will result in an + * error in JavaScript 1.4. This restriction is also in place for the With and + * Closure constructors. + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324451 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + * + * REVISION: 05 February 2001 + * Author: pschwartau@netscape.com + * + * Indirect eval IS NOT ILLEGAL per ECMA3!!! See + * + * http://bugzilla.mozilla.org/show_bug.cgi?id=38512 + * + * ------- Additional Comments From Brendan Eich 2001-01-30 17:12 ------- + * ECMA-262 Edition 3 doesn't require implementations to throw EvalError, + * see the short, section-less Chapter 16. It does say an implementation that + * doesn't throw EvalError must allow assignment to eval and indirect calls + * of the evalnative method. + * + */ + var SECTION = "eval-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Calling eval indirectly should NOT fail in version 140"; + var BUGNUMBER="38512"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var MY_EVAL = eval; + var RESULT = ""; + var EXPECT = "abcdefg"; + + MY_EVAL( "RESULT = EXPECT" ); + + testcases[tc++] = new TestCase( + SECTION, + "Call eval indirectly", + EXPECT, + RESULT ); + + test(); + diff --git a/tests/mozilla/js1_4/Eval/eval-002.js b/tests/mozilla/js1_4/Eval/eval-002.js new file mode 100644 index 0000000..159a9bd --- /dev/null +++ b/tests/mozilla/js1_4/Eval/eval-002.js @@ -0,0 +1,80 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: eval-002.js + * Description: (SEE REVISED DESCRIPTION FURTHER BELOW) + * + * The global eval function may not be accessed indirectly and then called. + * This feature will continue to work in JavaScript 1.3 but will result in an + * error in JavaScript 1.4. This restriction is also in place for the With and + * Closure constructors. + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324451 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + * + * REVISION: 05 February 2001 + * Author: pschwartau@netscape.com + * + * Indirect eval IS NOT ILLEGAL per ECMA3!!! See + * + * http://bugzilla.mozilla.org/show_bug.cgi?id=38512 + * + * ------- Additional Comments From Brendan Eich 2001-01-30 17:12 ------- + * ECMA-262 Edition 3 doesn't require implementations to throw EvalError, + * see the short, section-less Chapter 16. It does say an implementation that + * doesn't throw EvalError must allow assignment to eval and indirect calls + * of the evalnative method. + * + */ + var SECTION = "eval-002.js"; + var VERSION = "JS1_4"; + var TITLE = "Calling eval indirectly should NOT fail in version 140"; + var BUGNUMBER="38512"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var MY_EVAL = eval; + var RESULT = ""; + var EXPECT = 1 + "testString" + + EvalTest(); + + test(); + + +function EvalTest() +{ + MY_EVAL( "RESULT = EXPECT" ); + + testcases[tc++] = new TestCase( + SECTION, + "Call eval indirectly", + EXPECT, + RESULT ); +} + diff --git a/tests/mozilla/js1_4/Eval/eval-003.js b/tests/mozilla/js1_4/Eval/eval-003.js new file mode 100644 index 0000000..5c9f1ea --- /dev/null +++ b/tests/mozilla/js1_4/Eval/eval-003.js @@ -0,0 +1,85 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: eval-003.js + * Description: (SEE REVISED DESCRIPTION FURTHER BELOW) + * + * The global eval function may not be accessed indirectly and then called. + * This feature will continue to work in JavaScript 1.3 but will result in an + * error in JavaScript 1.4. This restriction is also in place for the With and + * Closure constructors. + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324451 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + * + * REVISION: 05 February 2001 + * Author: pschwartau@netscape.com + * + * Indirect eval IS NOT ILLEGAL per ECMA3!!! See + * + * http://bugzilla.mozilla.org/show_bug.cgi?id=38512 + * + * ------- Additional Comments From Brendan Eich 2001-01-30 17:12 ------- + * ECMA-262 Edition 3 doesn't require implementations to throw EvalError, + * see the short, section-less Chapter 16. It does say an implementation that + * doesn't throw EvalError must allow assignment to eval and indirect calls + * of the evalnative method. + * + */ + var SECTION = "eval-003.js"; + var VERSION = "JS1_4"; + var TITLE = "Calling eval indirectly should NOT fail in version 140"; + var BUGNUMBER="38512"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var MY_EVAL = eval; + var RESULT = ""; + var EXPECT= ""; + var h = function f(x,y){var g = function(z){return Math.exp(z);}; return g(x+y);}; + + + new EvalTest(); + + test(); + +function EvalTest() +{ + with( this ) + { + MY_EVAL( "RESULT = h(-1, 1)" ); + EXPECT = 1; //The base e to the power (-1 + 1), i.e. the power 0, equals 1 .... + + testcases[tc++] = new TestCase( + SECTION, + "Call eval indirectly", + EXPECT, + RESULT ); + } +} + diff --git a/tests/mozilla/js1_4/Functions/function-001.js b/tests/mozilla/js1_4/Functions/function-001.js new file mode 100644 index 0000000..c1e6a3d --- /dev/null +++ b/tests/mozilla/js1_4/Functions/function-001.js @@ -0,0 +1,106 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: function-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324455 + * + * Earlier versions of JavaScript supported access to the arguments property + * of the function object. This property held the arguments to the function. + * function f() { + * return f.arguments[0]; // deprecated + * } + * var x = f(3); // x will be 3 + * + * This feature is not a part of the final ECMA standard. Instead, scripts + * should simply use just "arguments": + * + * function f() { + * return arguments[0]; // okay + * } + * + * var x = f(3); // x will be 3 + * + * Again, this feature was motivated by performance concerns. Access to the + * arguments property is not threadsafe, which is of particular concern in + * server environments. Also, the compiler can generate better code for + * functions because it can tell when the arguments are being accessed only by + * name and avoid setting up the arguments object. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "function-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Accessing the arguments property of a function object"; + var BUGNUMBER="324455"; + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( + SECTION, + "return function.arguments", + "P", + TestFunction_2("P", "A","S","S")[0] +""); + + + testcases[tc++] = new TestCase( + SECTION, + "return arguments", + "P", + TestFunction_1( "P", "A", "S", "S" )[0] +""); + + testcases[tc++] = new TestCase( + SECTION, + "return arguments when function contains an arguments property", + "PASS", + TestFunction_3( "P", "A", "S", "S" ) +""); + + testcases[tc++] = new TestCase( + SECTION, + "return function.arguments when function contains an arguments property", + "PASS", + TestFunction_4( "F", "A", "I", "L" ) +""); + + test(); + + function TestFunction_1( a, b, c, d, e ) { + return arguments; + } + + function TestFunction_2( a, b, c, d, e ) { + return TestFunction_2.arguments; + } + + function TestFunction_3( a, b, c, d, e ) { + var arguments = "PASS"; + return arguments; + } + + function TestFunction_4( a, b, c, d, e ) { + var arguments = "PASS"; + return TestFunction_4.arguments; + } + diff --git a/tests/mozilla/js1_4/Regress/date-001-n.js b/tests/mozilla/js1_4/Regress/date-001-n.js new file mode 100644 index 0000000..d6f9f59 --- /dev/null +++ b/tests/mozilla/js1_4/Regress/date-001-n.js @@ -0,0 +1,55 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: date-001-n.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=299903 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "date-001-n.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 299903"; + var BUGNUMBER="299903"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + function MyDate() { + this.foo = "bar"; + } + MyDate.prototype = new Date(); + + testcases[tc++] = new TestCase( + SECTION, + "function MyDate() { this.foo = \"bar\"; }; "+ + "MyDate.prototype = new Date(); " + + "new MyDate().toString()", + "error", + new MyDate().toString() ); + + test(); diff --git a/tests/mozilla/js1_4/Regress/function-001.js b/tests/mozilla/js1_4/Regress/function-001.js new file mode 100644 index 0000000..4fed009 --- /dev/null +++ b/tests/mozilla/js1_4/Regress/function-001.js @@ -0,0 +1,79 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: function-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=325843 + * js> function f(a){var a,b;} + * + * causes an an assert on a null 'sprop' in the 'Variables' function in + * jsparse.c This will crash non-debug build. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "function-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 325843"; + var BUGNUMBER="3258435"; + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + eval("function f1 (a){ var a,b; }"); + + function f2( a ) { var a, b; }; + + testcases[tc++] = new TestCase( + SECTION, + "eval(\"function f1 (a){ var a,b; }\"); "+ + "function f2( a ) { var a, b; }; typeof f1", + "function", + typeof f1 ); + + // force a function decompilation + + testcases[tc++] = new TestCase( + SECTION, + "typeof f1.toString()", + "string", + typeof f1.toString() ); + + testcases[tc++] = new TestCase( + SECTION, + "typeof f2", + "function", + typeof f2 ); + + // force a function decompilation + + testcases[tc++] = new TestCase( + SECTION, + "typeof f2.toString()", + "string", + typeof f2.toString() ); + + test(); + diff --git a/tests/mozilla/js1_4/Regress/function-002.js b/tests/mozilla/js1_4/Regress/function-002.js new file mode 100644 index 0000000..0476869 --- /dev/null +++ b/tests/mozilla/js1_4/Regress/function-002.js @@ -0,0 +1,123 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: function-002.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=330462 + * js> function f(a){var a,b;} + * + * causes an an assert on a null 'sprop' in the 'Variables' function in + * jsparse.c This will crash non-debug build. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * REVISED: 04 February 2001 + * (changed the comma expressions from trivial to non-trivial) + * Author: pschwartau@netscape.com + * + * Brendan: "The test seemed to require something that ECMA does not + * guarantee, and that JS1.4 didn't either. For example, given + * + * dec2 = "function f2(){1,2}"; + * + * the engine is free to decompile a function object compiled from this source, + * via Function.prototype.toString(), into some other string that compiles to + * an equivalent function. The engine now eliminates the useless comma expression + * 1,2, giving function f2(){}. This should be legal by the testsuite's lights." + * + */ + var SECTION = "function-002.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 325843"; + var BUGNUMBER="330462"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + dec1 = "function f1(x,y){++x, --y}"; + dec2 = "function f2(){var y; f1(1,2); y=new Date(); print(y.toString())}"; + + eval(dec1); + eval(dec2); + + testcases[tc++] = new TestCase( + SECTION, + "typeof f1", + "function", + typeof f1 ); + + + // force a function decompilation + testcases[tc++] = new TestCase( + SECTION, + "f1.toString() == dec1", + true, + StripSpaces(f1.toString()) == StripSpaces(dec1)); + + testcases[tc++] = new TestCase( + SECTION, + "typeof f2", + "function", + typeof f2 ); + + // force a function decompilation + + testcases[tc++] = new TestCase( + SECTION, + "f2.toString() == dec2", + true, + StripSpaces(f2.toString()) == StripSpaces(dec2)); + + test(); + + function StripSpaces( s ) { + var strippedString = ""; + for ( var currentChar = 0; currentChar < s.length; currentChar++ ) { + if (!IsWhiteSpace(s.charAt(currentChar))) { + strippedString += s.charAt(currentChar); + } + } + return strippedString; + } + + function IsWhiteSpace( string ) { + var cc = string.charCodeAt(0); + + switch (cc) { + case (0x0009): + case (0x000B): + case (0x000C): + case (0x0020): + case (0x000A): + case (0x000D): + case ( 59 ): // let's strip out semicolons, too + return true; + break; + default: + return false; + } + } + diff --git a/tests/mozilla/js1_4/Regress/function-003.js b/tests/mozilla/js1_4/Regress/function-003.js new file mode 100644 index 0000000..1cf1ea3 --- /dev/null +++ b/tests/mozilla/js1_4/Regress/function-003.js @@ -0,0 +1,77 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: function-003.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104766 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "toString-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 104766"; + var BUGNUMBER="310514"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( + SECTION, + "StripSpaces(Array.prototype.concat.toString()).substring(0,17)", + "functionconcat(){", + StripSpaces(Array.prototype.concat.toString()).substring(0,17)); + + test(); + + function StripSpaces( s ) { + for ( var currentChar = 0, strippedString=""; + currentChar < s.length; currentChar++ ) + { + if (!IsWhiteSpace(s.charAt(currentChar))) { + strippedString += s.charAt(currentChar); + } + } + return strippedString; + } + + function IsWhiteSpace( string ) { + var cc = string.charCodeAt(0); + switch (cc) { + case (0x0009): + case (0x000B): + case (0x000C): + case (0x0020): + case (0x000A): + case (0x000D): + case ( 59 ): // let's strip out semicolons, too + return true; + break; + default: + return false; + } + } + diff --git a/tests/mozilla/js1_4/Regress/function-004-n.js b/tests/mozilla/js1_4/Regress/function-004-n.js new file mode 100644 index 0000000..5b94505 --- /dev/null +++ b/tests/mozilla/js1_4/Regress/function-004-n.js @@ -0,0 +1,51 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: function-004.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=310502 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "funtion-004-n.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 310502"; + var BUGNUMBER="310502"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var o = {}; + o.call = Function.prototype.call; + + testcases[tc++] = new TestCase( + SECTION, + "var o = {}; o.call = Function.prototype.call; o.call()", + "error", + o.call() ); + + test(); diff --git a/tests/mozilla/js1_4/Regress/regress-7224.js b/tests/mozilla/js1_4/Regress/regress-7224.js new file mode 100644 index 0000000..b63ecaa --- /dev/null +++ b/tests/mozilla/js1_4/Regress/regress-7224.js @@ -0,0 +1,72 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/** + * File Name: regress-7224.js + * Reference: js1_2 + * Description: Remove support for the arg + * Author: ** replace with your e-mail address ** + */ + + var SECTION = "regress"; // provide a document reference (ie, ECMA section) + var VERSION = "JS1_4"; // Version of JavaScript or ECMA + var TITLE = "Regression test for bugzilla #7224"; // Provide ECMA section title or a description + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7224"; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + /* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + + var f = new Function( "return arguments.caller" ); + var o = {}; + + o.foo = f; + o.foo("a", "b", "c") + + + AddTestCase( + "var f = new Function( 'return arguments.caller' ); f()", + undefined, + f() ); + + AddTestCase( + "var o = {}; o.foo = f; o.foo('a')", + undefined, + o.foo('a') ); + + test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/tests/mozilla/js1_4/Regress/toString-001-n.js b/tests/mozilla/js1_4/Regress/toString-001-n.js new file mode 100644 index 0000000..c075373 --- /dev/null +++ b/tests/mozilla/js1_4/Regress/toString-001-n.js @@ -0,0 +1,53 @@ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ +/** + * File Name: toString-001-n.js + * Description: + * + * Function.prototype.toString is not generic. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "toString-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 310514"; + var BUGNUMBER="310514"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var o = {}; + o.toString = Function.prototype.toString; + + + testcases[tc++] = new TestCase( + SECTION, + "var o = {}; o.toString = Function.prototype.toString; o.toString();", + "error", + o.toString() ); + + test(); diff --git a/tests/mozilla/js1_4/browser.js b/tests/mozilla/js1_4/browser.js new file mode 100644 index 0000000..5bbdf7c --- /dev/null +++ b/tests/mozilla/js1_4/browser.js @@ -0,0 +1,80 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * + * + * + */ + +onerror = err; + +function startTest() { + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function writeLineToLog( string ) { + document.write( string + "
\n"); +} +function writeHeaderToLog( string ) { + document.write( "

" + string + "

" ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } + document.write( "
" ); +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = ""+ string ; + s += "" ; + s += ( passed ) ? "  " + PASSED + : " " + FAILED + expect + ""; + writeLineToLog( s + "" ); + return passed; +} +function err( msg, page, line ) { + writeLineToLog( "Test failed with the message: " + msg ); + + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} diff --git a/tests/mozilla/js1_4/jsref.js b/tests/mozilla/js1_4/jsref.js new file mode 100644 index 0000000..982d14a --- /dev/null +++ b/tests/mozilla/js1_4/jsref.js @@ -0,0 +1,169 @@ +var completed = false; +var testcases; + +var BUGNUMBER=""; +var EXCLUDE = ""; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +version( 140 ); +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); +} +function startTest() { +/* + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). +*/ +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { +// s += NBSP; + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + writeLineToLog( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeLineToLog( string ) { + print( string + BR + CR ); +} +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() { + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + + } + print(doneTag); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} diff --git a/tests/mozilla/js1_4/shell.js b/tests/mozilla/js1_4/shell.js new file mode 100644 index 0000000..3afdc78 --- /dev/null +++ b/tests/mozilla/js1_4/shell.js @@ -0,0 +1,138 @@ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; + +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + + this.passed = getTestCaseResult( this.expect, this.actual ); +} +function startTest() { +/* + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( 130 ); + } + if ( VERSION == "JS_1.3" ) { + version ( 130 ); + } + if ( VERSION == "JS_1.2" ) { + version ( 120 ); + } + if ( VERSION == "JS_1.1" ) { + version ( 110 ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). +*/ + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +/* + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. + */ + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +/* end of print functions */ + +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } +} diff --git a/tests/mozilla/js1_5/Array/array-001.js b/tests/mozilla/js1_5/Array/array-001.js new file mode 100644 index 0000000..fbb6440 --- /dev/null +++ b/tests/mozilla/js1_5/Array/array-001.js @@ -0,0 +1,101 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): igor@icesoft.no, pschwartau@netscape.com +* Date: 24 September 2001 +* +* SUMMARY: Truncating arrays that have decimal property names. +* From correspondence with Igor Bukanov : +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = '(none)'; +var summary = 'Truncating arrays that have decimal property names'; +var BIG_INDEX = 4294967290; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +var arr = Array(BIG_INDEX); +arr[BIG_INDEX - 1] = 'a'; +arr[BIG_INDEX - 10000] = 'b'; +arr[BIG_INDEX - 0.5] = 'c'; // not an array index - but a valid property name +// Truncate the array - +arr.length = BIG_INDEX - 5000; + + +// Enumerate its properties with for..in +var s = ''; +for (var i in arr) +{ + s += arr[i]; +} + + +/* + * We expect s == 'cb' or 'bc' (EcmaScript does not fix the order). + * Note 'c' is included: for..in includes ALL enumerable properties, + * not just array-index properties. The bug was: Rhino gave s == ''. + */ +status = inSection(1); +actual = sortThis(s); +expect = 'bc'; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function sortThis(str) +{ + var chars = str.split(''); + chars = chars.sort(); + return chars.join(''); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i=0; i var arr = new Array(0xFFFFFFFF) +* js> arr.length +* 4294967295 +* +* js> var arr = new Array(0x100000000) +* RangeError: invalid array length +* +* +* We'll try the largest possible array first, then a couple others. +* We're just testing that we don't crash on Array.sort(). +* +* Try to be good about memory by nulling each array variable after it is +* used. This will tell the garbage collector the memory is no longer needed. +* +* As of 2002-08-13, the JS shell runs out of memory no matter what we do, +* when trying to sort such large arrays. +* +* We only want to test that we don't CRASH on the sort. So it will be OK +* if we get the JS "out of memory" error. Note this terminates the test +* with exit code 3. Therefore we put +* +* |expectExitCode(3);| +* +* The only problem will arise if the JS shell ever DOES have enough memory +* to do the sort. Then this test will terminate with the normal exit code 0 +* and fail. +* +* Right now, I can't see any other way to do this, because "out of memory" +* is not a catchable error: it cannot be trapped with try...catch. +* +* +* FURTHER HEADACHE: Rhino can't seem to handle the largest array: it hangs. +* So we skip this case in Rhino. Here is correspondence with Igor Bukanov. +* He explains that Rhino isn't actually hanging; it's doing the huge sort: +* +* Philip Schwartau wrote: +* +* > Hi, +* > +* > I'm getting a graceful OOM message on trying to sort certain large +* > arrays. But if the array is too big, Rhino simply hangs. Note that ECMA +* > allows array lengths to be anything less than Math.pow(2,32), so the +* > arrays I'm sorting are legal. +* > +* > Note below, I'm getting an instantaneous OOM error on arr.sort() for LEN +* > = Math.pow(2, 30). So shouldn't I also get one for every LEN between +* > that and Math.pow(2, 32)? For some reason, I start to hang with 100% CPU +* > as LEN hits, say, Math.pow(2, 31) and higher. SpiderMonkey gives OOM +* > messages for all of these. Should I file a bug on this? +* +* Igor Bukanov wrote: +* +* This is due to different sorting algorithm Rhino uses when sorting +* arrays with length > Integer.MAX_VALUE. If length can fit Java int, +* Rhino first copies internal spare array to a temporary buffer, and then +* sorts it, otherwise it sorts array directly. In case of very spare +* arrays, that Array(big_number) generates, it is rather inefficient and +* generates OutOfMemory if length fits int. It may be worth in your case +* to optimize sorting to take into account array spareness, but then it +* would be a good idea to file a bug about ineficient sorting of spare +* arrays both in case of Rhino and SpiderMonkey as SM always uses a +* temporary buffer. +* +*/ +//----------------------------------------------------------------------------- +var bug = 157652; +var summary = "Testing that Array.sort() doesn't crash on very large arrays"; + +printBugNumber(bug); +printStatus(summary); + +// KJS doesn't run out of memory, so we don't expect an abnormal exit code +//expectExitCode(3); +var IN_RHINO = inRhino(); + +if (!IN_RHINO) +{ + var a1=Array(0xFFFFFFFF); + a1.sort(); + a1 = null; +} + +var a2 = Array(0x40000000); +a2.sort(); +a2=null; + +var a3=Array(0x10000000/4); +a3.sort(); +a3=null; diff --git a/tests/mozilla/js1_5/Array/regress-178722.js b/tests/mozilla/js1_5/Array/regress-178722.js new file mode 100644 index 0000000..994b381 --- /dev/null +++ b/tests/mozilla/js1_5/Array/regress-178722.js @@ -0,0 +1,175 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 06 November 2002 +* SUMMARY: arr.sort() should not output |undefined| when |arr| is empty +* See http://bugzilla.mozilla.org/show_bug.cgi?id=178722 +* +* ECMA-262 Ed.3: 15.4.4.11 Array.prototype.sort (comparefn) +* +* 1. Call the [[Get]] method of this object with argument "length". +* 2. Call ToUint32(Result(1)). +* 3. Perform an implementation-dependent sequence of calls to the [[Get]], +* [[Put]], and [[Delete]] methods of this object, etc. etc. +* 4. Return this object. +* +* +* Note that sort() is done in-place on |arr|. In other words, sort() is a +* "destructive" method rather than a "functional" method. The return value +* of |arr.sort()| and |arr| are the same object. +* +* If |arr| is an empty array, the return value of |arr.sort()| should be +* an empty array, not the value |undefined| as was occurring in bug 178722. +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 178722; +var summary = 'arr.sort() should not output |undefined| when |arr| is empty'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var arr; + + +// create empty array or pseudo-array objects in various ways +var arr1 = Array(); +var arr2 = new Array(); +var arr3 = []; +var arr4 = [1]; +arr4.pop(); +function f () {return arguments}; +var arr5 = f(); +arr5.__proto__ = Array.prototype; + + +status = inSection(1); +arr = arr1.sort(); +actual = arr instanceof Array && arr.length === 0 && arr === arr1; +expect = true; +addThis(); + +status = inSection(2); +arr = arr2.sort(); +actual = arr instanceof Array && arr.length === 0 && arr === arr2; +expect = true; +addThis(); + +status = inSection(3); +arr = arr3.sort(); +actual = arr instanceof Array && arr.length === 0 && arr === arr3; +expect = true; +addThis(); + +status = inSection(4); +arr = arr4.sort(); +actual = arr instanceof Array && arr.length === 0 && arr === arr4; +expect = true; +addThis(); + +status = inSection(5); +arr = arr5.sort(); +actual = arr instanceof Array && arr.length === 0 && arr === arr5; +expect = true; +addThis(); + + +// now do the same thing, with non-default sorting: +function g() {return 1;} + +status = inSection('1a'); +arr = arr1.sort(g); +actual = arr instanceof Array && arr.length === 0 && arr === arr1; +expect = true; +addThis(); + +status = inSection('2a'); +arr = arr2.sort(g); +actual = arr instanceof Array && arr.length === 0 && arr === arr2; +expect = true; +addThis(); + +status = inSection('3a'); +arr = arr3.sort(g); +actual = arr instanceof Array && arr.length === 0 && arr === arr3; +expect = true; +addThis(); + +status = inSection('4a'); +arr = arr4.sort(g); +actual = arr instanceof Array && arr.length === 0 && arr === arr4; +expect = true; +addThis(); + +status = inSection('5a'); +arr = arr5.sort(g); +actual = arr instanceof Array && arr.length === 0 && arr === arr5; +expect = true; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i0. The bug was filed because we were getting +* i===0; i.e. |i| did not retain the value it had at the location of the error. +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 121658; +var msg = '"Too much recursion" errors should be safely caught by try...catch'; +var TEST_PASSED = 'i retained the value it had at location of error'; +var TEST_FAILED = 'i did NOT retain this value'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var i; + + +function f() +{ + ++i; + + // try...catch should catch the "too much recursion" error to ensue + try + { + f(); + } + catch(e) + { + } +} + +i=0; +f(); +status = inSection(1); +actual = (i>0); +expect = true; +addThis(); + + + +// Now try in function scope - +function g() +{ + f(); +} + +i=0; +g(); +status = inSection(2); +actual = (i>0); +expect = true; +addThis(); + + + +// Now try in eval scope - +var sEval = 'function h(){++i; try{h();} catch(e){}}; i=0; h();'; +eval(sEval); +status = inSection(3); +actual = (i>0); +expect = true; +addThis(); + + + +// Try in eval scope and mix functions up - +sEval = 'function a(){++i; try{h();} catch(e){}}; i=0; a();'; +eval(sEval); +status = inSection(4); +actual = (i>0); +expect = true; +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = formatThis(actual); + expectedvalues[UBound] = formatThis(expect); + UBound++; +} + + +function formatThis(bool) +{ + return bool? TEST_PASSED : TEST_FAILED; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(msg); + + for (var i=0; i", t._y, "y prototype check"); + + reportCompare ("got ", t.y, "y getter, before set"); + + t.y = "new y"; + reportCompare ("got new y", t.y, "y getter, after set"); + + t.y = 2; + reportCompare (2, t.y, "y getter, after numeric set"); + + var d = new Date(); + t.y = d; + reportCompare (d, t.y, "y getter, after date set"); + +} diff --git a/tests/mozilla/js1_5/GetSet/getset-002.js b/tests/mozilla/js1_5/GetSet/getset-002.js new file mode 100644 index 0000000..07d32ed --- /dev/null +++ b/tests/mozilla/js1_5/GetSet/getset-002.js @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +var t = { + _y: "", + + y getter: function get_y () + { + var rv; + if (typeof this._y == "string") + rv = "got " + this._y; + else + rv = this._y; + + return rv; + }, + + y setter: function set_y (newVal) + { + this._y = newVal; + } +} + + +test(t); + +function test(t) +{ + enterFunc ("test"); + + printStatus ("Basic Getter/ Setter test (object literal notation)"); + + reportCompare ("", t._y, "y prototype check"); + + reportCompare ("got ", t.y, "y getter, before set"); + + t.y = "new y"; + reportCompare ("got new y", t.y, "y getter, after set"); + + t.y = 2; + reportCompare (2, t.y, "y getter, after numeric set"); + + var d = new Date(); + t.y = d; + reportCompare (d, t.y, "y getter, after date set"); + +} diff --git a/tests/mozilla/js1_5/GetSet/getset-003.js b/tests/mozilla/js1_5/GetSet/getset-003.js new file mode 100644 index 0000000..952d3d7 --- /dev/null +++ b/tests/mozilla/js1_5/GetSet/getset-003.js @@ -0,0 +1,190 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 14 April 2001 +* +* SUMMARY: Testing obj.prop getter/setter +* Note: this is a non-ECMA extension to the language. +*/ +//------------------------------------------------------------------------------------------------- +var UBound = 0; +var bug = '(none)'; +var summary = 'Testing obj.prop getter/setter'; +var statprefix = 'Status: '; +var status = ''; +var statusitems = [ ]; +var actual = ''; +var actualvalues = [ ]; +var expect= ''; +var expectedvalues = [ ]; +var cnDEFAULT = 'default name'; +var cnFRED = 'Fred'; +var obj = {}; +var obj2 = {}; +var s = ''; + + +// SECTION1: define getter/setter directly on an object (not its prototype) +obj = new Object(); +obj.nameSETS = 0; +obj.nameGETS = 0; +obj.name setter = function(newValue) {this._name=newValue; this.nameSETS++;} +obj.name getter = function() {this.nameGETS++; return this._name;} + +status = 'In SECTION1 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION1 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION1 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION1 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION2: define getter/setter in Object.prototype +Object.prototype.nameSETS = 0; +Object.prototype.nameGETS = 0; +Object.prototype.name setter = function(newValue) {this._name=newValue; this.nameSETS++;} +Object.prototype.name getter = function() {this.nameGETS++; return this._name;} + +obj = new Object(); +status = 'In SECTION2 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION2 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION2 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION2 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION 3: define getter/setter in prototype of user-defined constructor +function TestObject() +{ +} +TestObject.prototype.nameSETS = 0; +TestObject.prototype.nameGETS = 0; +TestObject.prototype.name setter = function(newValue) {this._name=newValue; this.nameSETS++;} +TestObject.prototype.name getter = function() {this.nameGETS++; return this._name;} +TestObject.prototype.name = cnDEFAULT; + +obj = new TestObject(); +status = 'In SECTION3 of test after 1 set, 0 gets'; // (we set a default value in the prototype) +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,0]; +addThis(); + +s = obj.name; +status = 'In SECTION3 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION3 of test after 2 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION3 of test after 3 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [3,2]; +addThis(); + +obj2 = new TestObject(); +status = 'obj2 = new TestObject() after 1 set, 0 gets'; +actual = [obj2.nameSETS,obj2.nameGETS]; +expect = [1,0]; // we set a default value in the prototype - +addThis(); + +// Use both obj and obj2 - +obj2.name = obj.name + obj2.name; + status = 'obj2 = new TestObject() after 2 sets, 1 get'; + actual = [obj2.nameSETS,obj2.nameGETS]; + expect = [2,1]; + addThis(); + + status = 'In SECTION3 of test after 3 sets, 3 gets'; + actual = [obj.nameSETS,obj.nameGETS]; + expect = [3,3]; // we left off at [3,2] above - + addThis(); + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual.toString(); + expectedvalues[UBound] = expect.toString(); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], getStatus(i)); + } + + exitFunc ('test'); +} + + +function getStatus(i) +{ + return statprefix + statusitems[i]; +} diff --git a/tests/mozilla/js1_5/GetSet/getset-004.js b/tests/mozilla/js1_5/GetSet/getset-004.js new file mode 100644 index 0000000..4445e80 --- /dev/null +++ b/tests/mozilla/js1_5/GetSet/getset-004.js @@ -0,0 +1,190 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 14 April 2001 +* +* SUMMARY: Testing obj.__defineSetter__(), obj.__defineGetter__() +* Note: this is a non-ECMA language extension +*/ +//------------------------------------------------------------------------------------------------- +var UBound = 0; +var bug = '(none)'; +var summary = 'Testing obj.__defineSetter__(), obj.__defineGetter__()'; +var statprefix = 'Status: '; +var status = ''; +var statusitems = [ ]; +var actual = ''; +var actualvalues = [ ]; +var expect= ''; +var expectedvalues = [ ]; +var cnDEFAULT = 'default name'; +var cnFRED = 'Fred'; +var obj = {}; +var obj2 = {}; +var s = ''; + + +// SECTION1: define getter/setter directly on an object (not its prototype) +obj = new Object(); +obj.nameSETS = 0; +obj.nameGETS = 0; +obj.__defineSetter__('name', function(newValue) {this._name=newValue; this.nameSETS++;}); +obj.__defineGetter__('name', function() {this.nameGETS++; return this._name;}); + +status = 'In SECTION1 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION1 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION1 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION1 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION2: define getter/setter in Object.prototype +Object.prototype.nameSETS = 0; +Object.prototype.nameGETS = 0; +Object.prototype.__defineSetter__('name', function(newValue) {this._name=newValue; this.nameSETS++;}); +Object.prototype.__defineGetter__('name', function() {this.nameGETS++; return this._name;}); + +obj = new Object(); +status = 'In SECTION2 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION2 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION2 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION2 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION 3: define getter/setter in prototype of user-defined constructor +function TestObject() +{ +} +TestObject.prototype.nameSETS = 0; +TestObject.prototype.nameGETS = 0; +TestObject.prototype.__defineSetter__('name', function(newValue) {this._name=newValue; this.nameSETS++;}); +TestObject.prototype.__defineGetter__('name', function() {this.nameGETS++; return this._name;}); +TestObject.prototype.name = cnDEFAULT; + +obj = new TestObject(); +status = 'In SECTION3 of test after 1 set, 0 gets'; // (we set a default value in the prototype) +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,0]; +addThis(); + +s = obj.name; +status = 'In SECTION3 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION3 of test after 2 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION3 of test after 3 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [3,2]; +addThis(); + +obj2 = new TestObject(); +status = 'obj2 = new TestObject() after 1 set, 0 gets'; +actual = [obj2.nameSETS,obj2.nameGETS]; +expect = [1,0]; // we set a default value in the prototype - +addThis(); + +// Use both obj and obj2 - +obj2.name = obj.name + obj2.name; + status = 'obj2 = new TestObject() after 2 sets, 1 get'; + actual = [obj2.nameSETS,obj2.nameGETS]; + expect = [2,1]; + addThis(); + + status = 'In SECTION3 of test after 3 sets, 3 gets'; + actual = [obj.nameSETS,obj.nameGETS]; + expect = [3,3]; // we left off at [3,2] above - + addThis(); + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual.toString(); + expectedvalues[UBound] = expect.toString(); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], getStatus(i)); + } + + exitFunc ('test'); +} + + +function getStatus(i) +{ + return statprefix + statusitems[i]; +} diff --git a/tests/mozilla/js1_5/GetSet/getset-005.js b/tests/mozilla/js1_5/GetSet/getset-005.js new file mode 100644 index 0000000..c0e61f9 --- /dev/null +++ b/tests/mozilla/js1_5/GetSet/getset-005.js @@ -0,0 +1,199 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 14 April 2001 +* +* SUMMARY: Testing obj.__defineSetter__(), obj.__defineGetter__() +* Note: this is a non-ECMA language extension +* +* This test is the same as getset-004.js, except that here we +* store the getter/setter functions in global variables. +*/ +//------------------------------------------------------------------------------------------------- +var UBound = 0; +var bug = '(none)'; +var summary = 'Testing obj.__defineSetter__(), obj.__defineGetter__()'; +var statprefix = 'Status: '; +var status = ''; +var statusitems = [ ]; +var actual = ''; +var actualvalues = [ ]; +var expect= ''; +var expectedvalues = [ ]; +var cnName = 'name'; +var cnDEFAULT = 'default name'; +var cnFRED = 'Fred'; +var obj = {}; +var obj2 = {}; +var s = ''; + + +// The getter/setter functions we'll use in all three sections below - +var cnNameSetter = function(newValue) {this._name=newValue; this.nameSETS++;}; +var cnNameGetter = function() {this.nameGETS++; return this._name;}; + + +// SECTION1: define getter/setter directly on an object (not its prototype) +obj = new Object(); +obj.nameSETS = 0; +obj.nameGETS = 0; +obj.__defineSetter__(cnName, cnNameSetter); +obj.__defineGetter__(cnName, cnNameGetter); + +status = 'In SECTION1 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION1 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION1 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION1 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION2: define getter/setter in Object.prototype +Object.prototype.nameSETS = 0; +Object.prototype.nameGETS = 0; +Object.prototype.__defineSetter__(cnName, cnNameSetter); +Object.prototype.__defineGetter__(cnName, cnNameGetter); + +obj = new Object(); +status = 'In SECTION2 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION2 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION2 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION2 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION 3: define getter/setter in prototype of user-defined constructor +function TestObject() +{ +} +TestObject.prototype.nameSETS = 0; +TestObject.prototype.nameGETS = 0; +TestObject.prototype.__defineSetter__(cnName, cnNameSetter); +TestObject.prototype.__defineGetter__(cnName, cnNameGetter); +TestObject.prototype.name = cnDEFAULT; + +obj = new TestObject(); +status = 'In SECTION3 of test after 1 set, 0 gets'; // (we set a default value in the prototype) +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,0]; +addThis(); + +s = obj.name; +status = 'In SECTION3 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION3 of test after 2 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION3 of test after 3 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [3,2]; +addThis(); + +obj2 = new TestObject(); +status = 'obj2 = new TestObject() after 1 set, 0 gets'; +actual = [obj2.nameSETS,obj2.nameGETS]; +expect = [1,0]; // we set a default value in the prototype - +addThis(); + +// Use both obj and obj2 - +obj2.name = obj.name + obj2.name; + status = 'obj2 = new TestObject() after 2 sets, 1 get'; + actual = [obj2.nameSETS,obj2.nameGETS]; + expect = [2,1]; + addThis(); + + status = 'In SECTION3 of test after 3 sets, 3 gets'; + actual = [obj.nameSETS,obj.nameGETS]; + expect = [3,3]; // we left off at [3,2] above - + addThis(); + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual.toString(); + expectedvalues[UBound] = expect.toString(); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], getStatus(i)); + } + + exitFunc ('test'); +} + + +function getStatus(i) +{ + return statprefix + statusitems[i]; +} diff --git a/tests/mozilla/js1_5/GetSet/getset-006.js b/tests/mozilla/js1_5/GetSet/getset-006.js new file mode 100644 index 0000000..8d35bc9 --- /dev/null +++ b/tests/mozilla/js1_5/GetSet/getset-006.js @@ -0,0 +1,173 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" +* basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 14 April 2001 +* +* SUMMARY: Testing obj.__lookupGetter__(), obj.__lookupSetter__() +* See http://bugzilla.mozilla.org/show_bug.cgi?id=71992 +* +* Brendan: "I see no need to provide more than the minimum: +* o.__lookupGetter__('p') returns the getter function for o.p, +* or undefined if o.p has no getter. Users can wrap and layer." +*/ +//------------------------------------------------------------------------------------------------- +var UBound = 0; +var bug = 71992; +var summary = 'Testing obj.__lookupGetter__(), obj.__lookupSetter__()'; +var statprefix = 'Status: '; +var status = ''; +var statusitems = [ ]; +var actual = ''; +var actualvalues = [ ]; +var expect= ''; +var expectedvalues = [ ]; +var cnName = 'name'; +var cnColor = 'color'; +var cnNonExistingProp = 'ASDF_#_$%'; +var cnDEFAULT = 'default name'; +var cnFRED = 'Fred'; +var cnRED = 'red'; +var obj = {}; +var obj2 = {}; +var s; + + +// The only setter and getter functions we'll use in the three sections below - +var cnNameSetter = function(newValue) {this._name=newValue; this.nameSETS++;}; +var cnNameGetter = function() {this.nameGETS++; return this._name;}; + + + +// SECTION1: define getter/setter directly on an object (not its prototype) +obj = new Object(); +obj.nameSETS = 0; +obj.nameGETS = 0; +obj.__defineSetter__(cnName, cnNameSetter); +obj.__defineGetter__(cnName, cnNameGetter); +obj.name = cnFRED; +obj.color = cnRED; + +status ='In SECTION1 of test; looking up extant getter/setter'; +actual = [obj.__lookupSetter__(cnName), obj.__lookupGetter__(cnName)]; +expect = [cnNameSetter, cnNameGetter]; +addThis(); + +status = 'In SECTION1 of test; looking up nonexistent getter/setter'; +actual = [obj.__lookupSetter__(cnColor), obj.__lookupGetter__(cnColor)]; +expect = [undefined, undefined]; +addThis(); + +status = 'In SECTION1 of test; looking up getter/setter on nonexistent property'; +actual = [obj.__lookupSetter__(cnNonExistingProp), obj.__lookupGetter__(cnNonExistingProp)]; +expect = [undefined, undefined]; +addThis(); + + + +// SECTION2: define getter/setter in Object.prototype +Object.prototype.nameSETS = 0; +Object.prototype.nameGETS = 0; +Object.prototype.__defineSetter__(cnName, cnNameSetter); +Object.prototype.__defineGetter__(cnName, cnNameGetter); + +obj = new Object(); +obj.name = cnFRED; +obj.color = cnRED; + +status = 'In SECTION2 of test looking up extant getter/setter'; +actual = [obj.__lookupSetter__(cnName), obj.__lookupGetter__(cnName)]; +expect = [cnNameSetter, cnNameGetter]; +addThis(); + +status = 'In SECTION2 of test; looking up nonexistent getter/setter'; +actual = [obj.__lookupSetter__(cnColor), obj.__lookupGetter__(cnColor)]; +expect = [undefined, undefined]; +addThis(); + +status = 'In SECTION2 of test; looking up getter/setter on nonexistent property'; +actual = [obj.__lookupSetter__(cnNonExistingProp), obj.__lookupGetter__(cnNonExistingProp)]; +expect = [undefined, undefined]; +addThis(); + + + +// SECTION 3: define getter/setter in prototype of user-defined constructor +function TestObject() +{ +} +TestObject.prototype.nameSETS = 0; +TestObject.prototype.nameGETS = 0; +TestObject.prototype.__defineSetter__(cnName, cnNameSetter); +TestObject.prototype.__defineGetter__(cnName, cnNameGetter); +TestObject.prototype.name = cnDEFAULT; + +obj = new TestObject(); +obj.name = cnFRED; +obj.color = cnRED; + +status = 'In SECTION3 of test looking up extant getter/setter'; +actual = [obj.__lookupSetter__(cnName), obj.__lookupGetter__(cnName)]; +expect = [cnNameSetter, cnNameGetter]; +addThis(); + +status = 'In SECTION3 of test; looking up non-existent getter/setter'; +actual = [obj.__lookupSetter__(cnColor), obj.__lookupGetter__(cnColor)]; +expect = [undefined, undefined]; +addThis(); + +status = 'In SECTION3 of test; looking up getter/setter on nonexistent property'; +actual = [obj.__lookupSetter__(cnNonExistingProp), obj.__lookupGetter__(cnNonExistingProp)]; +expect = [undefined, undefined]; +addThis(); + + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual.toString(); + expectedvalues[UBound] = expect.toString(); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], getStatus(i)); + } + + exitFunc ('test'); +} + + +function getStatus(i) +{ + return statprefix + statusitems[i]; +} diff --git a/tests/mozilla/js1_5/LexicalConventions/lexical-001.js b/tests/mozilla/js1_5/LexicalConventions/lexical-001.js new file mode 100644 index 0000000..42e947d --- /dev/null +++ b/tests/mozilla/js1_5/LexicalConventions/lexical-001.js @@ -0,0 +1,161 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* 26 November 2000 +* +* +*SUMMARY: Testing numeric literals that begin with 0. +*This test arose from Bugzilla bug 49233. +*The best explanation is from jsscan.c: +* +* "We permit 08 and 09 as decimal numbers, which makes +* our behaviour a superset of the ECMA numeric grammar. +* We might not always be so permissive, so we warn about it." +* +*Thus an expression 010 will evaluate, as always, as an octal (to 8). +*However, 018 will evaluate as a decimal, to 18. Even though the +*user began the expression as an octal, he later used a non-octal +*digit. We forgive this and assume he intended a decimal. If the +*JavaScript "strict" option is set though, we will give a warning. +*/ +//------------------------------------------------------------------------------------------------- +var bug = '49233'; +var summary = 'Testing numeric literals that begin with 0'; +var statprefix = 'Testing '; +var quote = "'"; +var status = new Array(); +var actual = new Array(); +var expect = new Array(); + + +status[0]=showStatus('01') +actual[0]=01 +expect[0]=1 + +status[1]=showStatus('07') +actual[1]=07 +expect[1]=7 + +status[2]=showStatus('08') +actual[2]=08 +expect[2]=8 + +status[3]=showStatus('09') +actual[3]=09 +expect[3]=9 + +status[4]=showStatus('010') +actual[4]=010 +expect[4]=8 + +status[5]=showStatus('017') +actual[5]=017 +expect[5]=15 + +status[6]=showStatus('018') +actual[6]=018 +expect[6]=18 + +status[7]=showStatus('019') +actual[7]=019 +expect[7]=19 + +status[8]=showStatus('079') +actual[8]=079 +expect[8]=79 + +status[9]=showStatus('0079') +actual[9]=0079 +expect[9]=79 + +status[10]=showStatus('099') +actual[10]=099 +expect[10]=99 + +status[11]=showStatus('0099') +actual[11]=0099 +expect[11]=99 + +status[12]=showStatus('000000000077') +actual[12]=000000000077 +expect[12]=63 + +status[13]=showStatus('000000000078') +actual[13]=000000000078 +expect[13]=78 + +status[14]=showStatus('0000000000770000') +actual[14]=0000000000770000 +expect[14]=258048 + +status[15]=showStatus('0000000000780000') +actual[15]=0000000000780000 +expect[15]=780000 + +status[16]=showStatus('0765432198') +actual[16]=0765432198 +expect[16]=765432198 + +status[17]=showStatus('00076543219800') +actual[17]=00076543219800 +expect[17]=76543219800 + +status[18]=showStatus('0000001001007') +actual[18]=0000001001007 +expect[18]=262663 + +status[19]=showStatus('0000001001009') +actual[19]=0000001001009 +expect[19]=1001009 + +status[20]=showStatus('070') +actual[20]=070 +expect[20]=56 + +status[21]=showStatus('080') +actual[21]=080 +expect[21]=80 + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function showStatus(msg) +{ + return (statprefix + quote + msg + quote); +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + + for (i=0; i !=status.length; i++) + { + reportCompare (expect[i], actual[i], status[i]); + } + + exitFunc ('test'); +} \ No newline at end of file diff --git a/tests/mozilla/js1_5/LexicalConventions/regress-177314.js b/tests/mozilla/js1_5/LexicalConventions/regress-177314.js new file mode 100644 index 0000000..b085dfb --- /dev/null +++ b/tests/mozilla/js1_5/LexicalConventions/regress-177314.js @@ -0,0 +1,105 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 30 Oct 2002 +* SUMMARY: '\400' should lex as a 2-digit octal escape + '0' +* See http://bugzilla.mozilla.org/show_bug.cgi?id=177314 +* +* Bug was that Rhino interpreted '\400' as a 3-digit octal escape. As such +* it is invalid, since octal escapes may only run from '\0' to '\377'. But +* the lexer should interpret this as '\40' + '0' instead, and throw no error. +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 177314; +var summary = "'\\" + "400' should lex as a 2-digit octal escape + '0'"; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +// the last valid octal escape is '\377', which should equal hex escape '\xFF' +status = inSection(1); +actual = '\377'; +expect = '\xFF'; +addThis(); + +// now exercise the lexer by going one higher in the last digit +status = inSection(2); +actual = '\378'; +expect = '\37' + '8'; +addThis(); + +// trickier: 400 is a valid octal number, but '\400' isn't a valid octal escape +status = inSection(3); +actual = '\400'; +expect = '\40' + '0'; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i 5) + return sum; + sum += 1; + } + catch (e) + { + sum += 1; + print(e); + } + } + } + } + finally + { + try + { + sum +=1; + print("In finally block of addValues_3() function: sum = " + sum); + } + catch (e if e == 42) + { + sum +=1; + print('In finally catch block of addValues_3() function: sum = ' + sum + ', e = ' + e); + } + finally + { + sum +=1; + print("In finally finally block of addValues_3() function: sum = " + sum); + return sum; + } + } + } +} + +status = inSection(9); +obj = new Object(); +obj.arg1 = 1; +obj.arg2 = 2; +obj.arg3 = new Object(); +obj.arg3.a = 10; +obj.arg3.b = 20; +actual = addValues_3(obj); +expect = 8; +captureThis(); + + + + +function addValues_4(obj) +{ + var sum = 0; + + with (obj) + { + try + { + sum = arg1 + arg2; + with (arg3) + { + while (sum < 10) + { + try + { + if (sum > 5) + return sum; + sum += 1; + } + catch (e) + { + sum += 1; + print(e); + } + } + } + } + finally + { + try + { + sum += 1; + print("In finally block of addValues_4() function: sum = " + sum); + } + catch (e if e == 42) + { + sum += 1; + print("In 1st finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); + } + catch (e if e == 43) + { + sum += 1; + print("In 2nd finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); + } + finally + { + sum += 1; + print("In finally finally block of addValues_4() function: sum = " + sum); + return sum; + } + } + } +} + +status = inSection(10); +obj = new Object(); +obj.arg1 = 1; +obj.arg2 = 2; +obj.arg3 = new Object(); +obj.arg3.a = 10; +obj.arg3.b = 20; +actual = addValues_4(obj); +expect = 8; +captureThis(); + + + + +function addValues_5(obj) +{ + var sum = 0; + + with (obj) + { + try + { + sum = arg1 + arg2; + with (arg3) + { + while (sum < 10) + { + try + { + if (sum > 5) + return sum; + sum += 1; + } + catch (e) + { + sum += 1; + print(e); + } + } + } + } + finally + { + try + { + sum += 1; + print("In finally block of addValues_5() function: sum = " + sum); + } + catch (e) + { + sum += 1; + print("In finally catch block of addValues_5() function: sum = " + sum + ", e = " + e); + } + finally + { + sum += 1; + print("In finally finally block of addValues_5() function: sum = " + sum); + return sum; + } + } + } +} + +status = inSection(11); +obj = new Object(); +obj.arg1 = 1; +obj.arg2 = 2; +obj.arg3 = new Object(); +obj.arg3.a = 10; +obj.arg3.b = 20; +actual = addValues_5(obj); +expect = 8; +captureThis(); + + + + +function testObj(obj) +{ + var x = 42; + + try + { + with (obj) + { + if (obj.p) + throw obj.p; + x = obj.q; + } + } + finally + { + print("in finally block of testObj() function"); + return 999; + } +} + +status = inSection(12); +obj = {p:43}; +actual = testObj(obj); +expect = 999; +captureThis(); + + + +/* + * Next two cases are from http://bugzilla.mozilla.org/show_bug.cgi?id=120571 + */ +function a120571() +{ + while(0) + { + try + { + } + catch(e) + { + continue; + } + } +} + +// this caused a crash! Test to see that it doesn't now. +print(a120571); + +// Now test that we have a non-null value for a120571.toString() +status = inSection(13); +try +{ + actual = a120571.toString().match(/continue/)[0]; +} +catch(e) +{ + actual = 'FAILED! Did not find "continue" in function body'; +} +expect = 'continue'; +captureThis(); + + + + +function b() +{ + for(;;) + { + try + { + } + catch(e) + { + continue; + } + } +} + +// this caused a crash!!! Test to see that it doesn't now. +print(b); + +// Now test that we have a non-null value for b.toString() +status = inSection(14); +try +{ + actual = b.toString().match(/continue/)[0]; +} +catch(e) +{ + actual = 'FAILED! Did not find "continue" in function body'; +} +expect = 'continue'; +captureThis(); + + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function captureThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i=0; i (c) 1998-2000 +// This is version 2.2.6, dated 2000-03-30 + +// The script is freely distributable +// It may be used (and modified) as you wish, but retain this message +// For more information about the menu visit its home page +// http://www.treemenu.com/ + +/****************************************************************************** +* Define the MenuItem object. * +******************************************************************************/ + +function MTMenuItem(text, url, target,nsearchID, icon) { + this.text = text; + this.url = url ? url : ""; + this.target = target ? target : ""; + this.icon = icon ? icon : ""; + this.nsearchID = nsearchID; + + this.number = MTMSubNumber++; + this.parent = null; + this.submenu = null; + this.expanded = false; + this.selected = false; + this.childSelected = false; + + this.MTMakeSubmenu = MTMakeSubmenu; + +} + +function MTMakeSubmenu(menu) { + this.submenu = menu; + for (var i = 0; i < menu.items.length; i++) + { + menu.items[i].parent = this; + } +} + + + +function getChildrenChecked(item, selected) +{ + if (item.submenu != null) + { + for (var x = 0; x < item.submenu.items.length; x++) + { + item.submenu.items[x].selected = selected; + item.submenu.items[x].childSelected = false; + MarkChildren(item.submenu.items[x],selected); + } + } +} + +/****************************************************************************** +* Define the Menu object. * +******************************************************************************/ + +function MTMenu() { + this.items = new Array(); + this.MTMAddItem = MTMAddItem; +} + +function MTMAddItem(item) { + this.items[this.items.length] = item; +} + +/****************************************************************************** +* Define the icon list, addIcon function and MTMIcon item. * +******************************************************************************/ + +function IconList() { + this.items = new Array(); + this.addIcon = addIcon; +} + +function addIcon(item) { + this.items[this.items.length] = item; +} + +function MTMIcon(iconfile, match, type) { + this.file = iconfile; + this.match = match; + this.type = type; +} + +/****************************************************************************** +* Global variables. Not to be altered unless you know what you're doing. * +* User-configurable options are at the end of this document. * +******************************************************************************/ + +var MTMLoaded = false; +var MTMLevel; +var MTMBar = new Array(); +var MTMIndices = new Array(); +var MTMBrowser = null; +var MTMNN3 = false; +var MTMNN4 = false; +var MTMIE4 = false; +var MTMUseStyle = true; + +/* + * (For a standalone JS shell test, we will simply set these as follows:) + */ +MTMBrowser = true; +MTMNN4 = true; + + +var MTMClickedItem = false; +var MTMExpansion = false; + +var MTMSubNumber = 1; +var MTMTrackedItem = false; +var MTMTrack = false; + +var MTMPreHREF = ""; +if(MTMIE4 || MTMNN3) { + MTMPreHREF += ""; // document.location.href.substring(0, document.location.href.lastIndexOf("/") +1); +} + +var MTMFirstRun = true; +var MTMCurrentTime = 0; // for checking timeout. +var MTMUpdating = false; +var MTMWinSize, MTMyval; +var MTMOutputString = ""; + +/****************************************************************************** +* Code that picks up frame names of frames in the parent frameset. * +******************************************************************************/ + + +/****************************************************************************** +* Dummy function for sub-menus without URLs * +* Thanks to Michel Plungjan for the advice. :) * +******************************************************************************/ + +function myVoid() { ; } + +/****************************************************************************** +* Functions to draw the menu. * +******************************************************************************/ + +function MTMSubAction(SubItem, ReturnValue) { + + SubItem.expanded = (SubItem.expanded) ? false : true; + if(SubItem.expanded) { + MTMExpansion = true; + } + + MTMClickedItem = SubItem.number; + + if(MTMTrackedItem && MTMTrackedItem != SubItem.number) { + MTMTrackedItem = false; + } + + if(!ReturnValue) { + setTimeout("MTMDisplayMenu()", 10); + } + + return ReturnValue; +} + + +function MarkChildren(item, selected) +{ + if (item.submenu != null) + { + for (var x = 0; x < item.submenu.items.length; x++) + { + item.submenu.items[x].selected = selected; + item.submenu.items[x].childSelected = false; + MarkChildren(item.submenu.items[x],selected); + } + } + +} + +function isAllChildrenSelected(item) +{ + if (item.submenu != null) + { + for (var x = 0; x < item.submenu.items.length; x++) + { + if (!item.submenu.items[x].selected) + { + return false; + } + } + } + return true; +} + +function isSomeChildrenSelected(item) +{ + var retValue = false; + + if (item.submenu != null) + { + for (var x = 0; x < item.submenu.items.length; x++) + { + if (item.submenu.items[x].selected || item.submenu.items[x].childSelected) + { + retValue = true; + } + } + } + + return retValue; +} + +function ToggleSelected(item, ReturnValue) { + + item.selected = (item.selected) ? false : true; + item.childSelected = false; + + var currentNode = item; + + while (currentNode.parent) + { + currentNode.parent.selected = isAllChildrenSelected(currentNode.parent); + currentNode.parent.childSelected = isSomeChildrenSelected(currentNode.parent); + currentNode = currentNode.parent; + } + + MarkChildren(item,item.selected); + + if(!ReturnValue) { + setTimeout("MTMDisplayMenu()", 10); + } + + return ReturnValue; +} + + +function MTMStartMenu() { + MTMLoaded = true; + if(MTMFirstRun) { + MTMCurrentTime++; + if(MTMCurrentTime == MTMTimeOut) { // call MTMDisplayMenu + setTimeout("MTMDisplayMenu()",10); + } else { + setTimeout("MTMStartMenu()",100); + } + } +} + +function MTMDisplayMenu() { + if(MTMBrowser && !MTMUpdating) { + MTMUpdating = true; + MTMFirstRun = false; + + if(MTMTrack) { MTMTrackedItem = MTMTrackExpand(menu); } + + if(MTMExpansion && MTMSubsAutoClose) { MTMCloseSubs(menu); } + + MTMLevel = 0; + MTMDoc = parent.frames[MTMenuFrame].document + MTMDoc.open("text/html", "replace"); + MTMOutputString = ''; + if(MTMLinkedSS) { + MTMOutputString += ''; + } else if(MTMUseStyle) { + MTMOutputString += ''; + } + + MTMOutputString += ''; + + MTMOutputString += ''; + MTMOutputString += ''); + + MTMListItems(menu); + MTMDoc.writeln('
'; //REMOVED ROOT ICON '; + if(MTMUseStyle) { + MTMOutputString += ''; //REMOVED ROOT CAPTION  ' + MTMenuText + ''; + } else { + MTMOutputString += ''; //REMOVED ROOT CAPTION ' + MTMenuText + ''; + } + MTMDoc.writeln(MTMOutputString + '
'); + + MTMDoc.writeln(''); + MTMDoc.close(); + + if((MTMClickedItem || MTMTrackedItem) && (MTMNN4 || MTMIE4) && !MTMFirstRun) { + MTMItemName = "sub" + (MTMClickedItem ? MTMClickedItem : MTMTrackedItem); + if(document.layers && parent.frames[MTMenuFrame].scrollbars) { + MTMyval = parent.frames[MTMenuFrame].document.anchors[MTMItemName].y; + MTMWinSize = parent.frames[MTMenuFrame].innerHeight; + } else { + MTMyval = MTMGetPos(parent.frames[MTMenuFrame].document.all[MTMItemName]); + MTMWinSize = parent.frames[MTMenuFrame].document.body.offsetHeight; + } + if(MTMyval > (MTMWinSize - 60)) { + parent.frames[MTMenuFrame].scrollBy(0, parseInt(MTMyval - (MTMWinSize * 1/3))); + } + } + + MTMClickedItem = false; + MTMExpansion = false; + MTMTrack = false; + } +MTMUpdating = false; +} + +function MTMListItems(menu) { + var i, isLast; + for (i = 0; i < menu.items.length; i++) { + MTMIndices[MTMLevel] = i; + isLast = (i == menu.items.length -1); + MTMDisplayItem(menu.items[i], isLast); + + if (menu.items[i].submenu && menu.items[i].expanded) { + MTMBar[MTMLevel] = (isLast) ? false : true; + MTMLevel++; + MTMListItems(menu.items[i].submenu); + MTMLevel--; + } else { + MTMBar[MTMLevel] = false; + } + } + +} + +function MTMDisplayItem(item, last) { + var i, img, more; + + var MTMfrm = "parent.frames['code']"; + var MTMref = '.menu.items[' + MTMIndices[0] + ']'; + + if(item.submenu) { + var MTMouseOverText; + + var MTMClickCmd; + var MTMDblClickCmd = false; + + + if(MTMLevel > 0) { + for(i = 1; i <= MTMLevel; i++) { + MTMref += ".submenu.items[" + MTMIndices[i] + "]"; + } + } + + if(!MTMEmulateWE && !item.expanded && (item.url != "")) { + MTMClickCmd = "return " + MTMfrm + ".MTMSubAction(" + MTMfrm + MTMref + ",true);"; + } else { + MTMClickCmd = "return " + MTMfrm + ".MTMSubAction(" + MTMfrm + MTMref + ",false);"; + } + + if(item.url == "") { + MTMouseOverText = (item.text.indexOf("'") != -1) ? MTMEscapeQuotes(item.text) : item.text; + } else { + MTMouseOverText = "Expand/Collapse"; + } + } + + MTMOutputString = ''; + if(MTMLevel > 0) { + for (i = 0; i < MTMLevel; i++) { + MTMOutputString += (MTMBar[i]) ? MTMakeImage("menu_bar.gif") : MTMakeImage("menu_pixel.gif"); + } + } + + more = false; + if(item.submenu) { + if(MTMSubsGetPlus || MTMEmulateWE) { + more = true; + } else { + for (i = 0; i < item.submenu.items.length; i++) { + if (item.submenu.items[i].submenu) { + more = true; + } + } + } + } + if(!more) { + img = (last) ? "menu_corner.gif" : "menu_tee.gif"; + } else { + if(item.expanded) { + img = (last) ? "menu_corner_minus.gif" : "menu_tee_minus.gif"; + } else { + img = (last) ? "menu_corner_plus.gif" : "menu_tee_plus.gif"; + } + if(item.url == "" || item.expanded || MTMEmulateWE) { + MTMOutputString += MTMakeVoid(item, MTMClickCmd, MTMouseOverText); + } else { + MTMOutputString += MTMakeLink(item, true) + ' onclick="' + MTMClickCmd + '">'; + } + } + MTMOutputString += MTMakeImage(img); +///////////////////////////////////////// + +var MTMCheckRef = '.menu.items[' + MTMIndices[0] + ']'; +if(MTMLevel > 0) { + for(i = 1; i <= MTMLevel; i++) { + MTMCheckRef += ".submenu.items[" + MTMIndices[i] + "]"; + } + } + +MTMOutputString += MTMakeVoid(item, "return " + MTMfrm + ".ToggleSelected(" + MTMfrm + MTMCheckRef + ",false);", "Checked Status") ; +var checkedImage = item.selected ? "checked.gif" : "uchecked.gif"; +if (!item.selected) +{ + checkedImage = item.childSelected ? "gchecked.gif" : "uchecked.gif"; +} +MTMOutputString += MTMakeImage(checkedImage); +MTMOutputString += ''; +///////////////////////////////////////////////// + + + if(item.submenu) { + if(MTMEmulateWE && item.url != "") + { + MTMOutputString += '' + MTMakeLink(item, false) + '>'; + } + + img = (item.expanded) ? "menu_folder_open.gif" : "menu_folder_closed.gif"; + + if(!more) { + if(item.url == "" || item.expanded) { + MTMOutputString += MTMakeVoid(item, MTMClickCmd, MTMouseOverText); + } else { + MTMOutputString += MTMakeLink(item, true) + ' onclick="' + MTMClickCmd + '">'; + } + } + MTMOutputString += MTMakeImage(img); + + } else { + MTMOutputString += MTMakeLink(item, true) + '>'; + img = (item.icon != "") ? item.icon : MTMFetchIcon(item.url); + MTMOutputString += MTMakeImage(img); + } + + if(item.submenu && (item.url != "") && (item.expanded && !MTMEmulateWE)) { + MTMOutputString += '' + MTMakeLink(item, false) + '>'; + } + + if(MTMNN3 && !MTMLinkedSS) { + var stringColor; + if(item.submenu && (item.url == "") && (item.number == MTMClickedItem)) { + stringColor = (item.expanded) ? MTMSubExpandColor : MTMSubClosedColor; + } else if(MTMTrackedItem && MTMTrackedItem == item.number) { + stringColor = MTMTrackColor; + } else { + stringColor = MTMLinkColor; + } + MTMOutputString += ''; + } + MTMOutputString += ' ' + item.text + ((MTMNN3 && !MTMLinkedSS) ? '' : '') + '' ; + MTMDoc.writeln(MTMOutputString + ''); +} + +function MTMEscapeQuotes(myString) { + var newString = ""; + var cur_pos = myString.indexOf("'"); + var prev_pos = 0; + while (cur_pos != -1) { + if(cur_pos == 0) { + newString += "\\"; + } else if(myString.charAt(cur_pos-1) != "\\") { + newString += myString.substring(prev_pos, cur_pos) + "\\"; + } else if(myString.charAt(cur_pos-1) == "\\") { + newString += myString.substring(prev_pos, cur_pos); + } + prev_pos = cur_pos++; + cur_pos = myString.indexOf("'", cur_pos); + } + return(newString + myString.substring(prev_pos, myString.length)); +} + +function MTMTrackExpand(thisMenu) { + var i, targetPath; + var foundNumber = false; + for(i = 0; i < thisMenu.items.length; i++) { + if(thisMenu.items[i].url != "" && MTMTrackTarget(thisMenu.items[i].target)) { + targetPath = parent.frames[thisMenu.items[i].target].location.protocol + '//' + parent.frames[thisMenu.items[i].target].location.host + parent.frames[thisMenu.items[i].target].location.pathname; + + if(targetPath.lastIndexOf(thisMenu.items[i].url) != -1 && (targetPath.lastIndexOf(thisMenu.items[i].url) + thisMenu.items[i].url.length) == targetPath.length) { + return(thisMenu.items[i].number); + } + } + if(thisMenu.items[i].submenu) { + foundNumber = MTMTrackExpand(thisMenu.items[i].submenu); + if(foundNumber) { + if(!thisMenu.items[i].expanded) { + thisMenu.items[i].expanded = true; + if(!MTMClickedItem) { MTMClickedItem = thisMenu.items[i].number; } + MTMExpansion = true; + } + return(foundNumber); + } + } + } +return(foundNumber); +} + +function MTMCloseSubs(thisMenu) { + var i, j; + var foundMatch = false; + for(i = 0; i < thisMenu.items.length; i++) { + if(thisMenu.items[i].submenu && thisMenu.items[i].expanded) { + if(thisMenu.items[i].number == MTMClickedItem) { + foundMatch = true; + for(j = 0; j < thisMenu.items[i].submenu.items.length; j++) { + if(thisMenu.items[i].submenu.items[j].expanded) { + thisMenu.items[i].submenu.items[j].expanded = false; + } + } + } else { + if(foundMatch) { + thisMenu.items[i].expanded = false; + } else { + foundMatch = MTMCloseSubs(thisMenu.items[i].submenu); + if(!foundMatch) { + thisMenu.items[i].expanded = false; + } + } + } + } + } +return(foundMatch); +} + +function MTMFetchIcon(testString) { + var i; + for(i = 0; i < MTMIconList.items.length; i++) { + if((MTMIconList.items[i].type == 'any') && (testString.indexOf(MTMIconList.items[i].match) != -1)) { + return(MTMIconList.items[i].file); + } else if((MTMIconList.items[i].type == 'pre') && (testString.indexOf(MTMIconList.items[i].match) == 0)) { + return(MTMIconList.items[i].file); + } else if((MTMIconList.items[i].type == 'post') && (testString.indexOf(MTMIconList.items[i].match) != -1)) { + if((testString.lastIndexOf(MTMIconList.items[i].match) + MTMIconList.items[i].match.length) == testString.length) { + return(MTMIconList.items[i].file); + } + } + } +return("menu_link_default.gif"); +} + +function MTMGetPos(myObj) { + return(myObj.offsetTop + ((myObj.offsetParent) ? MTMGetPos(myObj.offsetParent) : 0)); +} + +function MTMCheckURL(myURL) { + var tempString = ""; + if((myURL.indexOf("http://") == 0) || (myURL.indexOf("https://") == 0) || (myURL.indexOf("mailto:") == 0) || (myURL.indexOf("ftp://") == 0) || (myURL.indexOf("telnet:") == 0) || (myURL.indexOf("news:") == 0) || (myURL.indexOf("gopher:") == 0) || (myURL.indexOf("nntp:") == 0) || (myURL.indexOf("javascript:") == 0)) { + tempString += myURL; + } else { + tempString += MTMPreHREF + myURL; + } +return(tempString); +} + +function MTMakeVoid(thisItem, thisCmd, thisText) { + var tempString = ""; + tempString += ''); +} + +function MTMakeLink(thisItem, addName) { + var tempString = ''); +} + +function MTMakeBackImage(thisImage) { + var tempString = 'transparent url("' + ((MTMPreHREF == "") ? "" : MTMPreHREF); + tempString += MTMenuImageDirectory + thisImage + '")' + return(tempString); +} + +function MTMakeA(thisType, thisText, thisColor) { + var tempString = ""; + tempString += 'a' + ((thisType == "pseudo") ? ':' : '.'); + return(tempString + thisText + '{color:' + thisColor + ';background:' + MTMakeBackground() + ';}'); +} + +function MTMakeBackground() { + return((MTMBackground == "") ? MTMBGColor : 'transparent'); +} + +function MTMTrackTarget(thisTarget) { + if(thisTarget.charAt(0) == "_") { + return false; + } else { + for(i = 0; i < MTMFrameNames.length; i++) { + if(thisTarget == MTMFrameNames[i]) { + return true; + } + } + } + return false; +} + + + + +/****************************************************************************** +* User-configurable options. * +******************************************************************************/ + +// Menu table width, either a pixel-value (number) or a percentage value. +var MTMTableWidth = "100%"; + +// Name of the frame where the menu is to appear. +var MTMenuFrame = "tocmain"; + +// variable for determining whether a sub-menu always gets a plus-sign +// regardless of whether it holds another sub-menu or not +var MTMSubsGetPlus = true; + + +// variable that defines whether the menu emulates the behaviour of +// Windows Explorer +var MTMEmulateWE = true; + +// Directory of menu images/icons +var MTMenuImageDirectory = "/ndk/doc/docui2k/menu-images/"; + +// Variables for controlling colors in the menu document. +// Regular BODY atttributes as in HTML documents. +var MTMBGColor = "#cc0000"; +var MTMBackground = ""; +var MTMTextColor = "white"; + +// color for all menu items +var MTMLinkColor = "#ffffcc"; + +// Hover color, when the mouse is over a menu link +var MTMAhoverColor = "#FF9933"; + +// Foreground color for the tracking & clicked submenu item +var MTMTrackColor ="#FF9933"; +var MTMSubExpandColor = "#ffffcc"; +var MTMSubClosedColor = "#ffffcc"; + +// All options regarding the root text and it's icon +var MTMRootIcon = "menu_new_root.gif"; +var MTMenuText = "Site contents:"; +var MTMRootColor = "white"; +var MTMRootFont = "Verdana"; +var MTMRootCSSize = "84%"; +var MTMRootFontSize = "-1"; + +// Font for menu items. +var MTMenuFont = "Verdana"; +var MTMenuCSSize = "74%"; +var MTMenuFontSize = "-1"; + +// Variables for style sheet usage +// 'true' means use a linked style sheet. +var MTMLinkedSS = false; +var MTMSSHREF = "style/menu.css"; + +// Whether you want an open sub-menu to close automagically +// when another sub-menu is opened. 'true' means auto-close +var MTMSubsAutoClose = false; + +// This variable controls how long it will take for the menu +// to appear if the tracking code in the content frame has +// failed to display the menu. Number if in tenths of a second +// (1/10) so 10 means "wait 1 second". +var MTMTimeOut = 25; + +/****************************************************************************** +* User-configurable list of icons. * +******************************************************************************/ + +var MTMIconList = null; +MTMIconList = new IconList(); +// examples: +//MTMIconList.addIcon(new MTMIcon("menu_link_external.gif", "http://", "pre")); +//MTMIconList.addIcon(new MTMIcon("menu_link_pdf.gif", ".pdf", "post")); + +/****************************************************************************** +* User-configurable menu. * +******************************************************************************/ + + +// navigation link is an object used to store the extracted information from +// the search request. The stored information will be used to build the +// navigation tree. + function navigationLink(title,URL,level,elementIndex,levelIndex,parentIndex,author) + { + var returnArray = new Array(); + returnArray.title = title; + returnArray.URL = URL; + returnArray.level = level; + returnArray.hasChild = false; + returnArray.elementIndex = elementIndex; + returnArray.parentIndex = parentIndex; + returnArray.levelIndex = levelIndex; + returnArray.author = author; + + return returnArray; + } + +// Variables used for tracking state as the search iterates through the list +// of documents returned. +var index = 0; +var currentLevel = 0; +var levelParents = new Array(); +var levelIndexes = new Array(); +var navigationTree = new Array(); +var treeNodes = new Array(); +var levelIndex = 0; +top.printList = ""; +top.printCount = 0; + +// asign the menu handle to the created tree +var menu = null; + + +function getNextChecked(item) +{ + // case that root of tree is selected + if ( item.parent == null && item.selected) + { + for (var i = 0 ; i < top.authors.length; i++) + { + var re = /\s$/; + + if (top.titles[i].replace(re,"") == item.text.replace(re,"")) + { + top.printList += (top.authors[i].length + 3) + "_" + top.authors[i].replace(/\s/g,"+") + "+en"; + top.printCount ++; + } + } + } + else if (item.submenu != null) + { + for (var x = 0; x < item.submenu.items.length; x++) + { + if (item.submenu.items[x].selected) + { + var name = item.submenu.items[x].text; + for (var i = 0 ; i < top.authors.length; i++) + { + var re = /\s$/; + if (top.titles[i].replace(re,"") == name.replace(re,"")) + { + top.printList += (top.authors[i].length + 3) + "_" + top.authors[i].replace(/\s/g,"+") + "+en"; + top.printCount ++; + } + } + + } + else + { + getNextChecked(item.submenu.items[x]); + } + } + } + +} + +// Get a URL to pass checked topics to the Print Servlet + + + +function getPrintUrl(menu) +{ + top.printList = ""; + top.printCount = 0; + + getNextChecked(menu.items[0]); + top.printList = top.printCount + "_" + top.printList; + + return top.printList; +} + +function setLevels() +{ + + // Tracking the parent of the next node. + levelParents[currentLevel + 1] = index; + + // levelIndex is the child index under a branch + if (levelIndexes[currentLevel] == null) + { + levelIndexes[currentLevel] = 0; + } + else + { + levelIndexes[currentLevel] = levelIndexes[currentLevel] + 1; + levelIndexes[currentLevel + 1] = -1; + } +} + +function buildTree() +{ + +// Determine which nodes have children and assign the correct property +for (var i = 0; i < navigationTree.length-1; i++) +{ + // see if the current node has chilren + var thisLevel = navigationTree[i]["level"]; + var nextLevel = navigationTree[i+1]["level"]; + + if (nextLevel > thisLevel) + { + navigationTree[i]["hasChild"] = true; + } + else + { + navigationTree[i]["hasChild"] = false; + } +} + + +// create tree object nodes. +for( var j = 0; j < navigationTree.length; j++) +{ + treeNodes[j] = null; + treeNodes[j] = new MTMenu(); +} + + +// add all items to nodes - +// NOTE, index to add to is the parent index + 1 for node tree offset of root=0 +for( var j3 = 0; j3 < navigationTree.length; j3++) +{ + if (navigationTree[j3]["parentIndex"] == null) + { + var nsearchID = navigationTree[j3]["author"]; + treeNodes[0].MTMAddItem(new MTMenuItem(navigationTree[j3]["title"], navigationTree[j3]["URL"].replace(/http...developer.novell.com.ndk/gi,"/ndk") , "content_frame", nsearchID)); + } + else + { + var nsearchID = navigationTree[j3]["author"]; + treeNodes[navigationTree[j3]["parentIndex"] + 1 ].MTMAddItem(new MTMenuItem(navigationTree[j3]["title"], navigationTree[j3]["URL"].replace(/http...developer.novell.com.ndk/gi,"/ndk"), "content_frame",nsearchID)); + } +} + +// create submenu structure +// NOTE: add 1 to parent nodes for root = 0 offset. +for( var j4 = 0; j4 < navigationTree.length; j4++) +{ + if (navigationTree[j4]["hasChild"]) + { + var pindex = null; + if (navigationTree[j4]["parentIndex"] == null) + { + + pindex = 0; + } + else + { + pindex = navigationTree[j4]["parentIndex"]+1; + } + + var lindex = navigationTree[j4]["levelIndex"]; + // document.write('treeNodes[' + pindex +'].items['+ lindex +'].MTMakeSubmenu(treeNodes['+(j4+1)+']);
'); + + treeNodes[pindex].items[lindex].MTMakeSubmenu(treeNodes[j4+1]); + } +} + + menu = treeNodes[0]; + +//expand the second item to display the sub contents on first display +if (menu.items[0] != null ) +{ + menu.items[0].expanded = true; + +} + + + +} + + + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NDS Libraries for C ","http://developer.novell.com/ndk/doc/ndslib/treetitl.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NDS Backup Services ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/hevgtl7k.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Functions ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/h7qwv271.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NDSBackupServerData ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/sdk5.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSFreeNameList ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/sdk12.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSGetReplicaPartitionNames ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/sdk19.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSIsOnlyServerInTree ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/sdk26.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSSYSVolumeRecovery ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/sdk33.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSVerifyServerInfo ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/sdk40.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Structures ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/hqp7vveq.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NAMEID_TYPE ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/sdk48.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Values ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/hmmmal7s.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NDS Reason Flags ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/h3r99io5.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Server Flags ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/hnlckbki.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Revision History ","http://developer.novell.com/ndk/doc/ndslib/dsbk_enu/data/a5i29ah.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Event Services ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hmwiqbwd.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Concepts ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hj3udfo7.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NDS Event Introduction ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hmgeu8a1.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Event Functions ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hxwcemsz.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Event Priorities ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hux0tdup.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Event Data Filtering ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/ha7nqbpy.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Event Types ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/h741eryw.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Global Network Monitoring ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/h9alatk4.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Tasks ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/huypg52u.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Monitoring NDS Events ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hhkihe7f.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Registering for NDS Events ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/h0xmzt1h.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Unregistering for NDS Events ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hk3fvwed.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Functions ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/h7qwv271.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NWDSEConvertEntryName ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk28.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSEGetLocalAttrID ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk33.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSEGetLocalAttrName ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk39.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSEGetLocalClassID ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk45.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSEGetLocalClassName ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk51.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSEGetLocalEntryID ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk57.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSEGetLocalEntryName ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk63.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSERegisterForEvent ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk69.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSERegisterForEventWithResult ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk75.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSEUnRegisterForEvent ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk81.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Structures ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hqp7vveq.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("DSEACL ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk88.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEBackLink ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk92.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEBinderyObjectInfo ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk96.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEBitString ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk100.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEChangeConnState ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk104.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSECIList ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk108.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEDebugInfo ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk112.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEEmailAddress ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk116.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEEntryInfo ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk120.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEEntryInfo2 ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk124.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEEventData ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk128.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEFaxNumber ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk132.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEHold ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk135.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEModuleState ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk139.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSENetAddress ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk143.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEOctetList ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk147.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEPath ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk151.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEReplicaPointer ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk155.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSESEVInfo ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk159.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSETimeStamp ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk163.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSETraceInfo ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk167.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSETypedName ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk172.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEVALData ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk176.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSEValueInfo ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/sdk179.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Values ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hmmmal7s.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Event Priorities ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hlerfllh.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Event Types ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/hiz5y84y.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Revision History ","http://developer.novell.com/ndk/doc/ndslib/dsev_enu/data/a6hw6zr.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Technical Overview ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h6tvg4z7.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NDS as the Internet Directory ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h273w870.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Requirements for Networks and the Internet ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/a2lh37b.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Compliance to X.500 Standard ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h0jj42d7.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Compliance with LDAP v3 ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/a2b6k5w.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Directory Access Protocols ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/a2b6k5x.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Programming Interfaces for NDS ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h2qzzkq8.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Architecture ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h6mny7fl.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Objects ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hp4dslw5.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NDS Names ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h0yh1byj.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Types of Information Stored in NDS ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hci52ynf.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Retrieval of Information from NDS ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hwwz5mda.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Tree Walking ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h2xhaphc.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Object Management ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h3mq2rf0.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Security ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hl8x1zxc.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Authentication ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hp901s8a.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Access Control Lists ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hr8sqtoi.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Inheritance ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hh9881ul.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NetWare File System ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h64btfhk.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Partitions and Replicas ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hmq60r6h.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Partitioning ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hqx5hvrp.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Replication ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hj5l8npv.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Distributed Reference Management ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hzap47de.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Partition Operations ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hgbpk7x9.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Synchronization ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hsiplgn4.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Background Processes ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hz2kcp2e.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Bindery Services ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hwug6ytv.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NDS Bindery Context ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h8dwby8o.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Bindery Context Path ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h6y3yva6.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Bindery Context Eclipsing ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hwcqk80m.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Bindery Objects ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hq4w9le6.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Return Values ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hbjry4gt.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NDS Return Values from the Operating System ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h5h16q77.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Client Return Values ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/he2lvhfy.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Agent Return Values ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hcvwzt90.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Directory Services Trace Utilities ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hujirj2n.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Using the DSTrace NLM ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hmg1e5gn.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Using Basic SET DSTrace Commands ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hdn0smja.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Starting Background Processes with SET DSTrace ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/h5pjd8fv.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Tuning Background Processes ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hhv9cqpk.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Enabling DSTrace Messages with SET DSTrace ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/hcah5j8v.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Revision History ","http://developer.novell.com/ndk/doc/ndslib/dsov_enu/data/a5i29ah.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Core Services ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h2y7hdit.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Programming Concepts ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h2x9gqr9.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Context Handles ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/huynzi7a.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Buffer Management ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h9xiygoj.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Read Requests for Object Information ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h7d6try4.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Search Requests ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h11es6ae.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Developing in a Loosely Consistent Environment ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hsaqomj7.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Add Object Requests ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hqjws9hi.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Security and Applications ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h3xwyggn.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Authentication of Client Applications ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h0m1k6ck.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Multiple Tree Support ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hu5a8flo.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Effective Rights Function ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/he06edkq.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Partition Functions ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/ha7fzu9h.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Replica Functions ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hpmsr4w7.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Read Requests for Schema Information ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h0a2o4v9.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Schema Extension Requests ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hrgy5k6e.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Tasks ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/huypg52u.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Context Handle Tasks ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hw34ixeu.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Buffer Tasks ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hb1nkqk4.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Authentication and Connection Tasks ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/huzx6sda.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Object Tasks ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hddp9m9i.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Partition and Replica Tasks ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hpx2o69b.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Schema Tasks ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hp85l75p.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Functions ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h7qwv271.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NWDSAbbreviateName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk135.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAbortPartitionOperation ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk144.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAddFilterToken ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk153.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAddObject ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk162.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAddPartition (obsolete---moved from .h file 11/99) ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk171.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAddReplica ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk180.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAddSecurityEquiv ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk189.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAllocBuf ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk198.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAllocFilter ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk207.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAuditGetObjectID ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk216.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAuthenticate ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk225.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAuthenticateConn ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk234.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSAuthenticateConnEx ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/a3fvxoz.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSBackupObject ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk243.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSBeginClassItem ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk252.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSCanDSAuthenticate ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk261.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSCanonicalizeName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk270.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSChangeObjectPassword ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk279.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSChangeReplicaType ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk288.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSCIStringsMatch ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk297.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSCloseIteration ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk305.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSCompare ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk314.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSComputeAttrValSize ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk360.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSCreateContext (obsolete---moved from .h file 6/99) ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk369.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSCreateContextHandle ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk371.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSDefineAttr ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk382.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSDefineClass ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk391.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSDelFilterToken ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk402.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSDuplicateContext (obsolete 03/99) ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk412.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSDuplicateContextHandle ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk423.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSExtSyncList ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk434.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSExtSyncRead ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk443.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSExtSyncSearch ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk455.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSFreeBuf ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk465.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSFreeContext ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk474.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSFreeFilter ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk491.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGenerateObjectKeyPair ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk501.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetAttrCount ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk511.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetAttrDef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk521.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetAttrName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk530.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetAttrVal ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk540.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetAttrValFlags ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk550.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetAttrValModTime ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk558.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetBinderyContext ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk566.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetClassDef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk603.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetClassDefCount ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk691.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetClassItem ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk769.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetClassItemCount ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk838.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetContext ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk919.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetCountByClassAndName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk972.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetCurrentUser ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1031.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetDefNameContext ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1041.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetDSIInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1117.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetDSVerInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1209.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetEffectiveRights ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1274.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetMonitoredConnRef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1346.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetNDSInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1425.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetObjectCount ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1528.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetObjectHostServerAddress ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1604.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetObjectName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1640.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetObjectNameAndInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1700.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetPartitionExtInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1781.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetPartitionExtInfoPtr ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1830.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetPartitionInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk1938.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetPartitionRoot ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2001.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetServerAddresses (obsolete 3/98) ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2021.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetServerAddresses2 ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2030.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetServerDN ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2039.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetServerName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2047.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetSyntaxCount ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2056.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetSyntaxDef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2065.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSGetSyntaxID ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2074.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSInitBuf ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2082.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSInspectEntry ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2091.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSJoinPartitions ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2099.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSList ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2108.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSListAttrsEffectiveRights ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2117.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSListByClassAndName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2126.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSListContainableClasses ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2135.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSListContainers ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2144.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSListPartitions ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2153.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSListPartitionsExtInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2162.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSLogin ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2171.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSLoginAsServer ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2180.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSLogout ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2187.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSMapIDToName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2196.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSMapNameToID ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2205.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSModifyClassDef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2214.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSModifyDN ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2223.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSModifyObject ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2232.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSModifyRDN ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2241.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSMoveObject ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2250.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSMutateObject ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/a37nkf6.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSOpenConnToNDSServer ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2259.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSOpenMonitoredConn ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2268.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSOpenStream ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2277.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPartitionReceiveAllUpdates ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2285.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPartitionSendAllUpdates ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2294.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPutAttrName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2303.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPutAttrNameAndVal ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2312.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPutAttrVal ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2321.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPutChange ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2330.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPutChangeAndVal ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2339.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPutClassItem ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2348.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPutClassName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2357.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPutFilter ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2364.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSPutSyntaxName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2373.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRead ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2380.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReadAttrDef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2389.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReadClassDef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2398.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReadNDSInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2407.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReadObjectDSIInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2416.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReadObjectInfo ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2425.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReadReferences ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2434.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReadSyntaxDef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2443.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReadSyntaxes ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2451.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReloadDS ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2459.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRemoveAllTypes ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2467.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRemoveAttrDef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2475.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRemoveClassDef ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2484.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRemoveObject ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2493.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRemovePartition ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2501.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRemoveReplica ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2510.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRemSecurityEquiv ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2519.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRepairTimeStamps ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2528.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReplaceAttrNameAbbrev ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2536.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSResolveName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2544.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSRestoreObject ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2553.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSReturnBlockOfAvailableTrees ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2562.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSScanConnsForTrees ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2573.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSScanForAvailableTrees ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2582.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSSearch ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2591.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSSetContext ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2600.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSSetCurrentUser ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2609.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSSetDefNameContext ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2615.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSSetMonitoredConnection ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2624.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSSplitPartition ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2633.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSSyncPartition ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2642.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSSyncReplicaToServer ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2651.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSSyncSchema ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2660.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSUnlockConnection ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2669.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSVerifyObjectPassword ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2678.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSWhoAmI ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2687.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWGetDefaultNameContext ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2695.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWGetFileServerUTCTime ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2704.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWGetNumConnections ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2712.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWGetNWNetVersion ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2720.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWGetPreferredConnName ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2727.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWIsDSAuthenticated ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2736.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWIsDSServer ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2743.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWNetInit ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2750.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWNetTerm ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2759.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWSetDefaultNameContext ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2767.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWSetPreferredDSTree ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2776.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Structures ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hqp7vveq.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Asn1ID_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2785.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Attr_Info_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2790.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Back_Link_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2795.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Bit_String_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2800.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Buf_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2805.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("CI_List_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2810.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Class_Info_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2815.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("EMail_Address_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2820.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Fax_Number_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2826.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Filter_Cursor_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2831.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Filter_Node_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2836.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Hold_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2841.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSOSVersion_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2846.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSStatsInfo_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2850.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Net_Address_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2855.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDS_TimeStamp_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2860.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Object_ACL_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2865.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Object_Info_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2870.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Octet_List_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2875.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Octet_String_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2880.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Path_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2885.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Replica_Pointer_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2890.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Syntax_Info_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2895.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("TimeStamp_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2900.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Typed_Name_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2906.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Unknown_Attr_T ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/sdk2911.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Values ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hmmmal7s.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Attribute Constraint Flags ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hudjk3k4.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Attribute Value Flags ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h6anqw6h.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Buffer Operation Types and Related Functions ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h8bn0lfm.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Class Flags ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hpj620k3.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Change Types for Modifying Objects ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hc4p686b.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Context Keys and Flags ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h1btx3en.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Default Context Key Values ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hlkcqs3t.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DCK_FLAGS Bit Values ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/he1wcp92.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DCK_NAME_FORM Values ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hmd7uuiw.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DCK_CONFIDENCE Bit Values ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h7hy5yg3.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DCK_DSI_FLAGS Values ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/huh0ri39.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSI_ENTRY_FLAGS Values ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hqwiyl1u.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Filter Tokens ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h487zxy3.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Information Types for Attribute Definitions ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hdqx1cns.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Information Types for Class Definitions ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hcq403ms.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Information Types for Search and Read ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/ha682lf8.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Name Space Types ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hs6qj0yl.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Access Control Rights ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h12s89uj.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDS Ping Flags ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hf0fdqhd.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DSP Replica Information Flags ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hw42a7qg.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Network Address Types ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hniuyp90.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Scope Flags ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h6wfyyfk.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Replica Types ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/he290q86.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Replica States ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/h9br9yt1.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Syntax Matching Flags ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hd8fn0rm.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Syntax IDs ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hn1dsa7y.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Example Code ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/hb05g04v.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Context Handle ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/a2sofgc.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Object and Attribute ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/a2snp6e.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Browsing and Searching ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/a2snu78.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Batch Modification of Objects and Attributes ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/a2snzot.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Schema ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/a2snqyd.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Revision History ","http://developer.novell.com/ndk/doc/ndslib/nds__enu/data/a5i29ah.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Schema Reference ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/h4q1mn1i.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Schema Concepts ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/h282spjh.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Schema Structure ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hpmkggmh.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Schema Components ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hvt5bdoi.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Object Classes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hbna398k.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Naming Attributes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/h9vf1k0r.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Containment Classes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hh1izaro.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Super Classes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hmdjysrx.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Object Class Flags ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/h6rvyaky.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Mandatory and Optional Attributes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/h2vnta8j.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Default ACL Templates ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hr9sm1l0.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Auxiliary Classes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hlh5m1af.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Attribute Type Definitions ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hotadinr.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Attribute Syntax Definitions ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/h2m59phc.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Schema Extensions ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/he5mef3b.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Base Object Class Definitions ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hmv2qd15.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("AFP Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk75.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Alias ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk83.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("applicationEntity ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk91.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("applicationProcess ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk99.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:File Object ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk107.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Bindery Object ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk115.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Bindery Queue ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk123.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("certificationAuthority ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk131.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("CommExec ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk139.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Computer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk147.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Country ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk155.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("cRLDistributionPoint ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk163.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("dcObject ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk171.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Device ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk179.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Directory Map ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk187.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("domain ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk195.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("dSA ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk203.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("External Entity ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk219.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Group ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk227.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Group ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a38rj6z.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk243.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk251.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Locality ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk259.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("MASV:Security Policy ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk267.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Message Routing Group ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk275.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Messaging Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk283.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NCP Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk291.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("ndsLoginProperties ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk347.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Certificate Authority ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk355.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Key Material ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk363.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:SD Key Access Partition ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2okvd6.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:SD Key List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2okvdx.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Trusted Root ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2okvbk.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Trusted Root Object ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2okvcf.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:groupOfCertificates ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk421.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailGroup1 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk445.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailRecipient ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk466.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:NetscapeMailServer5 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk474.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:NetscapeServer5 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk482.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nginfo3 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk510.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nsLicenseUser ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk518.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Organization ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk530.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Organizational Person ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk541.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Organizational Role ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk550.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Organizational Unit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk561.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Partition ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk570.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Person ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk578.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("pkiCA ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk586.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("pkiUser ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk594.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Print Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk602.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk610.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Profile ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk618.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Queue ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk626.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Resource ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk634.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SAS:Security ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk642.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SAS:Service ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk650.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk658.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("strongAuthenticationUser ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk698.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Template ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk706.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Top ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk714.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Tree Root ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk722.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Unknown ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk730.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("User ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk738.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("userSecurityInformation ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk746.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Volume ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk754.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("WANMAN:LAN Area ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk762.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Novell Object Class Extensions ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3fh4x1.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Entrust:CRLDistributionPoint ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk211.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("inetOrgPerson ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk235.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Broker ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk299.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Manager ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk307.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Printer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk315.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Catalog ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk323.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Master Catalog ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk331.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Slave Catalog ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk339.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NetSvc ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk379.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:License Certificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk386.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:License Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk394.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Product Container ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk412.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:groupOfUniqueNames5 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk432.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailGroup5 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk454.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:Nginfo ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk491.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:Nginfo2 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk502.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("residentialPerson ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3omhcl.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Scope Unit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk666.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Directory Agent ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk674.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Service ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk682.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SMS SMDR Class ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk690.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Graphical View of Object Class Inheritance ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hzah4ydk.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Alias and Bindery Object Classes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hw8hr9jx.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Tree Root, domain, and Unknown ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hu1mitlx.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Computer, Country, Device, and Printer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hnf7uif9.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("List and Locality ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/h48ynbap.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Organizational Role and Partition ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hrfg9w4e.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("ndsLoginProperties, Organization, and Organizational Unit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hzvb48kg.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("ndsLoginProperties, Person, Organizational Person, and User ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hknzjmiv.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Directory Map, Profile, Queues, Resource, and Volume ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/h8jovuwl.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Servers (AFP, Messaging, NCP, Print) and CommExec ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/ha47y85g.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("External Entity, Group, and Message Routing Group ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hds3w6ie.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Base Attribute Definitions ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/hf9qbbni.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Aliased Object Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk782.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Account Balance ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk788.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("ACL ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk794.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Allow Unlimited Credit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk800.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("associatedName ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a7bbra4.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("attributeCertificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk806.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:A Encryption Key ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk812.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:B Encryption Key ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk818.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:Contents ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk824.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:Current Encryption Key ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk830.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:File Link ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk836.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:Link List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk842.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:Path ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk848.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:Policy ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk854.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Audit:Type ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk860.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("authorityRevocationList ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk866.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Authority Revocation ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk872.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("AuxClass Object Class Backup ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk878.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Auxiliary Class Flag ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk884.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Back Link ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk890.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Bindery Object Restriction ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk896.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Bindery Property ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk902.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Bindery Restriction Level ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk908.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Bindery Type ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk914.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("businessCategory ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk920.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk932.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("cACertificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk938.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("CA Private Key ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk944.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("CA Public Key ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk950.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Cartridge ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk956.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("certificateRevocationList ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk962.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Certificate Revocation ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk968.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Certificate Validity Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk974.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("crossCertificatePair ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk926.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk986.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Convergence ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk998.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Cross Certificate Pair ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1004.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("dc ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1034.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Default Queue ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1040.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("deltaRevocationList ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1052.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("departmentNumber ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3on5am.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Description ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1058.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("destinationIndicator ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1064.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Detect Intruder ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1070.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Device ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1076.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("dmdName ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1082.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("dn ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1088.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("dnQualifier ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1094.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("DS Revision ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1100.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("EMail Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1106.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("employeeType ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3on9iy.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("enhancedSearchGuide ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1120.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Equivalent To Me ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1138.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("External Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1144.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("External Synchronizer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1150.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Facsimile Telephone Number ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1156.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Full Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1162.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Generational Qualifier ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1168.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("generationQualifier ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1174.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1180.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Given Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1186.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1192.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("GUID ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1198.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("High Convergence Sync Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1216.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Higher Privileges ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1222.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Home Directory ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1228.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Home Directory Rights ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1234.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("homePhone ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3onbgn.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("homePostalAddress ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3ondem.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("houseIdentifier ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1258.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Host Device ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1240.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Host Resource Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1246.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Host Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1252.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Inherited ACL ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1264.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Initials ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1270.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("internationaliSDNNumber ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1276.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Internet EMail Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1282.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Intruder Attempt Reset Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1288.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Intruder Lockout Reset Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1294.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("knowledgeInformation ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1312.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1318.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Language ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1324.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Last Login Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1330.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Last Referenced Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1336.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP ACL v11 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1342.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Allow Clear Text Password ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1348.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Anonymous Identity ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1354.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Attribute Map v11 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1360.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Backup Log Filename ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1366.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Class Map v11 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1378.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Enable SSL ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1384.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Enable TCP ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1390.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Enable UDP ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1396.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Group ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1402.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Host Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1408.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Log Filename ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1414.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Log Level ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1420.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Log Size Limit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1426.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Referral ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1432.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Screen Level ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1438.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Search Size Limit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1444.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Search Time Limit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1450.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1456.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Server Bind Limit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1462.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Server Idle Timeout ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1468.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Server List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1474.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP SSL Port ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1480.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Suffix ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1486.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP TCP Port ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1492.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP UDP Port ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1498.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:bindCatalog ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1516.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:bindCatalogUsage ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1522.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:keyMaterialName ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1546.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:otherReferralUsage ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1552.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:searchCatalog ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1558.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:searchCatalogUsage ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1564.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:searchReferralUsage ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1570.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Locked By Intruder ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1576.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Lockout After Detection ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1582.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Allowed Time Map ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1588.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Disabled ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1594.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Expiration Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1600.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Grace Limit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1606.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Grace Remaining ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1612.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Intruder Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1618.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Intruder Attempts ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1624.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Intruder Limit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1630.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Intruder Reset Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1636.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Maximum Simultaneous ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1642.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Script ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1648.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Login Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1654.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Low Convergence Reset Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1660.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Low Convergence Sync Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1666.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Mailbox ID ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1672.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Mailbox Location ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1678.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("manager ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3onljj.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("masvAuthorizedRange ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1684.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("masvDefaultRange ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1690.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("masvDomainPolicy ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1696.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("masvLabel ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1702.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("masvProposedLabel ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1708.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Member ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1726.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Members Of Template ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1732.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Memory ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1738.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Message Routing Group ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1744.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Message Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1750.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Messaging Database Location ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1756.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Messaging Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1762.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1768.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Minimum Account Balance ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1786.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("mobile ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3oojmc.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Certificate Chain ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4104.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Given Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4110.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Key File ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4116.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Key Material DN ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4122.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Keystore ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2oknqe.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Not After ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2oknpk.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Not Before ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2oknpe.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Parent CA ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4128.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Parent CA DN ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4134.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Private Key ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4140.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Public Key ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4146.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Public Key Certificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4152.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:SD Key Cert ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2oknq2.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:SD Key ID ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2oknq8.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:SD Key Server DN ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2oknpq.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:SD Key Struct ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2oknpw.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Subject Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4158.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Tree CA DN ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4164.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:Trusted Root Certificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2oknp8.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSPKI:userCertificateInfo ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2oknp2.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Network Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4170.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Network Address Restriction ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4176.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("New Object's DS Rights ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4182.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("New Object's FS Rights ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4188.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("New Object's Self Rights ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4194.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NNS Domain ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4338.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Notify ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4374.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:administratorContactInfo ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4392.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:adminURL ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4398.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailAccessDomain ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4404.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailAlternateAddress ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4410.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailAutoReplyMode ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4416.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailAutoReplyText ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4422.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailDeliveryOption ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4428.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailForwardingAddress ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4434.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailHost ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4440.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailMessageStore ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4446.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailProgramDeliveryInfo ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4452.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AmailQuota ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4458.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AnsLicenseEndTime ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4464.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AnsLicensedFor ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4470.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:AnsLicenseStartTime ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4476.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:employeeNumber ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4482.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:installationTimeStamp ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4488.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailRoutingAddress ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a2ixy4e.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:memberCertificateDesc ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4554.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mgrpRFC822mailmember ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4560.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:ngcomponentCIS ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4572.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nsaclrole ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4578.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nscreator ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4584.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nsflags ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4590.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nsnewsACL ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4614.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nsprettyname ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4620.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:serverHostName ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4626.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:serverProductName ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4632.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:serverRoot ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4638.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:serverVersionNumber ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4644.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:subtreeACI ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4650.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4656.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Obituary ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4662.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Obituary Notify ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4668.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Object Class ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4674.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Operator ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4680.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Other GUID ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4686.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4692.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Owner ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4698.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Page Description Language ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4704.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("pager ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3oojmj.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Partition Control ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4716.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Partition Creation Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4722.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Partition Status ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4728.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Password Allow Change ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4734.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Password Expiration Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4740.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Password Expiration Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4746.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Password Management ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4752.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Password Minimum Length ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4758.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Password Required ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4764.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Password Unique Required ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4770.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Passwords Used ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4776.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Path ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4782.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Permanent Config Parms ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4788.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Physical Delivery Office Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4794.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Postal Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4800.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Postal Code ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4806.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Postal Office Box ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4812.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Postmaster ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4818.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("preferredDeliveryMethod ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4824.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("presentationAddress ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4830.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Print Job Configuration ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4848.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Print Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4854.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4860.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer Configuration ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4872.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer Control ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4878.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Private Key ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4914.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Profile ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4920.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Profile Membership ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4926.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("protocolInformation ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4932.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Public Key ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4944.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Purge Vector ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4950.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Queue ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4956.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Queue Directory ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4962.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Received Up To ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4968.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Reference ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4974.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("registeredAddress ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4980.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Replica ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5010.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Replica Up To ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5016.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Resource ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5028.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Revision ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5064.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Role Occupant ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5070.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("roomNumber ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5076.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Run Setup Script ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5082.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5088.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5094.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SAP Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5100.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SAS:Security DN ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5106.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SAS:Service DN ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5112.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("searchGuide ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5118.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("searchSizeLimit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5124.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("searchTimeLimit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5130.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Security Equals ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5136.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Security Flags ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5142.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("See Also ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5148.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Serial Number ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5154.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5160.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Server Holds ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5166.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Set Password After Create ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5172.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Setup Script ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5178.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Status ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5286.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("supportedAlgorithms ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5298.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("supportedApplicationContext ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5304.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Supported Connections ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5310.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Supported Gateway ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5316.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Supported Services ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5322.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Supported Typefaces ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5328.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Surname ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5334.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Synchronization Tolerance ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5358.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Synchronized Up To ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5364.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5370.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Telephone Number ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5376.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("telexNumber ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5382.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("telexTerminalIdentifier ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5388.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Timezone ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5394.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Title ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5400.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Transitive Vector ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5406.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Trustees Of New Object ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5412.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Type Creator Map ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5418.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink(" ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5424.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("uniqueID ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5430.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Unknown ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5436.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Unknown Auxiliary Class ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5442.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Unknown Base Class ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5448.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Used By ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5454.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("User ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5460.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("userCertificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5466.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("userPassword ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6m1fnz.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Uses ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5472.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Version ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5478.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Volume ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5484.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Volume Space Restrictions ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5490.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("WANMAN:Cost ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5496.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("WANMAN:Default Cost ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5502.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("WANMAN:LAN Area Membership ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5508.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("WANMAN:WAN Policy ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5514.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("x121Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5520.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("x500UniqueIdentifier ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5526.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Novell Attribute Extensions ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3fh5xp.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("audio ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3omwno.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("carLicense ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3on4e7.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Client Install Candidate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk980.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Color Supported ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk992.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Database Dir Path ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1010.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Database Volume Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1016.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Datapool Location ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1022.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Datapool Locations ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1028.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Delivery Methods Installed ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1046.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("displayName ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3oorbo.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Employee ID ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1114.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Entrust:AttributeCertificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1126.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Entrust:User ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1132.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("GW API Gateway Directory Path ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1204.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("GW API Gateway Directory Volume ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1210.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("IPP URI ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1300.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("IPP URI Security Scheme ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1306.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("jpegPhoto ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3onfdu.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("labeledUri ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3onkke.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP Class Map ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1372.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("ldapPhoto ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3op8zp.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAPUserCertificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1504.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:ARL ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1510.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:caCertificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1528.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:CRL ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1534.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("LDAP:crossCertificatePair ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1540.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("MASV:Authorized Range ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a9j2co5.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("MASV:Default Range ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a9j2cob.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("MASV:Domain Policy ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a9j2coh.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("MASV:Label ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a9j2con.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("MASV:Proposed Label ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a9j2cot.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Maximum Speed ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1714.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Maximum Speed Units ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1720.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("MHS Send Directory Path ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1774.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("MHS Send Directory Volume ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1780.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Accountant Role ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1792.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Control Flags ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1798.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Database Saved Timestamp ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1804.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Database Saved Data Image ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1810.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Database Saved Index Image ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1816.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Default Printer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1822.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Default Public Printer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1828.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Job Configuration ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1834.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Manager Status ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1840.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Operator Role ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1846.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Printer Install List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1852.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Printer Install Timestamp ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1858.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Printer Queue List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1864.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Printer Siblings ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1870.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Public Printer Install List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1876.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS Replace All Client Printers ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1882.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS SMTP Server ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1888.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDPS User Role ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1894.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual All Attributes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1900.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Attribute Count ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1906.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Attributes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1912.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Base Object ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1918.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Catalog Size ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1924.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual End Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1930.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Filter ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1936.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Object Count ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1942.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Return Code ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1948.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Scope ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1954.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Search Aliases ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1960.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Start Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1966.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Actual Value Count ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1972.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:All Attributes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1978.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:AttrDefTbl ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1984.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Attributes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1990.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Auto Dredge ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk1996.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Base Object ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk2002.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:CatalogDB ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk2008.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Catalog List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk2014.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Dredge Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4008.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Filter ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4014.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:IndexDefTbl ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4020.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Indexes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4026.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Label ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4032.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Log ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4038.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Master Catalog ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4044.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Max Log Size ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4050.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Max Retries ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4056.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Max Threads ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4062.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Retry Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4068.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Scope ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4074.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Search Aliases ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4080.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Slave Catalog List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4086.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Start Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4092.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NDSCat:Synch Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4098.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Common Certificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4200.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Current Installed ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4206.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Current Peak Installed ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4212.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Current Peak Used ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4218.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Current Used ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4224.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Hourly Data Size ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4230.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:License Database ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4236.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:License ID ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4242.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:License Service Provider ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4248.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:LSP Revision ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4254.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Owner ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4260.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Peak Installed Data ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4266.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Peak Used Data ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4272.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Product ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4278.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Publisher ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4284.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Revision ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4290.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Search Type ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4296.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Summary Update Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4302.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Summary Version ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4308.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Transaction Database ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4314.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Transaction Log Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4320.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Transaction Log Size ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4326.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NLS:Version ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4332.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Notification Consumers ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4344.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Notification Profile ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4350.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Notification Service Enabled ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4356.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Notification Srvc Net Addr ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4362.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Notification Srvc Net Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4368.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NRD:Registry Data ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4380.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NRD:Registry Index ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4386.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailAccessDomain ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4494.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailAlternateAddress ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4500.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailAutoReplyMode ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4506.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailAutoReplyText ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4512.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailDeliveryOption ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4518.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailForwardingAddress ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4524.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailHost ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4530.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailMessageStore ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4536.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailProgramDeliveryInfo ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4542.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:mailQuota ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4548.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:ngComponent ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4566.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nsLicenseEndTime ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4596.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nsLicensedFor ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4602.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NSCP:nsLicenseStartTime ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4608.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Page Description Languages ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4710.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("preferredLanguage ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3oon3t.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Primary Notification Service ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4836.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Primary Resource Service ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4842.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer Agent Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4866.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer Manufacturer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4884.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer Mechanism Types ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4890.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer Model ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4896.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer Status ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4902.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printer to PA ID Mappings ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4908.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("PSM Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4938.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Registry Advertising Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4986.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Registry Service Enabled ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4992.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Registry Srvc Net Addr ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk4998.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Registry Srvc Net Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5004.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Resolution ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5022.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Resource Mgmt Srvc Net Addr ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5034.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Resource Mgmt Srvc Net Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5040.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Resource Mgmt Service Enabled ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5046.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Resource Mgr Database Path ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5052.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Resource Mgr Database Volume ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5058.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("secretary ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3oon40.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Sides Supported ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5184.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Attribute ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5190.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Cache Limit ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5196.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP DA Back Link ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5202.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Directory Agent DN ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5208.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Language ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5214.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Lifetime ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5220.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Scope Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5226.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Scope Unit DN ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5232.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Start Purge Hour ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5238.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Status ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5244.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP SU Back Link ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5250.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP SU Type ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5256.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP Type ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5262.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SLP URL ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5268.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SMS Protocol Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5274.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SMS Registered Service ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5280.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SU ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5292.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SvcInfo ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5340.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SvcType ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5346.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("SvcTypeID ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5352.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("userSMIMECertificate ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a3oorbh.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("LDAP Operational Attributes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a7lnqjy.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("createTimeStamp ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fur3q.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("creatorsName ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fur3f.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("entryFlags ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fuxcp.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("federationBoundary ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fzxsm.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("localEntryID ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fzcam.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("modifiersName ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fur3j.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("modifyTimeStamp ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fur3x.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("structuralObjectClass ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fuxcb.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("subordinateCount ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fuxci.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("subschemaSubentry ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a6fuxc4.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Attribute Syntax Definitions ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/h55cqjqs.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Back Link ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5533.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Boolean ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5540.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Case Exact String ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5547.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Case Ignore List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5554.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Case Ignore String ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5561.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Class Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5568.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Counter ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5575.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Distinguished Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5582.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("EMail Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5589.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Facsimile Telephone Number ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5596.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Hold ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5603.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Integer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5610.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Interval ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5617.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Net Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5624.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Numeric String ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5631.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Object ACL ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5638.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Octet List ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5645.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Octet String ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5652.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Path ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5659.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Postal Address ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5666.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Printable String ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5673.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Replica Pointer ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5680.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Stream ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5687.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Telephone Number ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5694.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Time ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5701.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Timestamp ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5708.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Typed Name ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5715.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Unknown ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/sdk5722.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Index of Classes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx1.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("A through B ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx2.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("C through D ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx3.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("E through K ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx4.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("L through M ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx5.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("N ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx6.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("O ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx7.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("P through R ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx8.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("S ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx9.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("T through Z ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx10.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Index of Attributes ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx11.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("A ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx12.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("B ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx13.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("C ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx14.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("D ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx15.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("E ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx16.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("F through G ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx17.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("H ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx18.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("I through K ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx19.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("L ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx20.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("M ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx21.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("N ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx22.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("O ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx23.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("P ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx24.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Q ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx25.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("R ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx26.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("S ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx27.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("T ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx28.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("U ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx29.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("V through Z ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx30.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Index of ASN.1 IDs ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx31.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("0 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx32.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("1 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx33.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("2 through 2.4 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx34.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("2.5 through 2.9 ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx35.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Index of LDAP Names ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx36.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("A through B ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx37.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("C ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx38.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("D ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx39.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("E through F ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx40.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("G ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx41.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("H ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx42.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("I through K ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx43.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("L ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx44.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("M ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx45.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("N ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx46.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("O ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx47.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("P ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx48.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Q through R ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx49.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("S ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx50.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("T ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx51.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("U through Z ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/schidx52.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Revision History ","http://developer.novell.com/ndk/doc/ndslib/schm_enu/data/a5i29ah.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Iterator Services ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hnv8aaj7.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Concepts ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hj3udfo7.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Iterator Objects ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hwiuqovp.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Creation of an Iterator Object ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hrb7xece.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Iterator Indexes ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hqngpqag.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Positions of an Iterator Object ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/h25zhm0d.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Current Position Movement with Retrieval Functions ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hn9jdbnd.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Retrieval of Data ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hy7j1t07.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Tasks ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/huypg52u.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Creating a Search Iterator Object ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hcyx2utx.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Retrieving and Unpacking Object and Attribute Name Data ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/h9evr0ru.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Retrieving and Unpacking Object, Attribute, and Value Data ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/htq89y7t.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Functions ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/h7qwv271.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("NWDSItrAtEOF ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk29.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrAtFirst ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk36.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrClone ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk43.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrCount ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk50.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrCreateList ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk57.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrCreateSearch ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk64.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrDestroy ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk71.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrGetCurrent ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk77.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrGetInfo ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk84.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrGetNext ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk91.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrGetPosition ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk98.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrGetPrev ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk105.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrSetPosition ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk112.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrSetPositionFromIterator ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk119.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrSkip ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk126.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("NWDSItrTypeDown ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/sdk133.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("NDS Iterator Example Code ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hw9m9u6o.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +currentLevel++; + +setLevels(); +var navElement = navigationLink("Cloning an Iterator Object: Example ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hur66hmi.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Counting with NDS Iterators: Example ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hgllfzfg.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Creating and Using a List Iterator: Example ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hfnbz1tw.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Creating a Search Iterator and Displaying the Results: Example ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hhe6xegc.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Getting Iterator Information: Example ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hfg59w8k.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Getting and Setting the Iterator's Position: Example ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hh03dp06.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Listing in Reverse Order: Example ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hsj5zfs1.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Positioning the Iterator with Typedown: Example ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/hqvieqdk.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +setLevels(); +var navElement = navigationLink("Skipping Objects in the List: Example ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/ho81tg5d.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +setLevels(); +var navElement = navigationLink("Revision History ","http://developer.novell.com/ndk/doc/ndslib/skds_enu/data/a5i29ah.html",currentLevel,index,levelIndexes[currentLevel],levelParents[currentLevel],""); +navigationTree[index] = navElement; +index++; + +if (currentLevel > 1) currentLevel-- + +if (currentLevel > 1) currentLevel-- + + diff --git a/tests/mozilla/js1_5/Regress/regress-114491.js b/tests/mozilla/js1_5/Regress/regress-114491.js new file mode 100644 index 0000000..b4470ee --- /dev/null +++ b/tests/mozilla/js1_5/Regress/regress-114491.js @@ -0,0 +1,101 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2001 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): rokicki@instantis.com, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 10 December 2001 +* SUMMARY: Regression test for bug 114491 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=114491 +* +* Rhino crashed on this code. It should produce a syntax error, not a crash. +* Using the () operator after a function STATEMENT is incorrect syntax. +* Rhino correctly caught the error when there was no |if (true)|. +* With the |if (true)|, however, Rhino crashed - +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 114491; +var summary = 'Regression test for bug 114491'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +status = inSection(1); +actual = 'Program execution did NOT fall into catch-block'; +expect = 'Program execution fell into into catch-block'; +try +{ + var sEval = 'if (true) function f(){}()'; + eval(sEval); +} +catch(e) +{ + actual = expect; +} +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/mozilla/js1_5/Regress/regress-114493.js b/tests/mozilla/js1_5/Regress/regress-114493.js new file mode 100644 index 0000000..41e94b4 --- /dev/null +++ b/tests/mozilla/js1_5/Regress/regress-114493.js @@ -0,0 +1,109 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2001 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): rokicki@instantis.com, pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 10 December 2001 +* SUMMARY: Regression test for bug 114493 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=114493 +* +* Rhino crashed on this code. It should produce a syntax error, not a crash. +* Note that "3"[5] === undefined, and Rhino correctly gave an error if you +* tried to use the call operator on |undefined|: +* +* js> undefined(); +* js: TypeError: undefined is not a function. +* +* However, Rhino CRASHED if you tried to do "3"[5](). +* +* Rhino would NOT crash if you tried "3"[0]() or "3"[5]. Only array indices +* that were out of bounds, followed by the call operator, would crash. +* +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 114493; +var summary = 'Regression test for bug 114493'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var sEval = ''; + + +status = inSection(1); +actual = 'Program execution did NOT fall into catch-block'; +expect = 'Program execution fell into into catch-block'; +try +{ + sEval = '"3"[5]()'; + eval(sEval); +} +catch(e) +{ + actual = expect; +} +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/mozilla/js1_5/Regress/regress-118849.js b/tests/mozilla/js1_5/Regress/regress-118849.js new file mode 100644 index 0000000..3d7b89a --- /dev/null +++ b/tests/mozilla/js1_5/Regress/regress-118849.js @@ -0,0 +1,181 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2001 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 08 Jan 2002 +* SUMMARY: Just testing that we don't crash on this code +* See http://bugzilla.mozilla.org/show_bug.cgi?id=118849 +* +* http://developer.netscape.com:80/docs/manuals/js/core/jsref/function.htm +* The Function constructor: +* Function ([arg1[, arg2[, ... argN]],] functionBody) +* +* Parameters +* arg1, arg2, ... argN +* (Optional) Names to be used by the function as formal argument names. +* Each must be a string that corresponds to a valid JavaScript identifier. +* +* functionBody +* A string containing JS statements comprising the function definition. +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 118849; +var summary = 'Should not crash if we provide Function() with bad arguments' +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var cnFAIL_1 = 'LEGAL call to Function() caused an ERROR!!!'; +var cnFAIL_2 = 'ILLEGAL call to Function() FAILED to cause an error'; +var cnSTRING = 'ASDF'; +var cnNUMBER = 123; + + +/***********************************************************/ +/**** THESE ARE LEGITMATE CALLS AND SHOULD ALL SUCCEED ***/ +/***********************************************************/ +status = inSection(1); +actual = cnFAIL_1; // initialize to failure +try +{ + Function(cnSTRING); + Function(cnNUMBER); // cnNUMBER is a valid functionBody + Function(cnSTRING,cnSTRING); + Function(cnSTRING,cnNUMBER); + Function(cnSTRING,cnSTRING,cnNUMBER); + + new Function(cnSTRING); + new Function(cnNUMBER); + new Function(cnSTRING,cnSTRING); + new Function(cnSTRING,cnNUMBER); + new Function(cnSTRING,cnSTRING,cnNUMBER); + + actual = expect; +} +catch(e) +{ +} +addThis(); + + + +/**********************************************************/ +/*** EACH CASE THAT FOLLOWS SHOULD TRIGGER AN ERROR ***/ +/*** (BUT NOT A CRASH) ***/ +/*** NOTE WE NOW USE cnFAIL_2 INSTEAD OF cnFAIL_1 ***/ +/**********************************************************/ +status = inSection(2); +actual = cnFAIL_2; +try +{ + Function(cnNUMBER,cnNUMBER); // cnNUMBER is an invalid JS identifier name +} +catch(e) +{ + actual = expect; +} +addThis(); + + +status = inSection(3); +actual = cnFAIL_2; +try +{ + Function(cnNUMBER,cnSTRING,cnSTRING); +} +catch(e) +{ + actual = expect; +} +addThis(); + + +status = inSection(4); +actual = cnFAIL_2; +try +{ + new Function(cnNUMBER,cnNUMBER); +} +catch(e) +{ + actual = expect; +} +addThis(); + + +status = inSection(5); +actual = cnFAIL_2; +try +{ + new Function(cnNUMBER,cnSTRING,cnSTRING); +} +catch(e) +{ + actual = expect; +} +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/mozilla/js1_5/Regress/regress-127557.js b/tests/mozilla/js1_5/Regress/regress-127557.js new file mode 100644 index 0000000..80b4e29 --- /dev/null +++ b/tests/mozilla/js1_5/Regress/regress-127557.js @@ -0,0 +1,113 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: NPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Netscape Public License +* Version 1.1 (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is JavaScript Engine testing utilities. +* +* The Initial Developer of the Original Code is Netscape Communications Corp. +* Portions created by the Initial Developer are Copyright (C) 2002 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): brendan@mozilla.org +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the NPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the NPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** +* +* +* Date: 06 Mar 2002 +* SUMMARY: Testing cloned function objects +* See http://bugzilla.mozilla.org/show_bug.cgi?id=127557 +* +* Before this bug was fixed, this testcase would error when run: +* +* ReferenceError: h_peer is not defined +* +* The line |g.prototype = new Object| below is essential: this is +* what was confusing the engine in its attempt to look up h_peer +*/ +//----------------------------------------------------------------------------- +var UBound = 0; +var bug = 127557; +var summary = 'Testing cloned function objects'; +var cnCOMMA = ','; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +function f(x,y) +{ + function h() + { + return h_peer(); + } + function h_peer() + { + return (x + cnCOMMA + y); + } + return h; +} + +status = inSection(1); +var g = clone(f); +g.prototype = new Object; +var h = g(5,6); +actual = h(); +expect = '5,6'; +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i>> 1); + return buildEval_r(beginLine, middle) + buildEval_r(middle, endLine); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i12||day>31||month<=0||day<=0||(isNaN(month)==true)||(isNaN(day)==true)||(isNaN(year)==true)){ +alert(pbc0409); +formfield.focus(); +return false; +} + +if(((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&day>31)||(year%4==0&&month==2&&day>29)||(year%4!=0&&month==2&&day>28)||((month==4||month==6||month==9||month==11)&&day>30)){ +alert(pbc0409); +formfield.focus(); +return false; +} +return true; +} + +function vkdt(formfield){ +date=formfield.value; +year=date.substring(0,4); +hy1=date.charAt(4); +month=date.substring(5,7); +hy2=date.charAt(7); +day=date.substring(8,10); +today=new Date(); +tdy=today.getDate(); +tmn=today.getMonth()+1; +if(today.getYear()<2000)tyr=today.getYear()+1900; +else tyr=today.getYear(); +if(date.match(/^\s*$/)){ +alert(pbc0425); +formfield.focus(); +return false; +} +if(hy1!="/"||hy2!="/"){ +alert(pbc0409); +formfield.focus(); +return false; +} + +if(month>12||day>31||month<=0||day<=0||(isNaN(month)==true)||(isNaN(day)==true)||(isNaN(year)==true)){ +alert(pbc0409); +formfield.focus(); +return false; +} + +if(((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&day>31)||(year%4==0&&month==2&&day>29)||(year%4!=0&&month==2&&day>28)||((month==4||month==6||month==9||month==11)&&day>30)){ +alert(pbc0409); +formfield.focus(); +return false; +} +return true; +} + +function ddif(month1,day1,year1,month2,day2,year2){ +start = new Date(); +start.setYear(year1); +start.setMonth(month1-1); +start.setDate(day1); +start.setMinutes(0); +start.setHours(0); +start.setSeconds(0); +end = new Date(); +end.setYear(year2); +end.setMonth(month2-1); +end.setDate(day2); +end.setMinutes(0); +end.setHours(0); +end.setSeconds(0); +current =(end.getTime() - start.getTime()); +days = Math.floor(current /(1000 * 60 * 60 * 24)); +return(days); +} + +function vsub(form,status,ism,action){ +if(!vol()){ return false; } +if(status<9||status==12){ +band=form.BAND.options[form.BAND.selectedIndex].value; +if(band=="00"){ +alert(pbc0425); +form.BAND.focus(); +return false; +} +} + +if((status>=0&&status<5)||(status==7)||(status>=5&&status<9&&ism=="YES")||(status==12&&ism=="YES")){ +if(!vnull(form.PT)) { return false; } +adt1=form.STD; +adt2=form.END; +stdt=adt1.value; +etdt=adt2.value; +syr=stdt.substring(0,4); +start_hy1=stdt.charAt(4); +smon=stdt.substring(5,7); +start_hy2=stdt.charAt(7); +sdy=stdt.substring(8,10); +eyr=etdt.substring(0,4); +end_hy1=etdt.charAt(4); +emon=etdt.substring(5,7); +end_hy2=etdt.charAt(7); +edy=etdt.substring(8,10); +today=new Date(); +date=today.getDate(); +month=today.getMonth()+1; +if(today.getYear()<2000)year=today.getYear()+1900; else year=today.getYear(); +nextYear=year+1; +if(!vnull(form.STD)){ return false; } +if(!vnull(form.END)){ return false; } +if(start_hy1!="/"||start_hy2!="/"){ +alert(pbc0409); +form.STD.focus(); +return false; +} +if(end_hy1!="/"||end_hy2!="/"){ +alert(pbc0409); +form.END.focus(); +return false; +} +if(smon>12||sdy>31||smon<=0||sdy<=0||(isNaN(smon)==true)||(isNaN(sdy)==true)||(isNaN(syr)==true)){ +alert(pbc0409); +form.STD.focus(); +return false; +} +if(emon>12||edy>31||emon<=0||edy<=0||(isNaN(emon)==true)||(isNaN(edy)==true)||(isNaN(eyr)==true)){ +alert(pbc0409); +form.END.focus(); +return false; +} +if(((smon==1||smon==3||smon==5||smon==7||smon==8||smon==10||smon==12)&&sdy>31)||(syr%4==0&&smon==2&&sdy>29)||(syr%4!=0&&smon==2&&sdy>28)||((smon==4||smon==6||smon==9||smon==11)&&sdy>30)){ +alert(pbc0409); +form.STD.focus(); +return false; +} +if(((emon==1||emon==3||emon==5||emon==7||emon==8||emon==10||emon==12)&&edy>31)||(eyr%4==0&&emon==2&&edy>29)||(eyr%4!=0&&emon==2&&edy>28)||((emon==4||emon==6||emon==9||emon==11)&&edy>30)){ +alert(pbc0409); +form.END.focus(); +return false; +} +if ((eyr==nextYear)&&(syr==year)) { +if ((emon>1)||(edy >31)) { +alert(pbc0401); +form.END.focus(); +return false; +} +} else { + +if ((syr!=eyr)){ +alert(pbc0406); +form.STD.focus(); +return false; +} +if(smon>emon||(smon==emon&&sdy>=edy)){ +alert(pbc0402); +form.STD.focus(); +return false; +} +if((eyr!=year)&&(eyr!=year-1)){ +alert(pbc0405); +form.END.focus(); +return false; +} +} +if(ism=='YES'&&(status==5||status==6||status==12)){ +if(ddif(month,date,year,emon,edy,eyr)>31){ +alert(pbc0421); +form.END.focus(); +return false; +} +} +if((status>2&&status<5)||(status==7)||((status>=5&&status<9||status==12)&&ism=="YES")){ +if(status!=5){ +if(!vdt(form.IRD1)){ +return false; +} +if(!vdt(form.IRD2)){ +return false; +} +if(!vdt(form.IRD3)){ +return false; +} +ird1=form.IRD1.value; +ird2=form.IRD2.value; +ird3=form.IRD3.value; +if(((ird1==ird2)&&(!ird1.match(/^\s*$/)))||((ird1==ird3)&&(!ird1.match(/^\s*$/)))){ +alert(pbc0417); +form.IRD1.focus(); +return false; +} +else if((ird2==ird3)&&(!ird2.match(/^\s*$/))){ +alert(pbc0417); +form.IRD2.focus(); +return false; +} +if(!vdt(form.FRD1)){ return false;} +} +if(status==5){ +if(!vdt(form.IRD1)){return false;} +if(!vdt(form.IRD2)){return false;} +if(!vdt(form.IRD3)){return false;} +ird1=form.IRD1.value; +ird2=form.IRD2.value; +ird3=form.IRD3.value; +if(((ird1==ird2)&&(!ird1.match(/^\s*$/)))||((ird1==ird3)&&(!ird1.match(/^\s*$/)))){ +alert(pbc0417); +form.IRD1.focus(); +return false; +} +else if((ird2==ird3)&&(!ird2.match(/^\s*$/))){ +alert(pbc0417); +form.IRD2.focus(); +return false; +} +if(!vkdt(form.FRD1)){ +return false; +} +} +} +} +if((status>=0&&status<2)||(status==3)||(status==7)||(status>=2&&status<9&&ism=="YES")||(status==12&&ism=="YES")){ +if(!vnull(form.WO)){ +return false; +} +if(!vnull(form.EO)){ +return false; +} +if(!vnull(form.TO)){ +return false; +} +} +if((status==2||status==4)||(status>=5&&status<9&&ism=="YES")||(status==12&&ism=="YES")){ +if(!vnull(form.WR)){return false;} +if(!vnull(form.ER)){return false;} +if(!vnull(form.TR)){return false;} +} +if((status==5||status==6||status==12)&&ism=="YES"){ +if(!vkdt(form.FRD1)){return false;} +frdt=form.FRD1.value; +fryr=frdt.substring(0,4); +frmn=frdt.substring(5,7); +frdy=frdt.substring(8,10); +if(fryr90){ +if(!confirm(pbc0439+" "+pbc0442)){ +form.SID.focus(); +return false; +}}} else { +// MK/06-20-01 = If Rating Not equals to 4 blank out the sustained improve Date +form.SID.value=""; +} +if(!vnull(form.OAT)){ return false; } +if(form.MSRQ.checked==true){ +if(form.NEW_SIGN_MGR_ID.value.match(/^\s*$/)){ +alert(pbc0418); +form.NEW_SIGN_MGR_ID.focus(); +return false; +} +if(vnid(form.NEW_SIGN_MGR_ID)==false){ return false; } +} else { +if(!form.NEW_SIGN_MGR_ID.value.match(/^\s*$/)){ +alert(pbc0422); +form.NEW_SIGN_MGR_ID.focus(); +return false; +} +if ( (form.TOC.value=="YES") && (form.RSRQ.checked==true) ) { +alert(pbc0429); +form.NEW_SEC_LINE_REV_ID.focus(); +return false; +} +} +if(form.RSRQ.checked==true){ +if(form.NEW_SEC_LINE_REV_ID.value.match(/^\s*$/)){ +alert(pbc0418); +form.NEW_SEC_LINE_REV_ID.focus(); +return false; +} +if(vnid(form.NEW_SEC_LINE_REV_ID)==false){ return false; } +} else { +if(!form.NEW_SEC_LINE_REV_ID.value.match(/^\s*$/)) { +alert(pbc0423); +form.NEW_SEC_LINE_REV_ID.focus(); +return false; +} +if ( (form.TOC.value=="YES") && (form.MSRQ.checked==true) ) { +alert(pbc0431); +form.NEW_SEC_LINE_REV_ID.focus(); +return false; +}}} +if(status!=9){ +/**for returned objectives **/ +if(status==3){ +if(conf(pbc0466) == false) return false; +} + +if(ism=='NO'){ +if(status==0||status==1||status==3||status==7){ +if(conf(pbc0456) == false) return false; +} + +if(status==2||status==4||status==8){ +if(conf(pbc0457) == false) return false; +} +} else if(ism=='YES'){ +if(status==0||status==1||status==3||status==7){ +if(conf(pbc0458) == false)return false; +} +if(status==2||status==4||status==8){ +if(conf(pbc0459) == false)return false; +} +if(status==5||status==6){ +if(form.ESRQ.checked==false){ +if(conf(pbc0460) == false)return false; +} else { +if(conf(pbc0461) == false)return false; +}}}} +if(status==9){ +if(ism=='NO'){ +if(conf(pbc0462) == false)return false; +} else if(ism=='YES'){ +if(conf(pbc0463) == false)return false; +} else if(ism=='REVIEWER'){ +if(conf(pbc0464) == false)return false; +}} +sact(action); +if(status>=9&&status<=11){ snul(); } +form.submit(); +return true; +} + +function vsav(form,status,ism,action) { +if(!vol()){ return false; } +adt1=form.STD; +adt2=form.END; +stdt=adt1.value; +etdt=adt2.value; +syr=stdt.substring(0,4); +start_hy1=stdt.charAt(4); +smon=stdt.substring(5,7); +start_hy2=stdt.charAt(7); +sdy=stdt.substring(8,10); +eyr=etdt.substring(0,4); +end_hy1=etdt.charAt(4); +emon=etdt.substring(5,7); +end_hy2=etdt.charAt(7); +edy=etdt.substring(8,10); +today=new Date(); +date=today.getDate(); +month=today.getMonth()+1; +if(today.getYear()<2000) year=today.getYear()+1900; else year=today.getYear(); +nextYear=year+1; +if(!vnull(form.STD)) return false; +if(!vnull(form.END)) return false; +if(start_hy1!="/"||start_hy2!="/"){ +alert(pbc0409); +form.STD.focus(); +return false; +} +if(end_hy1!="/"||end_hy2!="/"){ +alert(pbc0409); +form.END.focus(); +return false; +} +if(smon>12||sdy>31||smon<=0||sdy<=0||(isNaN(smon)==true)||(isNaN(sdy)==true)||(isNaN(syr)==true)){ +alert(pbc0409); +form.STD.focus(); +return false; +} +if(emon>12||edy>31||emon<=0||edy<=0||(isNaN(emon)==true)||(isNaN(edy)==true)||(isNaN(eyr)==true)){ +alert(pbc0409); +form.END.focus(); +return false; +} +if(((smon==1||smon==3||smon==5||smon==7||smon==8||smon==10||smon==12)&&sdy>31)||(syr%4==0&&smon==2&&sdy>29)||(syr%4!=0&&smon==2&&sdy>28)||((smon==4||smon==6||smon==9||smon==11)&&sdy>30)){ +alert(pbc0409); +form.STD.focus(); +return false; +} +if(((emon==1||emon==3||emon==5||emon==7||emon==8||emon==10||emon==12)&&edy>31)||(eyr%4==0&&emon==2&&edy>29)||(eyr%4!=0&&emon==2&&edy>28)||((emon==4||emon==6||emon==9||emon==11)&&edy>30)){ +alert(pbc0409); +form.END.focus(); +return false; +} +if ((eyr==nextYear)&&(syr==year)) { +if ((emon>1)||(edy >31)) { +alert(pbc0401); +form.END.focus(); +return false; +} +} else { +if ((syryear)) { +alert(pbc0407); +form.STD.focus(); +return false; +} +if((eyr!=year)&&(eyr!=year-1)){ +alert(pbc0405); +form.END.focus(); +return false; +} +if(smon>emon||(smon==emon&&sdy>=edy)){ +alert(pbc0403); +form.STD.focus(); +return false; +} +} +if((status>2&&status<5)||(status>=5&&status<9&&ism=="YES")||(status==12&&ism=="YES")){ +if(!vdt(form.IRD1)){return false;} +if(!vdt(form.IRD2)){return false;} +if(!vdt(form.IRD3)){ return false; } +ird1=form.IRD1.value; +ird2=form.IRD2.value; +ird3=form.IRD3.value; +if(((ird1==ird2)&&(!ird1.match(/^\s*$/)))||((ird1==ird3)&&(!ird1.match(/^\s*$/)))){ +alert(pbc0417); +form.IRD1.focus(); +return false; +} +else if((ird2==ird3)&&(!ird2.match(/^\s*$/))){ +alert(pbc0417); +form.IRD2.focus(); +return false; +} +if(!vdt(form.FRD1)){return false;} +if(ism=="YES"){ +if(!vdt(form.FRD1)){return false;} +} +} +if((status==5||status==6)&&ism=="YES"){ +rating=""; +for(i=0;i=9&&status<=11){ +snul(); +} +form.submit(); +return true; +} +function cft(formfield){ +nid=formfield.value; +if(nid.match(/^\s*$/)){ +alert(pbc0419); +formfield.focus(); +return false; +} +nl=nid.split('/').length; +if(nl!=2&&nl!=3){ +alert(pbc0420); +formfield.focus(); +return false; +} +return true; +} +function dcf(form,pbcId,cnum,sequence,status,atyp,ver){ +if(!vol()){} +dflg=confirm("\n\n<====================== " + pbc0468 + " ======================>\n\n" + pbc0469 + "\n\n<==================================================================>"); +if(dflg==true) { +form.ATYP.value=atyp; +form.PID.value=pbcId; +form.CNUM.value=cnum; +form.SEQ.value=sequence; +form.ST.value=status; +form.VER.value=ver; +form.submit(); +} + +} + + + +function lop(){ +//if(confirm(pbc0447+" "+pbc0451)){ +sck("timer",""); +sck("PBC_AUTH4",""); +sck("IBM004",""); +this.close(); +//} + +} + +function csrlop(){ + top.location="logoff.jsp"; +} +function lof(){ +csr=gck("IBM004"); +if(csr==null){ top.location="logoff.jsp"; } +else if(csr.charAt(0)==3){ window.location="csrlogoff.jsp"; } +else{ top.location="logoff.jsp"; } +} + +function goToHome(){ + top.location="pbcmain.jsp"; + } + +function docsr(){ +sck("IBM004","1^NONE^1"); +window.location="pbcmain.jsp" +} + +function ccd(){ +if(confirm(pbc0434)){ +if(navigator.appName!="Netscape"){ +if(!window.navigator.onLine){ +window.close(); +} +else { +window.location='pbcmain.jsp'; +} +} +else { +window.location='pbcmain.jsp'; +} +} +} + +function crt(form,action){ +if(!vol()){return false;} +band=form.BAND.options[form.BAND.selectedIndex].value; +if(band=="00"){ +alert(pbc0425); +form.BAND.focus(); +return false; +} +if(!confirm(pbc0450)){return false;} +sact(action); +form.submit(); +return true; +} +function cusat(form,action){ +if(!vol()){return false;} +sact(action); +form.action="unsatreq.jsp"; +form.submit(); +return true; +} +function cfrt(form,ism,action){ +if(!vol()){return false;} +sact(action); +if(ism=="NO"){ +if(confirm(pbc0449+" "+pbc0432)){ +snul(); +form.submit(); +return true; +} +} +if(ism=="REVIEWER"){ +if(confirm(pbc0449+" "+pbc0448)){ +snul(); +form.submit(); +return true; +} +} +if(ism=="YES"){ +if(confirm(pbc0440)){ +snul(); +form.submit(); +return true; +} +} +} + +function cces(form){ +if(form.ESRQ.checked==true){ +if(!confirm(pbc0435+" "+pbc0443))form.ESRQ.checked=false; +else {form.ESRQ.checked=true;} +} +} + +function ccms(form){ +if(form.MSRQ.checked==true){ +if(!confirm(pbc0441+" "+pbc0438+" "+pbc0444+" "+pbc0445))form.MSRQ.checked=false; +else { +form.MSRQ.checked=true; +} +} +} + +function ccrs(form){ +if(form.RSRQ.checked==true){ +if(!confirm(pbc0441+" "+pbc0438+" "+pbc0444+" "+pbc0446))form.RSRQ.checked=false; +else { +form.RSRQ.checked=true; +} +} +} + +function seo(){ +alert(pbc0412+" "+pbc0413+" "+pbc0414); +} +function cows(form,action){ +if(!vol()){ +return false; +} +if(confirm(pbc0437)){ +sact(action); +form.submit(); +return true; +} +} + +function srdb(rdb,value) { +for(i=0; i 0) { +for(i=0;i < lbx.options.length;i++) { +if(lbx.options[i].value == value) { +lbx.options[i].selected = true; +return true; +} +} +} +return true; +} + +function ourl(URL,WIN_NAME){ +if(!vol()){ return; } +var emp_win; +if(document.layers) { +child_screenX=window.screenX+50; +child_width=window.innerWidth-75; +child_height=window.innerHeight-75; +emp_win=window.open(URL,WIN_NAME,"screenX="+ child_screenX +",screenY=75,height="+ child_height +",width="+ child_width +",resizable,status,scrollbars"); +} else{ +child_width = screen.width-160; +child_height = screen.height-200; +emp_win=window.open(URL,WIN_NAME,"height="+ child_height +",width="+ child_width +",resizable=yes,status=no,scrollbars=yes"); +//emp_win.moveTo(110,0); +} +//if (URL.indexOf("pbcsitehelp")==-1) { alert("Opened new window."); } +emp_win.focus(); +} + +function dnh(form){ +form.NHS[0].checked=false; +form.NHS[1].checked=false; +form.NHB[0].checked=false; +form.NHB[1].checked=false; +} + +function cnh(form){ +isnh=""; +for(i=0; i"); +var txtValue3 = txtValue2.replace((/</g),"<"); +return txtValue3; +} + +function encodeText(txtValue) { +if (txtValue.match(/^\s*$/)) return txtValue; +var txtValue0 = txtValue.replace((/\r\n/g),'&lf;'); +var txtValue1 = txtValue0.replace((/"/g),'"'); +var txtValue2 = txtValue1.replace((/>/g),'>'); +var txtValue3 = txtValue2.replace((/ as a single-line comment indicator. +* Whitespace may occur before the --> on the same line. +* +* See http://bugzilla.mozilla.org/show_bug.cgi?id=31255 +* and http://bugzilla.mozilla.org/show_bug.cgi?id=179366 (Rhino version) +* +* Note: are the HTML multi-line comment opener, closer. +* JS already accepted as a single-line comment indicator'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + + HTML comment end is JS comments until end-of-line + --> but only if it follows a possible whitespace after line start + --> so in the following --> should not be treated as comments +if (x-->0) + x = 2; + +status = inSection(2); +actual = (x == 2); +expect = true; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i 0) check ('a string 1'); break; + case 2: if (n[2]++ > 0) check ('a string 2'); break; + case 3: if (n[3]++ > 0) check ('a string 3'); break; + case 4: if (n[4]++ > 0) check ('a string 4'); break; + case 5: if (n[5]++ > 0) check ('a string 5'); break; + case 6: if (n[6]++ > 0) check ('a string 6'); break; + case 7: if (n[7]++ > 0) check ('a string 7'); break; + case 8: if (n[8]++ > 0) check ('a string 8'); break; + case 9: if (n[9]++ > 0) check ('a string 9'); break; + case 10: if (n[10]++ > 0) check ('a string 10'); break; + case 11: if (n[11]++ > 0) check ('a string 11'); break; + case 12: if (n[12]++ > 0) check ('a string 12'); break; + case 13: if (n[13]++ > 0) check ('a string 13'); break; + case 14: if (n[14]++ > 0) check ('a string 14'); break; + case 15: if (n[15]++ > 0) check ('a string 15'); break; + case 16: if (n[16]++ > 0) check ('a string 16'); break; + case 17: if (n[17]++ > 0) check ('a string 17'); break; + case 18: if (n[18]++ > 0) check ('a string 18'); break; + case 19: if (n[19]++ > 0) check ('a string 19'); break; + case 20: if (n[20]++ > 0) check ('a string 20'); break; + case 21: if (n[21]++ > 0) check ('a string 21'); break; + case 22: if (n[22]++ > 0) check ('a string 22'); break; + case 23: if (n[23]++ > 0) check ('a string 23'); break; + case 24: if (n[24]++ > 0) check ('a string 24'); break; + case 25: if (n[25]++ > 0) check ('a string 25'); break; + case 26: if (n[26]++ > 0) check ('a string 26'); break; + case 27: if (n[27]++ > 0) check ('a string 27'); break; + case 28: if (n[28]++ > 0) check ('a string 28'); break; + case 29: if (n[29]++ > 0) check ('a string 29'); break; + case 30: if (n[30]++ > 0) check ('a string 30'); break; + case 31: if (n[31]++ > 0) check ('a string 31'); break; + case 32: if (n[32]++ > 0) check ('a string 32'); break; + case 33: if (n[33]++ > 0) check ('a string 33'); break; + case 34: if (n[34]++ > 0) check ('a string 34'); break; + case 35: if (n[35]++ > 0) check ('a string 35'); break; + case 36: if (n[36]++ > 0) check ('a string 36'); break; + case 37: if (n[37]++ > 0) check ('a string 37'); break; + case 38: if (n[38]++ > 0) check ('a string 38'); break; + case 39: if (n[39]++ > 0) check ('a string 39'); break; + case 40: if (n[40]++ > 0) check ('a string 40'); break; + case 41: if (n[41]++ > 0) check ('a string 41'); break; + case 42: if (n[42]++ > 0) check ('a string 42'); break; + case 43: if (n[43]++ > 0) check ('a string 43'); break; + case 44: if (n[44]++ > 0) check ('a string 44'); break; + case 45: if (n[45]++ > 0) check ('a string 45'); break; + case 46: if (n[46]++ > 0) check ('a string 46'); break; + case 47: if (n[47]++ > 0) check ('a string 47'); break; + case 48: if (n[48]++ > 0) check ('a string 48'); break; + case 49: if (n[49]++ > 0) check ('a string 49'); break; + case 50: if (n[50]++ > 0) check ('a string 50'); break; + case 51: if (n[51]++ > 0) check ('a string 51'); break; + case 52: if (n[52]++ > 0) check ('a string 52'); break; + case 53: if (n[53]++ > 0) check ('a string 53'); break; + case 54: if (n[54]++ > 0) check ('a string 54'); break; + case 55: if (n[55]++ > 0) check ('a string 55'); break; + case 56: if (n[56]++ > 0) check ('a string 56'); break; + case 57: if (n[57]++ > 0) check ('a string 57'); break; + case 58: if (n[58]++ > 0) check ('a string 58'); break; + case 59: if (n[59]++ > 0) check ('a string 59'); break; + case 60: if (n[60]++ > 0) check ('a string 60'); break; + case 61: if (n[61]++ > 0) check ('a string 61'); break; + case 62: if (n[62]++ > 0) check ('a string 62'); break; + case 63: if (n[63]++ > 0) check ('a string 63'); break; + case 64: if (n[64]++ > 0) check ('a string 64'); break; + case 65: if (n[65]++ > 0) check ('a string 65'); break; + case 66: if (n[66]++ > 0) check ('a string 66'); break; + case 67: if (n[67]++ > 0) check ('a string 67'); break; + case 68: if (n[68]++ > 0) check ('a string 68'); break; + case 69: if (n[69]++ > 0) check ('a string 69'); break; + case 70: if (n[70]++ > 0) check ('a string 70'); break; + case 71: if (n[71]++ > 0) check ('a string 71'); break; + case 72: if (n[72]++ > 0) check ('a string 72'); break; + case 73: if (n[73]++ > 0) check ('a string 73'); break; + case 74: if (n[74]++ > 0) check ('a string 74'); break; + case 75: if (n[75]++ > 0) check ('a string 75'); break; + case 76: if (n[76]++ > 0) check ('a string 76'); break; + case 77: if (n[77]++ > 0) check ('a string 77'); break; + case 78: if (n[78]++ > 0) check ('a string 78'); break; + case 79: if (n[79]++ > 0) check ('a string 79'); break; + case 80: if (n[80]++ > 0) check ('a string 80'); break; + case 81: if (n[81]++ > 0) check ('a string 81'); break; + case 82: if (n[82]++ > 0) check ('a string 82'); break; + case 83: if (n[83]++ > 0) check ('a string 83'); break; + case 84: if (n[84]++ > 0) check ('a string 84'); break; + case 85: if (n[85]++ > 0) check ('a string 85'); break; + case 86: if (n[86]++ > 0) check ('a string 86'); break; + case 87: if (n[87]++ > 0) check ('a string 87'); break; + case 88: if (n[88]++ > 0) check ('a string 88'); break; + case 89: if (n[89]++ > 0) check ('a string 89'); break; + case 90: if (n[90]++ > 0) check ('a string 90'); break; + case 91: if (n[91]++ > 0) check ('a string 91'); break; + case 92: if (n[92]++ > 0) check ('a string 92'); break; + case 93: if (n[93]++ > 0) check ('a string 93'); break; + case 94: if (n[94]++ > 0) check ('a string 94'); break; + case 95: if (n[95]++ > 0) check ('a string 95'); break; + case 96: if (n[96]++ > 0) check ('a string 96'); break; + case 97: if (n[97]++ > 0) check ('a string 97'); break; + case 98: if (n[98]++ > 0) check ('a string 98'); break; + case 99: if (n[99]++ > 0) check ('a string 99'); break; + case 100: if (n[100]++ > 0) check ('a string 100'); break; + case 101: if (n[101]++ > 0) check ('a string 101'); break; + case 102: if (n[102]++ > 0) check ('a string 102'); break; + case 103: if (n[103]++ > 0) check ('a string 103'); break; + case 104: if (n[104]++ > 0) check ('a string 104'); break; + case 105: if (n[105]++ > 0) check ('a string 105'); break; + case 106: if (n[106]++ > 0) check ('a string 106'); break; + case 107: if (n[107]++ > 0) check ('a string 107'); break; + case 108: if (n[108]++ > 0) check ('a string 108'); break; + case 109: if (n[109]++ > 0) check ('a string 109'); break; + case 110: if (n[110]++ > 0) check ('a string 110'); break; + case 111: if (n[111]++ > 0) check ('a string 111'); break; + case 112: if (n[112]++ > 0) check ('a string 112'); break; + case 113: if (n[113]++ > 0) check ('a string 113'); break; + case 114: if (n[114]++ > 0) check ('a string 114'); break; + case 115: if (n[115]++ > 0) check ('a string 115'); break; + case 116: if (n[116]++ > 0) check ('a string 116'); break; + case 117: if (n[117]++ > 0) check ('a string 117'); break; + case 118: if (n[118]++ > 0) check ('a string 118'); break; + case 119: if (n[119]++ > 0) check ('a string 119'); break; + case 120: if (n[120]++ > 0) check ('a string 120'); break; + case 121: if (n[121]++ > 0) check ('a string 121'); break; + case 122: if (n[122]++ > 0) check ('a string 122'); break; + case 123: if (n[123]++ > 0) check ('a string 123'); break; + case 124: if (n[124]++ > 0) check ('a string 124'); break; + case 125: if (n[125]++ > 0) check ('a string 125'); break; + case 126: if (n[126]++ > 0) check ('a string 126'); break; + case 127: if (n[127]++ > 0) check ('a string 127'); break; + case 128: if (n[128]++ > 0) check ('a string 128'); break; + case 129: if (n[129]++ > 0) check ('a string 129'); break; + case 130: if (n[130]++ > 0) check ('a string 130'); break; + case 131: if (n[131]++ > 0) check ('a string 131'); break; + case 132: if (n[132]++ > 0) check ('a string 132'); break; + case 133: if (n[133]++ > 0) check ('a string 133'); break; + case 134: if (n[134]++ > 0) check ('a string 134'); break; + case 135: if (n[135]++ > 0) check ('a string 135'); break; + case 136: if (n[136]++ > 0) check ('a string 136'); break; + case 137: if (n[137]++ > 0) check ('a string 137'); break; + case 138: if (n[138]++ > 0) check ('a string 138'); break; + case 139: if (n[139]++ > 0) check ('a string 139'); break; + case 140: if (n[140]++ > 0) check ('a string 140'); break; + case 141: if (n[141]++ > 0) check ('a string 141'); break; + case 142: if (n[142]++ > 0) check ('a string 142'); break; + case 143: if (n[143]++ > 0) check ('a string 143'); break; + case 144: if (n[144]++ > 0) check ('a string 144'); break; + case 145: if (n[145]++ > 0) check ('a string 145'); break; + case 146: if (n[146]++ > 0) check ('a string 146'); break; + case 147: if (n[147]++ > 0) check ('a string 147'); break; + case 148: if (n[148]++ > 0) check ('a string 148'); break; + case 149: if (n[149]++ > 0) check ('a string 149'); break; + case 150: if (n[150]++ > 0) check ('a string 150'); break; + case 151: if (n[151]++ > 0) check ('a string 151'); break; + case 152: if (n[152]++ > 0) check ('a string 152'); break; + case 153: if (n[153]++ > 0) check ('a string 153'); break; + case 154: if (n[154]++ > 0) check ('a string 154'); break; + case 155: if (n[155]++ > 0) check ('a string 155'); break; + case 156: if (n[156]++ > 0) check ('a string 156'); break; + case 157: if (n[157]++ > 0) check ('a string 157'); break; + case 158: if (n[158]++ > 0) check ('a string 158'); break; + case 159: if (n[159]++ > 0) check ('a string 159'); break; + case 160: if (n[160]++ > 0) check ('a string 160'); break; + case 161: if (n[161]++ > 0) check ('a string 161'); break; + case 162: if (n[162]++ > 0) check ('a string 162'); break; + case 163: if (n[163]++ > 0) check ('a string 163'); break; + case 164: if (n[164]++ > 0) check ('a string 164'); break; + case 165: if (n[165]++ > 0) check ('a string 165'); break; + case 166: if (n[166]++ > 0) check ('a string 166'); break; + case 167: if (n[167]++ > 0) check ('a string 167'); break; + case 168: if (n[168]++ > 0) check ('a string 168'); break; + case 169: if (n[169]++ > 0) check ('a string 169'); break; + case 170: if (n[170]++ > 0) check ('a string 170'); break; + case 171: if (n[171]++ > 0) check ('a string 171'); break; + case 172: if (n[172]++ > 0) check ('a string 172'); break; + case 173: if (n[173]++ > 0) check ('a string 173'); break; + case 174: if (n[174]++ > 0) check ('a string 174'); break; + case 175: if (n[175]++ > 0) check ('a string 175'); break; + case 176: if (n[176]++ > 0) check ('a string 176'); break; + case 177: if (n[177]++ > 0) check ('a string 177'); break; + case 178: if (n[178]++ > 0) check ('a string 178'); break; + case 179: if (n[179]++ > 0) check ('a string 179'); break; + case 180: if (n[180]++ > 0) check ('a string 180'); break; + case 181: if (n[181]++ > 0) check ('a string 181'); break; + case 182: if (n[182]++ > 0) check ('a string 182'); break; + case 183: if (n[183]++ > 0) check ('a string 183'); break; + case 184: if (n[184]++ > 0) check ('a string 184'); break; + case 185: if (n[185]++ > 0) check ('a string 185'); break; + case 186: if (n[186]++ > 0) check ('a string 186'); break; + case 187: if (n[187]++ > 0) check ('a string 187'); break; + case 188: if (n[188]++ > 0) check ('a string 188'); break; + case 189: if (n[189]++ > 0) check ('a string 189'); break; + case 190: if (n[190]++ > 0) check ('a string 190'); break; + case 191: if (n[191]++ > 0) check ('a string 191'); break; + case 192: if (n[192]++ > 0) check ('a string 192'); break; + case 193: if (n[193]++ > 0) check ('a string 193'); break; + case 194: if (n[194]++ > 0) check ('a string 194'); break; + case 195: if (n[195]++ > 0) check ('a string 195'); break; + case 196: if (n[196]++ > 0) check ('a string 196'); break; + case 197: if (n[197]++ > 0) check ('a string 197'); break; + case 198: if (n[198]++ > 0) check ('a string 198'); break; + case 199: if (n[199]++ > 0) check ('a string 199'); break; + case 200: if (n[200]++ > 0) check ('a string 200'); break; + case 201: if (n[201]++ > 0) check ('a string 201'); break; + case 202: if (n[202]++ > 0) check ('a string 202'); break; + case 203: if (n[203]++ > 0) check ('a string 203'); break; + case 204: if (n[204]++ > 0) check ('a string 204'); break; + case 205: if (n[205]++ > 0) check ('a string 205'); break; + case 206: if (n[206]++ > 0) check ('a string 206'); break; + case 207: if (n[207]++ > 0) check ('a string 207'); break; + case 208: if (n[208]++ > 0) check ('a string 208'); break; + case 209: if (n[209]++ > 0) check ('a string 209'); break; + case 210: if (n[210]++ > 0) check ('a string 210'); break; + case 211: if (n[211]++ > 0) check ('a string 211'); break; + case 212: if (n[212]++ > 0) check ('a string 212'); break; + case 213: if (n[213]++ > 0) check ('a string 213'); break; + case 214: if (n[214]++ > 0) check ('a string 214'); break; + case 215: if (n[215]++ > 0) check ('a string 215'); break; + case 216: if (n[216]++ > 0) check ('a string 216'); break; + case 217: if (n[217]++ > 0) check ('a string 217'); break; + case 218: if (n[218]++ > 0) check ('a string 218'); break; + case 219: if (n[219]++ > 0) check ('a string 219'); break; + case 220: if (n[220]++ > 0) check ('a string 220'); break; + case 221: if (n[221]++ > 0) check ('a string 221'); break; + case 222: if (n[222]++ > 0) check ('a string 222'); break; + case 223: if (n[223]++ > 0) check ('a string 223'); break; + case 224: if (n[224]++ > 0) check ('a string 224'); break; + case 225: if (n[225]++ > 0) check ('a string 225'); break; + case 226: if (n[226]++ > 0) check ('a string 226'); break; + case 227: if (n[227]++ > 0) check ('a string 227'); break; + case 228: if (n[228]++ > 0) check ('a string 228'); break; + case 229: if (n[229]++ > 0) check ('a string 229'); break; + case 230: if (n[230]++ > 0) check ('a string 230'); break; + case 231: if (n[231]++ > 0) check ('a string 231'); break; + case 232: if (n[232]++ > 0) check ('a string 232'); break; + case 233: if (n[233]++ > 0) check ('a string 233'); break; + case 234: if (n[234]++ > 0) check ('a string 234'); break; + case 235: if (n[235]++ > 0) check ('a string 235'); break; + case 236: if (n[236]++ > 0) check ('a string 236'); break; + case 237: if (n[237]++ > 0) check ('a string 237'); break; + case 238: if (n[238]++ > 0) check ('a string 238'); break; + case 239: if (n[239]++ > 0) check ('a string 239'); break; + case 240: if (n[240]++ > 0) check ('a string 240'); break; + case 241: if (n[241]++ > 0) check ('a string 241'); break; + case 242: if (n[242]++ > 0) check ('a string 242'); break; + case 243: if (n[243]++ > 0) check ('a string 243'); break; + case 244: if (n[244]++ > 0) check ('a string 244'); break; + case 245: if (n[245]++ > 0) check ('a string 245'); break; + case 246: if (n[246]++ > 0) check ('a string 246'); break; + case 247: if (n[247]++ > 0) check ('a string 247'); break; + case 248: if (n[248]++ > 0) check ('a string 248'); break; + case 249: if (n[249]++ > 0) check ('a string 249'); break; + case 250: if (n[250]++ > 0) check ('a string 250'); break; + case 251: if (n[251]++ > 0) check ('a string 251'); break; + case 252: if (n[252]++ > 0) check ('a string 252'); break; + case 253: if (n[253]++ > 0) check ('a string 253'); break; + case 254: if (n[254]++ > 0) check ('a string 254'); break; + case 255: if (n[255]++ > 0) check ('a string 255'); break; + case 256: if (n[256]++ > 0) check ('a string 256'); break; + case 257: if (n[257]++ > 0) check ('a string 257'); break; + case 258: if (n[258]++ > 0) check ('a string 258'); break; + case 259: if (n[259]++ > 0) check ('a string 259'); break; + case 260: if (n[260]++ > 0) check ('a string 260'); break; + case 261: if (n[261]++ > 0) check ('a string 261'); break; + case 262: if (n[262]++ > 0) check ('a string 262'); break; + case 263: if (n[263]++ > 0) check ('a string 263'); break; + case 264: if (n[264]++ > 0) check ('a string 264'); break; + case 265: if (n[265]++ > 0) check ('a string 265'); break; + case 266: if (n[266]++ > 0) check ('a string 266'); break; + case 267: if (n[267]++ > 0) check ('a string 267'); break; + case 268: if (n[268]++ > 0) check ('a string 268'); break; + case 269: if (n[269]++ > 0) check ('a string 269'); break; + case 270: if (n[270]++ > 0) check ('a string 270'); break; + case 271: if (n[271]++ > 0) check ('a string 271'); break; + case 272: if (n[272]++ > 0) check ('a string 272'); break; + case 273: if (n[273]++ > 0) check ('a string 273'); break; + case 274: if (n[274]++ > 0) check ('a string 274'); break; + case 275: if (n[275]++ > 0) check ('a string 275'); break; + case 276: if (n[276]++ > 0) check ('a string 276'); break; + case 277: if (n[277]++ > 0) check ('a string 277'); break; + case 278: if (n[278]++ > 0) check ('a string 278'); break; + case 279: if (n[279]++ > 0) check ('a string 279'); break; + case 280: if (n[280]++ > 0) check ('a string 280'); break; + case 281: if (n[281]++ > 0) check ('a string 281'); break; + case 282: if (n[282]++ > 0) check ('a string 282'); break; + case 283: if (n[283]++ > 0) check ('a string 283'); break; + case 284: if (n[284]++ > 0) check ('a string 284'); break; + case 285: if (n[285]++ > 0) check ('a string 285'); break; + case 286: if (n[286]++ > 0) check ('a string 286'); break; + case 287: if (n[287]++ > 0) check ('a string 287'); break; + case 288: if (n[288]++ > 0) check ('a string 288'); break; + case 289: if (n[289]++ > 0) check ('a string 289'); break; + case 290: if (n[290]++ > 0) check ('a string 290'); break; + case 291: if (n[291]++ > 0) check ('a string 291'); break; + case 292: if (n[292]++ > 0) check ('a string 292'); break; + case 293: if (n[293]++ > 0) check ('a string 293'); break; + case 294: if (n[294]++ > 0) check ('a string 294'); break; + case 295: if (n[295]++ > 0) check ('a string 295'); break; + case 296: if (n[296]++ > 0) check ('a string 296'); break; + case 297: if (n[297]++ > 0) check ('a string 297'); break; + case 298: if (n[298]++ > 0) check ('a string 298'); break; + case 299: if (n[299]++ > 0) check ('a string 299'); break; + case 300: if (n[300]++ > 0) check ('a string 300'); break; + case 301: if (n[301]++ > 0) check ('a string 301'); break; + case 302: if (n[302]++ > 0) check ('a string 302'); break; + case 303: if (n[303]++ > 0) check ('a string 303'); break; + case 304: if (n[304]++ > 0) check ('a string 304'); break; + case 305: if (n[305]++ > 0) check ('a string 305'); break; + case 306: if (n[306]++ > 0) check ('a string 306'); break; + case 307: if (n[307]++ > 0) check ('a string 307'); break; + case 308: if (n[308]++ > 0) check ('a string 308'); break; + case 309: if (n[309]++ > 0) check ('a string 309'); break; + case 310: if (n[310]++ > 0) check ('a string 310'); break; + case 311: if (n[311]++ > 0) check ('a string 311'); break; + case 312: if (n[312]++ > 0) check ('a string 312'); break; + case 313: if (n[313]++ > 0) check ('a string 313'); break; + case 314: if (n[314]++ > 0) check ('a string 314'); break; + case 315: if (n[315]++ > 0) check ('a string 315'); break; + case 316: if (n[316]++ > 0) check ('a string 316'); break; + case 317: if (n[317]++ > 0) check ('a string 317'); break; + case 318: if (n[318]++ > 0) check ('a string 318'); break; + case 319: if (n[319]++ > 0) check ('a string 319'); break; + case 320: if (n[320]++ > 0) check ('a string 320'); break; + case 321: if (n[321]++ > 0) check ('a string 321'); break; + case 322: if (n[322]++ > 0) check ('a string 322'); break; + case 323: if (n[323]++ > 0) check ('a string 323'); break; + case 324: if (n[324]++ > 0) check ('a string 324'); break; + case 325: if (n[325]++ > 0) check ('a string 325'); break; + case 326: if (n[326]++ > 0) check ('a string 326'); break; + case 327: if (n[327]++ > 0) check ('a string 327'); break; + case 328: if (n[328]++ > 0) check ('a string 328'); break; + case 329: if (n[329]++ > 0) check ('a string 329'); break; + case 330: if (n[330]++ > 0) check ('a string 330'); break; + case 331: if (n[331]++ > 0) check ('a string 331'); break; + case 332: if (n[332]++ > 0) check ('a string 332'); break; + case 333: if (n[333]++ > 0) check ('a string 333'); break; + case 334: if (n[334]++ > 0) check ('a string 334'); break; + case 335: if (n[335]++ > 0) check ('a string 335'); break; + case 336: if (n[336]++ > 0) check ('a string 336'); break; + case 337: if (n[337]++ > 0) check ('a string 337'); break; + case 338: if (n[338]++ > 0) check ('a string 338'); break; + case 339: if (n[339]++ > 0) check ('a string 339'); break; + case 340: if (n[340]++ > 0) check ('a string 340'); break; + case 341: if (n[341]++ > 0) check ('a string 341'); break; + case 342: if (n[342]++ > 0) check ('a string 342'); break; + case 343: if (n[343]++ > 0) check ('a string 343'); break; + case 344: if (n[344]++ > 0) check ('a string 344'); break; + case 345: if (n[345]++ > 0) check ('a string 345'); break; + case 346: if (n[346]++ > 0) check ('a string 346'); break; + case 347: if (n[347]++ > 0) check ('a string 347'); break; + case 348: if (n[348]++ > 0) check ('a string 348'); break; + case 349: if (n[349]++ > 0) check ('a string 349'); break; + case 350: if (n[350]++ > 0) check ('a string 350'); break; + case 351: if (n[351]++ > 0) check ('a string 351'); break; + case 352: if (n[352]++ > 0) check ('a string 352'); break; + case 353: if (n[353]++ > 0) check ('a string 353'); break; + case 354: if (n[354]++ > 0) check ('a string 354'); break; + case 355: if (n[355]++ > 0) check ('a string 355'); break; + case 356: if (n[356]++ > 0) check ('a string 356'); break; + case 357: if (n[357]++ > 0) check ('a string 357'); break; + case 358: if (n[358]++ > 0) check ('a string 358'); break; + case 359: if (n[359]++ > 0) check ('a string 359'); break; + case 360: if (n[360]++ > 0) check ('a string 360'); break; + case 361: if (n[361]++ > 0) check ('a string 361'); break; + case 362: if (n[362]++ > 0) check ('a string 362'); break; + case 363: if (n[363]++ > 0) check ('a string 363'); break; + case 364: if (n[364]++ > 0) check ('a string 364'); break; + case 365: if (n[365]++ > 0) check ('a string 365'); break; + case 366: if (n[366]++ > 0) check ('a string 366'); break; + case 367: if (n[367]++ > 0) check ('a string 367'); break; + case 368: if (n[368]++ > 0) check ('a string 368'); break; + case 369: if (n[369]++ > 0) check ('a string 369'); break; + case 370: if (n[370]++ > 0) check ('a string 370'); break; + case 371: if (n[371]++ > 0) check ('a string 371'); break; + case 372: if (n[372]++ > 0) check ('a string 372'); break; + case 373: if (n[373]++ > 0) check ('a string 373'); break; + case 374: if (n[374]++ > 0) check ('a string 374'); break; + case 375: if (n[375]++ > 0) check ('a string 375'); break; + case 376: if (n[376]++ > 0) check ('a string 376'); break; + case 377: if (n[377]++ > 0) check ('a string 377'); break; + case 378: if (n[378]++ > 0) check ('a string 378'); break; + case 379: if (n[379]++ > 0) check ('a string 379'); break; + case 380: if (n[380]++ > 0) check ('a string 380'); break; + case 381: if (n[381]++ > 0) check ('a string 381'); break; + case 382: if (n[382]++ > 0) check ('a string 382'); break; + case 383: if (n[383]++ > 0) check ('a string 383'); break; + case 384: if (n[384]++ > 0) check ('a string 384'); break; + case 385: if (n[385]++ > 0) check ('a string 385'); break; + case 386: if (n[386]++ > 0) check ('a string 386'); break; + case 387: if (n[387]++ > 0) check ('a string 387'); break; + case 388: if (n[388]++ > 0) check ('a string 388'); break; + case 389: if (n[389]++ > 0) check ('a string 389'); break; + case 390: if (n[390]++ > 0) check ('a string 390'); break; + case 391: if (n[391]++ > 0) check ('a string 391'); break; + case 392: if (n[392]++ > 0) check ('a string 392'); break; + case 393: if (n[393]++ > 0) check ('a string 393'); break; + case 394: if (n[394]++ > 0) check ('a string 394'); break; + case 395: if (n[395]++ > 0) check ('a string 395'); break; + case 396: if (n[396]++ > 0) check ('a string 396'); break; + case 397: if (n[397]++ > 0) check ('a string 397'); break; + case 398: if (n[398]++ > 0) check ('a string 398'); break; + case 399: if (n[399]++ > 0) check ('a string 399'); break; + case 400: if (n[400]++ > 0) check ('a string 400'); break; + case 401: if (n[401]++ > 0) check ('a string 401'); break; + case 402: if (n[402]++ > 0) check ('a string 402'); break; + case 403: if (n[403]++ > 0) check ('a string 403'); break; + case 404: if (n[404]++ > 0) check ('a string 404'); break; + case 405: if (n[405]++ > 0) check ('a string 405'); break; + case 406: if (n[406]++ > 0) check ('a string 406'); break; + case 407: if (n[407]++ > 0) check ('a string 407'); break; + case 408: if (n[408]++ > 0) check ('a string 408'); break; + case 409: if (n[409]++ > 0) check ('a string 409'); break; + case 410: if (n[410]++ > 0) check ('a string 410'); break; + case 411: if (n[411]++ > 0) check ('a string 411'); break; + case 412: if (n[412]++ > 0) check ('a string 412'); break; + case 413: if (n[413]++ > 0) check ('a string 413'); break; + case 414: if (n[414]++ > 0) check ('a string 414'); break; + case 415: if (n[415]++ > 0) check ('a string 415'); break; + case 416: if (n[416]++ > 0) check ('a string 416'); break; + case 417: if (n[417]++ > 0) check ('a string 417'); break; + case 418: if (n[418]++ > 0) check ('a string 418'); break; + case 419: if (n[419]++ > 0) check ('a string 419'); break; + case 420: if (n[420]++ > 0) check ('a string 420'); break; + case 421: if (n[421]++ > 0) check ('a string 421'); break; + case 422: if (n[422]++ > 0) check ('a string 422'); break; + case 423: if (n[423]++ > 0) check ('a string 423'); break; + case 424: if (n[424]++ > 0) check ('a string 424'); break; + case 425: if (n[425]++ > 0) check ('a string 425'); break; + case 426: if (n[426]++ > 0) check ('a string 426'); break; + case 427: if (n[427]++ > 0) check ('a string 427'); break; + case 428: if (n[428]++ > 0) check ('a string 428'); break; + case 429: if (n[429]++ > 0) check ('a string 429'); break; + case 430: if (n[430]++ > 0) check ('a string 430'); break; + case 431: if (n[431]++ > 0) check ('a string 431'); break; + case 432: if (n[432]++ > 0) check ('a string 432'); break; + case 433: if (n[433]++ > 0) check ('a string 433'); break; + case 434: if (n[434]++ > 0) check ('a string 434'); break; + case 435: if (n[435]++ > 0) check ('a string 435'); break; + case 436: if (n[436]++ > 0) check ('a string 436'); break; + case 437: if (n[437]++ > 0) check ('a string 437'); break; + case 438: if (n[438]++ > 0) check ('a string 438'); break; + case 439: if (n[439]++ > 0) check ('a string 439'); break; + case 440: if (n[440]++ > 0) check ('a string 440'); break; + case 441: if (n[441]++ > 0) check ('a string 441'); break; + case 442: if (n[442]++ > 0) check ('a string 442'); break; + case 443: if (n[443]++ > 0) check ('a string 443'); break; + case 444: if (n[444]++ > 0) check ('a string 444'); break; + case 445: if (n[445]++ > 0) check ('a string 445'); break; + case 446: if (n[446]++ > 0) check ('a string 446'); break; + case 447: if (n[447]++ > 0) check ('a string 447'); break; + case 448: if (n[448]++ > 0) check ('a string 448'); break; + case 449: if (n[449]++ > 0) check ('a string 449'); break; + case 450: if (n[450]++ > 0) check ('a string 450'); break; + case 451: if (n[451]++ > 0) check ('a string 451'); break; + case 452: if (n[452]++ > 0) check ('a string 452'); break; + case 453: if (n[453]++ > 0) check ('a string 453'); break; + case 454: if (n[454]++ > 0) check ('a string 454'); break; + case 455: if (n[455]++ > 0) check ('a string 455'); break; + case 456: if (n[456]++ > 0) check ('a string 456'); break; + case 457: if (n[457]++ > 0) check ('a string 457'); break; + case 458: if (n[458]++ > 0) check ('a string 458'); break; + case 459: if (n[459]++ > 0) check ('a string 459'); break; + case 460: if (n[460]++ > 0) check ('a string 460'); break; + case 461: if (n[461]++ > 0) check ('a string 461'); break; + case 462: if (n[462]++ > 0) check ('a string 462'); break; + case 463: if (n[463]++ > 0) check ('a string 463'); break; + case 464: if (n[464]++ > 0) check ('a string 464'); break; + case 465: if (n[465]++ > 0) check ('a string 465'); break; + case 466: if (n[466]++ > 0) check ('a string 466'); break; + case 467: if (n[467]++ > 0) check ('a string 467'); break; + case 468: if (n[468]++ > 0) check ('a string 468'); break; + case 469: if (n[469]++ > 0) check ('a string 469'); break; + case 470: if (n[470]++ > 0) check ('a string 470'); break; + case 471: if (n[471]++ > 0) check ('a string 471'); break; + case 472: if (n[472]++ > 0) check ('a string 472'); break; + case 473: if (n[473]++ > 0) check ('a string 473'); break; + case 474: if (n[474]++ > 0) check ('a string 474'); break; + case 475: if (n[475]++ > 0) check ('a string 475'); break; + case 476: if (n[476]++ > 0) check ('a string 476'); break; + case 477: if (n[477]++ > 0) check ('a string 477'); break; + case 478: if (n[478]++ > 0) check ('a string 478'); break; + case 479: if (n[479]++ > 0) check ('a string 479'); break; + case 480: if (n[480]++ > 0) check ('a string 480'); break; + case 481: if (n[481]++ > 0) check ('a string 481'); break; + case 482: if (n[482]++ > 0) check ('a string 482'); break; + case 483: if (n[483]++ > 0) check ('a string 483'); break; + case 484: if (n[484]++ > 0) check ('a string 484'); break; + case 485: if (n[485]++ > 0) check ('a string 485'); break; + case 486: if (n[486]++ > 0) check ('a string 486'); break; + case 487: if (n[487]++ > 0) check ('a string 487'); break; + case 488: if (n[488]++ > 0) check ('a string 488'); break; + case 489: if (n[489]++ > 0) check ('a string 489'); break; + case 490: if (n[490]++ > 0) check ('a string 490'); break; + case 491: if (n[491]++ > 0) check ('a string 491'); break; + case 492: if (n[492]++ > 0) check ('a string 492'); break; + case 493: if (n[493]++ > 0) check ('a string 493'); break; + case 494: if (n[494]++ > 0) check ('a string 494'); break; + case 495: if (n[495]++ > 0) check ('a string 495'); break; + case 496: if (n[496]++ > 0) check ('a string 496'); break; + case 497: if (n[497]++ > 0) check ('a string 497'); break; + case 498: if (n[498]++ > 0) check ('a string 498'); break; + case 499: if (n[499]++ > 0) check ('a string 499'); break; + case 500: if (n[500]++ > 0) check ('a string 500'); break; + case 501: if (n[501]++ > 0) check ('a string 501'); break; + case 502: if (n[502]++ > 0) check ('a string 502'); break; + case 503: if (n[503]++ > 0) check ('a string 503'); break; + case 504: if (n[504]++ > 0) check ('a string 504'); break; + case 505: if (n[505]++ > 0) check ('a string 505'); break; + case 506: if (n[506]++ > 0) check ('a string 506'); break; + case 507: if (n[507]++ > 0) check ('a string 507'); break; + case 508: if (n[508]++ > 0) check ('a string 508'); break; + case 509: if (n[509]++ > 0) check ('a string 509'); break; + case 510: if (n[510]++ > 0) check ('a string 510'); break; + case 511: if (n[511]++ > 0) check ('a string 511'); break; + case 512: if (n[512]++ > 0) check ('a string 512'); break; + case 513: if (n[513]++ > 0) check ('a string 513'); break; + case 514: if (n[514]++ > 0) check ('a string 514'); break; + case 515: if (n[515]++ > 0) check ('a string 515'); break; + case 516: if (n[516]++ > 0) check ('a string 516'); break; + case 517: if (n[517]++ > 0) check ('a string 517'); break; + case 518: if (n[518]++ > 0) check ('a string 518'); break; + case 519: if (n[519]++ > 0) check ('a string 519'); break; + case 520: if (n[520]++ > 0) check ('a string 520'); break; + case 521: if (n[521]++ > 0) check ('a string 521'); break; + case 522: if (n[522]++ > 0) check ('a string 522'); break; + case 523: if (n[523]++ > 0) check ('a string 523'); break; + case 524: if (n[524]++ > 0) check ('a string 524'); break; + case 525: if (n[525]++ > 0) check ('a string 525'); break; + case 526: if (n[526]++ > 0) check ('a string 526'); break; + case 527: if (n[527]++ > 0) check ('a string 527'); break; + case 528: if (n[528]++ > 0) check ('a string 528'); break; + case 529: if (n[529]++ > 0) check ('a string 529'); break; + case 530: if (n[530]++ > 0) check ('a string 530'); break; + case 531: if (n[531]++ > 0) check ('a string 531'); break; + case 532: if (n[532]++ > 0) check ('a string 532'); break; + case 533: if (n[533]++ > 0) check ('a string 533'); break; + case 534: if (n[534]++ > 0) check ('a string 534'); break; + case 535: if (n[535]++ > 0) check ('a string 535'); break; + case 536: if (n[536]++ > 0) check ('a string 536'); break; + case 537: if (n[537]++ > 0) check ('a string 537'); break; + case 538: if (n[538]++ > 0) check ('a string 538'); break; + case 539: if (n[539]++ > 0) check ('a string 539'); break; + case 540: if (n[540]++ > 0) check ('a string 540'); break; + case 541: if (n[541]++ > 0) check ('a string 541'); break; + case 542: if (n[542]++ > 0) check ('a string 542'); break; + case 543: if (n[543]++ > 0) check ('a string 543'); break; + case 544: if (n[544]++ > 0) check ('a string 544'); break; + case 545: if (n[545]++ > 0) check ('a string 545'); break; + case 546: if (n[546]++ > 0) check ('a string 546'); break; + case 547: if (n[547]++ > 0) check ('a string 547'); break; + case 548: if (n[548]++ > 0) check ('a string 548'); break; + case 549: if (n[549]++ > 0) check ('a string 549'); break; + case 550: if (n[550]++ > 0) check ('a string 550'); break; + case 551: if (n[551]++ > 0) check ('a string 551'); break; + case 552: if (n[552]++ > 0) check ('a string 552'); break; + case 553: if (n[553]++ > 0) check ('a string 553'); break; + case 554: if (n[554]++ > 0) check ('a string 554'); break; + case 555: if (n[555]++ > 0) check ('a string 555'); break; + case 556: if (n[556]++ > 0) check ('a string 556'); break; + case 557: if (n[557]++ > 0) check ('a string 557'); break; + case 558: if (n[558]++ > 0) check ('a string 558'); break; + case 559: if (n[559]++ > 0) check ('a string 559'); break; + case 560: if (n[560]++ > 0) check ('a string 560'); break; + case 561: if (n[561]++ > 0) check ('a string 561'); break; + case 562: if (n[562]++ > 0) check ('a string 562'); break; + case 563: if (n[563]++ > 0) check ('a string 563'); break; + case 564: if (n[564]++ > 0) check ('a string 564'); break; + case 565: if (n[565]++ > 0) check ('a string 565'); break; + case 566: if (n[566]++ > 0) check ('a string 566'); break; + case 567: if (n[567]++ > 0) check ('a string 567'); break; + case 568: if (n[568]++ > 0) check ('a string 568'); break; + case 569: if (n[569]++ > 0) check ('a string 569'); break; + case 570: if (n[570]++ > 0) check ('a string 570'); break; + case 571: if (n[571]++ > 0) check ('a string 571'); break; + case 572: if (n[572]++ > 0) check ('a string 572'); break; + case 573: if (n[573]++ > 0) check ('a string 573'); break; + case 574: if (n[574]++ > 0) check ('a string 574'); break; + case 575: if (n[575]++ > 0) check ('a string 575'); break; + case 576: if (n[576]++ > 0) check ('a string 576'); break; + case 577: if (n[577]++ > 0) check ('a string 577'); break; + case 578: if (n[578]++ > 0) check ('a string 578'); break; + case 579: if (n[579]++ > 0) check ('a string 579'); break; + case 580: if (n[580]++ > 0) check ('a string 580'); break; + case 581: if (n[581]++ > 0) check ('a string 581'); break; + case 582: if (n[582]++ > 0) check ('a string 582'); break; + case 583: if (n[583]++ > 0) check ('a string 583'); break; + case 584: if (n[584]++ > 0) check ('a string 584'); break; + case 585: if (n[585]++ > 0) check ('a string 585'); break; + case 586: if (n[586]++ > 0) check ('a string 586'); break; + case 587: if (n[587]++ > 0) check ('a string 587'); break; + case 588: if (n[588]++ > 0) check ('a string 588'); break; + case 589: if (n[589]++ > 0) check ('a string 589'); break; + case 590: if (n[590]++ > 0) check ('a string 590'); break; + case 591: if (n[591]++ > 0) check ('a string 591'); break; + case 592: if (n[592]++ > 0) check ('a string 592'); break; + case 593: if (n[593]++ > 0) check ('a string 593'); break; + case 594: if (n[594]++ > 0) check ('a string 594'); break; + case 595: if (n[595]++ > 0) check ('a string 595'); break; + case 596: if (n[596]++ > 0) check ('a string 596'); break; + case 597: if (n[597]++ > 0) check ('a string 597'); break; + case 598: if (n[598]++ > 0) check ('a string 598'); break; + case 599: if (n[599]++ > 0) check ('a string 599'); break; + case 600: if (n[600]++ > 0) check ('a string 600'); break; + case 601: if (n[601]++ > 0) check ('a string 601'); break; + case 602: if (n[602]++ > 0) check ('a string 602'); break; + case 603: if (n[603]++ > 0) check ('a string 603'); break; + case 604: if (n[604]++ > 0) check ('a string 604'); break; + case 605: if (n[605]++ > 0) check ('a string 605'); break; + case 606: if (n[606]++ > 0) check ('a string 606'); break; + case 607: if (n[607]++ > 0) check ('a string 607'); break; + case 608: if (n[608]++ > 0) check ('a string 608'); break; + case 609: if (n[609]++ > 0) check ('a string 609'); break; + case 610: if (n[610]++ > 0) check ('a string 610'); break; + case 611: if (n[611]++ > 0) check ('a string 611'); break; + case 612: if (n[612]++ > 0) check ('a string 612'); break; + case 613: if (n[613]++ > 0) check ('a string 613'); break; + case 614: if (n[614]++ > 0) check ('a string 614'); break; + case 615: if (n[615]++ > 0) check ('a string 615'); break; + case 616: if (n[616]++ > 0) check ('a string 616'); break; + case 617: if (n[617]++ > 0) check ('a string 617'); break; + case 618: if (n[618]++ > 0) check ('a string 618'); break; + case 619: if (n[619]++ > 0) check ('a string 619'); break; + case 620: if (n[620]++ > 0) check ('a string 620'); break; + case 621: if (n[621]++ > 0) check ('a string 621'); break; + case 622: if (n[622]++ > 0) check ('a string 622'); break; + case 623: if (n[623]++ > 0) check ('a string 623'); break; + case 624: if (n[624]++ > 0) check ('a string 624'); break; + case 625: if (n[625]++ > 0) check ('a string 625'); break; + case 626: if (n[626]++ > 0) check ('a string 626'); break; + case 627: if (n[627]++ > 0) check ('a string 627'); break; + case 628: if (n[628]++ > 0) check ('a string 628'); break; + case 629: if (n[629]++ > 0) check ('a string 629'); break; + case 630: if (n[630]++ > 0) check ('a string 630'); break; + case 631: if (n[631]++ > 0) check ('a string 631'); break; + case 632: if (n[632]++ > 0) check ('a string 632'); break; + case 633: if (n[633]++ > 0) check ('a string 633'); break; + case 634: if (n[634]++ > 0) check ('a string 634'); break; + case 635: if (n[635]++ > 0) check ('a string 635'); break; + case 636: if (n[636]++ > 0) check ('a string 636'); break; + case 637: if (n[637]++ > 0) check ('a string 637'); break; + case 638: if (n[638]++ > 0) check ('a string 638'); break; + case 639: if (n[639]++ > 0) check ('a string 639'); break; + case 640: if (n[640]++ > 0) check ('a string 640'); break; + case 641: if (n[641]++ > 0) check ('a string 641'); break; + case 642: if (n[642]++ > 0) check ('a string 642'); break; + case 643: if (n[643]++ > 0) check ('a string 643'); break; + case 644: if (n[644]++ > 0) check ('a string 644'); break; + case 645: if (n[645]++ > 0) check ('a string 645'); break; + case 646: if (n[646]++ > 0) check ('a string 646'); break; + case 647: if (n[647]++ > 0) check ('a string 647'); break; + case 648: if (n[648]++ > 0) check ('a string 648'); break; + case 649: if (n[649]++ > 0) check ('a string 649'); break; + case 650: if (n[650]++ > 0) check ('a string 650'); break; + case 651: if (n[651]++ > 0) check ('a string 651'); break; + case 652: if (n[652]++ > 0) check ('a string 652'); break; + case 653: if (n[653]++ > 0) check ('a string 653'); break; + case 654: if (n[654]++ > 0) check ('a string 654'); break; + case 655: if (n[655]++ > 0) check ('a string 655'); break; + case 656: if (n[656]++ > 0) check ('a string 656'); break; + case 657: if (n[657]++ > 0) check ('a string 657'); break; + case 658: if (n[658]++ > 0) check ('a string 658'); break; + case 659: if (n[659]++ > 0) check ('a string 659'); break; + case 660: if (n[660]++ > 0) check ('a string 660'); break; + case 661: if (n[661]++ > 0) check ('a string 661'); break; + case 662: if (n[662]++ > 0) check ('a string 662'); break; + case 663: if (n[663]++ > 0) check ('a string 663'); break; + case 664: if (n[664]++ > 0) check ('a string 664'); break; + case 665: if (n[665]++ > 0) check ('a string 665'); break; + case 666: if (n[666]++ > 0) check ('a string 666'); break; + case 667: if (n[667]++ > 0) check ('a string 667'); break; + case 668: if (n[668]++ > 0) check ('a string 668'); break; + case 669: if (n[669]++ > 0) check ('a string 669'); break; + case 670: if (n[670]++ > 0) check ('a string 670'); break; + case 671: if (n[671]++ > 0) check ('a string 671'); break; + case 672: if (n[672]++ > 0) check ('a string 672'); break; + case 673: if (n[673]++ > 0) check ('a string 673'); break; + case 674: if (n[674]++ > 0) check ('a string 674'); break; + case 675: if (n[675]++ > 0) check ('a string 675'); break; + case 676: if (n[676]++ > 0) check ('a string 676'); break; + case 677: if (n[677]++ > 0) check ('a string 677'); break; + case 678: if (n[678]++ > 0) check ('a string 678'); break; + case 679: if (n[679]++ > 0) check ('a string 679'); break; + case 680: if (n[680]++ > 0) check ('a string 680'); break; + case 681: if (n[681]++ > 0) check ('a string 681'); break; + case 682: if (n[682]++ > 0) check ('a string 682'); break; + case 683: if (n[683]++ > 0) check ('a string 683'); break; + case 684: if (n[684]++ > 0) check ('a string 684'); break; + case 685: if (n[685]++ > 0) check ('a string 685'); break; + case 686: if (n[686]++ > 0) check ('a string 686'); break; + case 687: if (n[687]++ > 0) check ('a string 687'); break; + case 688: if (n[688]++ > 0) check ('a string 688'); break; + case 689: if (n[689]++ > 0) check ('a string 689'); break; + case 690: if (n[690]++ > 0) check ('a string 690'); break; + case 691: if (n[691]++ > 0) check ('a string 691'); break; + case 692: if (n[692]++ > 0) check ('a string 692'); break; + case 693: if (n[693]++ > 0) check ('a string 693'); break; + case 694: if (n[694]++ > 0) check ('a string 694'); break; + case 695: if (n[695]++ > 0) check ('a string 695'); break; + case 696: if (n[696]++ > 0) check ('a string 696'); break; + case 697: if (n[697]++ > 0) check ('a string 697'); break; + case 698: if (n[698]++ > 0) check ('a string 698'); break; + case 699: if (n[699]++ > 0) check ('a string 699'); break; + case 700: if (n[700]++ > 0) check ('a string 700'); break; + case 701: if (n[701]++ > 0) check ('a string 701'); break; + case 702: if (n[702]++ > 0) check ('a string 702'); break; + case 703: if (n[703]++ > 0) check ('a string 703'); break; + case 704: if (n[704]++ > 0) check ('a string 704'); break; + case 705: if (n[705]++ > 0) check ('a string 705'); break; + case 706: if (n[706]++ > 0) check ('a string 706'); break; + case 707: if (n[707]++ > 0) check ('a string 707'); break; + case 708: if (n[708]++ > 0) check ('a string 708'); break; + case 709: if (n[709]++ > 0) check ('a string 709'); break; + case 710: if (n[710]++ > 0) check ('a string 710'); break; + case 711: if (n[711]++ > 0) check ('a string 711'); break; + case 712: if (n[712]++ > 0) check ('a string 712'); break; + case 713: if (n[713]++ > 0) check ('a string 713'); break; + case 714: if (n[714]++ > 0) check ('a string 714'); break; + case 715: if (n[715]++ > 0) check ('a string 715'); break; + case 716: if (n[716]++ > 0) check ('a string 716'); break; + case 717: if (n[717]++ > 0) check ('a string 717'); break; + case 718: if (n[718]++ > 0) check ('a string 718'); break; + case 719: if (n[719]++ > 0) check ('a string 719'); break; + case 720: if (n[720]++ > 0) check ('a string 720'); break; + case 721: if (n[721]++ > 0) check ('a string 721'); break; + case 722: if (n[722]++ > 0) check ('a string 722'); break; + case 723: if (n[723]++ > 0) check ('a string 723'); break; + case 724: if (n[724]++ > 0) check ('a string 724'); break; + case 725: if (n[725]++ > 0) check ('a string 725'); break; + case 726: if (n[726]++ > 0) check ('a string 726'); break; + case 727: if (n[727]++ > 0) check ('a string 727'); break; + case 728: if (n[728]++ > 0) check ('a string 728'); break; + case 729: if (n[729]++ > 0) check ('a string 729'); break; + case 730: if (n[730]++ > 0) check ('a string 730'); break; + case 731: if (n[731]++ > 0) check ('a string 731'); break; + case 732: if (n[732]++ > 0) check ('a string 732'); break; + case 733: if (n[733]++ > 0) check ('a string 733'); break; + case 734: if (n[734]++ > 0) check ('a string 734'); break; + case 735: if (n[735]++ > 0) check ('a string 735'); break; + case 736: if (n[736]++ > 0) check ('a string 736'); break; + case 737: if (n[737]++ > 0) check ('a string 737'); break; + case 738: if (n[738]++ > 0) check ('a string 738'); break; + case 739: if (n[739]++ > 0) check ('a string 739'); break; + case 740: if (n[740]++ > 0) check ('a string 740'); break; + case 741: if (n[741]++ > 0) check ('a string 741'); break; + case 742: if (n[742]++ > 0) check ('a string 742'); break; + case 743: if (n[743]++ > 0) check ('a string 743'); break; + case 744: if (n[744]++ > 0) check ('a string 744'); break; + case 745: if (n[745]++ > 0) check ('a string 745'); break; + case 746: if (n[746]++ > 0) check ('a string 746'); break; + case 747: if (n[747]++ > 0) check ('a string 747'); break; + case 748: if (n[748]++ > 0) check ('a string 748'); break; + case 749: if (n[749]++ > 0) check ('a string 749'); break; + case 750: if (n[750]++ > 0) check ('a string 750'); break; + case 751: if (n[751]++ > 0) check ('a string 751'); break; + case 752: if (n[752]++ > 0) check ('a string 752'); break; + case 753: if (n[753]++ > 0) check ('a string 753'); break; + case 754: if (n[754]++ > 0) check ('a string 754'); break; + case 755: if (n[755]++ > 0) check ('a string 755'); break; + case 756: if (n[756]++ > 0) check ('a string 756'); break; + case 757: if (n[757]++ > 0) check ('a string 757'); break; + case 758: if (n[758]++ > 0) check ('a string 758'); break; + case 759: if (n[759]++ > 0) check ('a string 759'); break; + case 760: if (n[760]++ > 0) check ('a string 760'); break; + case 761: if (n[761]++ > 0) check ('a string 761'); break; + case 762: if (n[762]++ > 0) check ('a string 762'); break; + case 763: if (n[763]++ > 0) check ('a string 763'); break; + case 764: if (n[764]++ > 0) check ('a string 764'); break; + case 765: if (n[765]++ > 0) check ('a string 765'); break; + case 766: if (n[766]++ > 0) check ('a string 766'); break; + case 767: if (n[767]++ > 0) check ('a string 767'); break; + case 768: if (n[768]++ > 0) check ('a string 768'); break; + case 769: if (n[769]++ > 0) check ('a string 769'); break; + case 770: if (n[770]++ > 0) check ('a string 770'); break; + case 771: if (n[771]++ > 0) check ('a string 771'); break; + case 772: if (n[772]++ > 0) check ('a string 772'); break; + case 773: if (n[773]++ > 0) check ('a string 773'); break; + case 774: if (n[774]++ > 0) check ('a string 774'); break; + case 775: if (n[775]++ > 0) check ('a string 775'); break; + case 776: if (n[776]++ > 0) check ('a string 776'); break; + case 777: if (n[777]++ > 0) check ('a string 777'); break; + case 778: if (n[778]++ > 0) check ('a string 778'); break; + case 779: if (n[779]++ > 0) check ('a string 779'); break; + case 780: if (n[780]++ > 0) check ('a string 780'); break; + case 781: if (n[781]++ > 0) check ('a string 781'); break; + case 782: if (n[782]++ > 0) check ('a string 782'); break; + case 783: if (n[783]++ > 0) check ('a string 783'); break; + case 784: if (n[784]++ > 0) check ('a string 784'); break; + case 785: if (n[785]++ > 0) check ('a string 785'); break; + case 786: if (n[786]++ > 0) check ('a string 786'); break; + case 787: if (n[787]++ > 0) check ('a string 787'); break; + case 788: if (n[788]++ > 0) check ('a string 788'); break; + case 789: if (n[789]++ > 0) check ('a string 789'); break; + case 790: if (n[790]++ > 0) check ('a string 790'); break; + case 791: if (n[791]++ > 0) check ('a string 791'); break; + case 792: if (n[792]++ > 0) check ('a string 792'); break; + case 793: if (n[793]++ > 0) check ('a string 793'); break; + case 794: if (n[794]++ > 0) check ('a string 794'); break; + case 795: if (n[795]++ > 0) check ('a string 795'); break; + case 796: if (n[796]++ > 0) check ('a string 796'); break; + case 797: if (n[797]++ > 0) check ('a string 797'); break; + case 798: if (n[798]++ > 0) check ('a string 798'); break; + case 799: if (n[799]++ > 0) check ('a string 799'); break; + case 800: if (n[800]++ > 0) check ('a string 800'); break; + case 801: if (n[801]++ > 0) check ('a string 801'); break; + case 802: if (n[802]++ > 0) check ('a string 802'); break; + case 803: if (n[803]++ > 0) check ('a string 803'); break; + case 804: if (n[804]++ > 0) check ('a string 804'); break; + case 805: if (n[805]++ > 0) check ('a string 805'); break; + case 806: if (n[806]++ > 0) check ('a string 806'); break; + case 807: if (n[807]++ > 0) check ('a string 807'); break; + case 808: if (n[808]++ > 0) check ('a string 808'); break; + case 809: if (n[809]++ > 0) check ('a string 809'); break; + case 810: if (n[810]++ > 0) check ('a string 810'); break; + case 811: if (n[811]++ > 0) check ('a string 811'); break; + case 812: if (n[812]++ > 0) check ('a string 812'); break; + case 813: if (n[813]++ > 0) check ('a string 813'); break; + case 814: if (n[814]++ > 0) check ('a string 814'); break; + case 815: if (n[815]++ > 0) check ('a string 815'); break; + case 816: if (n[816]++ > 0) check ('a string 816'); break; + case 817: if (n[817]++ > 0) check ('a string 817'); break; + case 818: if (n[818]++ > 0) check ('a string 818'); break; + case 819: if (n[819]++ > 0) check ('a string 819'); break; + case 820: if (n[820]++ > 0) check ('a string 820'); break; + case 821: if (n[821]++ > 0) check ('a string 821'); break; + case 822: if (n[822]++ > 0) check ('a string 822'); break; + case 823: if (n[823]++ > 0) check ('a string 823'); break; + case 824: if (n[824]++ > 0) check ('a string 824'); break; + case 825: if (n[825]++ > 0) check ('a string 825'); break; + case 826: if (n[826]++ > 0) check ('a string 826'); break; + case 827: if (n[827]++ > 0) check ('a string 827'); break; + case 828: if (n[828]++ > 0) check ('a string 828'); break; + case 829: if (n[829]++ > 0) check ('a string 829'); break; + case 830: if (n[830]++ > 0) check ('a string 830'); break; + case 831: if (n[831]++ > 0) check ('a string 831'); break; + case 832: if (n[832]++ > 0) check ('a string 832'); break; + case 833: if (n[833]++ > 0) check ('a string 833'); break; + case 834: if (n[834]++ > 0) check ('a string 834'); break; + case 835: if (n[835]++ > 0) check ('a string 835'); break; + case 836: if (n[836]++ > 0) check ('a string 836'); break; + case 837: if (n[837]++ > 0) check ('a string 837'); break; + case 838: if (n[838]++ > 0) check ('a string 838'); break; + case 839: if (n[839]++ > 0) check ('a string 839'); break; + case 840: if (n[840]++ > 0) check ('a string 840'); break; + case 841: if (n[841]++ > 0) check ('a string 841'); break; + case 842: if (n[842]++ > 0) check ('a string 842'); break; + case 843: if (n[843]++ > 0) check ('a string 843'); break; + case 844: if (n[844]++ > 0) check ('a string 844'); break; + case 845: if (n[845]++ > 0) check ('a string 845'); break; + case 846: if (n[846]++ > 0) check ('a string 846'); break; + case 847: if (n[847]++ > 0) check ('a string 847'); break; + case 848: if (n[848]++ > 0) check ('a string 848'); break; + case 849: if (n[849]++ > 0) check ('a string 849'); break; + case 850: if (n[850]++ > 0) check ('a string 850'); break; + case 851: if (n[851]++ > 0) check ('a string 851'); break; + case 852: if (n[852]++ > 0) check ('a string 852'); break; + case 853: if (n[853]++ > 0) check ('a string 853'); break; + case 854: if (n[854]++ > 0) check ('a string 854'); break; + case 855: if (n[855]++ > 0) check ('a string 855'); break; + case 856: if (n[856]++ > 0) check ('a string 856'); break; + case 857: if (n[857]++ > 0) check ('a string 857'); break; + case 858: if (n[858]++ > 0) check ('a string 858'); break; + case 859: if (n[859]++ > 0) check ('a string 859'); break; + case 860: if (n[860]++ > 0) check ('a string 860'); break; + case 861: if (n[861]++ > 0) check ('a string 861'); break; + case 862: if (n[862]++ > 0) check ('a string 862'); break; + case 863: if (n[863]++ > 0) check ('a string 863'); break; + case 864: if (n[864]++ > 0) check ('a string 864'); break; + case 865: if (n[865]++ > 0) check ('a string 865'); break; + case 866: if (n[866]++ > 0) check ('a string 866'); break; + case 867: if (n[867]++ > 0) check ('a string 867'); break; + case 868: if (n[868]++ > 0) check ('a string 868'); break; + case 869: if (n[869]++ > 0) check ('a string 869'); break; + case 870: if (n[870]++ > 0) check ('a string 870'); break; + case 871: if (n[871]++ > 0) check ('a string 871'); break; + case 872: if (n[872]++ > 0) check ('a string 872'); break; + case 873: if (n[873]++ > 0) check ('a string 873'); break; + case 874: if (n[874]++ > 0) check ('a string 874'); break; + case 875: if (n[875]++ > 0) check ('a string 875'); break; + case 876: if (n[876]++ > 0) check ('a string 876'); break; + case 877: if (n[877]++ > 0) check ('a string 877'); break; + case 878: if (n[878]++ > 0) check ('a string 878'); break; + case 879: if (n[879]++ > 0) check ('a string 879'); break; + case 880: if (n[880]++ > 0) check ('a string 880'); break; + case 881: if (n[881]++ > 0) check ('a string 881'); break; + case 882: if (n[882]++ > 0) check ('a string 882'); break; + case 883: if (n[883]++ > 0) check ('a string 883'); break; + case 884: if (n[884]++ > 0) check ('a string 884'); break; + case 885: if (n[885]++ > 0) check ('a string 885'); break; + case 886: if (n[886]++ > 0) check ('a string 886'); break; + case 887: if (n[887]++ > 0) check ('a string 887'); break; + case 888: if (n[888]++ > 0) check ('a string 888'); break; + case 889: if (n[889]++ > 0) check ('a string 889'); break; + case 890: if (n[890]++ > 0) check ('a string 890'); break; + case 891: if (n[891]++ > 0) check ('a string 891'); break; + case 892: if (n[892]++ > 0) check ('a string 892'); break; + case 893: if (n[893]++ > 0) check ('a string 893'); break; + case 894: if (n[894]++ > 0) check ('a string 894'); break; + case 895: if (n[895]++ > 0) check ('a string 895'); break; + case 896: if (n[896]++ > 0) check ('a string 896'); break; + case 897: if (n[897]++ > 0) check ('a string 897'); break; + case 898: if (n[898]++ > 0) check ('a string 898'); break; + case 899: if (n[899]++ > 0) check ('a string 899'); break; + case 900: if (n[900]++ > 0) check ('a string 900'); break; + case 901: if (n[901]++ > 0) check ('a string 901'); break; + case 902: if (n[902]++ > 0) check ('a string 902'); break; + case 903: if (n[903]++ > 0) check ('a string 903'); break; + case 904: if (n[904]++ > 0) check ('a string 904'); break; + case 905: if (n[905]++ > 0) check ('a string 905'); break; + case 906: if (n[906]++ > 0) check ('a string 906'); break; + case 907: if (n[907]++ > 0) check ('a string 907'); break; + case 908: if (n[908]++ > 0) check ('a string 908'); break; + case 909: if (n[909]++ > 0) check ('a string 909'); break; + case 910: if (n[910]++ > 0) check ('a string 910'); break; + case 911: if (n[911]++ > 0) check ('a string 911'); break; + case 912: if (n[912]++ > 0) check ('a string 912'); break; + case 913: if (n[913]++ > 0) check ('a string 913'); break; + case 914: if (n[914]++ > 0) check ('a string 914'); break; + case 915: if (n[915]++ > 0) check ('a string 915'); break; + case 916: if (n[916]++ > 0) check ('a string 916'); break; + case 917: if (n[917]++ > 0) check ('a string 917'); break; + case 918: if (n[918]++ > 0) check ('a string 918'); break; + case 919: if (n[919]++ > 0) check ('a string 919'); break; + case 920: if (n[920]++ > 0) check ('a string 920'); break; + case 921: if (n[921]++ > 0) check ('a string 921'); break; + case 922: if (n[922]++ > 0) check ('a string 922'); break; + case 923: if (n[923]++ > 0) check ('a string 923'); break; + case 924: if (n[924]++ > 0) check ('a string 924'); break; + case 925: if (n[925]++ > 0) check ('a string 925'); break; + case 926: if (n[926]++ > 0) check ('a string 926'); break; + case 927: if (n[927]++ > 0) check ('a string 927'); break; + case 928: if (n[928]++ > 0) check ('a string 928'); break; + case 929: if (n[929]++ > 0) check ('a string 929'); break; + case 930: if (n[930]++ > 0) check ('a string 930'); break; + case 931: if (n[931]++ > 0) check ('a string 931'); break; + case 932: if (n[932]++ > 0) check ('a string 932'); break; + case 933: if (n[933]++ > 0) check ('a string 933'); break; + case 934: if (n[934]++ > 0) check ('a string 934'); break; + case 935: if (n[935]++ > 0) check ('a string 935'); break; + case 936: if (n[936]++ > 0) check ('a string 936'); break; + case 937: if (n[937]++ > 0) check ('a string 937'); break; + case 938: if (n[938]++ > 0) check ('a string 938'); break; + case 939: if (n[939]++ > 0) check ('a string 939'); break; + case 940: if (n[940]++ > 0) check ('a string 940'); break; + case 941: if (n[941]++ > 0) check ('a string 941'); break; + case 942: if (n[942]++ > 0) check ('a string 942'); break; + case 943: if (n[943]++ > 0) check ('a string 943'); break; + case 944: if (n[944]++ > 0) check ('a string 944'); break; + case 945: if (n[945]++ > 0) check ('a string 945'); break; + case 946: if (n[946]++ > 0) check ('a string 946'); break; + case 947: if (n[947]++ > 0) check ('a string 947'); break; + case 948: if (n[948]++ > 0) check ('a string 948'); break; + case 949: if (n[949]++ > 0) check ('a string 949'); break; + case 950: if (n[950]++ > 0) check ('a string 950'); break; + case 951: if (n[951]++ > 0) check ('a string 951'); break; + case 952: if (n[952]++ > 0) check ('a string 952'); break; + case 953: if (n[953]++ > 0) check ('a string 953'); break; + case 954: if (n[954]++ > 0) check ('a string 954'); break; + case 955: if (n[955]++ > 0) check ('a string 955'); break; + case 956: if (n[956]++ > 0) check ('a string 956'); break; + case 957: if (n[957]++ > 0) check ('a string 957'); break; + case 958: if (n[958]++ > 0) check ('a string 958'); break; + case 959: if (n[959]++ > 0) check ('a string 959'); break; + case 960: if (n[960]++ > 0) check ('a string 960'); break; + case 961: if (n[961]++ > 0) check ('a string 961'); break; + case 962: if (n[962]++ > 0) check ('a string 962'); break; + case 963: if (n[963]++ > 0) check ('a string 963'); break; + case 964: if (n[964]++ > 0) check ('a string 964'); break; + case 965: if (n[965]++ > 0) check ('a string 965'); break; + case 966: if (n[966]++ > 0) check ('a string 966'); break; + case 967: if (n[967]++ > 0) check ('a string 967'); break; + case 968: if (n[968]++ > 0) check ('a string 968'); break; + case 969: if (n[969]++ > 0) check ('a string 969'); break; + case 970: if (n[970]++ > 0) check ('a string 970'); break; + case 971: if (n[971]++ > 0) check ('a string 971'); break; + case 972: if (n[972]++ > 0) check ('a string 972'); break; + case 973: if (n[973]++ > 0) check ('a string 973'); break; + case 974: if (n[974]++ > 0) check ('a string 974'); break; + case 975: if (n[975]++ > 0) check ('a string 975'); break; + case 976: if (n[976]++ > 0) check ('a string 976'); break; + case 977: if (n[977]++ > 0) check ('a string 977'); break; + case 978: if (n[978]++ > 0) check ('a string 978'); break; + case 979: if (n[979]++ > 0) check ('a string 979'); break; + case 980: if (n[980]++ > 0) check ('a string 980'); break; + case 981: if (n[981]++ > 0) check ('a string 981'); break; + case 982: if (n[982]++ > 0) check ('a string 982'); break; + case 983: if (n[983]++ > 0) check ('a string 983'); break; + case 984: if (n[984]++ > 0) check ('a string 984'); break; + case 985: if (n[985]++ > 0) check ('a string 985'); break; + case 986: if (n[986]++ > 0) check ('a string 986'); break; + case 987: if (n[987]++ > 0) check ('a string 987'); break; + case 988: if (n[988]++ > 0) check ('a string 988'); break; + case 989: if (n[989]++ > 0) check ('a string 989'); break; + case 990: if (n[990]++ > 0) check ('a string 990'); break; + case 991: if (n[991]++ > 0) check ('a string 991'); break; + case 992: if (n[992]++ > 0) check ('a string 992'); break; + case 993: if (n[993]++ > 0) check ('a string 993'); break; + case 994: if (n[994]++ > 0) check ('a string 994'); break; + case 995: if (n[995]++ > 0) check ('a string 995'); break; + case 996: if (n[996]++ > 0) check ('a string 996'); break; + case 997: if (n[997]++ > 0) check ('a string 997'); break; + case 998: if (n[998]++ > 0) check ('a string 998'); break; + case 999: if (n[999]++ > 0) check ('a string 999'); break; + case 1000: if (n[1000]++ > 0) check ('a string 1000'); break; + case 1001: if (n[1001]++ > 0) check ('a string 1001'); break; + case 1002: if (n[1002]++ > 0) check ('a string 1002'); break; + case 1003: if (n[1003]++ > 0) check ('a string 1003'); break; + case 1004: if (n[1004]++ > 0) check ('a string 1004'); break; + case 1005: if (n[1005]++ > 0) check ('a string 1005'); break; + case 1006: if (n[1006]++ > 0) check ('a string 1006'); break; + case 1007: if (n[1007]++ > 0) check ('a string 1007'); break; + case 1008: if (n[1008]++ > 0) check ('a string 1008'); break; + case 1009: if (n[1009]++ > 0) check ('a string 1009'); break; + case 1010: if (n[1010]++ > 0) check ('a string 1010'); break; + case 1011: if (n[1011]++ > 0) check ('a string 1011'); break; + case 1012: if (n[1012]++ > 0) check ('a string 1012'); break; + case 1013: if (n[1013]++ > 0) check ('a string 1013'); break; + case 1014: if (n[1014]++ > 0) check ('a string 1014'); break; + case 1015: if (n[1015]++ > 0) check ('a string 1015'); break; + case 1016: if (n[1016]++ > 0) check ('a string 1016'); break; + case 1017: if (n[1017]++ > 0) check ('a string 1017'); break; + case 1018: if (n[1018]++ > 0) check ('a string 1018'); break; + case 1019: if (n[1019]++ > 0) check ('a string 1019'); break; + case 1020: if (n[1020]++ > 0) check ('a string 1020'); break; + case 1021: if (n[1021]++ > 0) check ('a string 1021'); break; + case 1022: if (n[1022]++ > 0) check ('a string 1022'); break; + case 1023: if (n[1023]++ > 0) check ('a string 1023'); break; + case 1024: if (n[1024]++ > 0) check ('a string 1024'); break; + case 1025: if (n[1025]++ > 0) check ('a string 1025'); break; + case 1026: if (n[1026]++ > 0) check ('a string 1026'); break; + case 1027: if (n[1027]++ > 0) check ('a string 1027'); break; + case 1028: if (n[1028]++ > 0) check ('a string 1028'); break; + case 1029: if (n[1029]++ > 0) check ('a string 1029'); break; + case 1030: if (n[1030]++ > 0) check ('a string 1030'); break; + case 1031: if (n[1031]++ > 0) check ('a string 1031'); break; + case 1032: if (n[1032]++ > 0) check ('a string 1032'); break; + case 1033: if (n[1033]++ > 0) check ('a string 1033'); break; + case 1034: if (n[1034]++ > 0) check ('a string 1034'); break; + case 1035: if (n[1035]++ > 0) check ('a string 1035'); break; + case 1036: if (n[1036]++ > 0) check ('a string 1036'); break; + case 1037: if (n[1037]++ > 0) check ('a string 1037'); break; + case 1038: if (n[1038]++ > 0) check ('a string 1038'); break; + case 1039: if (n[1039]++ > 0) check ('a string 1039'); break; + case 1040: if (n[1040]++ > 0) check ('a string 1040'); break; + case 1041: if (n[1041]++ > 0) check ('a string 1041'); break; + case 1042: if (n[1042]++ > 0) check ('a string 1042'); break; + case 1043: if (n[1043]++ > 0) check ('a string 1043'); break; + case 1044: if (n[1044]++ > 0) check ('a string 1044'); break; + case 1045: if (n[1045]++ > 0) check ('a string 1045'); break; + case 1046: if (n[1046]++ > 0) check ('a string 1046'); break; + case 1047: if (n[1047]++ > 0) check ('a string 1047'); break; + case 1048: if (n[1048]++ > 0) check ('a string 1048'); break; + case 1049: if (n[1049]++ > 0) check ('a string 1049'); break; + case 1050: if (n[1050]++ > 0) check ('a string 1050'); break; + case 1051: if (n[1051]++ > 0) check ('a string 1051'); break; + case 1052: if (n[1052]++ > 0) check ('a string 1052'); break; + case 1053: if (n[1053]++ > 0) check ('a string 1053'); break; + case 1054: if (n[1054]++ > 0) check ('a string 1054'); break; + case 1055: if (n[1055]++ > 0) check ('a string 1055'); break; + case 1056: if (n[1056]++ > 0) check ('a string 1056'); break; + case 1057: if (n[1057]++ > 0) check ('a string 1057'); break; + case 1058: if (n[1058]++ > 0) check ('a string 1058'); break; + case 1059: if (n[1059]++ > 0) check ('a string 1059'); break; + case 1060: if (n[1060]++ > 0) check ('a string 1060'); break; + case 1061: if (n[1061]++ > 0) check ('a string 1061'); break; + case 1062: if (n[1062]++ > 0) check ('a string 1062'); break; + case 1063: if (n[1063]++ > 0) check ('a string 1063'); break; + case 1064: if (n[1064]++ > 0) check ('a string 1064'); break; + case 1065: if (n[1065]++ > 0) check ('a string 1065'); break; + case 1066: if (n[1066]++ > 0) check ('a string 1066'); break; + case 1067: if (n[1067]++ > 0) check ('a string 1067'); break; + case 1068: if (n[1068]++ > 0) check ('a string 1068'); break; + case 1069: if (n[1069]++ > 0) check ('a string 1069'); break; + case 1070: if (n[1070]++ > 0) check ('a string 1070'); break; + case 1071: if (n[1071]++ > 0) check ('a string 1071'); break; + case 1072: if (n[1072]++ > 0) check ('a string 1072'); break; + case 1073: if (n[1073]++ > 0) check ('a string 1073'); break; + case 1074: if (n[1074]++ > 0) check ('a string 1074'); break; + case 1075: if (n[1075]++ > 0) check ('a string 1075'); break; + case 1076: if (n[1076]++ > 0) check ('a string 1076'); break; + case 1077: if (n[1077]++ > 0) check ('a string 1077'); break; + case 1078: if (n[1078]++ > 0) check ('a string 1078'); break; + case 1079: if (n[1079]++ > 0) check ('a string 1079'); break; + case 1080: if (n[1080]++ > 0) check ('a string 1080'); break; + case 1081: if (n[1081]++ > 0) check ('a string 1081'); break; + case 1082: if (n[1082]++ > 0) check ('a string 1082'); break; + case 1083: if (n[1083]++ > 0) check ('a string 1083'); break; + case 1084: if (n[1084]++ > 0) check ('a string 1084'); break; + case 1085: if (n[1085]++ > 0) check ('a string 1085'); break; + case 1086: if (n[1086]++ > 0) check ('a string 1086'); break; + case 1087: if (n[1087]++ > 0) check ('a string 1087'); break; + case 1088: if (n[1088]++ > 0) check ('a string 1088'); break; + case 1089: if (n[1089]++ > 0) check ('a string 1089'); break; + case 1090: if (n[1090]++ > 0) check ('a string 1090'); break; + case 1091: if (n[1091]++ > 0) check ('a string 1091'); break; + case 1092: if (n[1092]++ > 0) check ('a string 1092'); break; + case 1093: if (n[1093]++ > 0) check ('a string 1093'); break; + case 1094: if (n[1094]++ > 0) check ('a string 1094'); break; + case 1095: if (n[1095]++ > 0) check ('a string 1095'); break; + case 1096: if (n[1096]++ > 0) check ('a string 1096'); break; + case 1097: if (n[1097]++ > 0) check ('a string 1097'); break; + case 1098: if (n[1098]++ > 0) check ('a string 1098'); break; + case 1099: if (n[1099]++ > 0) check ('a string 1099'); break; + case 1100: if (n[1100]++ > 0) check ('a string 1100'); break; + case 1101: if (n[1101]++ > 0) check ('a string 1101'); break; + case 1102: if (n[1102]++ > 0) check ('a string 1102'); break; + case 1103: if (n[1103]++ > 0) check ('a string 1103'); break; + case 1104: if (n[1104]++ > 0) check ('a string 1104'); break; + case 1105: if (n[1105]++ > 0) check ('a string 1105'); break; + case 1106: if (n[1106]++ > 0) check ('a string 1106'); break; + case 1107: if (n[1107]++ > 0) check ('a string 1107'); break; + case 1108: if (n[1108]++ > 0) check ('a string 1108'); break; + case 1109: if (n[1109]++ > 0) check ('a string 1109'); break; + case 1110: if (n[1110]++ > 0) check ('a string 1110'); break; + case 1111: if (n[1111]++ > 0) check ('a string 1111'); break; + case 1112: if (n[1112]++ > 0) check ('a string 1112'); break; + case 1113: if (n[1113]++ > 0) check ('a string 1113'); break; + case 1114: if (n[1114]++ > 0) check ('a string 1114'); break; + case 1115: if (n[1115]++ > 0) check ('a string 1115'); break; + case 1116: if (n[1116]++ > 0) check ('a string 1116'); break; + case 1117: if (n[1117]++ > 0) check ('a string 1117'); break; + case 1118: if (n[1118]++ > 0) check ('a string 1118'); break; + case 1119: if (n[1119]++ > 0) check ('a string 1119'); break; + case 1120: if (n[1120]++ > 0) check ('a string 1120'); break; + case 1121: if (n[1121]++ > 0) check ('a string 1121'); break; + case 1122: if (n[1122]++ > 0) check ('a string 1122'); break; + case 1123: if (n[1123]++ > 0) check ('a string 1123'); break; + case 1124: if (n[1124]++ > 0) check ('a string 1124'); break; + case 1125: if (n[1125]++ > 0) check ('a string 1125'); break; + case 1126: if (n[1126]++ > 0) check ('a string 1126'); break; + case 1127: if (n[1127]++ > 0) check ('a string 1127'); break; + case 1128: if (n[1128]++ > 0) check ('a string 1128'); break; + case 1129: if (n[1129]++ > 0) check ('a string 1129'); break; + case 1130: if (n[1130]++ > 0) check ('a string 1130'); break; + case 1131: if (n[1131]++ > 0) check ('a string 1131'); break; + case 1132: if (n[1132]++ > 0) check ('a string 1132'); break; + case 1133: if (n[1133]++ > 0) check ('a string 1133'); break; + case 1134: if (n[1134]++ > 0) check ('a string 1134'); break; + case 1135: if (n[1135]++ > 0) check ('a string 1135'); break; + case 1136: if (n[1136]++ > 0) check ('a string 1136'); break; + case 1137: if (n[1137]++ > 0) check ('a string 1137'); break; + case 1138: if (n[1138]++ > 0) check ('a string 1138'); break; + case 1139: if (n[1139]++ > 0) check ('a string 1139'); break; + case 1140: if (n[1140]++ > 0) check ('a string 1140'); break; + case 1141: if (n[1141]++ > 0) check ('a string 1141'); break; + case 1142: if (n[1142]++ > 0) check ('a string 1142'); break; + case 1143: if (n[1143]++ > 0) check ('a string 1143'); break; + case 1144: if (n[1144]++ > 0) check ('a string 1144'); break; + case 1145: if (n[1145]++ > 0) check ('a string 1145'); break; + case 1146: if (n[1146]++ > 0) check ('a string 1146'); break; + case 1147: if (n[1147]++ > 0) check ('a string 1147'); break; + case 1148: if (n[1148]++ > 0) check ('a string 1148'); break; + case 1149: if (n[1149]++ > 0) check ('a string 1149'); break; + case 1150: if (n[1150]++ > 0) check ('a string 1150'); break; + case 1151: if (n[1151]++ > 0) check ('a string 1151'); break; + case 1152: if (n[1152]++ > 0) check ('a string 1152'); break; + case 1153: if (n[1153]++ > 0) check ('a string 1153'); break; + case 1154: if (n[1154]++ > 0) check ('a string 1154'); break; + case 1155: if (n[1155]++ > 0) check ('a string 1155'); break; + case 1156: if (n[1156]++ > 0) check ('a string 1156'); break; + case 1157: if (n[1157]++ > 0) check ('a string 1157'); break; + case 1158: if (n[1158]++ > 0) check ('a string 1158'); break; + case 1159: if (n[1159]++ > 0) check ('a string 1159'); break; + case 1160: if (n[1160]++ > 0) check ('a string 1160'); break; + case 1161: if (n[1161]++ > 0) check ('a string 1161'); break; + case 1162: if (n[1162]++ > 0) check ('a string 1162'); break; + case 1163: if (n[1163]++ > 0) check ('a string 1163'); break; + case 1164: if (n[1164]++ > 0) check ('a string 1164'); break; + case 1165: if (n[1165]++ > 0) check ('a string 1165'); break; + case 1166: if (n[1166]++ > 0) check ('a string 1166'); break; + case 1167: if (n[1167]++ > 0) check ('a string 1167'); break; + case 1168: if (n[1168]++ > 0) check ('a string 1168'); break; + case 1169: if (n[1169]++ > 0) check ('a string 1169'); break; + case 1170: if (n[1170]++ > 0) check ('a string 1170'); break; + case 1171: if (n[1171]++ > 0) check ('a string 1171'); break; + case 1172: if (n[1172]++ > 0) check ('a string 1172'); break; + case 1173: if (n[1173]++ > 0) check ('a string 1173'); break; + case 1174: if (n[1174]++ > 0) check ('a string 1174'); break; + case 1175: if (n[1175]++ > 0) check ('a string 1175'); break; + case 1176: if (n[1176]++ > 0) check ('a string 1176'); break; + case 1177: if (n[1177]++ > 0) check ('a string 1177'); break; + case 1178: if (n[1178]++ > 0) check ('a string 1178'); break; + case 1179: if (n[1179]++ > 0) check ('a string 1179'); break; + case 1180: if (n[1180]++ > 0) check ('a string 1180'); break; + case 1181: if (n[1181]++ > 0) check ('a string 1181'); break; + case 1182: if (n[1182]++ > 0) check ('a string 1182'); break; + case 1183: if (n[1183]++ > 0) check ('a string 1183'); break; + case 1184: if (n[1184]++ > 0) check ('a string 1184'); break; + case 1185: if (n[1185]++ > 0) check ('a string 1185'); break; + case 1186: if (n[1186]++ > 0) check ('a string 1186'); break; + case 1187: if (n[1187]++ > 0) check ('a string 1187'); break; + case 1188: if (n[1188]++ > 0) check ('a string 1188'); break; + case 1189: if (n[1189]++ > 0) check ('a string 1189'); break; + case 1190: if (n[1190]++ > 0) check ('a string 1190'); break; + case 1191: if (n[1191]++ > 0) check ('a string 1191'); break; + case 1192: if (n[1192]++ > 0) check ('a string 1192'); break; + case 1193: if (n[1193]++ > 0) check ('a string 1193'); break; + case 1194: if (n[1194]++ > 0) check ('a string 1194'); break; + case 1195: if (n[1195]++ > 0) check ('a string 1195'); break; + case 1196: if (n[1196]++ > 0) check ('a string 1196'); break; + case 1197: if (n[1197]++ > 0) check ('a string 1197'); break; + case 1198: if (n[1198]++ > 0) check ('a string 1198'); break; + case 1199: if (n[1199]++ > 0) check ('a string 1199'); break; + case 1200: if (n[1200]++ > 0) check ('a string 1200'); break; + case 1201: if (n[1201]++ > 0) check ('a string 1201'); break; + case 1202: if (n[1202]++ > 0) check ('a string 1202'); break; + case 1203: if (n[1203]++ > 0) check ('a string 1203'); break; + case 1204: if (n[1204]++ > 0) check ('a string 1204'); break; + case 1205: if (n[1205]++ > 0) check ('a string 1205'); break; + case 1206: if (n[1206]++ > 0) check ('a string 1206'); break; + case 1207: if (n[1207]++ > 0) check ('a string 1207'); break; + case 1208: if (n[1208]++ > 0) check ('a string 1208'); break; + case 1209: if (n[1209]++ > 0) check ('a string 1209'); break; + case 1210: if (n[1210]++ > 0) check ('a string 1210'); break; + case 1211: if (n[1211]++ > 0) check ('a string 1211'); break; + case 1212: if (n[1212]++ > 0) check ('a string 1212'); break; + case 1213: if (n[1213]++ > 0) check ('a string 1213'); break; + case 1214: if (n[1214]++ > 0) check ('a string 1214'); break; + case 1215: if (n[1215]++ > 0) check ('a string 1215'); break; + case 1216: if (n[1216]++ > 0) check ('a string 1216'); break; + case 1217: if (n[1217]++ > 0) check ('a string 1217'); break; + case 1218: if (n[1218]++ > 0) check ('a string 1218'); break; + case 1219: if (n[1219]++ > 0) check ('a string 1219'); break; + case 1220: if (n[1220]++ > 0) check ('a string 1220'); break; + case 1221: if (n[1221]++ > 0) check ('a string 1221'); break; + case 1222: if (n[1222]++ > 0) check ('a string 1222'); break; + case 1223: if (n[1223]++ > 0) check ('a string 1223'); break; + case 1224: if (n[1224]++ > 0) check ('a string 1224'); break; + case 1225: if (n[1225]++ > 0) check ('a string 1225'); break; + case 1226: if (n[1226]++ > 0) check ('a string 1226'); break; + case 1227: if (n[1227]++ > 0) check ('a string 1227'); break; + case 1228: if (n[1228]++ > 0) check ('a string 1228'); break; + case 1229: if (n[1229]++ > 0) check ('a string 1229'); break; + case 1230: if (n[1230]++ > 0) check ('a string 1230'); break; + case 1231: if (n[1231]++ > 0) check ('a string 1231'); break; + case 1232: if (n[1232]++ > 0) check ('a string 1232'); break; + case 1233: if (n[1233]++ > 0) check ('a string 1233'); break; + case 1234: if (n[1234]++ > 0) check ('a string 1234'); break; + case 1235: if (n[1235]++ > 0) check ('a string 1235'); break; + case 1236: if (n[1236]++ > 0) check ('a string 1236'); break; + case 1237: if (n[1237]++ > 0) check ('a string 1237'); break; + case 1238: if (n[1238]++ > 0) check ('a string 1238'); break; + case 1239: if (n[1239]++ > 0) check ('a string 1239'); break; + case 1240: if (n[1240]++ > 0) check ('a string 1240'); break; + case 1241: if (n[1241]++ > 0) check ('a string 1241'); break; + case 1242: if (n[1242]++ > 0) check ('a string 1242'); break; + case 1243: if (n[1243]++ > 0) check ('a string 1243'); break; + case 1244: if (n[1244]++ > 0) check ('a string 1244'); break; + case 1245: if (n[1245]++ > 0) check ('a string 1245'); break; + case 1246: if (n[1246]++ > 0) check ('a string 1246'); break; + case 1247: if (n[1247]++ > 0) check ('a string 1247'); break; + case 1248: if (n[1248]++ > 0) check ('a string 1248'); break; + case 1249: if (n[1249]++ > 0) check ('a string 1249'); break; + case 1250: if (n[1250]++ > 0) check ('a string 1250'); break; + case 1251: if (n[1251]++ > 0) check ('a string 1251'); break; + case 1252: if (n[1252]++ > 0) check ('a string 1252'); break; + case 1253: if (n[1253]++ > 0) check ('a string 1253'); break; + case 1254: if (n[1254]++ > 0) check ('a string 1254'); break; + case 1255: if (n[1255]++ > 0) check ('a string 1255'); break; + case 1256: if (n[1256]++ > 0) check ('a string 1256'); break; + case 1257: if (n[1257]++ > 0) check ('a string 1257'); break; + case 1258: if (n[1258]++ > 0) check ('a string 1258'); break; + case 1259: if (n[1259]++ > 0) check ('a string 1259'); break; + case 1260: if (n[1260]++ > 0) check ('a string 1260'); break; + case 1261: if (n[1261]++ > 0) check ('a string 1261'); break; + case 1262: if (n[1262]++ > 0) check ('a string 1262'); break; + case 1263: if (n[1263]++ > 0) check ('a string 1263'); break; + case 1264: if (n[1264]++ > 0) check ('a string 1264'); break; + case 1265: if (n[1265]++ > 0) check ('a string 1265'); break; + case 1266: if (n[1266]++ > 0) check ('a string 1266'); break; + case 1267: if (n[1267]++ > 0) check ('a string 1267'); break; + case 1268: if (n[1268]++ > 0) check ('a string 1268'); break; + case 1269: if (n[1269]++ > 0) check ('a string 1269'); break; + case 1270: if (n[1270]++ > 0) check ('a string 1270'); break; + case 1271: if (n[1271]++ > 0) check ('a string 1271'); break; + case 1272: if (n[1272]++ > 0) check ('a string 1272'); break; + case 1273: if (n[1273]++ > 0) check ('a string 1273'); break; + case 1274: if (n[1274]++ > 0) check ('a string 1274'); break; + case 1275: if (n[1275]++ > 0) check ('a string 1275'); break; + case 1276: if (n[1276]++ > 0) check ('a string 1276'); break; + case 1277: if (n[1277]++ > 0) check ('a string 1277'); break; + case 1278: if (n[1278]++ > 0) check ('a string 1278'); break; + case 1279: if (n[1279]++ > 0) check ('a string 1279'); break; + case 1280: if (n[1280]++ > 0) check ('a string 1280'); break; + case 1281: if (n[1281]++ > 0) check ('a string 1281'); break; + case 1282: if (n[1282]++ > 0) check ('a string 1282'); break; + case 1283: if (n[1283]++ > 0) check ('a string 1283'); break; + case 1284: if (n[1284]++ > 0) check ('a string 1284'); break; + case 1285: if (n[1285]++ > 0) check ('a string 1285'); break; + case 1286: if (n[1286]++ > 0) check ('a string 1286'); break; + case 1287: if (n[1287]++ > 0) check ('a string 1287'); break; + case 1288: if (n[1288]++ > 0) check ('a string 1288'); break; + case 1289: if (n[1289]++ > 0) check ('a string 1289'); break; + case 1290: if (n[1290]++ > 0) check ('a string 1290'); break; + case 1291: if (n[1291]++ > 0) check ('a string 1291'); break; + case 1292: if (n[1292]++ > 0) check ('a string 1292'); break; + case 1293: if (n[1293]++ > 0) check ('a string 1293'); break; + case 1294: if (n[1294]++ > 0) check ('a string 1294'); break; + case 1295: if (n[1295]++ > 0) check ('a string 1295'); break; + case 1296: if (n[1296]++ > 0) check ('a string 1296'); break; + case 1297: if (n[1297]++ > 0) check ('a string 1297'); break; + case 1298: if (n[1298]++ > 0) check ('a string 1298'); break; + case 1299: if (n[1299]++ > 0) check ('a string 1299'); break; + case 1300: if (n[1300]++ > 0) check ('a string 1300'); break; + case 1301: if (n[1301]++ > 0) check ('a string 1301'); break; + case 1302: if (n[1302]++ > 0) check ('a string 1302'); break; + case 1303: if (n[1303]++ > 0) check ('a string 1303'); break; + case 1304: if (n[1304]++ > 0) check ('a string 1304'); break; + case 1305: if (n[1305]++ > 0) check ('a string 1305'); break; + case 1306: if (n[1306]++ > 0) check ('a string 1306'); break; + case 1307: if (n[1307]++ > 0) check ('a string 1307'); break; + case 1308: if (n[1308]++ > 0) check ('a string 1308'); break; + case 1309: if (n[1309]++ > 0) check ('a string 1309'); break; + case 1310: if (n[1310]++ > 0) check ('a string 1310'); break; + case 1311: if (n[1311]++ > 0) check ('a string 1311'); break; + case 1312: if (n[1312]++ > 0) check ('a string 1312'); break; + case 1313: if (n[1313]++ > 0) check ('a string 1313'); break; + case 1314: if (n[1314]++ > 0) check ('a string 1314'); break; + case 1315: if (n[1315]++ > 0) check ('a string 1315'); break; + case 1316: if (n[1316]++ > 0) check ('a string 1316'); break; + case 1317: if (n[1317]++ > 0) check ('a string 1317'); break; + case 1318: if (n[1318]++ > 0) check ('a string 1318'); break; + case 1319: if (n[1319]++ > 0) check ('a string 1319'); break; + case 1320: if (n[1320]++ > 0) check ('a string 1320'); break; + case 1321: if (n[1321]++ > 0) check ('a string 1321'); break; + case 1322: if (n[1322]++ > 0) check ('a string 1322'); break; + case 1323: if (n[1323]++ > 0) check ('a string 1323'); break; + case 1324: if (n[1324]++ > 0) check ('a string 1324'); break; + case 1325: if (n[1325]++ > 0) check ('a string 1325'); break; + case 1326: if (n[1326]++ > 0) check ('a string 1326'); break; + case 1327: if (n[1327]++ > 0) check ('a string 1327'); break; + case 1328: if (n[1328]++ > 0) check ('a string 1328'); break; + case 1329: if (n[1329]++ > 0) check ('a string 1329'); break; + case 1330: if (n[1330]++ > 0) check ('a string 1330'); break; + case 1331: if (n[1331]++ > 0) check ('a string 1331'); break; + case 1332: if (n[1332]++ > 0) check ('a string 1332'); break; + case 1333: if (n[1333]++ > 0) check ('a string 1333'); break; + case 1334: if (n[1334]++ > 0) check ('a string 1334'); break; + case 1335: if (n[1335]++ > 0) check ('a string 1335'); break; + case 1336: if (n[1336]++ > 0) check ('a string 1336'); break; + case 1337: if (n[1337]++ > 0) check ('a string 1337'); break; + case 1338: if (n[1338]++ > 0) check ('a string 1338'); break; + case 1339: if (n[1339]++ > 0) check ('a string 1339'); break; + case 1340: if (n[1340]++ > 0) check ('a string 1340'); break; + case 1341: if (n[1341]++ > 0) check ('a string 1341'); break; + case 1342: if (n[1342]++ > 0) check ('a string 1342'); break; + case 1343: if (n[1343]++ > 0) check ('a string 1343'); break; + case 1344: if (n[1344]++ > 0) check ('a string 1344'); break; + case 1345: if (n[1345]++ > 0) check ('a string 1345'); break; + case 1346: if (n[1346]++ > 0) check ('a string 1346'); break; + case 1347: if (n[1347]++ > 0) check ('a string 1347'); break; + case 1348: if (n[1348]++ > 0) check ('a string 1348'); break; + case 1349: if (n[1349]++ > 0) check ('a string 1349'); break; + case 1350: if (n[1350]++ > 0) check ('a string 1350'); break; + case 1351: if (n[1351]++ > 0) check ('a string 1351'); break; + case 1352: if (n[1352]++ > 0) check ('a string 1352'); break; + case 1353: if (n[1353]++ > 0) check ('a string 1353'); break; + case 1354: if (n[1354]++ > 0) check ('a string 1354'); break; + case 1355: if (n[1355]++ > 0) check ('a string 1355'); break; + case 1356: if (n[1356]++ > 0) check ('a string 1356'); break; + case 1357: if (n[1357]++ > 0) check ('a string 1357'); break; + case 1358: if (n[1358]++ > 0) check ('a string 1358'); break; + case 1359: if (n[1359]++ > 0) check ('a string 1359'); break; + case 1360: if (n[1360]++ > 0) check ('a string 1360'); break; + case 1361: if (n[1361]++ > 0) check ('a string 1361'); break; + case 1362: if (n[1362]++ > 0) check ('a string 1362'); break; + case 1363: if (n[1363]++ > 0) check ('a string 1363'); break; + case 1364: if (n[1364]++ > 0) check ('a string 1364'); break; + case 1365: if (n[1365]++ > 0) check ('a string 1365'); break; + case 1366: if (n[1366]++ > 0) check ('a string 1366'); break; + case 1367: if (n[1367]++ > 0) check ('a string 1367'); break; + case 1368: if (n[1368]++ > 0) check ('a string 1368'); break; + case 1369: if (n[1369]++ > 0) check ('a string 1369'); break; + case 1370: if (n[1370]++ > 0) check ('a string 1370'); break; + case 1371: if (n[1371]++ > 0) check ('a string 1371'); break; + case 1372: if (n[1372]++ > 0) check ('a string 1372'); break; + case 1373: if (n[1373]++ > 0) check ('a string 1373'); break; + case 1374: if (n[1374]++ > 0) check ('a string 1374'); break; + case 1375: if (n[1375]++ > 0) check ('a string 1375'); break; + case 1376: if (n[1376]++ > 0) check ('a string 1376'); break; + case 1377: if (n[1377]++ > 0) check ('a string 1377'); break; + case 1378: if (n[1378]++ > 0) check ('a string 1378'); break; + case 1379: if (n[1379]++ > 0) check ('a string 1379'); break; + case 1380: if (n[1380]++ > 0) check ('a string 1380'); break; + case 1381: if (n[1381]++ > 0) check ('a string 1381'); break; + case 1382: if (n[1382]++ > 0) check ('a string 1382'); break; + case 1383: if (n[1383]++ > 0) check ('a string 1383'); break; + case 1384: if (n[1384]++ > 0) check ('a string 1384'); break; + case 1385: if (n[1385]++ > 0) check ('a string 1385'); break; + case 1386: if (n[1386]++ > 0) check ('a string 1386'); break; + case 1387: if (n[1387]++ > 0) check ('a string 1387'); break; + case 1388: if (n[1388]++ > 0) check ('a string 1388'); break; + case 1389: if (n[1389]++ > 0) check ('a string 1389'); break; + case 1390: if (n[1390]++ > 0) check ('a string 1390'); break; + case 1391: if (n[1391]++ > 0) check ('a string 1391'); break; + case 1392: if (n[1392]++ > 0) check ('a string 1392'); break; + case 1393: if (n[1393]++ > 0) check ('a string 1393'); break; + case 1394: if (n[1394]++ > 0) check ('a string 1394'); break; + case 1395: if (n[1395]++ > 0) check ('a string 1395'); break; + case 1396: if (n[1396]++ > 0) check ('a string 1396'); break; + case 1397: if (n[1397]++ > 0) check ('a string 1397'); break; + case 1398: if (n[1398]++ > 0) check ('a string 1398'); break; + case 1399: if (n[1399]++ > 0) check ('a string 1399'); break; + case 1400: if (n[1400]++ > 0) check ('a string 1400'); break; + case 1401: if (n[1401]++ > 0) check ('a string 1401'); break; + case 1402: if (n[1402]++ > 0) check ('a string 1402'); break; + case 1403: if (n[1403]++ > 0) check ('a string 1403'); break; + case 1404: if (n[1404]++ > 0) check ('a string 1404'); break; + case 1405: if (n[1405]++ > 0) check ('a string 1405'); break; + case 1406: if (n[1406]++ > 0) check ('a string 1406'); break; + case 1407: if (n[1407]++ > 0) check ('a string 1407'); break; + case 1408: if (n[1408]++ > 0) check ('a string 1408'); break; + case 1409: if (n[1409]++ > 0) check ('a string 1409'); break; + case 1410: if (n[1410]++ > 0) check ('a string 1410'); break; + case 1411: if (n[1411]++ > 0) check ('a string 1411'); break; + case 1412: if (n[1412]++ > 0) check ('a string 1412'); break; + case 1413: if (n[1413]++ > 0) check ('a string 1413'); break; + case 1414: if (n[1414]++ > 0) check ('a string 1414'); break; + case 1415: if (n[1415]++ > 0) check ('a string 1415'); break; + case 1416: if (n[1416]++ > 0) check ('a string 1416'); break; + case 1417: if (n[1417]++ > 0) check ('a string 1417'); break; + case 1418: if (n[1418]++ > 0) check ('a string 1418'); break; + case 1419: if (n[1419]++ > 0) check ('a string 1419'); break; + case 1420: if (n[1420]++ > 0) check ('a string 1420'); break; + case 1421: if (n[1421]++ > 0) check ('a string 1421'); break; + case 1422: if (n[1422]++ > 0) check ('a string 1422'); break; + case 1423: if (n[1423]++ > 0) check ('a string 1423'); break; + case 1424: if (n[1424]++ > 0) check ('a string 1424'); break; + case 1425: if (n[1425]++ > 0) check ('a string 1425'); break; + case 1426: if (n[1426]++ > 0) check ('a string 1426'); break; + case 1427: if (n[1427]++ > 0) check ('a string 1427'); break; + case 1428: if (n[1428]++ > 0) check ('a string 1428'); break; + case 1429: if (n[1429]++ > 0) check ('a string 1429'); break; + case 1430: if (n[1430]++ > 0) check ('a string 1430'); break; + case 1431: if (n[1431]++ > 0) check ('a string 1431'); break; + case 1432: if (n[1432]++ > 0) check ('a string 1432'); break; + case 1433: if (n[1433]++ > 0) check ('a string 1433'); break; + case 1434: if (n[1434]++ > 0) check ('a string 1434'); break; + case 1435: if (n[1435]++ > 0) check ('a string 1435'); break; + case 1436: if (n[1436]++ > 0) check ('a string 1436'); break; + case 1437: if (n[1437]++ > 0) check ('a string 1437'); break; + case 1438: if (n[1438]++ > 0) check ('a string 1438'); break; + case 1439: if (n[1439]++ > 0) check ('a string 1439'); break; + case 1440: if (n[1440]++ > 0) check ('a string 1440'); break; + case 1441: if (n[1441]++ > 0) check ('a string 1441'); break; + case 1442: if (n[1442]++ > 0) check ('a string 1442'); break; + case 1443: if (n[1443]++ > 0) check ('a string 1443'); break; + case 1444: if (n[1444]++ > 0) check ('a string 1444'); break; + case 1445: if (n[1445]++ > 0) check ('a string 1445'); break; + case 1446: if (n[1446]++ > 0) check ('a string 1446'); break; + case 1447: if (n[1447]++ > 0) check ('a string 1447'); break; + case 1448: if (n[1448]++ > 0) check ('a string 1448'); break; + case 1449: if (n[1449]++ > 0) check ('a string 1449'); break; + case 1450: if (n[1450]++ > 0) check ('a string 1450'); break; + case 1451: if (n[1451]++ > 0) check ('a string 1451'); break; + case 1452: if (n[1452]++ > 0) check ('a string 1452'); break; + case 1453: if (n[1453]++ > 0) check ('a string 1453'); break; + case 1454: if (n[1454]++ > 0) check ('a string 1454'); break; + case 1455: if (n[1455]++ > 0) check ('a string 1455'); break; + case 1456: if (n[1456]++ > 0) check ('a string 1456'); break; + case 1457: if (n[1457]++ > 0) check ('a string 1457'); break; + case 1458: if (n[1458]++ > 0) check ('a string 1458'); break; + case 1459: if (n[1459]++ > 0) check ('a string 1459'); break; + case 1460: if (n[1460]++ > 0) check ('a string 1460'); break; + case 1461: if (n[1461]++ > 0) check ('a string 1461'); break; + case 1462: if (n[1462]++ > 0) check ('a string 1462'); break; + case 1463: if (n[1463]++ > 0) check ('a string 1463'); break; + case 1464: if (n[1464]++ > 0) check ('a string 1464'); break; + case 1465: if (n[1465]++ > 0) check ('a string 1465'); break; + case 1466: if (n[1466]++ > 0) check ('a string 1466'); break; + case 1467: if (n[1467]++ > 0) check ('a string 1467'); break; + case 1468: if (n[1468]++ > 0) check ('a string 1468'); break; + case 1469: if (n[1469]++ > 0) check ('a string 1469'); break; + case 1470: if (n[1470]++ > 0) check ('a string 1470'); break; + case 1471: if (n[1471]++ > 0) check ('a string 1471'); break; + case 1472: if (n[1472]++ > 0) check ('a string 1472'); break; + case 1473: if (n[1473]++ > 0) check ('a string 1473'); break; + case 1474: if (n[1474]++ > 0) check ('a string 1474'); break; + case 1475: if (n[1475]++ > 0) check ('a string 1475'); break; + case 1476: if (n[1476]++ > 0) check ('a string 1476'); break; + case 1477: if (n[1477]++ > 0) check ('a string 1477'); break; + case 1478: if (n[1478]++ > 0) check ('a string 1478'); break; + case 1479: if (n[1479]++ > 0) check ('a string 1479'); break; + case 1480: if (n[1480]++ > 0) check ('a string 1480'); break; + case 1481: if (n[1481]++ > 0) check ('a string 1481'); break; + case 1482: if (n[1482]++ > 0) check ('a string 1482'); break; + case 1483: if (n[1483]++ > 0) check ('a string 1483'); break; + case 1484: if (n[1484]++ > 0) check ('a string 1484'); break; + case 1485: if (n[1485]++ > 0) check ('a string 1485'); break; + case 1486: if (n[1486]++ > 0) check ('a string 1486'); break; + case 1487: if (n[1487]++ > 0) check ('a string 1487'); break; + case 1488: if (n[1488]++ > 0) check ('a string 1488'); break; + case 1489: if (n[1489]++ > 0) check ('a string 1489'); break; + case 1490: if (n[1490]++ > 0) check ('a string 1490'); break; + case 1491: if (n[1491]++ > 0) check ('a string 1491'); break; + case 1492: if (n[1492]++ > 0) check ('a string 1492'); break; + case 1493: if (n[1493]++ > 0) check ('a string 1493'); break; + case 1494: if (n[1494]++ > 0) check ('a string 1494'); break; + case 1495: if (n[1495]++ > 0) check ('a string 1495'); break; + case 1496: if (n[1496]++ > 0) check ('a string 1496'); break; + case 1497: if (n[1497]++ > 0) check ('a string 1497'); break; + case 1498: if (n[1498]++ > 0) check ('a string 1498'); break; + case 1499: if (n[1499]++ > 0) check ('a string 1499'); break; + case 1500: if (n[1500]++ > 0) check ('a string 1500'); break; + case 1501: if (n[1501]++ > 0) check ('a string 1501'); break; + case 1502: if (n[1502]++ > 0) check ('a string 1502'); break; + case 1503: if (n[1503]++ > 0) check ('a string 1503'); break; + case 1504: if (n[1504]++ > 0) check ('a string 1504'); break; + case 1505: if (n[1505]++ > 0) check ('a string 1505'); break; + case 1506: if (n[1506]++ > 0) check ('a string 1506'); break; + case 1507: if (n[1507]++ > 0) check ('a string 1507'); break; + case 1508: if (n[1508]++ > 0) check ('a string 1508'); break; + case 1509: if (n[1509]++ > 0) check ('a string 1509'); break; + case 1510: if (n[1510]++ > 0) check ('a string 1510'); break; + case 1511: if (n[1511]++ > 0) check ('a string 1511'); break; + case 1512: if (n[1512]++ > 0) check ('a string 1512'); break; + case 1513: if (n[1513]++ > 0) check ('a string 1513'); break; + case 1514: if (n[1514]++ > 0) check ('a string 1514'); break; + case 1515: if (n[1515]++ > 0) check ('a string 1515'); break; + case 1516: if (n[1516]++ > 0) check ('a string 1516'); break; + case 1517: if (n[1517]++ > 0) check ('a string 1517'); break; + case 1518: if (n[1518]++ > 0) check ('a string 1518'); break; + case 1519: if (n[1519]++ > 0) check ('a string 1519'); break; + case 1520: if (n[1520]++ > 0) check ('a string 1520'); break; + case 1521: if (n[1521]++ > 0) check ('a string 1521'); break; + case 1522: if (n[1522]++ > 0) check ('a string 1522'); break; + case 1523: if (n[1523]++ > 0) check ('a string 1523'); break; + case 1524: if (n[1524]++ > 0) check ('a string 1524'); break; + case 1525: if (n[1525]++ > 0) check ('a string 1525'); break; + case 1526: if (n[1526]++ > 0) check ('a string 1526'); break; + case 1527: if (n[1527]++ > 0) check ('a string 1527'); break; + case 1528: if (n[1528]++ > 0) check ('a string 1528'); break; + case 1529: if (n[1529]++ > 0) check ('a string 1529'); break; + case 1530: if (n[1530]++ > 0) check ('a string 1530'); break; + case 1531: if (n[1531]++ > 0) check ('a string 1531'); break; + case 1532: if (n[1532]++ > 0) check ('a string 1532'); break; + case 1533: if (n[1533]++ > 0) check ('a string 1533'); break; + case 1534: if (n[1534]++ > 0) check ('a string 1534'); break; + case 1535: if (n[1535]++ > 0) check ('a string 1535'); break; + case 1536: if (n[1536]++ > 0) check ('a string 1536'); break; + case 1537: if (n[1537]++ > 0) check ('a string 1537'); break; + case 1538: if (n[1538]++ > 0) check ('a string 1538'); break; + case 1539: if (n[1539]++ > 0) check ('a string 1539'); break; + case 1540: if (n[1540]++ > 0) check ('a string 1540'); break; + case 1541: if (n[1541]++ > 0) check ('a string 1541'); break; + case 1542: if (n[1542]++ > 0) check ('a string 1542'); break; + case 1543: if (n[1543]++ > 0) check ('a string 1543'); break; + case 1544: if (n[1544]++ > 0) check ('a string 1544'); break; + case 1545: if (n[1545]++ > 0) check ('a string 1545'); break; + case 1546: if (n[1546]++ > 0) check ('a string 1546'); break; + case 1547: if (n[1547]++ > 0) check ('a string 1547'); break; + case 1548: if (n[1548]++ > 0) check ('a string 1548'); break; + case 1549: if (n[1549]++ > 0) check ('a string 1549'); break; + case 1550: if (n[1550]++ > 0) check ('a string 1550'); break; + case 1551: if (n[1551]++ > 0) check ('a string 1551'); break; + case 1552: if (n[1552]++ > 0) check ('a string 1552'); break; + case 1553: if (n[1553]++ > 0) check ('a string 1553'); break; + case 1554: if (n[1554]++ > 0) check ('a string 1554'); break; + case 1555: if (n[1555]++ > 0) check ('a string 1555'); break; + case 1556: if (n[1556]++ > 0) check ('a string 1556'); break; + case 1557: if (n[1557]++ > 0) check ('a string 1557'); break; + case 1558: if (n[1558]++ > 0) check ('a string 1558'); break; + case 1559: if (n[1559]++ > 0) check ('a string 1559'); break; + case 1560: if (n[1560]++ > 0) check ('a string 1560'); break; + case 1561: if (n[1561]++ > 0) check ('a string 1561'); break; + case 1562: if (n[1562]++ > 0) check ('a string 1562'); break; + case 1563: if (n[1563]++ > 0) check ('a string 1563'); break; + case 1564: if (n[1564]++ > 0) check ('a string 1564'); break; + case 1565: if (n[1565]++ > 0) check ('a string 1565'); break; + case 1566: if (n[1566]++ > 0) check ('a string 1566'); break; + case 1567: if (n[1567]++ > 0) check ('a string 1567'); break; + case 1568: if (n[1568]++ > 0) check ('a string 1568'); break; + case 1569: if (n[1569]++ > 0) check ('a string 1569'); break; + case 1570: if (n[1570]++ > 0) check ('a string 1570'); break; + case 1571: if (n[1571]++ > 0) check ('a string 1571'); break; + case 1572: if (n[1572]++ > 0) check ('a string 1572'); break; + case 1573: if (n[1573]++ > 0) check ('a string 1573'); break; + case 1574: if (n[1574]++ > 0) check ('a string 1574'); break; + case 1575: if (n[1575]++ > 0) check ('a string 1575'); break; + case 1576: if (n[1576]++ > 0) check ('a string 1576'); break; + case 1577: if (n[1577]++ > 0) check ('a string 1577'); break; + case 1578: if (n[1578]++ > 0) check ('a string 1578'); break; + case 1579: if (n[1579]++ > 0) check ('a string 1579'); break; + case 1580: if (n[1580]++ > 0) check ('a string 1580'); break; + case 1581: if (n[1581]++ > 0) check ('a string 1581'); break; + case 1582: if (n[1582]++ > 0) check ('a string 1582'); break; + case 1583: if (n[1583]++ > 0) check ('a string 1583'); break; + case 1584: if (n[1584]++ > 0) check ('a string 1584'); break; + case 1585: if (n[1585]++ > 0) check ('a string 1585'); break; + case 1586: if (n[1586]++ > 0) check ('a string 1586'); break; + case 1587: if (n[1587]++ > 0) check ('a string 1587'); break; + case 1588: if (n[1588]++ > 0) check ('a string 1588'); break; + case 1589: if (n[1589]++ > 0) check ('a string 1589'); break; + case 1590: if (n[1590]++ > 0) check ('a string 1590'); break; + case 1591: if (n[1591]++ > 0) check ('a string 1591'); break; + case 1592: if (n[1592]++ > 0) check ('a string 1592'); break; + case 1593: if (n[1593]++ > 0) check ('a string 1593'); break; + case 1594: if (n[1594]++ > 0) check ('a string 1594'); break; + case 1595: if (n[1595]++ > 0) check ('a string 1595'); break; + case 1596: if (n[1596]++ > 0) check ('a string 1596'); break; + case 1597: if (n[1597]++ > 0) check ('a string 1597'); break; + case 1598: if (n[1598]++ > 0) check ('a string 1598'); break; + case 1599: if (n[1599]++ > 0) check ('a string 1599'); break; + case 1600: if (n[1600]++ > 0) check ('a string 1600'); break; + case 1601: if (n[1601]++ > 0) check ('a string 1601'); break; + case 1602: if (n[1602]++ > 0) check ('a string 1602'); break; + case 1603: if (n[1603]++ > 0) check ('a string 1603'); break; + case 1604: if (n[1604]++ > 0) check ('a string 1604'); break; + case 1605: if (n[1605]++ > 0) check ('a string 1605'); break; + case 1606: if (n[1606]++ > 0) check ('a string 1606'); break; + case 1607: if (n[1607]++ > 0) check ('a string 1607'); break; + case 1608: if (n[1608]++ > 0) check ('a string 1608'); break; + case 1609: if (n[1609]++ > 0) check ('a string 1609'); break; + case 1610: if (n[1610]++ > 0) check ('a string 1610'); break; + case 1611: if (n[1611]++ > 0) check ('a string 1611'); break; + case 1612: if (n[1612]++ > 0) check ('a string 1612'); break; + case 1613: if (n[1613]++ > 0) check ('a string 1613'); break; + case 1614: if (n[1614]++ > 0) check ('a string 1614'); break; + case 1615: if (n[1615]++ > 0) check ('a string 1615'); break; + case 1616: if (n[1616]++ > 0) check ('a string 1616'); break; + case 1617: if (n[1617]++ > 0) check ('a string 1617'); break; + case 1618: if (n[1618]++ > 0) check ('a string 1618'); break; + case 1619: if (n[1619]++ > 0) check ('a string 1619'); break; + case 1620: if (n[1620]++ > 0) check ('a string 1620'); break; + case 1621: if (n[1621]++ > 0) check ('a string 1621'); break; + case 1622: if (n[1622]++ > 0) check ('a string 1622'); break; + case 1623: if (n[1623]++ > 0) check ('a string 1623'); break; + case 1624: if (n[1624]++ > 0) check ('a string 1624'); break; + case 1625: if (n[1625]++ > 0) check ('a string 1625'); break; + case 1626: if (n[1626]++ > 0) check ('a string 1626'); break; + case 1627: if (n[1627]++ > 0) check ('a string 1627'); break; + case 1628: if (n[1628]++ > 0) check ('a string 1628'); break; + case 1629: if (n[1629]++ > 0) check ('a string 1629'); break; + case 1630: if (n[1630]++ > 0) check ('a string 1630'); break; + case 1631: if (n[1631]++ > 0) check ('a string 1631'); break; + case 1632: if (n[1632]++ > 0) check ('a string 1632'); break; + case 1633: if (n[1633]++ > 0) check ('a string 1633'); break; + case 1634: if (n[1634]++ > 0) check ('a string 1634'); break; + case 1635: if (n[1635]++ > 0) check ('a string 1635'); break; + case 1636: if (n[1636]++ > 0) check ('a string 1636'); break; + case 1637: if (n[1637]++ > 0) check ('a string 1637'); break; + case 1638: if (n[1638]++ > 0) check ('a string 1638'); break; + case 1639: if (n[1639]++ > 0) check ('a string 1639'); break; + case 1640: if (n[1640]++ > 0) check ('a string 1640'); break; + case 1641: if (n[1641]++ > 0) check ('a string 1641'); break; + case 1642: if (n[1642]++ > 0) check ('a string 1642'); break; + case 1643: if (n[1643]++ > 0) check ('a string 1643'); break; + case 1644: if (n[1644]++ > 0) check ('a string 1644'); break; + case 1645: if (n[1645]++ > 0) check ('a string 1645'); break; + case 1646: if (n[1646]++ > 0) check ('a string 1646'); break; + case 1647: if (n[1647]++ > 0) check ('a string 1647'); break; + case 1648: if (n[1648]++ > 0) check ('a string 1648'); break; + case 1649: if (n[1649]++ > 0) check ('a string 1649'); break; + case 1650: if (n[1650]++ > 0) check ('a string 1650'); break; + case 1651: if (n[1651]++ > 0) check ('a string 1651'); break; + case 1652: if (n[1652]++ > 0) check ('a string 1652'); break; + case 1653: if (n[1653]++ > 0) check ('a string 1653'); break; + case 1654: if (n[1654]++ > 0) check ('a string 1654'); break; + case 1655: if (n[1655]++ > 0) check ('a string 1655'); break; + case 1656: if (n[1656]++ > 0) check ('a string 1656'); break; + case 1657: if (n[1657]++ > 0) check ('a string 1657'); break; + case 1658: if (n[1658]++ > 0) check ('a string 1658'); break; + case 1659: if (n[1659]++ > 0) check ('a string 1659'); break; + case 1660: if (n[1660]++ > 0) check ('a string 1660'); break; + case 1661: if (n[1661]++ > 0) check ('a string 1661'); break; + case 1662: if (n[1662]++ > 0) check ('a string 1662'); break; + case 1663: if (n[1663]++ > 0) check ('a string 1663'); break; + case 1664: if (n[1664]++ > 0) check ('a string 1664'); break; + case 1665: if (n[1665]++ > 0) check ('a string 1665'); break; + case 1666: if (n[1666]++ > 0) check ('a string 1666'); break; + case 1667: if (n[1667]++ > 0) check ('a string 1667'); break; + case 1668: if (n[1668]++ > 0) check ('a string 1668'); break; + case 1669: if (n[1669]++ > 0) check ('a string 1669'); break; + case 1670: if (n[1670]++ > 0) check ('a string 1670'); break; + case 1671: if (n[1671]++ > 0) check ('a string 1671'); break; + case 1672: if (n[1672]++ > 0) check ('a string 1672'); break; + case 1673: if (n[1673]++ > 0) check ('a string 1673'); break; + case 1674: if (n[1674]++ > 0) check ('a string 1674'); break; + case 1675: if (n[1675]++ > 0) check ('a string 1675'); break; + case 1676: if (n[1676]++ > 0) check ('a string 1676'); break; + case 1677: if (n[1677]++ > 0) check ('a string 1677'); break; + case 1678: if (n[1678]++ > 0) check ('a string 1678'); break; + case 1679: if (n[1679]++ > 0) check ('a string 1679'); break; + case 1680: if (n[1680]++ > 0) check ('a string 1680'); break; + case 1681: if (n[1681]++ > 0) check ('a string 1681'); break; + case 1682: if (n[1682]++ > 0) check ('a string 1682'); break; + case 1683: if (n[1683]++ > 0) check ('a string 1683'); break; + case 1684: if (n[1684]++ > 0) check ('a string 1684'); break; + case 1685: if (n[1685]++ > 0) check ('a string 1685'); break; + case 1686: if (n[1686]++ > 0) check ('a string 1686'); break; + case 1687: if (n[1687]++ > 0) check ('a string 1687'); break; + case 1688: if (n[1688]++ > 0) check ('a string 1688'); break; + case 1689: if (n[1689]++ > 0) check ('a string 1689'); break; + case 1690: if (n[1690]++ > 0) check ('a string 1690'); break; + case 1691: if (n[1691]++ > 0) check ('a string 1691'); break; + case 1692: if (n[1692]++ > 0) check ('a string 1692'); break; + case 1693: if (n[1693]++ > 0) check ('a string 1693'); break; + case 1694: if (n[1694]++ > 0) check ('a string 1694'); break; + case 1695: if (n[1695]++ > 0) check ('a string 1695'); break; + case 1696: if (n[1696]++ > 0) check ('a string 1696'); break; + case 1697: if (n[1697]++ > 0) check ('a string 1697'); break; + case 1698: if (n[1698]++ > 0) check ('a string 1698'); break; + case 1699: if (n[1699]++ > 0) check ('a string 1699'); break; + case 1700: if (n[1700]++ > 0) check ('a string 1700'); break; + case 1701: if (n[1701]++ > 0) check ('a string 1701'); break; + case 1702: if (n[1702]++ > 0) check ('a string 1702'); break; + case 1703: if (n[1703]++ > 0) check ('a string 1703'); break; + case 1704: if (n[1704]++ > 0) check ('a string 1704'); break; + case 1705: if (n[1705]++ > 0) check ('a string 1705'); break; + case 1706: if (n[1706]++ > 0) check ('a string 1706'); break; + case 1707: if (n[1707]++ > 0) check ('a string 1707'); break; + case 1708: if (n[1708]++ > 0) check ('a string 1708'); break; + case 1709: if (n[1709]++ > 0) check ('a string 1709'); break; + case 1710: if (n[1710]++ > 0) check ('a string 1710'); break; + case 1711: if (n[1711]++ > 0) check ('a string 1711'); break; + case 1712: if (n[1712]++ > 0) check ('a string 1712'); break; + case 1713: if (n[1713]++ > 0) check ('a string 1713'); break; + case 1714: if (n[1714]++ > 0) check ('a string 1714'); break; + case 1715: if (n[1715]++ > 0) check ('a string 1715'); break; + case 1716: if (n[1716]++ > 0) check ('a string 1716'); break; + case 1717: if (n[1717]++ > 0) check ('a string 1717'); break; + case 1718: if (n[1718]++ > 0) check ('a string 1718'); break; + case 1719: if (n[1719]++ > 0) check ('a string 1719'); break; + case 1720: if (n[1720]++ > 0) check ('a string 1720'); break; + case 1721: if (n[1721]++ > 0) check ('a string 1721'); break; + case 1722: if (n[1722]++ > 0) check ('a string 1722'); break; + case 1723: if (n[1723]++ > 0) check ('a string 1723'); break; + case 1724: if (n[1724]++ > 0) check ('a string 1724'); break; + case 1725: if (n[1725]++ > 0) check ('a string 1725'); break; + case 1726: if (n[1726]++ > 0) check ('a string 1726'); break; + case 1727: if (n[1727]++ > 0) check ('a string 1727'); break; + case 1728: if (n[1728]++ > 0) check ('a string 1728'); break; + case 1729: if (n[1729]++ > 0) check ('a string 1729'); break; + case 1730: if (n[1730]++ > 0) check ('a string 1730'); break; + case 1731: if (n[1731]++ > 0) check ('a string 1731'); break; + case 1732: if (n[1732]++ > 0) check ('a string 1732'); break; + case 1733: if (n[1733]++ > 0) check ('a string 1733'); break; + case 1734: if (n[1734]++ > 0) check ('a string 1734'); break; + case 1735: if (n[1735]++ > 0) check ('a string 1735'); break; + case 1736: if (n[1736]++ > 0) check ('a string 1736'); break; + case 1737: if (n[1737]++ > 0) check ('a string 1737'); break; + case 1738: if (n[1738]++ > 0) check ('a string 1738'); break; + case 1739: if (n[1739]++ > 0) check ('a string 1739'); break; + case 1740: if (n[1740]++ > 0) check ('a string 1740'); break; + case 1741: if (n[1741]++ > 0) check ('a string 1741'); break; + case 1742: if (n[1742]++ > 0) check ('a string 1742'); break; + case 1743: if (n[1743]++ > 0) check ('a string 1743'); break; + case 1744: if (n[1744]++ > 0) check ('a string 1744'); break; + case 1745: if (n[1745]++ > 0) check ('a string 1745'); break; + case 1746: if (n[1746]++ > 0) check ('a string 1746'); break; + case 1747: if (n[1747]++ > 0) check ('a string 1747'); break; + case 1748: if (n[1748]++ > 0) check ('a string 1748'); break; + case 1749: if (n[1749]++ > 0) check ('a string 1749'); break; + case 1750: if (n[1750]++ > 0) check ('a string 1750'); break; + case 1751: if (n[1751]++ > 0) check ('a string 1751'); break; + case 1752: if (n[1752]++ > 0) check ('a string 1752'); break; + case 1753: if (n[1753]++ > 0) check ('a string 1753'); break; + case 1754: if (n[1754]++ > 0) check ('a string 1754'); break; + case 1755: if (n[1755]++ > 0) check ('a string 1755'); break; + case 1756: if (n[1756]++ > 0) check ('a string 1756'); break; + case 1757: if (n[1757]++ > 0) check ('a string 1757'); break; + case 1758: if (n[1758]++ > 0) check ('a string 1758'); break; + case 1759: if (n[1759]++ > 0) check ('a string 1759'); break; + case 1760: if (n[1760]++ > 0) check ('a string 1760'); break; + case 1761: if (n[1761]++ > 0) check ('a string 1761'); break; + case 1762: if (n[1762]++ > 0) check ('a string 1762'); break; + case 1763: if (n[1763]++ > 0) check ('a string 1763'); break; + case 1764: if (n[1764]++ > 0) check ('a string 1764'); break; + case 1765: if (n[1765]++ > 0) check ('a string 1765'); break; + case 1766: if (n[1766]++ > 0) check ('a string 1766'); break; + case 1767: if (n[1767]++ > 0) check ('a string 1767'); break; + case 1768: if (n[1768]++ > 0) check ('a string 1768'); break; + case 1769: if (n[1769]++ > 0) check ('a string 1769'); break; + case 1770: if (n[1770]++ > 0) check ('a string 1770'); break; + case 1771: if (n[1771]++ > 0) check ('a string 1771'); break; + case 1772: if (n[1772]++ > 0) check ('a string 1772'); break; + case 1773: if (n[1773]++ > 0) check ('a string 1773'); break; + case 1774: if (n[1774]++ > 0) check ('a string 1774'); break; + case 1775: if (n[1775]++ > 0) check ('a string 1775'); break; + case 1776: if (n[1776]++ > 0) check ('a string 1776'); break; + case 1777: if (n[1777]++ > 0) check ('a string 1777'); break; + case 1778: if (n[1778]++ > 0) check ('a string 1778'); break; + case 1779: if (n[1779]++ > 0) check ('a string 1779'); break; + case 1780: if (n[1780]++ > 0) check ('a string 1780'); break; + case 1781: if (n[1781]++ > 0) check ('a string 1781'); break; + case 1782: if (n[1782]++ > 0) check ('a string 1782'); break; + case 1783: if (n[1783]++ > 0) check ('a string 1783'); break; + case 1784: if (n[1784]++ > 0) check ('a string 1784'); break; + case 1785: if (n[1785]++ > 0) check ('a string 1785'); break; + case 1786: if (n[1786]++ > 0) check ('a string 1786'); break; + case 1787: if (n[1787]++ > 0) check ('a string 1787'); break; + case 1788: if (n[1788]++ > 0) check ('a string 1788'); break; + case 1789: if (n[1789]++ > 0) check ('a string 1789'); break; + case 1790: if (n[1790]++ > 0) check ('a string 1790'); break; + case 1791: if (n[1791]++ > 0) check ('a string 1791'); break; + case 1792: if (n[1792]++ > 0) check ('a string 1792'); break; + case 1793: if (n[1793]++ > 0) check ('a string 1793'); break; + case 1794: if (n[1794]++ > 0) check ('a string 1794'); break; + case 1795: if (n[1795]++ > 0) check ('a string 1795'); break; + case 1796: if (n[1796]++ > 0) check ('a string 1796'); break; + case 1797: if (n[1797]++ > 0) check ('a string 1797'); break; + case 1798: if (n[1798]++ > 0) check ('a string 1798'); break; + case 1799: if (n[1799]++ > 0) check ('a string 1799'); break; + case 1800: if (n[1800]++ > 0) check ('a string 1800'); break; + case 1801: if (n[1801]++ > 0) check ('a string 1801'); break; + case 1802: if (n[1802]++ > 0) check ('a string 1802'); break; + case 1803: if (n[1803]++ > 0) check ('a string 1803'); break; + case 1804: if (n[1804]++ > 0) check ('a string 1804'); break; + case 1805: if (n[1805]++ > 0) check ('a string 1805'); break; + case 1806: if (n[1806]++ > 0) check ('a string 1806'); break; + case 1807: if (n[1807]++ > 0) check ('a string 1807'); break; + case 1808: if (n[1808]++ > 0) check ('a string 1808'); break; + case 1809: if (n[1809]++ > 0) check ('a string 1809'); break; + case 1810: if (n[1810]++ > 0) check ('a string 1810'); break; + case 1811: if (n[1811]++ > 0) check ('a string 1811'); break; + case 1812: if (n[1812]++ > 0) check ('a string 1812'); break; + case 1813: if (n[1813]++ > 0) check ('a string 1813'); break; + case 1814: if (n[1814]++ > 0) check ('a string 1814'); break; + case 1815: if (n[1815]++ > 0) check ('a string 1815'); break; + case 1816: if (n[1816]++ > 0) check ('a string 1816'); break; + case 1817: if (n[1817]++ > 0) check ('a string 1817'); break; + case 1818: if (n[1818]++ > 0) check ('a string 1818'); break; + case 1819: if (n[1819]++ > 0) check ('a string 1819'); break; + case 1820: if (n[1820]++ > 0) check ('a string 1820'); break; + case 1821: if (n[1821]++ > 0) check ('a string 1821'); break; + case 1822: if (n[1822]++ > 0) check ('a string 1822'); break; + case 1823: if (n[1823]++ > 0) check ('a string 1823'); break; + case 1824: if (n[1824]++ > 0) check ('a string 1824'); break; + case 1825: if (n[1825]++ > 0) check ('a string 1825'); break; + case 1826: if (n[1826]++ > 0) check ('a string 1826'); break; + case 1827: if (n[1827]++ > 0) check ('a string 1827'); break; + case 1828: if (n[1828]++ > 0) check ('a string 1828'); break; + case 1829: if (n[1829]++ > 0) check ('a string 1829'); break; + case 1830: if (n[1830]++ > 0) check ('a string 1830'); break; + case 1831: if (n[1831]++ > 0) check ('a string 1831'); break; + case 1832: if (n[1832]++ > 0) check ('a string 1832'); break; + case 1833: if (n[1833]++ > 0) check ('a string 1833'); break; + case 1834: if (n[1834]++ > 0) check ('a string 1834'); break; + case 1835: if (n[1835]++ > 0) check ('a string 1835'); break; + case 1836: if (n[1836]++ > 0) check ('a string 1836'); break; + case 1837: if (n[1837]++ > 0) check ('a string 1837'); break; + case 1838: if (n[1838]++ > 0) check ('a string 1838'); break; + case 1839: if (n[1839]++ > 0) check ('a string 1839'); break; + case 1840: if (n[1840]++ > 0) check ('a string 1840'); break; + case 1841: if (n[1841]++ > 0) check ('a string 1841'); break; + case 1842: if (n[1842]++ > 0) check ('a string 1842'); break; + case 1843: if (n[1843]++ > 0) check ('a string 1843'); break; + case 1844: if (n[1844]++ > 0) check ('a string 1844'); break; + case 1845: if (n[1845]++ > 0) check ('a string 1845'); break; + case 1846: if (n[1846]++ > 0) check ('a string 1846'); break; + case 1847: if (n[1847]++ > 0) check ('a string 1847'); break; + case 1848: if (n[1848]++ > 0) check ('a string 1848'); break; + case 1849: if (n[1849]++ > 0) check ('a string 1849'); break; + case 1850: if (n[1850]++ > 0) check ('a string 1850'); break; + case 1851: if (n[1851]++ > 0) check ('a string 1851'); break; + case 1852: if (n[1852]++ > 0) check ('a string 1852'); break; + case 1853: if (n[1853]++ > 0) check ('a string 1853'); break; + case 1854: if (n[1854]++ > 0) check ('a string 1854'); break; + case 1855: if (n[1855]++ > 0) check ('a string 1855'); break; + case 1856: if (n[1856]++ > 0) check ('a string 1856'); break; + case 1857: if (n[1857]++ > 0) check ('a string 1857'); break; + case 1858: if (n[1858]++ > 0) check ('a string 1858'); break; + case 1859: if (n[1859]++ > 0) check ('a string 1859'); break; + case 1860: if (n[1860]++ > 0) check ('a string 1860'); break; + case 1861: if (n[1861]++ > 0) check ('a string 1861'); break; + case 1862: if (n[1862]++ > 0) check ('a string 1862'); break; + case 1863: if (n[1863]++ > 0) check ('a string 1863'); break; + case 1864: if (n[1864]++ > 0) check ('a string 1864'); break; + case 1865: if (n[1865]++ > 0) check ('a string 1865'); break; + case 1866: if (n[1866]++ > 0) check ('a string 1866'); break; + case 1867: if (n[1867]++ > 0) check ('a string 1867'); break; + case 1868: if (n[1868]++ > 0) check ('a string 1868'); break; + case 1869: if (n[1869]++ > 0) check ('a string 1869'); break; + case 1870: if (n[1870]++ > 0) check ('a string 1870'); break; + case 1871: if (n[1871]++ > 0) check ('a string 1871'); break; + case 1872: if (n[1872]++ > 0) check ('a string 1872'); break; + case 1873: if (n[1873]++ > 0) check ('a string 1873'); break; + case 1874: if (n[1874]++ > 0) check ('a string 1874'); break; + case 1875: if (n[1875]++ > 0) check ('a string 1875'); break; + case 1876: if (n[1876]++ > 0) check ('a string 1876'); break; + case 1877: if (n[1877]++ > 0) check ('a string 1877'); break; + case 1878: if (n[1878]++ > 0) check ('a string 1878'); break; + case 1879: if (n[1879]++ > 0) check ('a string 1879'); break; + case 1880: if (n[1880]++ > 0) check ('a string 1880'); break; + case 1881: if (n[1881]++ > 0) check ('a string 1881'); break; + case 1882: if (n[1882]++ > 0) check ('a string 1882'); break; + case 1883: if (n[1883]++ > 0) check ('a string 1883'); break; + case 1884: if (n[1884]++ > 0) check ('a string 1884'); break; + case 1885: if (n[1885]++ > 0) check ('a string 1885'); break; + case 1886: if (n[1886]++ > 0) check ('a string 1886'); break; + case 1887: if (n[1887]++ > 0) check ('a string 1887'); break; + case 1888: if (n[1888]++ > 0) check ('a string 1888'); break; + case 1889: if (n[1889]++ > 0) check ('a string 1889'); break; + case 1890: if (n[1890]++ > 0) check ('a string 1890'); break; + case 1891: if (n[1891]++ > 0) check ('a string 1891'); break; + case 1892: if (n[1892]++ > 0) check ('a string 1892'); break; + case 1893: if (n[1893]++ > 0) check ('a string 1893'); break; + case 1894: if (n[1894]++ > 0) check ('a string 1894'); break; + case 1895: if (n[1895]++ > 0) check ('a string 1895'); break; + case 1896: if (n[1896]++ > 0) check ('a string 1896'); break; + case 1897: if (n[1897]++ > 0) check ('a string 1897'); break; + case 1898: if (n[1898]++ > 0) check ('a string 1898'); break; + case 1899: if (n[1899]++ > 0) check ('a string 1899'); break; + case 1900: if (n[1900]++ > 0) check ('a string 1900'); break; + case 1901: if (n[1901]++ > 0) check ('a string 1901'); break; + case 1902: if (n[1902]++ > 0) check ('a string 1902'); break; + case 1903: if (n[1903]++ > 0) check ('a string 1903'); break; + case 1904: if (n[1904]++ > 0) check ('a string 1904'); break; + case 1905: if (n[1905]++ > 0) check ('a string 1905'); break; + case 1906: if (n[1906]++ > 0) check ('a string 1906'); break; + case 1907: if (n[1907]++ > 0) check ('a string 1907'); break; + case 1908: if (n[1908]++ > 0) check ('a string 1908'); break; + case 1909: if (n[1909]++ > 0) check ('a string 1909'); break; + case 1910: if (n[1910]++ > 0) check ('a string 1910'); break; + case 1911: if (n[1911]++ > 0) check ('a string 1911'); break; + case 1912: if (n[1912]++ > 0) check ('a string 1912'); break; + case 1913: if (n[1913]++ > 0) check ('a string 1913'); break; + case 1914: if (n[1914]++ > 0) check ('a string 1914'); break; + case 1915: if (n[1915]++ > 0) check ('a string 1915'); break; + case 1916: if (n[1916]++ > 0) check ('a string 1916'); break; + case 1917: if (n[1917]++ > 0) check ('a string 1917'); break; + case 1918: if (n[1918]++ > 0) check ('a string 1918'); break; + case 1919: if (n[1919]++ > 0) check ('a string 1919'); break; + case 1920: if (n[1920]++ > 0) check ('a string 1920'); break; + case 1921: if (n[1921]++ > 0) check ('a string 1921'); break; + case 1922: if (n[1922]++ > 0) check ('a string 1922'); break; + case 1923: if (n[1923]++ > 0) check ('a string 1923'); break; + case 1924: if (n[1924]++ > 0) check ('a string 1924'); break; + case 1925: if (n[1925]++ > 0) check ('a string 1925'); break; + case 1926: if (n[1926]++ > 0) check ('a string 1926'); break; + case 1927: if (n[1927]++ > 0) check ('a string 1927'); break; + case 1928: if (n[1928]++ > 0) check ('a string 1928'); break; + case 1929: if (n[1929]++ > 0) check ('a string 1929'); break; + case 1930: if (n[1930]++ > 0) check ('a string 1930'); break; + case 1931: if (n[1931]++ > 0) check ('a string 1931'); break; + case 1932: if (n[1932]++ > 0) check ('a string 1932'); break; + case 1933: if (n[1933]++ > 0) check ('a string 1933'); break; + case 1934: if (n[1934]++ > 0) check ('a string 1934'); break; + case 1935: if (n[1935]++ > 0) check ('a string 1935'); break; + case 1936: if (n[1936]++ > 0) check ('a string 1936'); break; + case 1937: if (n[1937]++ > 0) check ('a string 1937'); break; + case 1938: if (n[1938]++ > 0) check ('a string 1938'); break; + case 1939: if (n[1939]++ > 0) check ('a string 1939'); break; + case 1940: if (n[1940]++ > 0) check ('a string 1940'); break; + case 1941: if (n[1941]++ > 0) check ('a string 1941'); break; + case 1942: if (n[1942]++ > 0) check ('a string 1942'); break; + case 1943: if (n[1943]++ > 0) check ('a string 1943'); break; + case 1944: if (n[1944]++ > 0) check ('a string 1944'); break; + case 1945: if (n[1945]++ > 0) check ('a string 1945'); break; + case 1946: if (n[1946]++ > 0) check ('a string 1946'); break; + case 1947: if (n[1947]++ > 0) check ('a string 1947'); break; + case 1948: if (n[1948]++ > 0) check ('a string 1948'); break; + case 1949: if (n[1949]++ > 0) check ('a string 1949'); break; + case 1950: if (n[1950]++ > 0) check ('a string 1950'); break; + case 1951: if (n[1951]++ > 0) check ('a string 1951'); break; + case 1952: if (n[1952]++ > 0) check ('a string 1952'); break; + case 1953: if (n[1953]++ > 0) check ('a string 1953'); break; + case 1954: if (n[1954]++ > 0) check ('a string 1954'); break; + case 1955: if (n[1955]++ > 0) check ('a string 1955'); break; + case 1956: if (n[1956]++ > 0) check ('a string 1956'); break; + case 1957: if (n[1957]++ > 0) check ('a string 1957'); break; + case 1958: if (n[1958]++ > 0) check ('a string 1958'); break; + case 1959: if (n[1959]++ > 0) check ('a string 1959'); break; + case 1960: if (n[1960]++ > 0) check ('a string 1960'); break; + case 1961: if (n[1961]++ > 0) check ('a string 1961'); break; + case 1962: if (n[1962]++ > 0) check ('a string 1962'); break; + case 1963: if (n[1963]++ > 0) check ('a string 1963'); break; + case 1964: if (n[1964]++ > 0) check ('a string 1964'); break; + case 1965: if (n[1965]++ > 0) check ('a string 1965'); break; + case 1966: if (n[1966]++ > 0) check ('a string 1966'); break; + case 1967: if (n[1967]++ > 0) check ('a string 1967'); break; + case 1968: if (n[1968]++ > 0) check ('a string 1968'); break; + case 1969: if (n[1969]++ > 0) check ('a string 1969'); break; + case 1970: if (n[1970]++ > 0) check ('a string 1970'); break; + case 1971: if (n[1971]++ > 0) check ('a string 1971'); break; + case 1972: if (n[1972]++ > 0) check ('a string 1972'); break; + case 1973: if (n[1973]++ > 0) check ('a string 1973'); break; + case 1974: if (n[1974]++ > 0) check ('a string 1974'); break; + case 1975: if (n[1975]++ > 0) check ('a string 1975'); break; + case 1976: if (n[1976]++ > 0) check ('a string 1976'); break; + case 1977: if (n[1977]++ > 0) check ('a string 1977'); break; + case 1978: if (n[1978]++ > 0) check ('a string 1978'); break; + case 1979: if (n[1979]++ > 0) check ('a string 1979'); break; + case 1980: if (n[1980]++ > 0) check ('a string 1980'); break; + case 1981: if (n[1981]++ > 0) check ('a string 1981'); break; + case 1982: if (n[1982]++ > 0) check ('a string 1982'); break; + case 1983: if (n[1983]++ > 0) check ('a string 1983'); break; + case 1984: if (n[1984]++ > 0) check ('a string 1984'); break; + case 1985: if (n[1985]++ > 0) check ('a string 1985'); break; + case 1986: if (n[1986]++ > 0) check ('a string 1986'); break; + case 1987: if (n[1987]++ > 0) check ('a string 1987'); break; + case 1988: if (n[1988]++ > 0) check ('a string 1988'); break; + case 1989: if (n[1989]++ > 0) check ('a string 1989'); break; + case 1990: if (n[1990]++ > 0) check ('a string 1990'); break; + case 1991: if (n[1991]++ > 0) check ('a string 1991'); break; + case 1992: if (n[1992]++ > 0) check ('a string 1992'); break; + case 1993: if (n[1993]++ > 0) check ('a string 1993'); break; + case 1994: if (n[1994]++ > 0) check ('a string 1994'); break; + case 1995: if (n[1995]++ > 0) check ('a string 1995'); break; + case 1996: if (n[1996]++ > 0) check ('a string 1996'); break; + case 1997: if (n[1997]++ > 0) check ('a string 1997'); break; + case 1998: if (n[1998]++ > 0) check ('a string 1998'); break; + case 1999: if (n[1999]++ > 0) check ('a string 1999'); break; + case 2000: if (n[2000]++ > 0) check ('a string 2000'); break; + case 2001: if (n[2001]++ > 0) check ('a string 2001'); break; + case 2002: if (n[2002]++ > 0) check ('a string 2002'); break; + case 2003: if (n[2003]++ > 0) check ('a string 2003'); break; + case 2004: if (n[2004]++ > 0) check ('a string 2004'); break; + case 2005: if (n[2005]++ > 0) check ('a string 2005'); break; + case 2006: if (n[2006]++ > 0) check ('a string 2006'); break; + case 2007: if (n[2007]++ > 0) check ('a string 2007'); break; + case 2008: if (n[2008]++ > 0) check ('a string 2008'); break; + case 2009: if (n[2009]++ > 0) check ('a string 2009'); break; + case 2010: if (n[2010]++ > 0) check ('a string 2010'); break; + case 2011: if (n[2011]++ > 0) check ('a string 2011'); break; + case 2012: if (n[2012]++ > 0) check ('a string 2012'); break; + case 2013: if (n[2013]++ > 0) check ('a string 2013'); break; + case 2014: if (n[2014]++ > 0) check ('a string 2014'); break; + case 2015: if (n[2015]++ > 0) check ('a string 2015'); break; + case 2016: if (n[2016]++ > 0) check ('a string 2016'); break; + case 2017: if (n[2017]++ > 0) check ('a string 2017'); break; + case 2018: if (n[2018]++ > 0) check ('a string 2018'); break; + case 2019: if (n[2019]++ > 0) check ('a string 2019'); break; + case 2020: if (n[2020]++ > 0) check ('a string 2020'); break; + case 2021: if (n[2021]++ > 0) check ('a string 2021'); break; + case 2022: if (n[2022]++ > 0) check ('a string 2022'); break; + case 2023: if (n[2023]++ > 0) check ('a string 2023'); break; + case 2024: if (n[2024]++ > 0) check ('a string 2024'); break; + case 2025: if (n[2025]++ > 0) check ('a string 2025'); break; + case 2026: if (n[2026]++ > 0) check ('a string 2026'); break; + case 2027: if (n[2027]++ > 0) check ('a string 2027'); break; + case 2028: if (n[2028]++ > 0) check ('a string 2028'); break; + case 2029: if (n[2029]++ > 0) check ('a string 2029'); break; + case 2030: if (n[2030]++ > 0) check ('a string 2030'); break; + case 2031: if (n[2031]++ > 0) check ('a string 2031'); break; + case 2032: if (n[2032]++ > 0) check ('a string 2032'); break; + case 2033: if (n[2033]++ > 0) check ('a string 2033'); break; + case 2034: if (n[2034]++ > 0) check ('a string 2034'); break; + case 2035: if (n[2035]++ > 0) check ('a string 2035'); break; + case 2036: if (n[2036]++ > 0) check ('a string 2036'); break; + case 2037: if (n[2037]++ > 0) check ('a string 2037'); break; + case 2038: if (n[2038]++ > 0) check ('a string 2038'); break; + case 2039: if (n[2039]++ > 0) check ('a string 2039'); break; + case 2040: if (n[2040]++ > 0) check ('a string 2040'); break; + case 2041: if (n[2041]++ > 0) check ('a string 2041'); break; + case 2042: if (n[2042]++ > 0) check ('a string 2042'); break; + case 2043: if (n[2043]++ > 0) check ('a string 2043'); break; + case 2044: if (n[2044]++ > 0) check ('a string 2044'); break; + case 2045: if (n[2045]++ > 0) check ('a string 2045'); break; + case 2046: if (n[2046]++ > 0) check ('a string 2046'); break; + case 2047: if (n[2047]++ > 0) check ('a string 2047'); break; + case 2048: if (n[2048]++ > 0) check ('a string 2048'); break; + case 2049: if (n[2049]++ > 0) check ('a string 2049'); break; + case 2050: if (n[2050]++ > 0) check ('a string 2050'); break; + case 2051: if (n[2051]++ > 0) check ('a string 2051'); break; + case 2052: if (n[2052]++ > 0) check ('a string 2052'); break; + case 2053: if (n[2053]++ > 0) check ('a string 2053'); break; + case 2054: if (n[2054]++ > 0) check ('a string 2054'); break; + case 2055: if (n[2055]++ > 0) check ('a string 2055'); break; + case 2056: if (n[2056]++ > 0) check ('a string 2056'); break; + case 2057: if (n[2057]++ > 0) check ('a string 2057'); break; + case 2058: if (n[2058]++ > 0) check ('a string 2058'); break; + case 2059: if (n[2059]++ > 0) check ('a string 2059'); break; + case 2060: if (n[2060]++ > 0) check ('a string 2060'); break; + case 2061: if (n[2061]++ > 0) check ('a string 2061'); break; + case 2062: if (n[2062]++ > 0) check ('a string 2062'); break; + case 2063: if (n[2063]++ > 0) check ('a string 2063'); break; + case 2064: if (n[2064]++ > 0) check ('a string 2064'); break; + case 2065: if (n[2065]++ > 0) check ('a string 2065'); break; + case 2066: if (n[2066]++ > 0) check ('a string 2066'); break; + case 2067: if (n[2067]++ > 0) check ('a string 2067'); break; + case 2068: if (n[2068]++ > 0) check ('a string 2068'); break; + case 2069: if (n[2069]++ > 0) check ('a string 2069'); break; + case 2070: if (n[2070]++ > 0) check ('a string 2070'); break; + case 2071: if (n[2071]++ > 0) check ('a string 2071'); break; + case 2072: if (n[2072]++ > 0) check ('a string 2072'); break; + case 2073: if (n[2073]++ > 0) check ('a string 2073'); break; + case 2074: if (n[2074]++ > 0) check ('a string 2074'); break; + case 2075: if (n[2075]++ > 0) check ('a string 2075'); break; + case 2076: if (n[2076]++ > 0) check ('a string 2076'); break; + case 2077: if (n[2077]++ > 0) check ('a string 2077'); break; + case 2078: if (n[2078]++ > 0) check ('a string 2078'); break; + case 2079: if (n[2079]++ > 0) check ('a string 2079'); break; + case 2080: if (n[2080]++ > 0) check ('a string 2080'); break; + case 2081: if (n[2081]++ > 0) check ('a string 2081'); break; + case 2082: if (n[2082]++ > 0) check ('a string 2082'); break; + case 2083: if (n[2083]++ > 0) check ('a string 2083'); break; + case 2084: if (n[2084]++ > 0) check ('a string 2084'); break; + case 2085: if (n[2085]++ > 0) check ('a string 2085'); break; + case 2086: if (n[2086]++ > 0) check ('a string 2086'); break; + case 2087: if (n[2087]++ > 0) check ('a string 2087'); break; + case 2088: if (n[2088]++ > 0) check ('a string 2088'); break; + case 2089: if (n[2089]++ > 0) check ('a string 2089'); break; + case 2090: if (n[2090]++ > 0) check ('a string 2090'); break; + case 2091: if (n[2091]++ > 0) check ('a string 2091'); break; + case 2092: if (n[2092]++ > 0) check ('a string 2092'); break; + case 2093: if (n[2093]++ > 0) check ('a string 2093'); break; + case 2094: if (n[2094]++ > 0) check ('a string 2094'); break; + case 2095: if (n[2095]++ > 0) check ('a string 2095'); break; + case 2096: if (n[2096]++ > 0) check ('a string 2096'); break; + case 2097: if (n[2097]++ > 0) check ('a string 2097'); break; + case 2098: if (n[2098]++ > 0) check ('a string 2098'); break; + case 2099: if (n[2099]++ > 0) check ('a string 2099'); break; + case 2100: if (n[2100]++ > 0) check ('a string 2100'); break; + case 2101: if (n[2101]++ > 0) check ('a string 2101'); break; + case 2102: if (n[2102]++ > 0) check ('a string 2102'); break; + case 2103: if (n[2103]++ > 0) check ('a string 2103'); break; + case 2104: if (n[2104]++ > 0) check ('a string 2104'); break; + case 2105: if (n[2105]++ > 0) check ('a string 2105'); break; + case 2106: if (n[2106]++ > 0) check ('a string 2106'); break; + case 2107: if (n[2107]++ > 0) check ('a string 2107'); break; + case 2108: if (n[2108]++ > 0) check ('a string 2108'); break; + case 2109: if (n[2109]++ > 0) check ('a string 2109'); break; + case 2110: if (n[2110]++ > 0) check ('a string 2110'); break; + case 2111: if (n[2111]++ > 0) check ('a string 2111'); break; + case 2112: if (n[2112]++ > 0) check ('a string 2112'); break; + case 2113: if (n[2113]++ > 0) check ('a string 2113'); break; + case 2114: if (n[2114]++ > 0) check ('a string 2114'); break; + case 2115: if (n[2115]++ > 0) check ('a string 2115'); break; + case 2116: if (n[2116]++ > 0) check ('a string 2116'); break; + case 2117: if (n[2117]++ > 0) check ('a string 2117'); break; + case 2118: if (n[2118]++ > 0) check ('a string 2118'); break; + case 2119: if (n[2119]++ > 0) check ('a string 2119'); break; + case 2120: if (n[2120]++ > 0) check ('a string 2120'); break; + case 2121: if (n[2121]++ > 0) check ('a string 2121'); break; + case 2122: if (n[2122]++ > 0) check ('a string 2122'); break; + case 2123: if (n[2123]++ > 0) check ('a string 2123'); break; + case 2124: if (n[2124]++ > 0) check ('a string 2124'); break; + case 2125: if (n[2125]++ > 0) check ('a string 2125'); break; + case 2126: if (n[2126]++ > 0) check ('a string 2126'); break; + case 2127: if (n[2127]++ > 0) check ('a string 2127'); break; + case 2128: if (n[2128]++ > 0) check ('a string 2128'); break; + case 2129: if (n[2129]++ > 0) check ('a string 2129'); break; + case 2130: if (n[2130]++ > 0) check ('a string 2130'); break; + case 2131: if (n[2131]++ > 0) check ('a string 2131'); break; + case 2132: if (n[2132]++ > 0) check ('a string 2132'); break; + case 2133: if (n[2133]++ > 0) check ('a string 2133'); break; + case 2134: if (n[2134]++ > 0) check ('a string 2134'); break; + case 2135: if (n[2135]++ > 0) check ('a string 2135'); break; + case 2136: if (n[2136]++ > 0) check ('a string 2136'); break; + case 2137: if (n[2137]++ > 0) check ('a string 2137'); break; + case 2138: if (n[2138]++ > 0) check ('a string 2138'); break; + case 2139: if (n[2139]++ > 0) check ('a string 2139'); break; + case 2140: if (n[2140]++ > 0) check ('a string 2140'); break; + case 2141: if (n[2141]++ > 0) check ('a string 2141'); break; + case 2142: if (n[2142]++ > 0) check ('a string 2142'); break; + case 2143: if (n[2143]++ > 0) check ('a string 2143'); break; + case 2144: if (n[2144]++ > 0) check ('a string 2144'); break; + case 2145: if (n[2145]++ > 0) check ('a string 2145'); break; + case 2146: if (n[2146]++ > 0) check ('a string 2146'); break; + case 2147: if (n[2147]++ > 0) check ('a string 2147'); break; + case 2148: if (n[2148]++ > 0) check ('a string 2148'); break; + case 2149: if (n[2149]++ > 0) check ('a string 2149'); break; + case 2150: if (n[2150]++ > 0) check ('a string 2150'); break; + case 2151: if (n[2151]++ > 0) check ('a string 2151'); break; + case 2152: if (n[2152]++ > 0) check ('a string 2152'); break; + case 2153: if (n[2153]++ > 0) check ('a string 2153'); break; + case 2154: if (n[2154]++ > 0) check ('a string 2154'); break; + case 2155: if (n[2155]++ > 0) check ('a string 2155'); break; + case 2156: if (n[2156]++ > 0) check ('a string 2156'); break; + case 2157: if (n[2157]++ > 0) check ('a string 2157'); break; + case 2158: if (n[2158]++ > 0) check ('a string 2158'); break; + case 2159: if (n[2159]++ > 0) check ('a string 2159'); break; + case 2160: if (n[2160]++ > 0) check ('a string 2160'); break; + case 2161: if (n[2161]++ > 0) check ('a string 2161'); break; + case 2162: if (n[2162]++ > 0) check ('a string 2162'); break; + case 2163: if (n[2163]++ > 0) check ('a string 2163'); break; + case 2164: if (n[2164]++ > 0) check ('a string 2164'); break; + case 2165: if (n[2165]++ > 0) check ('a string 2165'); break; + case 2166: if (n[2166]++ > 0) check ('a string 2166'); break; + case 2167: if (n[2167]++ > 0) check ('a string 2167'); break; + case 2168: if (n[2168]++ > 0) check ('a string 2168'); break; + case 2169: if (n[2169]++ > 0) check ('a string 2169'); break; + case 2170: if (n[2170]++ > 0) check ('a string 2170'); break; + case 2171: if (n[2171]++ > 0) check ('a string 2171'); break; + case 2172: if (n[2172]++ > 0) check ('a string 2172'); break; + case 2173: if (n[2173]++ > 0) check ('a string 2173'); break; + case 2174: if (n[2174]++ > 0) check ('a string 2174'); break; + case 2175: if (n[2175]++ > 0) check ('a string 2175'); break; + case 2176: if (n[2176]++ > 0) check ('a string 2176'); break; + case 2177: if (n[2177]++ > 0) check ('a string 2177'); break; + case 2178: if (n[2178]++ > 0) check ('a string 2178'); break; + case 2179: if (n[2179]++ > 0) check ('a string 2179'); break; + case 2180: if (n[2180]++ > 0) check ('a string 2180'); break; + case 2181: if (n[2181]++ > 0) check ('a string 2181'); break; + case 2182: if (n[2182]++ > 0) check ('a string 2182'); break; + case 2183: if (n[2183]++ > 0) check ('a string 2183'); break; + case 2184: if (n[2184]++ > 0) check ('a string 2184'); break; + case 2185: if (n[2185]++ > 0) check ('a string 2185'); break; + case 2186: if (n[2186]++ > 0) check ('a string 2186'); break; + case 2187: if (n[2187]++ > 0) check ('a string 2187'); break; + case 2188: if (n[2188]++ > 0) check ('a string 2188'); break; + case 2189: if (n[2189]++ > 0) check ('a string 2189'); break; + case 2190: if (n[2190]++ > 0) check ('a string 2190'); break; + case 2191: if (n[2191]++ > 0) check ('a string 2191'); break; + case 2192: if (n[2192]++ > 0) check ('a string 2192'); break; + case 2193: if (n[2193]++ > 0) check ('a string 2193'); break; + case 2194: if (n[2194]++ > 0) check ('a string 2194'); break; + case 2195: if (n[2195]++ > 0) check ('a string 2195'); break; + case 2196: if (n[2196]++ > 0) check ('a string 2196'); break; + case 2197: if (n[2197]++ > 0) check ('a string 2197'); break; + case 2198: if (n[2198]++ > 0) check ('a string 2198'); break; + case 2199: if (n[2199]++ > 0) check ('a string 2199'); break; + case 2200: if (n[2200]++ > 0) check ('a string 2200'); break; + case 2201: if (n[2201]++ > 0) check ('a string 2201'); break; + case 2202: if (n[2202]++ > 0) check ('a string 2202'); break; + case 2203: if (n[2203]++ > 0) check ('a string 2203'); break; + case 2204: if (n[2204]++ > 0) check ('a string 2204'); break; + case 2205: if (n[2205]++ > 0) check ('a string 2205'); break; + case 2206: if (n[2206]++ > 0) check ('a string 2206'); break; + case 2207: if (n[2207]++ > 0) check ('a string 2207'); break; + case 2208: if (n[2208]++ > 0) check ('a string 2208'); break; + case 2209: if (n[2209]++ > 0) check ('a string 2209'); break; + case 2210: if (n[2210]++ > 0) check ('a string 2210'); break; + case 2211: if (n[2211]++ > 0) check ('a string 2211'); break; + case 2212: if (n[2212]++ > 0) check ('a string 2212'); break; + case 2213: if (n[2213]++ > 0) check ('a string 2213'); break; + case 2214: if (n[2214]++ > 0) check ('a string 2214'); break; + case 2215: if (n[2215]++ > 0) check ('a string 2215'); break; + case 2216: if (n[2216]++ > 0) check ('a string 2216'); break; + case 2217: if (n[2217]++ > 0) check ('a string 2217'); break; + case 2218: if (n[2218]++ > 0) check ('a string 2218'); break; + case 2219: if (n[2219]++ > 0) check ('a string 2219'); break; + case 2220: if (n[2220]++ > 0) check ('a string 2220'); break; + case 2221: if (n[2221]++ > 0) check ('a string 2221'); break; + case 2222: if (n[2222]++ > 0) check ('a string 2222'); break; + case 2223: if (n[2223]++ > 0) check ('a string 2223'); break; + case 2224: if (n[2224]++ > 0) check ('a string 2224'); break; + case 2225: if (n[2225]++ > 0) check ('a string 2225'); break; + case 2226: if (n[2226]++ > 0) check ('a string 2226'); break; + case 2227: if (n[2227]++ > 0) check ('a string 2227'); break; + case 2228: if (n[2228]++ > 0) check ('a string 2228'); break; + case 2229: if (n[2229]++ > 0) check ('a string 2229'); break; + case 2230: if (n[2230]++ > 0) check ('a string 2230'); break; + case 2231: if (n[2231]++ > 0) check ('a string 2231'); break; + case 2232: if (n[2232]++ > 0) check ('a string 2232'); break; + case 2233: if (n[2233]++ > 0) check ('a string 2233'); break; + case 2234: if (n[2234]++ > 0) check ('a string 2234'); break; + case 2235: if (n[2235]++ > 0) check ('a string 2235'); break; + case 2236: if (n[2236]++ > 0) check ('a string 2236'); break; + case 2237: if (n[2237]++ > 0) check ('a string 2237'); break; + case 2238: if (n[2238]++ > 0) check ('a string 2238'); break; + case 2239: if (n[2239]++ > 0) check ('a string 2239'); break; + case 2240: if (n[2240]++ > 0) check ('a string 2240'); break; + case 2241: if (n[2241]++ > 0) check ('a string 2241'); break; + case 2242: if (n[2242]++ > 0) check ('a string 2242'); break; + case 2243: if (n[2243]++ > 0) check ('a string 2243'); break; + case 2244: if (n[2244]++ > 0) check ('a string 2244'); break; + case 2245: if (n[2245]++ > 0) check ('a string 2245'); break; + case 2246: if (n[2246]++ > 0) check ('a string 2246'); break; + case 2247: if (n[2247]++ > 0) check ('a string 2247'); break; + case 2248: if (n[2248]++ > 0) check ('a string 2248'); break; + case 2249: if (n[2249]++ > 0) check ('a string 2249'); break; + case 2250: if (n[2250]++ > 0) check ('a string 2250'); break; + case 2251: if (n[2251]++ > 0) check ('a string 2251'); break; + case 2252: if (n[2252]++ > 0) check ('a string 2252'); break; + case 2253: if (n[2253]++ > 0) check ('a string 2253'); break; + case 2254: if (n[2254]++ > 0) check ('a string 2254'); break; + case 2255: if (n[2255]++ > 0) check ('a string 2255'); break; + case 2256: if (n[2256]++ > 0) check ('a string 2256'); break; + case 2257: if (n[2257]++ > 0) check ('a string 2257'); break; + case 2258: if (n[2258]++ > 0) check ('a string 2258'); break; + case 2259: if (n[2259]++ > 0) check ('a string 2259'); break; + case 2260: if (n[2260]++ > 0) check ('a string 2260'); break; + case 2261: if (n[2261]++ > 0) check ('a string 2261'); break; + case 2262: if (n[2262]++ > 0) check ('a string 2262'); break; + case 2263: if (n[2263]++ > 0) check ('a string 2263'); break; + case 2264: if (n[2264]++ > 0) check ('a string 2264'); break; + case 2265: if (n[2265]++ > 0) check ('a string 2265'); break; + case 2266: if (n[2266]++ > 0) check ('a string 2266'); break; + case 2267: if (n[2267]++ > 0) check ('a string 2267'); break; + case 2268: if (n[2268]++ > 0) check ('a string 2268'); break; + case 2269: if (n[2269]++ > 0) check ('a string 2269'); break; + case 2270: if (n[2270]++ > 0) check ('a string 2270'); break; + case 2271: if (n[2271]++ > 0) check ('a string 2271'); break; + case 2272: if (n[2272]++ > 0) check ('a string 2272'); break; + case 2273: if (n[2273]++ > 0) check ('a string 2273'); break; + case 2274: if (n[2274]++ > 0) check ('a string 2274'); break; + case 2275: if (n[2275]++ > 0) check ('a string 2275'); break; + case 2276: if (n[2276]++ > 0) check ('a string 2276'); break; + case 2277: if (n[2277]++ > 0) check ('a string 2277'); break; + case 2278: if (n[2278]++ > 0) check ('a string 2278'); break; + case 2279: if (n[2279]++ > 0) check ('a string 2279'); break; + case 2280: if (n[2280]++ > 0) check ('a string 2280'); break; + case 2281: if (n[2281]++ > 0) check ('a string 2281'); break; + case 2282: if (n[2282]++ > 0) check ('a string 2282'); break; + case 2283: if (n[2283]++ > 0) check ('a string 2283'); break; + case 2284: if (n[2284]++ > 0) check ('a string 2284'); break; + case 2285: if (n[2285]++ > 0) check ('a string 2285'); break; + case 2286: if (n[2286]++ > 0) check ('a string 2286'); break; + case 2287: if (n[2287]++ > 0) check ('a string 2287'); break; + case 2288: if (n[2288]++ > 0) check ('a string 2288'); break; + case 2289: if (n[2289]++ > 0) check ('a string 2289'); break; + case 2290: if (n[2290]++ > 0) check ('a string 2290'); break; + case 2291: if (n[2291]++ > 0) check ('a string 2291'); break; + case 2292: if (n[2292]++ > 0) check ('a string 2292'); break; + case 2293: if (n[2293]++ > 0) check ('a string 2293'); break; + case 2294: if (n[2294]++ > 0) check ('a string 2294'); break; + case 2295: if (n[2295]++ > 0) check ('a string 2295'); break; + case 2296: if (n[2296]++ > 0) check ('a string 2296'); break; + case 2297: if (n[2297]++ > 0) check ('a string 2297'); break; + case 2298: if (n[2298]++ > 0) check ('a string 2298'); break; + case 2299: if (n[2299]++ > 0) check ('a string 2299'); break; + case 2300: if (n[2300]++ > 0) check ('a string 2300'); break; + case 2301: if (n[2301]++ > 0) check ('a string 2301'); break; + case 2302: if (n[2302]++ > 0) check ('a string 2302'); break; + case 2303: if (n[2303]++ > 0) check ('a string 2303'); break; + case 2304: if (n[2304]++ > 0) check ('a string 2304'); break; + case 2305: if (n[2305]++ > 0) check ('a string 2305'); break; + case 2306: if (n[2306]++ > 0) check ('a string 2306'); break; + case 2307: if (n[2307]++ > 0) check ('a string 2307'); break; + case 2308: if (n[2308]++ > 0) check ('a string 2308'); break; + case 2309: if (n[2309]++ > 0) check ('a string 2309'); break; + case 2310: if (n[2310]++ > 0) check ('a string 2310'); break; + case 2311: if (n[2311]++ > 0) check ('a string 2311'); break; + case 2312: if (n[2312]++ > 0) check ('a string 2312'); break; + case 2313: if (n[2313]++ > 0) check ('a string 2313'); break; + case 2314: if (n[2314]++ > 0) check ('a string 2314'); break; + case 2315: if (n[2315]++ > 0) check ('a string 2315'); break; + case 2316: if (n[2316]++ > 0) check ('a string 2316'); break; + case 2317: if (n[2317]++ > 0) check ('a string 2317'); break; + case 2318: if (n[2318]++ > 0) check ('a string 2318'); break; + case 2319: if (n[2319]++ > 0) check ('a string 2319'); break; + case 2320: if (n[2320]++ > 0) check ('a string 2320'); break; + case 2321: if (n[2321]++ > 0) check ('a string 2321'); break; + case 2322: if (n[2322]++ > 0) check ('a string 2322'); break; + case 2323: if (n[2323]++ > 0) check ('a string 2323'); break; + case 2324: if (n[2324]++ > 0) check ('a string 2324'); break; + case 2325: if (n[2325]++ > 0) check ('a string 2325'); break; + case 2326: if (n[2326]++ > 0) check ('a string 2326'); break; + case 2327: if (n[2327]++ > 0) check ('a string 2327'); break; + case 2328: if (n[2328]++ > 0) check ('a string 2328'); break; + case 2329: if (n[2329]++ > 0) check ('a string 2329'); break; + case 2330: if (n[2330]++ > 0) check ('a string 2330'); break; + case 2331: if (n[2331]++ > 0) check ('a string 2331'); break; + case 2332: if (n[2332]++ > 0) check ('a string 2332'); break; + case 2333: if (n[2333]++ > 0) check ('a string 2333'); break; + case 2334: if (n[2334]++ > 0) check ('a string 2334'); break; + case 2335: if (n[2335]++ > 0) check ('a string 2335'); break; + case 2336: if (n[2336]++ > 0) check ('a string 2336'); break; + case 2337: if (n[2337]++ > 0) check ('a string 2337'); break; + case 2338: if (n[2338]++ > 0) check ('a string 2338'); break; + case 2339: if (n[2339]++ > 0) check ('a string 2339'); break; + case 2340: if (n[2340]++ > 0) check ('a string 2340'); break; + case 2341: if (n[2341]++ > 0) check ('a string 2341'); break; + case 2342: if (n[2342]++ > 0) check ('a string 2342'); break; + case 2343: if (n[2343]++ > 0) check ('a string 2343'); break; + case 2344: if (n[2344]++ > 0) check ('a string 2344'); break; + case 2345: if (n[2345]++ > 0) check ('a string 2345'); break; + case 2346: if (n[2346]++ > 0) check ('a string 2346'); break; + case 2347: if (n[2347]++ > 0) check ('a string 2347'); break; + case 2348: if (n[2348]++ > 0) check ('a string 2348'); break; + case 2349: if (n[2349]++ > 0) check ('a string 2349'); break; + case 2350: if (n[2350]++ > 0) check ('a string 2350'); break; + case 2351: if (n[2351]++ > 0) check ('a string 2351'); break; + case 2352: if (n[2352]++ > 0) check ('a string 2352'); break; + case 2353: if (n[2353]++ > 0) check ('a string 2353'); break; + case 2354: if (n[2354]++ > 0) check ('a string 2354'); break; + case 2355: if (n[2355]++ > 0) check ('a string 2355'); break; + case 2356: if (n[2356]++ > 0) check ('a string 2356'); break; + case 2357: if (n[2357]++ > 0) check ('a string 2357'); break; + case 2358: if (n[2358]++ > 0) check ('a string 2358'); break; + case 2359: if (n[2359]++ > 0) check ('a string 2359'); break; + case 2360: if (n[2360]++ > 0) check ('a string 2360'); break; + case 2361: if (n[2361]++ > 0) check ('a string 2361'); break; + case 2362: if (n[2362]++ > 0) check ('a string 2362'); break; + case 2363: if (n[2363]++ > 0) check ('a string 2363'); break; + case 2364: if (n[2364]++ > 0) check ('a string 2364'); break; + case 2365: if (n[2365]++ > 0) check ('a string 2365'); break; + case 2366: if (n[2366]++ > 0) check ('a string 2366'); break; + case 2367: if (n[2367]++ > 0) check ('a string 2367'); break; + case 2368: if (n[2368]++ > 0) check ('a string 2368'); break; + case 2369: if (n[2369]++ > 0) check ('a string 2369'); break; + case 2370: if (n[2370]++ > 0) check ('a string 2370'); break; + case 2371: if (n[2371]++ > 0) check ('a string 2371'); break; + case 2372: if (n[2372]++ > 0) check ('a string 2372'); break; + case 2373: if (n[2373]++ > 0) check ('a string 2373'); break; + case 2374: if (n[2374]++ > 0) check ('a string 2374'); break; + case 2375: if (n[2375]++ > 0) check ('a string 2375'); break; + case 2376: if (n[2376]++ > 0) check ('a string 2376'); break; + case 2377: if (n[2377]++ > 0) check ('a string 2377'); break; + case 2378: if (n[2378]++ > 0) check ('a string 2378'); break; + case 2379: if (n[2379]++ > 0) check ('a string 2379'); break; + case 2380: if (n[2380]++ > 0) check ('a string 2380'); break; + case 2381: if (n[2381]++ > 0) check ('a string 2381'); break; + case 2382: if (n[2382]++ > 0) check ('a string 2382'); break; + case 2383: if (n[2383]++ > 0) check ('a string 2383'); break; + case 2384: if (n[2384]++ > 0) check ('a string 2384'); break; + case 2385: if (n[2385]++ > 0) check ('a string 2385'); break; + case 2386: if (n[2386]++ > 0) check ('a string 2386'); break; + case 2387: if (n[2387]++ > 0) check ('a string 2387'); break; + case 2388: if (n[2388]++ > 0) check ('a string 2388'); break; + case 2389: if (n[2389]++ > 0) check ('a string 2389'); break; + case 2390: if (n[2390]++ > 0) check ('a string 2390'); break; + case 2391: if (n[2391]++ > 0) check ('a string 2391'); break; + case 2392: if (n[2392]++ > 0) check ('a string 2392'); break; + case 2393: if (n[2393]++ > 0) check ('a string 2393'); break; + case 2394: if (n[2394]++ > 0) check ('a string 2394'); break; + case 2395: if (n[2395]++ > 0) check ('a string 2395'); break; + case 2396: if (n[2396]++ > 0) check ('a string 2396'); break; + case 2397: if (n[2397]++ > 0) check ('a string 2397'); break; + case 2398: if (n[2398]++ > 0) check ('a string 2398'); break; + case 2399: if (n[2399]++ > 0) check ('a string 2399'); break; + case 2400: if (n[2400]++ > 0) check ('a string 2400'); break; + case 2401: if (n[2401]++ > 0) check ('a string 2401'); break; + case 2402: if (n[2402]++ > 0) check ('a string 2402'); break; + case 2403: if (n[2403]++ > 0) check ('a string 2403'); break; + case 2404: if (n[2404]++ > 0) check ('a string 2404'); break; + case 2405: if (n[2405]++ > 0) check ('a string 2405'); break; + case 2406: if (n[2406]++ > 0) check ('a string 2406'); break; + case 2407: if (n[2407]++ > 0) check ('a string 2407'); break; + case 2408: if (n[2408]++ > 0) check ('a string 2408'); break; + case 2409: if (n[2409]++ > 0) check ('a string 2409'); break; + case 2410: if (n[2410]++ > 0) check ('a string 2410'); break; + case 2411: if (n[2411]++ > 0) check ('a string 2411'); break; + case 2412: if (n[2412]++ > 0) check ('a string 2412'); break; + case 2413: if (n[2413]++ > 0) check ('a string 2413'); break; + case 2414: if (n[2414]++ > 0) check ('a string 2414'); break; + case 2415: if (n[2415]++ > 0) check ('a string 2415'); break; + case 2416: if (n[2416]++ > 0) check ('a string 2416'); break; + case 2417: if (n[2417]++ > 0) check ('a string 2417'); break; + case 2418: if (n[2418]++ > 0) check ('a string 2418'); break; + case 2419: if (n[2419]++ > 0) check ('a string 2419'); break; + case 2420: if (n[2420]++ > 0) check ('a string 2420'); break; + case 2421: if (n[2421]++ > 0) check ('a string 2421'); break; + case 2422: if (n[2422]++ > 0) check ('a string 2422'); break; + case 2423: if (n[2423]++ > 0) check ('a string 2423'); break; + case 2424: if (n[2424]++ > 0) check ('a string 2424'); break; + case 2425: if (n[2425]++ > 0) check ('a string 2425'); break; + case 2426: if (n[2426]++ > 0) check ('a string 2426'); break; + case 2427: if (n[2427]++ > 0) check ('a string 2427'); break; + case 2428: if (n[2428]++ > 0) check ('a string 2428'); break; + case 2429: if (n[2429]++ > 0) check ('a string 2429'); break; + case 2430: if (n[2430]++ > 0) check ('a string 2430'); break; + case 2431: if (n[2431]++ > 0) check ('a string 2431'); break; + case 2432: if (n[2432]++ > 0) check ('a string 2432'); break; + case 2433: if (n[2433]++ > 0) check ('a string 2433'); break; + case 2434: if (n[2434]++ > 0) check ('a string 2434'); break; + case 2435: if (n[2435]++ > 0) check ('a string 2435'); break; + case 2436: if (n[2436]++ > 0) check ('a string 2436'); break; + case 2437: if (n[2437]++ > 0) check ('a string 2437'); break; + case 2438: if (n[2438]++ > 0) check ('a string 2438'); break; + case 2439: if (n[2439]++ > 0) check ('a string 2439'); break; + case 2440: if (n[2440]++ > 0) check ('a string 2440'); break; + case 2441: if (n[2441]++ > 0) check ('a string 2441'); break; + case 2442: if (n[2442]++ > 0) check ('a string 2442'); break; + case 2443: if (n[2443]++ > 0) check ('a string 2443'); break; + case 2444: if (n[2444]++ > 0) check ('a string 2444'); break; + case 2445: if (n[2445]++ > 0) check ('a string 2445'); break; + case 2446: if (n[2446]++ > 0) check ('a string 2446'); break; + case 2447: if (n[2447]++ > 0) check ('a string 2447'); break; + case 2448: if (n[2448]++ > 0) check ('a string 2448'); break; + case 2449: if (n[2449]++ > 0) check ('a string 2449'); break; + case 2450: if (n[2450]++ > 0) check ('a string 2450'); break; + case 2451: if (n[2451]++ > 0) check ('a string 2451'); break; + case 2452: if (n[2452]++ > 0) check ('a string 2452'); break; + case 2453: if (n[2453]++ > 0) check ('a string 2453'); break; + case 2454: if (n[2454]++ > 0) check ('a string 2454'); break; + case 2455: if (n[2455]++ > 0) check ('a string 2455'); break; + case 2456: if (n[2456]++ > 0) check ('a string 2456'); break; + case 2457: if (n[2457]++ > 0) check ('a string 2457'); break; + case 2458: if (n[2458]++ > 0) check ('a string 2458'); break; + case 2459: if (n[2459]++ > 0) check ('a string 2459'); break; + case 2460: if (n[2460]++ > 0) check ('a string 2460'); break; + case 2461: if (n[2461]++ > 0) check ('a string 2461'); break; + case 2462: if (n[2462]++ > 0) check ('a string 2462'); break; + case 2463: if (n[2463]++ > 0) check ('a string 2463'); break; + case 2464: if (n[2464]++ > 0) check ('a string 2464'); break; + case 2465: if (n[2465]++ > 0) check ('a string 2465'); break; + case 2466: if (n[2466]++ > 0) check ('a string 2466'); break; + case 2467: if (n[2467]++ > 0) check ('a string 2467'); break; + case 2468: if (n[2468]++ > 0) check ('a string 2468'); break; + case 2469: if (n[2469]++ > 0) check ('a string 2469'); break; + case 2470: if (n[2470]++ > 0) check ('a string 2470'); break; + case 2471: if (n[2471]++ > 0) check ('a string 2471'); break; + case 2472: if (n[2472]++ > 0) check ('a string 2472'); break; + case 2473: if (n[2473]++ > 0) check ('a string 2473'); break; + case 2474: if (n[2474]++ > 0) check ('a string 2474'); break; + case 2475: if (n[2475]++ > 0) check ('a string 2475'); break; + case 2476: if (n[2476]++ > 0) check ('a string 2476'); break; + case 2477: if (n[2477]++ > 0) check ('a string 2477'); break; + case 2478: if (n[2478]++ > 0) check ('a string 2478'); break; + case 2479: if (n[2479]++ > 0) check ('a string 2479'); break; + case 2480: if (n[2480]++ > 0) check ('a string 2480'); break; + case 2481: if (n[2481]++ > 0) check ('a string 2481'); break; + case 2482: if (n[2482]++ > 0) check ('a string 2482'); break; + case 2483: if (n[2483]++ > 0) check ('a string 2483'); break; + case 2484: if (n[2484]++ > 0) check ('a string 2484'); break; + case 2485: if (n[2485]++ > 0) check ('a string 2485'); break; + case 2486: if (n[2486]++ > 0) check ('a string 2486'); break; + case 2487: if (n[2487]++ > 0) check ('a string 2487'); break; + case 2488: if (n[2488]++ > 0) check ('a string 2488'); break; + case 2489: if (n[2489]++ > 0) check ('a string 2489'); break; + case 2490: if (n[2490]++ > 0) check ('a string 2490'); break; + case 2491: if (n[2491]++ > 0) check ('a string 2491'); break; + case 2492: if (n[2492]++ > 0) check ('a string 2492'); break; + case 2493: if (n[2493]++ > 0) check ('a string 2493'); break; + case 2494: if (n[2494]++ > 0) check ('a string 2494'); break; + case 2495: if (n[2495]++ > 0) check ('a string 2495'); break; + case 2496: if (n[2496]++ > 0) check ('a string 2496'); break; + case 2497: if (n[2497]++ > 0) check ('a string 2497'); break; + case 2498: if (n[2498]++ > 0) check ('a string 2498'); break; + case 2499: if (n[2499]++ > 0) check ('a string 2499'); break; + case 2500: if (n[2500]++ > 0) check ('a string 2500'); break; + case 2501: if (n[2501]++ > 0) check ('a string 2501'); break; + case 2502: if (n[2502]++ > 0) check ('a string 2502'); break; + case 2503: if (n[2503]++ > 0) check ('a string 2503'); break; + case 2504: if (n[2504]++ > 0) check ('a string 2504'); break; + case 2505: if (n[2505]++ > 0) check ('a string 2505'); break; + case 2506: if (n[2506]++ > 0) check ('a string 2506'); break; + case 2507: if (n[2507]++ > 0) check ('a string 2507'); break; + case 2508: if (n[2508]++ > 0) check ('a string 2508'); break; + case 2509: if (n[2509]++ > 0) check ('a string 2509'); break; + case 2510: if (n[2510]++ > 0) check ('a string 2510'); break; + case 2511: if (n[2511]++ > 0) check ('a string 2511'); break; + case 2512: if (n[2512]++ > 0) check ('a string 2512'); break; + case 2513: if (n[2513]++ > 0) check ('a string 2513'); break; + case 2514: if (n[2514]++ > 0) check ('a string 2514'); break; + case 2515: if (n[2515]++ > 0) check ('a string 2515'); break; + case 2516: if (n[2516]++ > 0) check ('a string 2516'); break; + case 2517: if (n[2517]++ > 0) check ('a string 2517'); break; + case 2518: if (n[2518]++ > 0) check ('a string 2518'); break; + case 2519: if (n[2519]++ > 0) check ('a string 2519'); break; + case 2520: if (n[2520]++ > 0) check ('a string 2520'); break; + case 2521: if (n[2521]++ > 0) check ('a string 2521'); break; + case 2522: if (n[2522]++ > 0) check ('a string 2522'); break; + case 2523: if (n[2523]++ > 0) check ('a string 2523'); break; + case 2524: if (n[2524]++ > 0) check ('a string 2524'); break; + case 2525: if (n[2525]++ > 0) check ('a string 2525'); break; + case 2526: if (n[2526]++ > 0) check ('a string 2526'); break; + case 2527: if (n[2527]++ > 0) check ('a string 2527'); break; + case 2528: if (n[2528]++ > 0) check ('a string 2528'); break; + case 2529: if (n[2529]++ > 0) check ('a string 2529'); break; + case 2530: if (n[2530]++ > 0) check ('a string 2530'); break; + case 2531: if (n[2531]++ > 0) check ('a string 2531'); break; + case 2532: if (n[2532]++ > 0) check ('a string 2532'); break; + case 2533: if (n[2533]++ > 0) check ('a string 2533'); break; + case 2534: if (n[2534]++ > 0) check ('a string 2534'); break; + case 2535: if (n[2535]++ > 0) check ('a string 2535'); break; + case 2536: if (n[2536]++ > 0) check ('a string 2536'); break; + case 2537: if (n[2537]++ > 0) check ('a string 2537'); break; + case 2538: if (n[2538]++ > 0) check ('a string 2538'); break; + case 2539: if (n[2539]++ > 0) check ('a string 2539'); break; + case 2540: if (n[2540]++ > 0) check ('a string 2540'); break; + case 2541: if (n[2541]++ > 0) check ('a string 2541'); break; + case 2542: if (n[2542]++ > 0) check ('a string 2542'); break; + case 2543: if (n[2543]++ > 0) check ('a string 2543'); break; + case 2544: if (n[2544]++ > 0) check ('a string 2544'); break; + case 2545: if (n[2545]++ > 0) check ('a string 2545'); break; + case 2546: if (n[2546]++ > 0) check ('a string 2546'); break; + case 2547: if (n[2547]++ > 0) check ('a string 2547'); break; + case 2548: if (n[2548]++ > 0) check ('a string 2548'); break; + case 2549: if (n[2549]++ > 0) check ('a string 2549'); break; + case 2550: if (n[2550]++ > 0) check ('a string 2550'); break; + case 2551: if (n[2551]++ > 0) check ('a string 2551'); break; + case 2552: if (n[2552]++ > 0) check ('a string 2552'); break; + case 2553: if (n[2553]++ > 0) check ('a string 2553'); break; + case 2554: if (n[2554]++ > 0) check ('a string 2554'); break; + case 2555: if (n[2555]++ > 0) check ('a string 2555'); break; + case 2556: if (n[2556]++ > 0) check ('a string 2556'); break; + case 2557: if (n[2557]++ > 0) check ('a string 2557'); break; + case 2558: if (n[2558]++ > 0) check ('a string 2558'); break; + case 2559: if (n[2559]++ > 0) check ('a string 2559'); break; + case 2560: if (n[2560]++ > 0) check ('a string 2560'); break; + case 2561: if (n[2561]++ > 0) check ('a string 2561'); break; + case 2562: if (n[2562]++ > 0) check ('a string 2562'); break; + case 2563: if (n[2563]++ > 0) check ('a string 2563'); break; + case 2564: if (n[2564]++ > 0) check ('a string 2564'); break; + case 2565: if (n[2565]++ > 0) check ('a string 2565'); break; + case 2566: if (n[2566]++ > 0) check ('a string 2566'); break; + case 2567: if (n[2567]++ > 0) check ('a string 2567'); break; + case 2568: if (n[2568]++ > 0) check ('a string 2568'); break; + case 2569: if (n[2569]++ > 0) check ('a string 2569'); break; + case 2570: if (n[2570]++ > 0) check ('a string 2570'); break; + case 2571: if (n[2571]++ > 0) check ('a string 2571'); break; + case 2572: if (n[2572]++ > 0) check ('a string 2572'); break; + case 2573: if (n[2573]++ > 0) check ('a string 2573'); break; + case 2574: if (n[2574]++ > 0) check ('a string 2574'); break; + case 2575: if (n[2575]++ > 0) check ('a string 2575'); break; + case 2576: if (n[2576]++ > 0) check ('a string 2576'); break; + case 2577: if (n[2577]++ > 0) check ('a string 2577'); break; + case 2578: if (n[2578]++ > 0) check ('a string 2578'); break; + case 2579: if (n[2579]++ > 0) check ('a string 2579'); break; + case 2580: if (n[2580]++ > 0) check ('a string 2580'); break; + case 2581: if (n[2581]++ > 0) check ('a string 2581'); break; + case 2582: if (n[2582]++ > 0) check ('a string 2582'); break; + case 2583: if (n[2583]++ > 0) check ('a string 2583'); break; + case 2584: if (n[2584]++ > 0) check ('a string 2584'); break; + case 2585: if (n[2585]++ > 0) check ('a string 2585'); break; + case 2586: if (n[2586]++ > 0) check ('a string 2586'); break; + case 2587: if (n[2587]++ > 0) check ('a string 2587'); break; + case 2588: if (n[2588]++ > 0) check ('a string 2588'); break; + case 2589: if (n[2589]++ > 0) check ('a string 2589'); break; + case 2590: if (n[2590]++ > 0) check ('a string 2590'); break; + case 2591: if (n[2591]++ > 0) check ('a string 2591'); break; + case 2592: if (n[2592]++ > 0) check ('a string 2592'); break; + case 2593: if (n[2593]++ > 0) check ('a string 2593'); break; + case 2594: if (n[2594]++ > 0) check ('a string 2594'); break; + case 2595: if (n[2595]++ > 0) check ('a string 2595'); break; + case 2596: if (n[2596]++ > 0) check ('a string 2596'); break; + case 2597: if (n[2597]++ > 0) check ('a string 2597'); break; + case 2598: if (n[2598]++ > 0) check ('a string 2598'); break; + case 2599: if (n[2599]++ > 0) check ('a string 2599'); break; + case 2600: if (n[2600]++ > 0) check ('a string 2600'); break; + case 2601: if (n[2601]++ > 0) check ('a string 2601'); break; + case 2602: if (n[2602]++ > 0) check ('a string 2602'); break; + case 2603: if (n[2603]++ > 0) check ('a string 2603'); break; + case 2604: if (n[2604]++ > 0) check ('a string 2604'); break; + case 2605: if (n[2605]++ > 0) check ('a string 2605'); break; + case 2606: if (n[2606]++ > 0) check ('a string 2606'); break; + case 2607: if (n[2607]++ > 0) check ('a string 2607'); break; + case 2608: if (n[2608]++ > 0) check ('a string 2608'); break; + case 2609: if (n[2609]++ > 0) check ('a string 2609'); break; + case 2610: if (n[2610]++ > 0) check ('a string 2610'); break; + case 2611: if (n[2611]++ > 0) check ('a string 2611'); break; + case 2612: if (n[2612]++ > 0) check ('a string 2612'); break; + case 2613: if (n[2613]++ > 0) check ('a string 2613'); break; + case 2614: if (n[2614]++ > 0) check ('a string 2614'); break; + case 2615: if (n[2615]++ > 0) check ('a string 2615'); break; + case 2616: if (n[2616]++ > 0) check ('a string 2616'); break; + case 2617: if (n[2617]++ > 0) check ('a string 2617'); break; + case 2618: if (n[2618]++ > 0) check ('a string 2618'); break; + case 2619: if (n[2619]++ > 0) check ('a string 2619'); break; + case 2620: if (n[2620]++ > 0) check ('a string 2620'); break; + case 2621: if (n[2621]++ > 0) check ('a string 2621'); break; + case 2622: if (n[2622]++ > 0) check ('a string 2622'); break; + case 2623: if (n[2623]++ > 0) check ('a string 2623'); break; + case 2624: if (n[2624]++ > 0) check ('a string 2624'); break; + case 2625: if (n[2625]++ > 0) check ('a string 2625'); break; + case 2626: if (n[2626]++ > 0) check ('a string 2626'); break; + case 2627: if (n[2627]++ > 0) check ('a string 2627'); break; + case 2628: if (n[2628]++ > 0) check ('a string 2628'); break; + case 2629: if (n[2629]++ > 0) check ('a string 2629'); break; + case 2630: if (n[2630]++ > 0) check ('a string 2630'); break; + case 2631: if (n[2631]++ > 0) check ('a string 2631'); break; + case 2632: if (n[2632]++ > 0) check ('a string 2632'); break; + case 2633: if (n[2633]++ > 0) check ('a string 2633'); break; + case 2634: if (n[2634]++ > 0) check ('a string 2634'); break; + case 2635: if (n[2635]++ > 0) check ('a string 2635'); break; + case 2636: if (n[2636]++ > 0) check ('a string 2636'); break; + case 2637: if (n[2637]++ > 0) check ('a string 2637'); break; + case 2638: if (n[2638]++ > 0) check ('a string 2638'); break; + case 2639: if (n[2639]++ > 0) check ('a string 2639'); break; + case 2640: if (n[2640]++ > 0) check ('a string 2640'); break; + case 2641: if (n[2641]++ > 0) check ('a string 2641'); break; + case 2642: if (n[2642]++ > 0) check ('a string 2642'); break; + case 2643: if (n[2643]++ > 0) check ('a string 2643'); break; + case 2644: if (n[2644]++ > 0) check ('a string 2644'); break; + case 2645: if (n[2645]++ > 0) check ('a string 2645'); break; + case 2646: if (n[2646]++ > 0) check ('a string 2646'); break; + case 2647: if (n[2647]++ > 0) check ('a string 2647'); break; + case 2648: if (n[2648]++ > 0) check ('a string 2648'); break; + case 2649: if (n[2649]++ > 0) check ('a string 2649'); break; + case 2650: if (n[2650]++ > 0) check ('a string 2650'); break; + case 2651: if (n[2651]++ > 0) check ('a string 2651'); break; + case 2652: if (n[2652]++ > 0) check ('a string 2652'); break; + case 2653: if (n[2653]++ > 0) check ('a string 2653'); break; + case 2654: if (n[2654]++ > 0) check ('a string 2654'); break; + case 2655: if (n[2655]++ > 0) check ('a string 2655'); break; + case 2656: if (n[2656]++ > 0) check ('a string 2656'); break; + case 2657: if (n[2657]++ > 0) check ('a string 2657'); break; + case 2658: if (n[2658]++ > 0) check ('a string 2658'); break; + case 2659: if (n[2659]++ > 0) check ('a string 2659'); break; + case 2660: if (n[2660]++ > 0) check ('a string 2660'); break; + case 2661: if (n[2661]++ > 0) check ('a string 2661'); break; + case 2662: if (n[2662]++ > 0) check ('a string 2662'); break; + case 2663: if (n[2663]++ > 0) check ('a string 2663'); break; + case 2664: if (n[2664]++ > 0) check ('a string 2664'); break; + case 2665: if (n[2665]++ > 0) check ('a string 2665'); break; + case 2666: if (n[2666]++ > 0) check ('a string 2666'); break; + case 2667: if (n[2667]++ > 0) check ('a string 2667'); break; + case 2668: if (n[2668]++ > 0) check ('a string 2668'); break; + case 2669: if (n[2669]++ > 0) check ('a string 2669'); break; + case 2670: if (n[2670]++ > 0) check ('a string 2670'); break; + case 2671: if (n[2671]++ > 0) check ('a string 2671'); break; + case 2672: if (n[2672]++ > 0) check ('a string 2672'); break; + case 2673: if (n[2673]++ > 0) check ('a string 2673'); break; + case 2674: if (n[2674]++ > 0) check ('a string 2674'); break; + case 2675: if (n[2675]++ > 0) check ('a string 2675'); break; + case 2676: if (n[2676]++ > 0) check ('a string 2676'); break; + case 2677: if (n[2677]++ > 0) check ('a string 2677'); break; + case 2678: if (n[2678]++ > 0) check ('a string 2678'); break; + case 2679: if (n[2679]++ > 0) check ('a string 2679'); break; + case 2680: if (n[2680]++ > 0) check ('a string 2680'); break; + case 2681: if (n[2681]++ > 0) check ('a string 2681'); break; + case 2682: if (n[2682]++ > 0) check ('a string 2682'); break; + case 2683: if (n[2683]++ > 0) check ('a string 2683'); break; + case 2684: if (n[2684]++ > 0) check ('a string 2684'); break; + case 2685: if (n[2685]++ > 0) check ('a string 2685'); break; + case 2686: if (n[2686]++ > 0) check ('a string 2686'); break; + case 2687: if (n[2687]++ > 0) check ('a string 2687'); break; + case 2688: if (n[2688]++ > 0) check ('a string 2688'); break; + case 2689: if (n[2689]++ > 0) check ('a string 2689'); break; + case 2690: if (n[2690]++ > 0) check ('a string 2690'); break; + case 2691: if (n[2691]++ > 0) check ('a string 2691'); break; + case 2692: if (n[2692]++ > 0) check ('a string 2692'); break; + case 2693: if (n[2693]++ > 0) check ('a string 2693'); break; + case 2694: if (n[2694]++ > 0) check ('a string 2694'); break; + case 2695: if (n[2695]++ > 0) check ('a string 2695'); break; + case 2696: if (n[2696]++ > 0) check ('a string 2696'); break; + case 2697: if (n[2697]++ > 0) check ('a string 2697'); break; + case 2698: if (n[2698]++ > 0) check ('a string 2698'); break; + case 2699: if (n[2699]++ > 0) check ('a string 2699'); break; + case 2700: if (n[2700]++ > 0) check ('a string 2700'); break; + case 2701: if (n[2701]++ > 0) check ('a string 2701'); break; + case 2702: if (n[2702]++ > 0) check ('a string 2702'); break; + case 2703: if (n[2703]++ > 0) check ('a string 2703'); break; + case 2704: if (n[2704]++ > 0) check ('a string 2704'); break; + case 2705: if (n[2705]++ > 0) check ('a string 2705'); break; + case 2706: if (n[2706]++ > 0) check ('a string 2706'); break; + case 2707: if (n[2707]++ > 0) check ('a string 2707'); break; + case 2708: if (n[2708]++ > 0) check ('a string 2708'); break; + case 2709: if (n[2709]++ > 0) check ('a string 2709'); break; + case 2710: if (n[2710]++ > 0) check ('a string 2710'); break; + case 2711: if (n[2711]++ > 0) check ('a string 2711'); break; + case 2712: if (n[2712]++ > 0) check ('a string 2712'); break; + case 2713: if (n[2713]++ > 0) check ('a string 2713'); break; + case 2714: if (n[2714]++ > 0) check ('a string 2714'); break; + case 2715: if (n[2715]++ > 0) check ('a string 2715'); break; + case 2716: if (n[2716]++ > 0) check ('a string 2716'); break; + case 2717: if (n[2717]++ > 0) check ('a string 2717'); break; + case 2718: if (n[2718]++ > 0) check ('a string 2718'); break; + case 2719: if (n[2719]++ > 0) check ('a string 2719'); break; + case 2720: if (n[2720]++ > 0) check ('a string 2720'); break; + case 2721: if (n[2721]++ > 0) check ('a string 2721'); break; + case 2722: if (n[2722]++ > 0) check ('a string 2722'); break; + case 2723: if (n[2723]++ > 0) check ('a string 2723'); break; + case 2724: if (n[2724]++ > 0) check ('a string 2724'); break; + case 2725: if (n[2725]++ > 0) check ('a string 2725'); break; + case 2726: if (n[2726]++ > 0) check ('a string 2726'); break; + case 2727: if (n[2727]++ > 0) check ('a string 2727'); break; + case 2728: if (n[2728]++ > 0) check ('a string 2728'); break; + case 2729: if (n[2729]++ > 0) check ('a string 2729'); break; + case 2730: if (n[2730]++ > 0) check ('a string 2730'); break; + case 2731: if (n[2731]++ > 0) check ('a string 2731'); break; + case 2732: if (n[2732]++ > 0) check ('a string 2732'); break; + case 2733: if (n[2733]++ > 0) check ('a string 2733'); break; + case 2734: if (n[2734]++ > 0) check ('a string 2734'); break; + case 2735: if (n[2735]++ > 0) check ('a string 2735'); break; + case 2736: if (n[2736]++ > 0) check ('a string 2736'); break; + case 2737: if (n[2737]++ > 0) check ('a string 2737'); break; + case 2738: if (n[2738]++ > 0) check ('a string 2738'); break; + case 2739: if (n[2739]++ > 0) check ('a string 2739'); break; + case 2740: if (n[2740]++ > 0) check ('a string 2740'); break; + case 2741: if (n[2741]++ > 0) check ('a string 2741'); break; + case 2742: if (n[2742]++ > 0) check ('a string 2742'); break; + case 2743: if (n[2743]++ > 0) check ('a string 2743'); break; + case 2744: if (n[2744]++ > 0) check ('a string 2744'); break; + case 2745: if (n[2745]++ > 0) check ('a string 2745'); break; + case 2746: if (n[2746]++ > 0) check ('a string 2746'); break; + case 2747: if (n[2747]++ > 0) check ('a string 2747'); break; + case 2748: if (n[2748]++ > 0) check ('a string 2748'); break; + case 2749: if (n[2749]++ > 0) check ('a string 2749'); break; + case 2750: if (n[2750]++ > 0) check ('a string 2750'); break; + case 2751: if (n[2751]++ > 0) check ('a string 2751'); break; + case 2752: if (n[2752]++ > 0) check ('a string 2752'); break; + case 2753: if (n[2753]++ > 0) check ('a string 2753'); break; + case 2754: if (n[2754]++ > 0) check ('a string 2754'); break; + case 2755: if (n[2755]++ > 0) check ('a string 2755'); break; + case 2756: if (n[2756]++ > 0) check ('a string 2756'); break; + case 2757: if (n[2757]++ > 0) check ('a string 2757'); break; + case 2758: if (n[2758]++ > 0) check ('a string 2758'); break; + case 2759: if (n[2759]++ > 0) check ('a string 2759'); break; + case 2760: if (n[2760]++ > 0) check ('a string 2760'); break; + case 2761: if (n[2761]++ > 0) check ('a string 2761'); break; + case 2762: if (n[2762]++ > 0) check ('a string 2762'); break; + case 2763: if (n[2763]++ > 0) check ('a string 2763'); break; + case 2764: if (n[2764]++ > 0) check ('a string 2764'); break; + case 2765: if (n[2765]++ > 0) check ('a string 2765'); break; + case 2766: if (n[2766]++ > 0) check ('a string 2766'); break; + case 2767: if (n[2767]++ > 0) check ('a string 2767'); break; + case 2768: if (n[2768]++ > 0) check ('a string 2768'); break; + case 2769: if (n[2769]++ > 0) check ('a string 2769'); break; + case 2770: if (n[2770]++ > 0) check ('a string 2770'); break; + case 2771: if (n[2771]++ > 0) check ('a string 2771'); break; + case 2772: if (n[2772]++ > 0) check ('a string 2772'); break; + case 2773: if (n[2773]++ > 0) check ('a string 2773'); break; + case 2774: if (n[2774]++ > 0) check ('a string 2774'); break; + case 2775: if (n[2775]++ > 0) check ('a string 2775'); break; + case 2776: if (n[2776]++ > 0) check ('a string 2776'); break; + case 2777: if (n[2777]++ > 0) check ('a string 2777'); break; + case 2778: if (n[2778]++ > 0) check ('a string 2778'); break; + case 2779: if (n[2779]++ > 0) check ('a string 2779'); break; + case 2780: if (n[2780]++ > 0) check ('a string 2780'); break; + case 2781: if (n[2781]++ > 0) check ('a string 2781'); break; + case 2782: if (n[2782]++ > 0) check ('a string 2782'); break; + case 2783: if (n[2783]++ > 0) check ('a string 2783'); break; + case 2784: if (n[2784]++ > 0) check ('a string 2784'); break; + case 2785: if (n[2785]++ > 0) check ('a string 2785'); break; + case 2786: if (n[2786]++ > 0) check ('a string 2786'); break; + case 2787: if (n[2787]++ > 0) check ('a string 2787'); break; + case 2788: if (n[2788]++ > 0) check ('a string 2788'); break; + case 2789: if (n[2789]++ > 0) check ('a string 2789'); break; + case 2790: if (n[2790]++ > 0) check ('a string 2790'); break; + case 2791: if (n[2791]++ > 0) check ('a string 2791'); break; + case 2792: if (n[2792]++ > 0) check ('a string 2792'); break; + case 2793: if (n[2793]++ > 0) check ('a string 2793'); break; + case 2794: if (n[2794]++ > 0) check ('a string 2794'); break; + case 2795: if (n[2795]++ > 0) check ('a string 2795'); break; + case 2796: if (n[2796]++ > 0) check ('a string 2796'); break; + case 2797: if (n[2797]++ > 0) check ('a string 2797'); break; + case 2798: if (n[2798]++ > 0) check ('a string 2798'); break; + case 2799: if (n[2799]++ > 0) check ('a string 2799'); break; + case 2800: if (n[2800]++ > 0) check ('a string 2800'); break; + case 2801: if (n[2801]++ > 0) check ('a string 2801'); break; + case 2802: if (n[2802]++ > 0) check ('a string 2802'); break; + case 2803: if (n[2803]++ > 0) check ('a string 2803'); break; + case 2804: if (n[2804]++ > 0) check ('a string 2804'); break; + case 2805: if (n[2805]++ > 0) check ('a string 2805'); break; + case 2806: if (n[2806]++ > 0) check ('a string 2806'); break; + case 2807: if (n[2807]++ > 0) check ('a string 2807'); break; + case 2808: if (n[2808]++ > 0) check ('a string 2808'); break; + case 2809: if (n[2809]++ > 0) check ('a string 2809'); break; + case 2810: if (n[2810]++ > 0) check ('a string 2810'); break; + case 2811: if (n[2811]++ > 0) check ('a string 2811'); break; + case 2812: if (n[2812]++ > 0) check ('a string 2812'); break; + case 2813: if (n[2813]++ > 0) check ('a string 2813'); break; + case 2814: if (n[2814]++ > 0) check ('a string 2814'); break; + case 2815: if (n[2815]++ > 0) check ('a string 2815'); break; + case 2816: if (n[2816]++ > 0) check ('a string 2816'); break; + case 2817: if (n[2817]++ > 0) check ('a string 2817'); break; + case 2818: if (n[2818]++ > 0) check ('a string 2818'); break; + case 2819: if (n[2819]++ > 0) check ('a string 2819'); break; + case 2820: if (n[2820]++ > 0) check ('a string 2820'); break; + case 2821: if (n[2821]++ > 0) check ('a string 2821'); break; + case 2822: if (n[2822]++ > 0) check ('a string 2822'); break; + case 2823: if (n[2823]++ > 0) check ('a string 2823'); break; + case 2824: if (n[2824]++ > 0) check ('a string 2824'); break; + case 2825: if (n[2825]++ > 0) check ('a string 2825'); break; + case 2826: if (n[2826]++ > 0) check ('a string 2826'); break; + case 2827: if (n[2827]++ > 0) check ('a string 2827'); break; + case 2828: if (n[2828]++ > 0) check ('a string 2828'); break; + case 2829: if (n[2829]++ > 0) check ('a string 2829'); break; + case 2830: if (n[2830]++ > 0) check ('a string 2830'); break; + case 2831: if (n[2831]++ > 0) check ('a string 2831'); break; + case 2832: if (n[2832]++ > 0) check ('a string 2832'); break; + case 2833: if (n[2833]++ > 0) check ('a string 2833'); break; + case 2834: if (n[2834]++ > 0) check ('a string 2834'); break; + case 2835: if (n[2835]++ > 0) check ('a string 2835'); break; + case 2836: if (n[2836]++ > 0) check ('a string 2836'); break; + case 2837: if (n[2837]++ > 0) check ('a string 2837'); break; + case 2838: if (n[2838]++ > 0) check ('a string 2838'); break; + case 2839: if (n[2839]++ > 0) check ('a string 2839'); break; + case 2840: if (n[2840]++ > 0) check ('a string 2840'); break; + case 2841: if (n[2841]++ > 0) check ('a string 2841'); break; + case 2842: if (n[2842]++ > 0) check ('a string 2842'); break; + case 2843: if (n[2843]++ > 0) check ('a string 2843'); break; + case 2844: if (n[2844]++ > 0) check ('a string 2844'); break; + case 2845: if (n[2845]++ > 0) check ('a string 2845'); break; + case 2846: if (n[2846]++ > 0) check ('a string 2846'); break; + case 2847: if (n[2847]++ > 0) check ('a string 2847'); break; + case 2848: if (n[2848]++ > 0) check ('a string 2848'); break; + case 2849: if (n[2849]++ > 0) check ('a string 2849'); break; + case 2850: if (n[2850]++ > 0) check ('a string 2850'); break; + case 2851: if (n[2851]++ > 0) check ('a string 2851'); break; + case 2852: if (n[2852]++ > 0) check ('a string 2852'); break; + case 2853: if (n[2853]++ > 0) check ('a string 2853'); break; + case 2854: if (n[2854]++ > 0) check ('a string 2854'); break; + case 2855: if (n[2855]++ > 0) check ('a string 2855'); break; + case 2856: if (n[2856]++ > 0) check ('a string 2856'); break; + case 2857: if (n[2857]++ > 0) check ('a string 2857'); break; + case 2858: if (n[2858]++ > 0) check ('a string 2858'); break; + case 2859: if (n[2859]++ > 0) check ('a string 2859'); break; + case 2860: if (n[2860]++ > 0) check ('a string 2860'); break; + case 2861: if (n[2861]++ > 0) check ('a string 2861'); break; + case 2862: if (n[2862]++ > 0) check ('a string 2862'); break; + case 2863: if (n[2863]++ > 0) check ('a string 2863'); break; + case 2864: if (n[2864]++ > 0) check ('a string 2864'); break; + case 2865: if (n[2865]++ > 0) check ('a string 2865'); break; + case 2866: if (n[2866]++ > 0) check ('a string 2866'); break; + case 2867: if (n[2867]++ > 0) check ('a string 2867'); break; + case 2868: if (n[2868]++ > 0) check ('a string 2868'); break; + case 2869: if (n[2869]++ > 0) check ('a string 2869'); break; + case 2870: if (n[2870]++ > 0) check ('a string 2870'); break; + case 2871: if (n[2871]++ > 0) check ('a string 2871'); break; + case 2872: if (n[2872]++ > 0) check ('a string 2872'); break; + case 2873: if (n[2873]++ > 0) check ('a string 2873'); break; + case 2874: if (n[2874]++ > 0) check ('a string 2874'); break; + case 2875: if (n[2875]++ > 0) check ('a string 2875'); break; + case 2876: if (n[2876]++ > 0) check ('a string 2876'); break; + case 2877: if (n[2877]++ > 0) check ('a string 2877'); break; + case 2878: if (n[2878]++ > 0) check ('a string 2878'); break; + case 2879: if (n[2879]++ > 0) check ('a string 2879'); break; + case 2880: if (n[2880]++ > 0) check ('a string 2880'); break; + case 2881: if (n[2881]++ > 0) check ('a string 2881'); break; + case 2882: if (n[2882]++ > 0) check ('a string 2882'); break; + case 2883: if (n[2883]++ > 0) check ('a string 2883'); break; + case 2884: if (n[2884]++ > 0) check ('a string 2884'); break; + case 2885: if (n[2885]++ > 0) check ('a string 2885'); break; + case 2886: if (n[2886]++ > 0) check ('a string 2886'); break; + case 2887: if (n[2887]++ > 0) check ('a string 2887'); break; + case 2888: if (n[2888]++ > 0) check ('a string 2888'); break; + case 2889: if (n[2889]++ > 0) check ('a string 2889'); break; + case 2890: if (n[2890]++ > 0) check ('a string 2890'); break; + case 2891: if (n[2891]++ > 0) check ('a string 2891'); break; + case 2892: if (n[2892]++ > 0) check ('a string 2892'); break; + case 2893: if (n[2893]++ > 0) check ('a string 2893'); break; + case 2894: if (n[2894]++ > 0) check ('a string 2894'); break; + case 2895: if (n[2895]++ > 0) check ('a string 2895'); break; + case 2896: if (n[2896]++ > 0) check ('a string 2896'); break; + case 2897: if (n[2897]++ > 0) check ('a string 2897'); break; + case 2898: if (n[2898]++ > 0) check ('a string 2898'); break; + case 2899: if (n[2899]++ > 0) check ('a string 2899'); break; + case 2900: if (n[2900]++ > 0) check ('a string 2900'); break; + case 2901: if (n[2901]++ > 0) check ('a string 2901'); break; + case 2902: if (n[2902]++ > 0) check ('a string 2902'); break; + case 2903: if (n[2903]++ > 0) check ('a string 2903'); break; + case 2904: if (n[2904]++ > 0) check ('a string 2904'); break; + case 2905: if (n[2905]++ > 0) check ('a string 2905'); break; + case 2906: if (n[2906]++ > 0) check ('a string 2906'); break; + case 2907: if (n[2907]++ > 0) check ('a string 2907'); break; + case 2908: if (n[2908]++ > 0) check ('a string 2908'); break; + case 2909: if (n[2909]++ > 0) check ('a string 2909'); break; + case 2910: if (n[2910]++ > 0) check ('a string 2910'); break; + case 2911: if (n[2911]++ > 0) check ('a string 2911'); break; + case 2912: if (n[2912]++ > 0) check ('a string 2912'); break; + case 2913: if (n[2913]++ > 0) check ('a string 2913'); break; + case 2914: if (n[2914]++ > 0) check ('a string 2914'); break; + case 2915: if (n[2915]++ > 0) check ('a string 2915'); break; + case 2916: if (n[2916]++ > 0) check ('a string 2916'); break; + case 2917: if (n[2917]++ > 0) check ('a string 2917'); break; + case 2918: if (n[2918]++ > 0) check ('a string 2918'); break; + case 2919: if (n[2919]++ > 0) check ('a string 2919'); break; + case 2920: if (n[2920]++ > 0) check ('a string 2920'); break; + case 2921: if (n[2921]++ > 0) check ('a string 2921'); break; + case 2922: if (n[2922]++ > 0) check ('a string 2922'); break; + case 2923: if (n[2923]++ > 0) check ('a string 2923'); break; + case 2924: if (n[2924]++ > 0) check ('a string 2924'); break; + case 2925: if (n[2925]++ > 0) check ('a string 2925'); break; + case 2926: if (n[2926]++ > 0) check ('a string 2926'); break; + case 2927: if (n[2927]++ > 0) check ('a string 2927'); break; + case 2928: if (n[2928]++ > 0) check ('a string 2928'); break; + case 2929: if (n[2929]++ > 0) check ('a string 2929'); break; + case 2930: if (n[2930]++ > 0) check ('a string 2930'); break; + case 2931: if (n[2931]++ > 0) check ('a string 2931'); break; + case 2932: if (n[2932]++ > 0) check ('a string 2932'); break; + case 2933: if (n[2933]++ > 0) check ('a string 2933'); break; + case 2934: if (n[2934]++ > 0) check ('a string 2934'); break; + case 2935: if (n[2935]++ > 0) check ('a string 2935'); break; + case 2936: if (n[2936]++ > 0) check ('a string 2936'); break; + case 2937: if (n[2937]++ > 0) check ('a string 2937'); break; + case 2938: if (n[2938]++ > 0) check ('a string 2938'); break; + case 2939: if (n[2939]++ > 0) check ('a string 2939'); break; + case 2940: if (n[2940]++ > 0) check ('a string 2940'); break; + case 2941: if (n[2941]++ > 0) check ('a string 2941'); break; + case 2942: if (n[2942]++ > 0) check ('a string 2942'); break; + case 2943: if (n[2943]++ > 0) check ('a string 2943'); break; + case 2944: if (n[2944]++ > 0) check ('a string 2944'); break; + case 2945: if (n[2945]++ > 0) check ('a string 2945'); break; + case 2946: if (n[2946]++ > 0) check ('a string 2946'); break; + case 2947: if (n[2947]++ > 0) check ('a string 2947'); break; + case 2948: if (n[2948]++ > 0) check ('a string 2948'); break; + case 2949: if (n[2949]++ > 0) check ('a string 2949'); break; + case 2950: if (n[2950]++ > 0) check ('a string 2950'); break; + case 2951: if (n[2951]++ > 0) check ('a string 2951'); break; + case 2952: if (n[2952]++ > 0) check ('a string 2952'); break; + case 2953: if (n[2953]++ > 0) check ('a string 2953'); break; + case 2954: if (n[2954]++ > 0) check ('a string 2954'); break; + case 2955: if (n[2955]++ > 0) check ('a string 2955'); break; + case 2956: if (n[2956]++ > 0) check ('a string 2956'); break; + case 2957: if (n[2957]++ > 0) check ('a string 2957'); break; + case 2958: if (n[2958]++ > 0) check ('a string 2958'); break; + case 2959: if (n[2959]++ > 0) check ('a string 2959'); break; + case 2960: if (n[2960]++ > 0) check ('a string 2960'); break; + case 2961: if (n[2961]++ > 0) check ('a string 2961'); break; + case 2962: if (n[2962]++ > 0) check ('a string 2962'); break; + case 2963: if (n[2963]++ > 0) check ('a string 2963'); break; + case 2964: if (n[2964]++ > 0) check ('a string 2964'); break; + case 2965: if (n[2965]++ > 0) check ('a string 2965'); break; + case 2966: if (n[2966]++ > 0) check ('a string 2966'); break; + case 2967: if (n[2967]++ > 0) check ('a string 2967'); break; + case 2968: if (n[2968]++ > 0) check ('a string 2968'); break; + case 2969: if (n[2969]++ > 0) check ('a string 2969'); break; + case 2970: if (n[2970]++ > 0) check ('a string 2970'); break; + case 2971: if (n[2971]++ > 0) check ('a string 2971'); break; + case 2972: if (n[2972]++ > 0) check ('a string 2972'); break; + case 2973: if (n[2973]++ > 0) check ('a string 2973'); break; + case 2974: if (n[2974]++ > 0) check ('a string 2974'); break; + case 2975: if (n[2975]++ > 0) check ('a string 2975'); break; + case 2976: if (n[2976]++ > 0) check ('a string 2976'); break; + case 2977: if (n[2977]++ > 0) check ('a string 2977'); break; + case 2978: if (n[2978]++ > 0) check ('a string 2978'); break; + case 2979: if (n[2979]++ > 0) check ('a string 2979'); break; + case 2980: if (n[2980]++ > 0) check ('a string 2980'); break; + case 2981: if (n[2981]++ > 0) check ('a string 2981'); break; + case 2982: if (n[2982]++ > 0) check ('a string 2982'); break; + case 2983: if (n[2983]++ > 0) check ('a string 2983'); break; + case 2984: if (n[2984]++ > 0) check ('a string 2984'); break; + case 2985: if (n[2985]++ > 0) check ('a string 2985'); break; + case 2986: if (n[2986]++ > 0) check ('a string 2986'); break; + case 2987: if (n[2987]++ > 0) check ('a string 2987'); break; + case 2988: if (n[2988]++ > 0) check ('a string 2988'); break; + case 2989: if (n[2989]++ > 0) check ('a string 2989'); break; + case 2990: if (n[2990]++ > 0) check ('a string 2990'); break; + case 2991: if (n[2991]++ > 0) check ('a string 2991'); break; + case 2992: if (n[2992]++ > 0) check ('a string 2992'); break; + case 2993: if (n[2993]++ > 0) check ('a string 2993'); break; + case 2994: if (n[2994]++ > 0) check ('a string 2994'); break; + case 2995: if (n[2995]++ > 0) check ('a string 2995'); break; + case 2996: if (n[2996]++ > 0) check ('a string 2996'); break; + case 2997: if (n[2997]++ > 0) check ('a string 2997'); break; + case 2998: if (n[2998]++ > 0) check ('a string 2998'); break; + case 2999: if (n[2999]++ > 0) check ('a string 2999'); break; + case 3000: if (n[3000]++ > 0) check ('a string 3000'); break; + case 3001: if (n[3001]++ > 0) check ('a string 3001'); break; + case 3002: if (n[3002]++ > 0) check ('a string 3002'); break; + case 3003: if (n[3003]++ > 0) check ('a string 3003'); break; + case 3004: if (n[3004]++ > 0) check ('a string 3004'); break; + case 3005: if (n[3005]++ > 0) check ('a string 3005'); break; + case 3006: if (n[3006]++ > 0) check ('a string 3006'); break; + case 3007: if (n[3007]++ > 0) check ('a string 3007'); break; + case 3008: if (n[3008]++ > 0) check ('a string 3008'); break; + case 3009: if (n[3009]++ > 0) check ('a string 3009'); break; + default : if (n[3010]++ > 0) check ('a string 3010'); break; + } + } + + b4(); + b_after(); +} + + +function check(status) +{ + print('k = ' + k + ' j = ' + j + ' ' + status); + + for (i = 0; i < i2; i++) + { + if (n[i] != 1) + { + print('n[' + i + '] = ' + n[i]); + if (i != j) + { + print('Test failed'); + err_num++; + break; + } + } + } +} + + +function b4() +{ + print('Visited b4'); +} + + +function b_after() +{ + print('Visited b_after'); +} diff --git a/tests/mozilla/js1_5/Regress/regress-82306.js b/tests/mozilla/js1_5/Regress/regress-82306.js new file mode 100644 index 0000000..6841fd5 --- /dev/null +++ b/tests/mozilla/js1_5/Regress/regress-82306.js @@ -0,0 +1,59 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com, epstein@tellme.com +* Date: 23 May 2001 +* +* SUMMARY: Regression test for Bugzilla bug 82306 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=82306 +* +* This test used to crash the JS engine. This was discovered +* by Mike Epstein +*/ +//------------------------------------------------------------------------------------------------- +var bug = 82306; +var summary = "Testing we don't crash on encodeURI()"; +var URI = ''; + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + URI += ''; + URI += ''; + URI += ''; + URI += '650-930-xxxx'; + URI += '877-485-xxxx'; + URI += ''; + URI += ''; + URI += ''; + URI += ''; + + // Just testing that we don't crash on this + encodeURI(URI); + + exitFunc ('test'); +} diff --git a/tests/mozilla/js1_5/Regress/regress-89443.js b/tests/mozilla/js1_5/Regress/regress-89443.js new file mode 100644 index 0000000..ba4e1db --- /dev/null +++ b/tests/mozilla/js1_5/Regress/regress-89443.js @@ -0,0 +1,2130 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an +* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed +* or implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. +* All Rights Reserved. +* +* Contributor(s): pschwartau@netscape.com +* Date: 2001-07-12 +* +* SUMMARY: Regression test for bug 89443 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=89443 +* +* Just seeing if this script will compile without stack overflow. +*/ +//------------------------------------------------------------------------------------------------- +var bug = 89443; +var summary = 'Testing this script will compile without stack overflow'; + +printBugNumber (bug); +printStatus (summary); + + +// I don't know what these functions are supposed to be; use dummies - +function isPlainHostName() +{ +} + +function dnsDomainIs() +{ +} + +// Here's the big function - +function FindProxyForURL(url, host) +{ + +if (isPlainHostName(host) +|| dnsDomainIs(host, ".hennepin.lib.mn.us") +|| dnsDomainIs(host, ".hclib.org") +) + return "DIRECT"; +else if (isPlainHostName(host) + +// subscription database access + +|| dnsDomainIs(host, ".asahi.com") +|| dnsDomainIs(host, ".2facts.com") +|| dnsDomainIs(host, ".oclc.org") +|| dnsDomainIs(host, ".collegesource.com") +|| dnsDomainIs(host, ".cq.com") +|| dnsDomainIs(host, ".grolier.com") +|| dnsDomainIs(host, ".groveart.com") +|| dnsDomainIs(host, ".groveopera.com") +|| dnsDomainIs(host, ".fsonline.com") +|| dnsDomainIs(host, ".carl.org") +|| dnsDomainIs(host, ".newslibrary.com") +|| dnsDomainIs(host, ".pioneerplanet.com") +|| dnsDomainIs(host, ".startribune.com") +|| dnsDomainIs(host, ".poemfinder.com") +|| dnsDomainIs(host, ".umi.com") +|| dnsDomainIs(host, ".referenceusa.com") +|| dnsDomainIs(host, ".sirs.com") +|| dnsDomainIs(host, ".krmediastream.com") +|| dnsDomainIs(host, ".gale.com") +|| dnsDomainIs(host, ".galenet.com") +|| dnsDomainIs(host, ".galegroup.com") +|| dnsDomainIs(host, ".facts.com") +|| dnsDomainIs(host, ".eb.com") +|| dnsDomainIs(host, ".worldbookonline.com") +|| dnsDomainIs(host, ".galegroup.com") +|| dnsDomainIs(host, ".accessscience.com") +|| dnsDomainIs(host, ".booksinprint.com") +|| dnsDomainIs(host, ".infolearning.com") +|| dnsDomainIs(host, ".standardpoor.com") + +// image servers +|| dnsDomainIs(host, ".akamaitech.net") +|| dnsDomainIs(host, ".akamai.net") +|| dnsDomainIs(host, ".yimg.com") +|| dnsDomainIs(host, ".imgis.com") +|| dnsDomainIs(host, ".ibsys.com") + +// KidsClick-linked kids search engines +|| dnsDomainIs(host, ".edview.com") +|| dnsDomainIs(host, ".searchopolis.com") +|| dnsDomainIs(host, ".onekey.com") +|| dnsDomainIs(host, ".askjeeves.com") + +// Non-subscription Reference Tools URLs from the RecWebSites DBData table + || dnsDomainIs(host, "www.cnn.com") + || dnsDomainIs(host, "www.emulateme.com") + || dnsDomainIs(host, "terraserver.microsoft.com") + || dnsDomainIs(host, "www.theodora.com") + || dnsDomainIs(host, "www.3datlas.com") + || dnsDomainIs(host, "www.infoplease.com") + || dnsDomainIs(host, "www.switchboard.com") + || dnsDomainIs(host, "www.bartleby.com") + || dnsDomainIs(host, "www.mn-politics.com") + || dnsDomainIs(host, "www.thesaurus.com") + || dnsDomainIs(host, "www.usnews.com") + || dnsDomainIs(host, "www.petersons.com") + || dnsDomainIs(host, "www.collegenet.com") + || dnsDomainIs(host, "www.m-w.com") + || dnsDomainIs(host, "clever.net") + || dnsDomainIs(host, "maps.expedia.com") + || dnsDomainIs(host, "www.CollegeEdge.com") + || dnsDomainIs(host, "www.homeworkcentral.com") + || dnsDomainIs(host, "www.studyweb.com") + || dnsDomainIs(host, "www.mnpro.com") + +// custom URLs for local and other access +|| dnsDomainIs(host, ".dsdukes.com") +|| dnsDomainIs(host, ".spsaints.com") +|| dnsDomainIs(host, ".mnzoo.com") +|| dnsDomainIs(host, ".realaudio.com") +|| dnsDomainIs(host, ".co.hennepin.mn.us") +|| dnsDomainIs(host, ".gov") +|| dnsDomainIs(host, ".org") +|| dnsDomainIs(host, ".edu") +|| dnsDomainIs(host, ".fox29.com") +|| dnsDomainIs(host, ".wcco.com") +|| dnsDomainIs(host, ".kstp.com") +|| dnsDomainIs(host, ".kmsp.com") +|| dnsDomainIs(host, ".kare11.com") +|| dnsDomainIs(host, ".macromedia.com") +|| dnsDomainIs(host, ".shockwave.com") +|| dnsDomainIs(host, ".wwf.com") +|| dnsDomainIs(host, ".wwfsuperstars.com") +|| dnsDomainIs(host, ".summerslam.com") +|| dnsDomainIs(host, ".yahooligans.com") +|| dnsDomainIs(host, ".mhoob.com") +|| dnsDomainIs(host, "www.hmonginternet.com") +|| dnsDomainIs(host, "www.hmongonline.com") +|| dnsDomainIs(host, ".yahoo.com") +|| dnsDomainIs(host, ".pokemon.com") +|| dnsDomainIs(host, ".bet.com") +|| dnsDomainIs(host, ".smallworld.com") +|| dnsDomainIs(host, ".cartoonnetwork.com") +|| dnsDomainIs(host, ".carmensandiego.com") +|| dnsDomainIs(host, ".disney.com") +|| dnsDomainIs(host, ".powerpuffgirls.com") +|| dnsDomainIs(host, ".aol.com") + +// Smithsonian +|| dnsDomainIs(host, "160.111.100.190") + +// Hotmail +|| dnsDomainIs(host, ".passport.com") +|| dnsDomainIs(host, ".hotmail.com") +|| dnsDomainIs(host, "216.33.236.24") +|| dnsDomainIs(host, "216.32.182.251") +|| dnsDomainIs(host, ".hotmail.msn.com") + +// K12 schools +|| dnsDomainIs(host, ".k12.al.us") +|| dnsDomainIs(host, ".k12.ak.us") +|| dnsDomainIs(host, ".k12.ar.us") +|| dnsDomainIs(host, ".k12.az.us") +|| dnsDomainIs(host, ".k12.ca.us") +|| dnsDomainIs(host, ".k12.co.us") +|| dnsDomainIs(host, ".k12.ct.us") +|| dnsDomainIs(host, ".k12.dc.us") +|| dnsDomainIs(host, ".k12.de.us") +|| dnsDomainIs(host, ".k12.fl.us") +|| dnsDomainIs(host, ".k12.ga.us") +|| dnsDomainIs(host, ".k12.hi.us") +|| dnsDomainIs(host, ".k12.id.us") +|| dnsDomainIs(host, ".k12.il.us") +|| dnsDomainIs(host, ".k12.in.us") +|| dnsDomainIs(host, ".k12.ia.us") +|| dnsDomainIs(host, ".k12.ks.us") +|| dnsDomainIs(host, ".k12.ky.us") +|| dnsDomainIs(host, ".k12.la.us") +|| dnsDomainIs(host, ".k12.me.us") +|| dnsDomainIs(host, ".k12.md.us") +|| dnsDomainIs(host, ".k12.ma.us") +|| dnsDomainIs(host, ".k12.mi.us") +|| dnsDomainIs(host, ".k12.mn.us") +|| dnsDomainIs(host, ".k12.ms.us") +|| dnsDomainIs(host, ".k12.mo.us") +|| dnsDomainIs(host, ".k12.mt.us") +|| dnsDomainIs(host, ".k12.ne.us") +|| dnsDomainIs(host, ".k12.nv.us") +|| dnsDomainIs(host, ".k12.nh.us") +|| dnsDomainIs(host, ".k12.nj.us") +|| dnsDomainIs(host, ".k12.nm.us") +|| dnsDomainIs(host, ".k12.ny.us") +|| dnsDomainIs(host, ".k12.nc.us") +|| dnsDomainIs(host, ".k12.nd.us") +|| dnsDomainIs(host, ".k12.oh.us") +|| dnsDomainIs(host, ".k12.ok.us") +|| dnsDomainIs(host, ".k12.or.us") +|| dnsDomainIs(host, ".k12.pa.us") +|| dnsDomainIs(host, ".k12.ri.us") +|| dnsDomainIs(host, ".k12.sc.us") +|| dnsDomainIs(host, ".k12.sd.us") +|| dnsDomainIs(host, ".k12.tn.us") +|| dnsDomainIs(host, ".k12.tx.us") +|| dnsDomainIs(host, ".k12.ut.us") +|| dnsDomainIs(host, ".k12.vt.us") +|| dnsDomainIs(host, ".k12.va.us") +|| dnsDomainIs(host, ".k12.wa.us") +|| dnsDomainIs(host, ".k12.wv.us") +|| dnsDomainIs(host, ".k12.wi.us") +|| dnsDomainIs(host, ".k12.wy.us") + +// U.S. Libraries +|| dnsDomainIs(host, ".lib.al.us") +|| dnsDomainIs(host, ".lib.ak.us") +|| dnsDomainIs(host, ".lib.ar.us") +|| dnsDomainIs(host, ".lib.az.us") +|| dnsDomainIs(host, ".lib.ca.us") +|| dnsDomainIs(host, ".lib.co.us") +|| dnsDomainIs(host, ".lib.ct.us") +|| dnsDomainIs(host, ".lib.dc.us") +|| dnsDomainIs(host, ".lib.de.us") +|| dnsDomainIs(host, ".lib.fl.us") +|| dnsDomainIs(host, ".lib.ga.us") +|| dnsDomainIs(host, ".lib.hi.us") +|| dnsDomainIs(host, ".lib.id.us") +|| dnsDomainIs(host, ".lib.il.us") +|| dnsDomainIs(host, ".lib.in.us") +|| dnsDomainIs(host, ".lib.ia.us") +|| dnsDomainIs(host, ".lib.ks.us") +|| dnsDomainIs(host, ".lib.ky.us") +|| dnsDomainIs(host, ".lib.la.us") +|| dnsDomainIs(host, ".lib.me.us") +|| dnsDomainIs(host, ".lib.md.us") +|| dnsDomainIs(host, ".lib.ma.us") +|| dnsDomainIs(host, ".lib.mi.us") +|| dnsDomainIs(host, ".lib.mn.us") +|| dnsDomainIs(host, ".lib.ms.us") +|| dnsDomainIs(host, ".lib.mo.us") +|| dnsDomainIs(host, ".lib.mt.us") +|| dnsDomainIs(host, ".lib.ne.us") +|| dnsDomainIs(host, ".lib.nv.us") +|| dnsDomainIs(host, ".lib.nh.us") +|| dnsDomainIs(host, ".lib.nj.us") +|| dnsDomainIs(host, ".lib.nm.us") +|| dnsDomainIs(host, ".lib.ny.us") +|| dnsDomainIs(host, ".lib.nc.us") +|| dnsDomainIs(host, ".lib.nd.us") +|| dnsDomainIs(host, ".lib.oh.us") +|| dnsDomainIs(host, ".lib.ok.us") +|| dnsDomainIs(host, ".lib.or.us") +|| dnsDomainIs(host, ".lib.pa.us") +|| dnsDomainIs(host, ".lib.ri.us") +|| dnsDomainIs(host, ".lib.sc.us") +|| dnsDomainIs(host, ".lib.sd.us") +|| dnsDomainIs(host, ".lib.tn.us") +|| dnsDomainIs(host, ".lib.tx.us") +|| dnsDomainIs(host, ".lib.ut.us") +|| dnsDomainIs(host, ".lib.vt.us") +|| dnsDomainIs(host, ".lib.va.us") +|| dnsDomainIs(host, ".lib.wa.us") +|| dnsDomainIs(host, ".lib.wv.us") +|| dnsDomainIs(host, ".lib.wi.us") +|| dnsDomainIs(host, ".lib.wy.us") + +// U.S. Cities +|| dnsDomainIs(host, ".ci.al.us") +|| dnsDomainIs(host, ".ci.ak.us") +|| dnsDomainIs(host, ".ci.ar.us") +|| dnsDomainIs(host, ".ci.az.us") +|| dnsDomainIs(host, ".ci.ca.us") +|| dnsDomainIs(host, ".ci.co.us") +|| dnsDomainIs(host, ".ci.ct.us") +|| dnsDomainIs(host, ".ci.dc.us") +|| dnsDomainIs(host, ".ci.de.us") +|| dnsDomainIs(host, ".ci.fl.us") +|| dnsDomainIs(host, ".ci.ga.us") +|| dnsDomainIs(host, ".ci.hi.us") +|| dnsDomainIs(host, ".ci.id.us") +|| dnsDomainIs(host, ".ci.il.us") +|| dnsDomainIs(host, ".ci.in.us") +|| dnsDomainIs(host, ".ci.ia.us") +|| dnsDomainIs(host, ".ci.ks.us") +|| dnsDomainIs(host, ".ci.ky.us") +|| dnsDomainIs(host, ".ci.la.us") +|| dnsDomainIs(host, ".ci.me.us") +|| dnsDomainIs(host, ".ci.md.us") +|| dnsDomainIs(host, ".ci.ma.us") +|| dnsDomainIs(host, ".ci.mi.us") +|| dnsDomainIs(host, ".ci.mn.us") +|| dnsDomainIs(host, ".ci.ms.us") +|| dnsDomainIs(host, ".ci.mo.us") +|| dnsDomainIs(host, ".ci.mt.us") +|| dnsDomainIs(host, ".ci.ne.us") +|| dnsDomainIs(host, ".ci.nv.us") +|| dnsDomainIs(host, ".ci.nh.us") +|| dnsDomainIs(host, ".ci.nj.us") +|| dnsDomainIs(host, ".ci.nm.us") +|| dnsDomainIs(host, ".ci.ny.us") +|| dnsDomainIs(host, ".ci.nc.us") +|| dnsDomainIs(host, ".ci.nd.us") +|| dnsDomainIs(host, ".ci.oh.us") +|| dnsDomainIs(host, ".ci.ok.us") +|| dnsDomainIs(host, ".ci.or.us") +|| dnsDomainIs(host, ".ci.pa.us") +|| dnsDomainIs(host, ".ci.ri.us") +|| dnsDomainIs(host, ".ci.sc.us") +|| dnsDomainIs(host, ".ci.sd.us") +|| dnsDomainIs(host, ".ci.tn.us") +|| dnsDomainIs(host, ".ci.tx.us") +|| dnsDomainIs(host, ".ci.ut.us") +|| dnsDomainIs(host, ".ci.vt.us") +|| dnsDomainIs(host, ".ci.va.us") +|| dnsDomainIs(host, ".ci.wa.us") +|| dnsDomainIs(host, ".ci.wv.us") +|| dnsDomainIs(host, ".ci.wi.us") +|| dnsDomainIs(host, ".ci.wy.us") + +// U.S. Counties +|| dnsDomainIs(host, ".co.al.us") +|| dnsDomainIs(host, ".co.ak.us") +|| dnsDomainIs(host, ".co.ar.us") +|| dnsDomainIs(host, ".co.az.us") +|| dnsDomainIs(host, ".co.ca.us") +|| dnsDomainIs(host, ".co.co.us") +|| dnsDomainIs(host, ".co.ct.us") +|| dnsDomainIs(host, ".co.dc.us") +|| dnsDomainIs(host, ".co.de.us") +|| dnsDomainIs(host, ".co.fl.us") +|| dnsDomainIs(host, ".co.ga.us") +|| dnsDomainIs(host, ".co.hi.us") +|| dnsDomainIs(host, ".co.id.us") +|| dnsDomainIs(host, ".co.il.us") +|| dnsDomainIs(host, ".co.in.us") +|| dnsDomainIs(host, ".co.ia.us") +|| dnsDomainIs(host, ".co.ks.us") +|| dnsDomainIs(host, ".co.ky.us") +|| dnsDomainIs(host, ".co.la.us") +|| dnsDomainIs(host, ".co.me.us") +|| dnsDomainIs(host, ".co.md.us") +|| dnsDomainIs(host, ".co.ma.us") +|| dnsDomainIs(host, ".co.mi.us") +|| dnsDomainIs(host, ".co.mn.us") +|| dnsDomainIs(host, ".co.ms.us") +|| dnsDomainIs(host, ".co.mo.us") +|| dnsDomainIs(host, ".co.mt.us") +|| dnsDomainIs(host, ".co.ne.us") +|| dnsDomainIs(host, ".co.nv.us") +|| dnsDomainIs(host, ".co.nh.us") +|| dnsDomainIs(host, ".co.nj.us") +|| dnsDomainIs(host, ".co.nm.us") +|| dnsDomainIs(host, ".co.ny.us") +|| dnsDomainIs(host, ".co.nc.us") +|| dnsDomainIs(host, ".co.nd.us") +|| dnsDomainIs(host, ".co.oh.us") +|| dnsDomainIs(host, ".co.ok.us") +|| dnsDomainIs(host, ".co.or.us") +|| dnsDomainIs(host, ".co.pa.us") +|| dnsDomainIs(host, ".co.ri.us") +|| dnsDomainIs(host, ".co.sc.us") +|| dnsDomainIs(host, ".co.sd.us") +|| dnsDomainIs(host, ".co.tn.us") +|| dnsDomainIs(host, ".co.tx.us") +|| dnsDomainIs(host, ".co.ut.us") +|| dnsDomainIs(host, ".co.vt.us") +|| dnsDomainIs(host, ".co.va.us") +|| dnsDomainIs(host, ".co.wa.us") +|| dnsDomainIs(host, ".co.wv.us") +|| dnsDomainIs(host, ".co.wi.us") +|| dnsDomainIs(host, ".co.wy.us") + +// U.S. States +|| dnsDomainIs(host, ".state.al.us") +|| dnsDomainIs(host, ".state.ak.us") +|| dnsDomainIs(host, ".state.ar.us") +|| dnsDomainIs(host, ".state.az.us") +|| dnsDomainIs(host, ".state.ca.us") +|| dnsDomainIs(host, ".state.co.us") +|| dnsDomainIs(host, ".state.ct.us") +|| dnsDomainIs(host, ".state.dc.us") +|| dnsDomainIs(host, ".state.de.us") +|| dnsDomainIs(host, ".state.fl.us") +|| dnsDomainIs(host, ".state.ga.us") +|| dnsDomainIs(host, ".state.hi.us") +|| dnsDomainIs(host, ".state.id.us") +|| dnsDomainIs(host, ".state.il.us") +|| dnsDomainIs(host, ".state.in.us") +|| dnsDomainIs(host, ".state.ia.us") +|| dnsDomainIs(host, ".state.ks.us") +|| dnsDomainIs(host, ".state.ky.us") +|| dnsDomainIs(host, ".state.la.us") +|| dnsDomainIs(host, ".state.me.us") +|| dnsDomainIs(host, ".state.md.us") +|| dnsDomainIs(host, ".state.ma.us") +|| dnsDomainIs(host, ".state.mi.us") +|| dnsDomainIs(host, ".state.mn.us") +|| dnsDomainIs(host, ".state.ms.us") +|| dnsDomainIs(host, ".state.mo.us") +|| dnsDomainIs(host, ".state.mt.us") +|| dnsDomainIs(host, ".state.ne.us") +|| dnsDomainIs(host, ".state.nv.us") +|| dnsDomainIs(host, ".state.nh.us") +|| dnsDomainIs(host, ".state.nj.us") +|| dnsDomainIs(host, ".state.nm.us") +|| dnsDomainIs(host, ".state.ny.us") +|| dnsDomainIs(host, ".state.nc.us") +|| dnsDomainIs(host, ".state.nd.us") +|| dnsDomainIs(host, ".state.oh.us") +|| dnsDomainIs(host, ".state.ok.us") +|| dnsDomainIs(host, ".state.or.us") +|| dnsDomainIs(host, ".state.pa.us") +|| dnsDomainIs(host, ".state.ri.us") +|| dnsDomainIs(host, ".state.sc.us") +|| dnsDomainIs(host, ".state.sd.us") +|| dnsDomainIs(host, ".state.tn.us") +|| dnsDomainIs(host, ".state.tx.us") +|| dnsDomainIs(host, ".state.ut.us") +|| dnsDomainIs(host, ".state.vt.us") +|| dnsDomainIs(host, ".state.va.us") +|| dnsDomainIs(host, ".state.wa.us") +|| dnsDomainIs(host, ".state.wv.us") +|| dnsDomainIs(host, ".state.wi.us") +|| dnsDomainIs(host, ".state.wy.us") + +// KidsClick URLs + +|| dnsDomainIs(host, "12.16.163.163") +|| dnsDomainIs(host, "128.59.173.136") +|| dnsDomainIs(host, "165.112.78.61") +|| dnsDomainIs(host, "216.55.23.140") +|| dnsDomainIs(host, "63.111.53.150") +|| dnsDomainIs(host, "64.94.206.8") + +|| dnsDomainIs(host, "abc.go.com") +|| dnsDomainIs(host, "acmepet.petsmart.com") +|| dnsDomainIs(host, "adver-net.com") +|| dnsDomainIs(host, "aint-it-cool-news.com") +|| dnsDomainIs(host, "akidsheart.com") +|| dnsDomainIs(host, "alabanza.com") +|| dnsDomainIs(host, "allerdays.com") +|| dnsDomainIs(host, "allgame.com") +|| dnsDomainIs(host, "allowancenet.com") +|| dnsDomainIs(host, "amish-heartland.com") +|| dnsDomainIs(host, "ancienthistory.about.com") +|| dnsDomainIs(host, "animals.about.com") +|| dnsDomainIs(host, "antenna.nl") +|| dnsDomainIs(host, "arcweb.sos.state.or.us") +|| dnsDomainIs(host, "artistmummer.homestead.com") +|| dnsDomainIs(host, "artists.vh1.com") +|| dnsDomainIs(host, "arts.lausd.k12.ca.us") +|| dnsDomainIs(host, "asiatravel.com") +|| dnsDomainIs(host, "asterius.com") +|| dnsDomainIs(host, "atlas.gc.ca") +|| dnsDomainIs(host, "atschool.eduweb.co.uk") +|| dnsDomainIs(host, "ayya.pd.net") +|| dnsDomainIs(host, "babelfish.altavista.com") +|| dnsDomainIs(host, "babylon5.warnerbros.com") +|| dnsDomainIs(host, "banzai.neosoft.com") +|| dnsDomainIs(host, "barneyonline.com") +|| dnsDomainIs(host, "baroque-music.com") +|| dnsDomainIs(host, "barsoom.msss.com") +|| dnsDomainIs(host, "baseball-almanac.com") +|| dnsDomainIs(host, "bcadventure.com") +|| dnsDomainIs(host, "beadiecritters.hosting4less.com") +|| dnsDomainIs(host, "beverlyscrafts.com") +|| dnsDomainIs(host, "biology.about.com") +|| dnsDomainIs(host, "birding.about.com") +|| dnsDomainIs(host, "boatsafe.com") +|| dnsDomainIs(host, "bombpop.com") +|| dnsDomainIs(host, "boulter.com") +|| dnsDomainIs(host, "bright-ideas-software.com") +|| dnsDomainIs(host, "buckman.pps.k12.or.us") +|| dnsDomainIs(host, "buffalobills.com") +|| dnsDomainIs(host, "bvsd.k12.co.us") +|| dnsDomainIs(host, "cagle.slate.msn.com") +|| dnsDomainIs(host, "calc.entisoft.com") +|| dnsDomainIs(host, "canada.gc.ca") +|| dnsDomainIs(host, "candleandsoap.about.com") +|| dnsDomainIs(host, "caselaw.lp.findlaw.com") +|| dnsDomainIs(host, "catalog.com") +|| dnsDomainIs(host, "catalog.socialstudies.com") +|| dnsDomainIs(host, "cavern.com") +|| dnsDomainIs(host, "cbs.sportsline.com") +|| dnsDomainIs(host, "cc.matsuyama-u.ac.jp") +|| dnsDomainIs(host, "celt.net") +|| dnsDomainIs(host, "cgfa.kelloggcreek.com") +|| dnsDomainIs(host, "channel4000.com") +|| dnsDomainIs(host, "chess.delorie.com") +|| dnsDomainIs(host, "chess.liveonthenet.com") +|| dnsDomainIs(host, "childfun.com") +|| dnsDomainIs(host, "christmas.com") +|| dnsDomainIs(host, "citystar.com") +|| dnsDomainIs(host, "claim.goldrush.com") +|| dnsDomainIs(host, "clairerosemaryjane.com") +|| dnsDomainIs(host, "clevermedia.com") +|| dnsDomainIs(host, "cobblestonepub.com") +|| dnsDomainIs(host, "codebrkr.infopages.net") +|| dnsDomainIs(host, "colitz.com") +|| dnsDomainIs(host, "collections.ic.gc.ca") +|| dnsDomainIs(host, "coloquio.com") +|| dnsDomainIs(host, "come.to") +|| dnsDomainIs(host, "coombs.anu.edu.au") +|| dnsDomainIs(host, "crafterscommunity.com") +|| dnsDomainIs(host, "craftsforkids.about.com") +|| dnsDomainIs(host, "creativity.net") +|| dnsDomainIs(host, "cslewis.drzeus.net") +|| dnsDomainIs(host, "cust.idl.com.au") +|| dnsDomainIs(host, "cvs.anu.edu.au") +|| dnsDomainIs(host, "cybersleuth-kids.com") +|| dnsDomainIs(host, "cybertown.com") +|| dnsDomainIs(host, "darkfish.com") +|| dnsDomainIs(host, "datadragon.com") +|| dnsDomainIs(host, "davesite.com") +|| dnsDomainIs(host, "dbertens.www.cistron.nl") +|| dnsDomainIs(host, "detnews.com") +|| dnsDomainIs(host, "dhr.dos.state.fl.us") +|| dnsDomainIs(host, "dialspace.dial.pipex.com") +|| dnsDomainIs(host, "dictionaries.travlang.com") +|| dnsDomainIs(host, "disney.go.com") +|| dnsDomainIs(host, "disneyland.disney.go.com") +|| dnsDomainIs(host, "district.gresham.k12.or.us") +|| dnsDomainIs(host, "dmarie.com") +|| dnsDomainIs(host, "dreamwater.com") +|| dnsDomainIs(host, "duke.fuse.net") +|| dnsDomainIs(host, "earlyamerica.com") +|| dnsDomainIs(host, "earthsky.com") +|| dnsDomainIs(host, "easyweb.easynet.co.uk") +|| dnsDomainIs(host, "ecards1.bansheeweb.com") +|| dnsDomainIs(host, "edugreen.teri.res.in") +|| dnsDomainIs(host, "edwardlear.tripod.com") +|| dnsDomainIs(host, "eelink.net") +|| dnsDomainIs(host, "elizabethsings.com") +|| dnsDomainIs(host, "enature.com") +|| dnsDomainIs(host, "encarta.msn.com") +|| dnsDomainIs(host, "endangeredspecie.com") +|| dnsDomainIs(host, "enterprise.america.com") +|| dnsDomainIs(host, "ericae.net") +|| dnsDomainIs(host, "esl.about.com") +|| dnsDomainIs(host, "eveander.com") +|| dnsDomainIs(host, "exn.ca") +|| dnsDomainIs(host, "fallscam.niagara.com") +|| dnsDomainIs(host, "family.go.com") +|| dnsDomainIs(host, "family2.go.com") +|| dnsDomainIs(host, "familyeducation.com") +|| dnsDomainIs(host, "finditquick.com") +|| dnsDomainIs(host, "fln-bma.yazigi.com.br") +|| dnsDomainIs(host, "fln-con.yazigi.com.br") +|| dnsDomainIs(host, "food.epicurious.com") +|| dnsDomainIs(host, "forums.sympatico.ca") +|| dnsDomainIs(host, "fotw.vexillum.com") +|| dnsDomainIs(host, "fox.nstn.ca") +|| dnsDomainIs(host, "framingham.com") +|| dnsDomainIs(host, "freevote.com") +|| dnsDomainIs(host, "freeweb.pdq.net") +|| dnsDomainIs(host, "games.yahoo.com") +|| dnsDomainIs(host, "gardening.sierrahome.com") +|| dnsDomainIs(host, "gardenofpraise.com") +|| dnsDomainIs(host, "gcclearn.gcc.cc.va.us") +|| dnsDomainIs(host, "genealogytoday.com") +|| dnsDomainIs(host, "genesis.ne.mediaone.net") +|| dnsDomainIs(host, "geniefind.com") +|| dnsDomainIs(host, "geography.about.com") +|| dnsDomainIs(host, "gf.state.wy.us") +|| dnsDomainIs(host, "gi.grolier.com") +|| dnsDomainIs(host, "golf.com") +|| dnsDomainIs(host, "greatseal.com") +|| dnsDomainIs(host, "guardians.net") +|| dnsDomainIs(host, "hamlet.hypermart.net") +|| dnsDomainIs(host, "happypuppy.com") +|| dnsDomainIs(host, "harcourt.fsc.follett.com") +|| dnsDomainIs(host, "haringkids.com") +|| dnsDomainIs(host, "harrietmaysavitz.com") +|| dnsDomainIs(host, "harrypotter.warnerbros.com") +|| dnsDomainIs(host, "hca.gilead.org.il") +|| dnsDomainIs(host, "header.future.easyspace.com") +|| dnsDomainIs(host, "historymedren.about.com") +|| dnsDomainIs(host, "home.att.net") +|| dnsDomainIs(host, "home.austin.rr.com") +|| dnsDomainIs(host, "home.capu.net") +|| dnsDomainIs(host, "home.cfl.rr.com") +|| dnsDomainIs(host, "home.clara.net") +|| dnsDomainIs(host, "home.clear.net.nz") +|| dnsDomainIs(host, "home.earthlink.net") +|| dnsDomainIs(host, "home.eznet.net") +|| dnsDomainIs(host, "home.flash.net") +|| dnsDomainIs(host, "home.hiwaay.net") +|| dnsDomainIs(host, "home.hkstar.com") +|| dnsDomainIs(host, "home.ici.net") +|| dnsDomainIs(host, "home.inreach.com") +|| dnsDomainIs(host, "home.interlynx.net") +|| dnsDomainIs(host, "home.istar.ca") +|| dnsDomainIs(host, "home.mira.net") +|| dnsDomainIs(host, "home.nycap.rr.com") +|| dnsDomainIs(host, "home.online.no") +|| dnsDomainIs(host, "home.pb.net") +|| dnsDomainIs(host, "home2.pacific.net.sg") +|| dnsDomainIs(host, "homearts.com") +|| dnsDomainIs(host, "homepage.mac.com") +|| dnsDomainIs(host, "hometown.aol.com") +|| dnsDomainIs(host, "homiliesbyemail.com") +|| dnsDomainIs(host, "hotei.fix.co.jp") +|| dnsDomainIs(host, "hotwired.lycos.com") +|| dnsDomainIs(host, "hp.vector.co.jp") +|| dnsDomainIs(host, "hum.amu.edu.pl") +|| dnsDomainIs(host, "i-cias.com") +|| dnsDomainIs(host, "icatapults.freeservers.com") +|| dnsDomainIs(host, "ind.cioe.com") +|| dnsDomainIs(host, "info.ex.ac.uk") +|| dnsDomainIs(host, "infocan.gc.ca") +|| dnsDomainIs(host, "infoservice.gc.ca") +|| dnsDomainIs(host, "interoz.com") +|| dnsDomainIs(host, "ireland.iol.ie") +|| dnsDomainIs(host, "is.dal.ca") +|| dnsDomainIs(host, "itss.raytheon.com") +|| dnsDomainIs(host, "iul.com") +|| dnsDomainIs(host, "jameswhitcombriley.com") +|| dnsDomainIs(host, "jellieszone.com") +|| dnsDomainIs(host, "jordan.sportsline.com") +|| dnsDomainIs(host, "judyanddavid.com") +|| dnsDomainIs(host, "jurai.murdoch.edu.au") +|| dnsDomainIs(host, "just.about.com") +|| dnsDomainIs(host, "kayleigh.tierranet.com") +|| dnsDomainIs(host, "kcwingwalker.tripod.com") +|| dnsDomainIs(host, "kidexchange.about.com") +|| dnsDomainIs(host, "kids-world.colgatepalmolive.com") +|| dnsDomainIs(host, "kids.mysterynet.com") +|| dnsDomainIs(host, "kids.ot.com") +|| dnsDomainIs(host, "kidsartscrafts.about.com") +|| dnsDomainIs(host, "kidsastronomy.about.com") +|| dnsDomainIs(host, "kidscience.about.com") +|| dnsDomainIs(host, "kidscience.miningco.com") +|| dnsDomainIs(host, "kidscollecting.about.com") +|| dnsDomainIs(host, "kidsfun.co.uk") +|| dnsDomainIs(host, "kidsinternet.about.com") +|| dnsDomainIs(host, "kidslangarts.about.com") +|| dnsDomainIs(host, "kidspenpals.about.com") +|| dnsDomainIs(host, "kitecast.com") +|| dnsDomainIs(host, "knight.city.ba.k12.md.us") +|| dnsDomainIs(host, "kodak.com") +|| dnsDomainIs(host, "kwanzaa4kids.homestead.com") +|| dnsDomainIs(host, "lagos.africaonline.com") +|| dnsDomainIs(host, "lancearmstrong.com") +|| dnsDomainIs(host, "landru.i-link-2.net") +|| dnsDomainIs(host, "lang.nagoya-u.ac.jp") +|| dnsDomainIs(host, "lascala.milano.it") +|| dnsDomainIs(host, "latinoculture.about.com") +|| dnsDomainIs(host, "litcal.yasuda-u.ac.jp") +|| dnsDomainIs(host, "littlebit.com") +|| dnsDomainIs(host, "live.edventures.com") +|| dnsDomainIs(host, "look.net") +|| dnsDomainIs(host, "lycoskids.infoplease.com") +|| dnsDomainIs(host, "lynx.uio.no") +|| dnsDomainIs(host, "macdict.dict.mq.edu.au") +|| dnsDomainIs(host, "maori.culture.co.nz") +|| dnsDomainIs(host, "marktwain.about.com") +|| dnsDomainIs(host, "marktwain.miningco.com") +|| dnsDomainIs(host, "mars2030.net") +|| dnsDomainIs(host, "martin.parasitology.mcgill.ca") +|| dnsDomainIs(host, "martinlutherking.8m.com") +|| dnsDomainIs(host, "mastercollector.com") +|| dnsDomainIs(host, "mathcentral.uregina.ca") +|| dnsDomainIs(host, "members.aol.com") +|| dnsDomainIs(host, "members.carol.net") +|| dnsDomainIs(host, "members.cland.net") +|| dnsDomainIs(host, "members.cruzio.com") +|| dnsDomainIs(host, "members.easyspace.com") +|| dnsDomainIs(host, "members.eisa.net.au") +|| dnsDomainIs(host, "members.home.net") +|| dnsDomainIs(host, "members.iinet.net.au") +|| dnsDomainIs(host, "members.nbci.com") +|| dnsDomainIs(host, "members.ozemail.com.au") +|| dnsDomainIs(host, "members.surfsouth.com") +|| dnsDomainIs(host, "members.theglobe.com") +|| dnsDomainIs(host, "members.tripod.com") +|| dnsDomainIs(host, "mexplaza.udg.mx") +|| dnsDomainIs(host, "mgfx.com") +|| dnsDomainIs(host, "microimg.com") +|| dnsDomainIs(host, "midusa.net") +|| dnsDomainIs(host, "mildan.com") +|| dnsDomainIs(host, "millennianet.com") +|| dnsDomainIs(host, "mindbreakers.e-fun.nu") +|| dnsDomainIs(host, "missjanet.xs4all.nl") +|| dnsDomainIs(host, "mistral.culture.fr") +|| dnsDomainIs(host, "mobileation.com") +|| dnsDomainIs(host, "mrshowbiz.go.com") +|| dnsDomainIs(host, "ms.simplenet.com") +|| dnsDomainIs(host, "museum.gov.ns.ca") +|| dnsDomainIs(host, "music.excite.com") +|| dnsDomainIs(host, "musicfinder.yahoo.com") +|| dnsDomainIs(host, "my.freeway.net") +|| dnsDomainIs(host, "mytrains.com") +|| dnsDomainIs(host, "nativeauthors.com") +|| dnsDomainIs(host, "nba.com") +|| dnsDomainIs(host, "nch.ari.net") +|| dnsDomainIs(host, "neonpeach.tripod.com") +|| dnsDomainIs(host, "net.indra.com") +|| dnsDomainIs(host, "ngeorgia.com") +|| dnsDomainIs(host, "ngp.ngpc.state.ne.us") +|| dnsDomainIs(host, "nhd.heinle.com") +|| dnsDomainIs(host, "nick.com") +|| dnsDomainIs(host, "normandy.eb.com") +|| dnsDomainIs(host, "northshore.shore.net") +|| dnsDomainIs(host, "now2000.com") +|| dnsDomainIs(host, "npc.nunavut.ca") +|| dnsDomainIs(host, "ns2.carib-link.net") +|| dnsDomainIs(host, "ntl.sympatico.ca") +|| dnsDomainIs(host, "oceanographer.navy.mil") +|| dnsDomainIs(host, "oddens.geog.uu.nl") +|| dnsDomainIs(host, "officialcitysites.com") +|| dnsDomainIs(host, "oneida-nation.net") +|| dnsDomainIs(host, "onlinegeorgia.com") +|| dnsDomainIs(host, "originator_2.tripod.com") +|| dnsDomainIs(host, "ortech-engr.com") +|| dnsDomainIs(host, "osage.voorhees.k12.nj.us") +|| dnsDomainIs(host, "osiris.sund.ac.uk") +|| dnsDomainIs(host, "ourworld.compuserve.com") +|| dnsDomainIs(host, "outdoorphoto.com") +|| dnsDomainIs(host, "pages.map.com") +|| dnsDomainIs(host, "pages.prodigy.com") +|| dnsDomainIs(host, "pages.prodigy.net") +|| dnsDomainIs(host, "pages.tca.net") +|| dnsDomainIs(host, "parcsafari.qc.ca") +|| dnsDomainIs(host, "parenthoodweb.com") +|| dnsDomainIs(host, "pathfinder.com") +|| dnsDomainIs(host, "people.clarityconnect.com") +|| dnsDomainIs(host, "people.enternet.com.au") +|| dnsDomainIs(host, "people.ne.mediaone.net") +|| dnsDomainIs(host, "phonics.jazzles.com") +|| dnsDomainIs(host, "pibburns.com") +|| dnsDomainIs(host, "pilgrims.net") +|| dnsDomainIs(host, "pinenet.com") +|| dnsDomainIs(host, "place.scholastic.com") +|| dnsDomainIs(host, "playground.kodak.com") +|| dnsDomainIs(host, "politicalgraveyard.com") +|| dnsDomainIs(host, "polk.ga.net") +|| dnsDomainIs(host, "pompstory.home.mindspring.com") +|| dnsDomainIs(host, "popularmechanics.com") +|| dnsDomainIs(host, "projects.edtech.sandi.net") +|| dnsDomainIs(host, "psyche.usno.navy.mil") +|| dnsDomainIs(host, "pubweb.parc.xerox.com") +|| dnsDomainIs(host, "puzzlemaker.school.discovery.com") +|| dnsDomainIs(host, "quest.classroom.com") +|| dnsDomainIs(host, "quilting.about.com") +|| dnsDomainIs(host, "rabbitmoon.home.mindspring.com") +|| dnsDomainIs(host, "radio.cbc.ca") +|| dnsDomainIs(host, "rats2u.com") +|| dnsDomainIs(host, "rbcm1.rbcm.gov.bc.ca") +|| dnsDomainIs(host, "readplay.com") +|| dnsDomainIs(host, "recipes4children.homestead.com") +|| dnsDomainIs(host, "redsox.com") +|| dnsDomainIs(host, "renaissance.district96.k12.il.us") +|| dnsDomainIs(host, "rhyme.lycos.com") +|| dnsDomainIs(host, "rhythmweb.com") +|| dnsDomainIs(host, "riverresource.com") +|| dnsDomainIs(host, "rockhoundingar.com") +|| dnsDomainIs(host, "rockies.mlb.com") +|| dnsDomainIs(host, "rosecity.net") +|| dnsDomainIs(host, "rr-vs.informatik.uni-ulm.de") +|| dnsDomainIs(host, "rubens.anu.edu.au") +|| dnsDomainIs(host, "rummelplatz.uni-mannheim.de") +|| dnsDomainIs(host, "sandbox.xerox.com") +|| dnsDomainIs(host, "sarah.fredart.com") +|| dnsDomainIs(host, "schmidel.com") +|| dnsDomainIs(host, "scholastic.com") +|| dnsDomainIs(host, "school.discovery.com") +|| dnsDomainIs(host, "schoolcentral.com") +|| dnsDomainIs(host, "seattletimes.nwsource.com") +|| dnsDomainIs(host, "sericulum.com") +|| dnsDomainIs(host, "sf.airforce.com") +|| dnsDomainIs(host, "shop.usps.com") +|| dnsDomainIs(host, "showcase.netins.net") +|| dnsDomainIs(host, "sikids.com") +|| dnsDomainIs(host, "sites.huji.ac.il") +|| dnsDomainIs(host, "sjliving.com") +|| dnsDomainIs(host, "skullduggery.com") +|| dnsDomainIs(host, "skyways.lib.ks.us") +|| dnsDomainIs(host, "snowdaymovie.nick.com") +|| dnsDomainIs(host, "sosa21.hypermart.net") +|| dnsDomainIs(host, "soundamerica.com") +|| dnsDomainIs(host, "spaceboy.nasda.go.jp") +|| dnsDomainIs(host, "sports.nfl.com") +|| dnsDomainIs(host, "sportsillustrated.cnn.com") +|| dnsDomainIs(host, "starwars.hasbro.com") +|| dnsDomainIs(host, "statelibrary.dcr.state.nc.us") +|| dnsDomainIs(host, "streetplay.com") +|| dnsDomainIs(host, "sts.gsc.nrcan.gc.ca") +|| dnsDomainIs(host, "sunniebunniezz.com") +|| dnsDomainIs(host, "sunsite.nus.edu.sg") +|| dnsDomainIs(host, "sunsite.sut.ac.jp") +|| dnsDomainIs(host, "superm.bart.nl") +|| dnsDomainIs(host, "surf.to") +|| dnsDomainIs(host, "svinet2.fs.fed.us") +|| dnsDomainIs(host, "swiminfo.com") +|| dnsDomainIs(host, "tabletennis.about.com") +|| dnsDomainIs(host, "teacher.scholastic.com") +|| dnsDomainIs(host, "theforce.net") +|| dnsDomainIs(host, "thejessicas.homestead.com") +|| dnsDomainIs(host, "themes.editthispage.com") +|| dnsDomainIs(host, "theory.uwinnipeg.ca") +|| dnsDomainIs(host, "theshadowlands.net") +|| dnsDomainIs(host, "thinks.com") +|| dnsDomainIs(host, "thryomanes.tripod.com") +|| dnsDomainIs(host, "time_zone.tripod.com") +|| dnsDomainIs(host, "titania.cobuild.collins.co.uk") +|| dnsDomainIs(host, "torre.duomo.pisa.it") +|| dnsDomainIs(host, "touregypt.net") +|| dnsDomainIs(host, "toycollecting.about.com") +|| dnsDomainIs(host, "trace.ntu.ac.uk") +|| dnsDomainIs(host, "travelwithkids.about.com") +|| dnsDomainIs(host, "tukids.tucows.com") +|| dnsDomainIs(host, "tv.yahoo.com") +|| dnsDomainIs(host, "tycho.usno.navy.mil") +|| dnsDomainIs(host, "ubl.artistdirect.com") +|| dnsDomainIs(host, "uk-pages.net") +|| dnsDomainIs(host, "ukraine.uazone.net") +|| dnsDomainIs(host, "unmuseum.mus.pa.us") +|| dnsDomainIs(host, "us.imdb.com") +|| dnsDomainIs(host, "userpage.chemie.fu-berlin.de") +|| dnsDomainIs(host, "userpage.fu-berlin.de") +|| dnsDomainIs(host, "userpages.aug.com") +|| dnsDomainIs(host, "users.aol.com") +|| dnsDomainIs(host, "users.bigpond.net.au") +|| dnsDomainIs(host, "users.breathemail.net") +|| dnsDomainIs(host, "users.erols.com") +|| dnsDomainIs(host, "users.imag.net") +|| dnsDomainIs(host, "users.inetw.net") +|| dnsDomainIs(host, "users.massed.net") +|| dnsDomainIs(host, "users.skynet.be") +|| dnsDomainIs(host, "users.uniserve.com") +|| dnsDomainIs(host, "venus.spaceports.com") +|| dnsDomainIs(host, "vgstrategies.about.com") +|| dnsDomainIs(host, "victorian.fortunecity.com") +|| dnsDomainIs(host, "vilenski.com") +|| dnsDomainIs(host, "village.infoweb.ne.jp") +|| dnsDomainIs(host, "virtual.finland.fi") +|| dnsDomainIs(host, "vrml.fornax.hu") +|| dnsDomainIs(host, "vvv.com") +|| dnsDomainIs(host, "w1.xrefer.com") +|| dnsDomainIs(host, "w3.one.net") +|| dnsDomainIs(host, "w3.rz-berlin.mpg.de") +|| dnsDomainIs(host, "w3.trib.com") +|| dnsDomainIs(host, "wallofsound.go.com") +|| dnsDomainIs(host, "web.aimnet.com") +|| dnsDomainIs(host, "web.ccsd.k12.wy.us") +|| dnsDomainIs(host, "web.cs.ualberta.ca") +|| dnsDomainIs(host, "web.idirect.com") +|| dnsDomainIs(host, "web.kyoto-inet.or.jp") +|| dnsDomainIs(host, "web.macam98.ac.il") +|| dnsDomainIs(host, "web.massvacation.com") +|| dnsDomainIs(host, "web.one.net.au") +|| dnsDomainIs(host, "web.qx.net") +|| dnsDomainIs(host, "web.uvic.ca") +|| dnsDomainIs(host, "web2.airmail.net") +|| dnsDomainIs(host, "webcoast.com") +|| dnsDomainIs(host, "webgames.kalisto.com") +|| dnsDomainIs(host, "webhome.idirect.com") +|| dnsDomainIs(host, "webpages.homestead.com") +|| dnsDomainIs(host, "webrum.uni-mannheim.de") +|| dnsDomainIs(host, "webusers.anet-stl.com") +|| dnsDomainIs(host, "welcome.to") +|| dnsDomainIs(host, "wgntv.com") +|| dnsDomainIs(host, "whales.magna.com.au") +|| dnsDomainIs(host, "wildheart.com") +|| dnsDomainIs(host, "wilstar.net") +|| dnsDomainIs(host, "winter-wonderland.com") +|| dnsDomainIs(host, "women.com") +|| dnsDomainIs(host, "woodrow.mpls.frb.fed.us") +|| dnsDomainIs(host, "wordzap.com") +|| dnsDomainIs(host, "worldkids.net") +|| dnsDomainIs(host, "worldwideguide.net") +|| dnsDomainIs(host, "ww3.bay.k12.fl.us") +|| dnsDomainIs(host, "ww3.sportsline.com") +|| dnsDomainIs(host, "www-groups.dcs.st-and.ac.uk") +|| dnsDomainIs(host, "www-public.rz.uni-duesseldorf.de") +|| dnsDomainIs(host, "www.1stkids.com") +|| dnsDomainIs(host, "www.2020tech.com") +|| dnsDomainIs(host, "www.21stcenturytoys.com") +|| dnsDomainIs(host, "www.4adventure.com") +|| dnsDomainIs(host, "www.50states.com") +|| dnsDomainIs(host, "www.800padutch.com") +|| dnsDomainIs(host, "www.88.com") +|| dnsDomainIs(host, "www.a-better.com") +|| dnsDomainIs(host, "www.aaa.com.au") +|| dnsDomainIs(host, "www.aacca.com") +|| dnsDomainIs(host, "www.aalbc.com") +|| dnsDomainIs(host, "www.aardman.com") +|| dnsDomainIs(host, "www.aardvarkelectric.com") +|| dnsDomainIs(host, "www.aawc.com") +|| dnsDomainIs(host, "www.ababmx.com") +|| dnsDomainIs(host, "www.abbeville.com") +|| dnsDomainIs(host, "www.abc.net.au") +|| dnsDomainIs(host, "www.abcb.com") +|| dnsDomainIs(host, "www.abctooncenter.com") +|| dnsDomainIs(host, "www.about.ch") +|| dnsDomainIs(host, "www.accessart.org.uk") +|| dnsDomainIs(host, "www.accu.or.jp") +|| dnsDomainIs(host, "www.accuweather.com") +|| dnsDomainIs(host, "www.achuka.co.uk") +|| dnsDomainIs(host, "www.acmecity.com") +|| dnsDomainIs(host, "www.acorn-group.com") +|| dnsDomainIs(host, "www.acs.ucalgary.ca") +|| dnsDomainIs(host, "www.actden.com") +|| dnsDomainIs(host, "www.actionplanet.com") +|| dnsDomainIs(host, "www.activityvillage.co.uk") +|| dnsDomainIs(host, "www.actwin.com") +|| dnsDomainIs(host, "www.adequate.com") +|| dnsDomainIs(host, "www.adidas.com") +|| dnsDomainIs(host, "www.advent-calendars.com") +|| dnsDomainIs(host, "www.aegis.com") +|| dnsDomainIs(host, "www.af.mil") +|| dnsDomainIs(host, "www.africaindex.africainfo.no") +|| dnsDomainIs(host, "www.africam.com") +|| dnsDomainIs(host, "www.africancrafts.com") +|| dnsDomainIs(host, "www.aggressive.com") +|| dnsDomainIs(host, "www.aghines.com") +|| dnsDomainIs(host, "www.agirlsworld.com") +|| dnsDomainIs(host, "www.agora.stm.it") +|| dnsDomainIs(host, "www.agriculture.com") +|| dnsDomainIs(host, "www.aikidofaq.com") +|| dnsDomainIs(host, "www.ajkids.com") +|| dnsDomainIs(host, "www.akfkoala.gil.com.au") +|| dnsDomainIs(host, "www.akhlah.com") +|| dnsDomainIs(host, "www.alabamainfo.com") +|| dnsDomainIs(host, "www.aland.fi") +|| dnsDomainIs(host, "www.albion.com") +|| dnsDomainIs(host, "www.alcoholismhelp.com") +|| dnsDomainIs(host, "www.alcottweb.com") +|| dnsDomainIs(host, "www.alfanet.it") +|| dnsDomainIs(host, "www.alfy.com") +|| dnsDomainIs(host, "www.algebra-online.com") +|| dnsDomainIs(host, "www.alienexplorer.com") +|| dnsDomainIs(host, "www.aliensatschool.com") +|| dnsDomainIs(host, "www.all-links.com") +|| dnsDomainIs(host, "www.alldetroit.com") +|| dnsDomainIs(host, "www.allexperts.com") +|| dnsDomainIs(host, "www.allmixedup.com") +|| dnsDomainIs(host, "www.allmusic.com") +|| dnsDomainIs(host, "www.almanac.com") +|| dnsDomainIs(host, "www.almaz.com") +|| dnsDomainIs(host, "www.almondseed.com") +|| dnsDomainIs(host, "www.aloha.com") +|| dnsDomainIs(host, "www.aloha.net") +|| dnsDomainIs(host, "www.altonweb.com") +|| dnsDomainIs(host, "www.alyeska-pipe.com") +|| dnsDomainIs(host, "www.am-wood.com") +|| dnsDomainIs(host, "www.amazingadventure.com") +|| dnsDomainIs(host, "www.amazon.com") +|| dnsDomainIs(host, "www.americancheerleader.com") +|| dnsDomainIs(host, "www.americancowboy.com") +|| dnsDomainIs(host, "www.americangirl.com") +|| dnsDomainIs(host, "www.americanparknetwork.com") +|| dnsDomainIs(host, "www.americansouthwest.net") +|| dnsDomainIs(host, "www.americanwest.com") +|| dnsDomainIs(host, "www.ameritech.net") +|| dnsDomainIs(host, "www.amtexpo.com") +|| dnsDomainIs(host, "www.anbg.gov.au") +|| dnsDomainIs(host, "www.anc.org.za") +|| dnsDomainIs(host, "www.ancientegypt.co.uk") +|| dnsDomainIs(host, "www.angelfire.com") +|| dnsDomainIs(host, "www.angelsbaseball.com") +|| dnsDomainIs(host, "www.anholt.co.uk") +|| dnsDomainIs(host, "www.animabets.com") +|| dnsDomainIs(host, "www.animalnetwork.com") +|| dnsDomainIs(host, "www.animalpicturesarchive.com") +|| dnsDomainIs(host, "www.anime-genesis.com") +|| dnsDomainIs(host, "www.annefrank.com") +|| dnsDomainIs(host, "www.annefrank.nl") +|| dnsDomainIs(host, "www.annie75.com") +|| dnsDomainIs(host, "www.antbee.com") +|| dnsDomainIs(host, "www.antiquetools.com") +|| dnsDomainIs(host, "www.antiquetoy.com") +|| dnsDomainIs(host, "www.anzsbeg.org.au") +|| dnsDomainIs(host, "www.aol.com") +|| dnsDomainIs(host, "www.aone.com") +|| dnsDomainIs(host, "www.aphids.com") +|| dnsDomainIs(host, "www.apl.com") +|| dnsDomainIs(host, "www.aplusmath.com") +|| dnsDomainIs(host, "www.applebookshop.co.uk") +|| dnsDomainIs(host, "www.appropriatesoftware.com") +|| dnsDomainIs(host, "www.appukids.com") +|| dnsDomainIs(host, "www.april-joy.com") +|| dnsDomainIs(host, "www.arab.net") +|| dnsDomainIs(host, "www.aracnet.com") +|| dnsDomainIs(host, "www.arborday.com") +|| dnsDomainIs(host, "www.arcadevillage.com") +|| dnsDomainIs(host, "www.archiecomics.com") +|| dnsDomainIs(host, "www.archives.state.al.us") +|| dnsDomainIs(host, "www.arctic.ca") +|| dnsDomainIs(host, "www.ardenjohnson.com") +|| dnsDomainIs(host, "www.aristotle.net") +|| dnsDomainIs(host, "www.arizhwys.com") +|| dnsDomainIs(host, "www.arizonaguide.com") +|| dnsDomainIs(host, "www.arlingtoncemetery.com") +|| dnsDomainIs(host, "www.armory.com") +|| dnsDomainIs(host, "www.armwrestling.com") +|| dnsDomainIs(host, "www.arnprior.com") +|| dnsDomainIs(host, "www.artabunga.com") +|| dnsDomainIs(host, "www.artcarte.com") +|| dnsDomainIs(host, "www.artchive.com") +|| dnsDomainIs(host, "www.artcontest.com") +|| dnsDomainIs(host, "www.artcyclopedia.com") +|| dnsDomainIs(host, "www.artisandevelopers.com") +|| dnsDomainIs(host, "www.artlex.com") +|| dnsDomainIs(host, "www.artsandkids.com") +|| dnsDomainIs(host, "www.artyastro.com") +|| dnsDomainIs(host, "www.arwhead.com") +|| dnsDomainIs(host, "www.asahi-net.or.jp") +|| dnsDomainIs(host, "www.asap.unimelb.edu.au") +|| dnsDomainIs(host, "www.ascpl.lib.oh.us") +|| dnsDomainIs(host, "www.asia-art.net") +|| dnsDomainIs(host, "www.asiabigtime.com") +|| dnsDomainIs(host, "www.asianart.com") +|| dnsDomainIs(host, "www.asiatour.com") +|| dnsDomainIs(host, "www.asiaweek.com") +|| dnsDomainIs(host, "www.askanexpert.com") +|| dnsDomainIs(host, "www.askbasil.com") +|| dnsDomainIs(host, "www.assa.org.au") +|| dnsDomainIs(host, "www.ast.cam.ac.uk") +|| dnsDomainIs(host, "www.astronomy.com") +|| dnsDomainIs(host, "www.astros.com") +|| dnsDomainIs(host, "www.atek.com") +|| dnsDomainIs(host, "www.athlete.com") +|| dnsDomainIs(host, "www.athropolis.com") +|| dnsDomainIs(host, "www.atkielski.com") +|| dnsDomainIs(host, "www.atlantabraves.com") +|| dnsDomainIs(host, "www.atlantafalcons.com") +|| dnsDomainIs(host, "www.atlantathrashers.com") +|| dnsDomainIs(host, "www.atlanticus.com") +|| dnsDomainIs(host, "www.atm.ch.cam.ac.uk") +|| dnsDomainIs(host, "www.atom.co.jp") +|| dnsDomainIs(host, "www.atomicarchive.com") +|| dnsDomainIs(host, "www.att.com") +|| dnsDomainIs(host, "www.audreywood.com") +|| dnsDomainIs(host, "www.auntannie.com") +|| dnsDomainIs(host, "www.auntie.com") +|| dnsDomainIs(host, "www.avi-writer.com") +|| dnsDomainIs(host, "www.awesomeclipartforkids.com") +|| dnsDomainIs(host, "www.awhitehorse.com") +|| dnsDomainIs(host, "www.axess.com") +|| dnsDomainIs(host, "www.ayles.com") +|| dnsDomainIs(host, "www.ayn.ca") +|| dnsDomainIs(host, "www.azcardinals.com") +|| dnsDomainIs(host, "www.azdiamondbacks.com") +|| dnsDomainIs(host, "www.azsolarcenter.com") +|| dnsDomainIs(host, "www.azstarnet.com") +|| dnsDomainIs(host, "www.aztecafoods.com") +|| dnsDomainIs(host, "www.b-witched.com") +|| dnsDomainIs(host, "www.baberuthmuseum.com") +|| dnsDomainIs(host, "www.backstreetboys.com") +|| dnsDomainIs(host, "www.bagheera.com") +|| dnsDomainIs(host, "www.bahamas.com") +|| dnsDomainIs(host, "www.baileykids.com") +|| dnsDomainIs(host, "www.baldeagleinfo.com") +|| dnsDomainIs(host, "www.balloonhq.com") +|| dnsDomainIs(host, "www.balloonzone.com") +|| dnsDomainIs(host, "www.ballparks.com") +|| dnsDomainIs(host, "www.balmoralsoftware.com") +|| dnsDomainIs(host, "www.banja.com") +|| dnsDomainIs(host, "www.banph.com") +|| dnsDomainIs(host, "www.barbie.com") +|| dnsDomainIs(host, "www.barkingbuddies.com") +|| dnsDomainIs(host, "www.barnsdle.demon.co.uk") +|| dnsDomainIs(host, "www.barrysclipart.com") +|| dnsDomainIs(host, "www.bartleby.com") +|| dnsDomainIs(host, "www.baseplate.com") +|| dnsDomainIs(host, "www.batman-superman.com") +|| dnsDomainIs(host, "www.batmanbeyond.com") +|| dnsDomainIs(host, "www.bbc.co.uk") +|| dnsDomainIs(host, "www.bbhighway.com") +|| dnsDomainIs(host, "www.bboy.com") +|| dnsDomainIs(host, "www.bcit.tec.nj.us") +|| dnsDomainIs(host, "www.bconnex.net") +|| dnsDomainIs(host, "www.bcpl.net") +|| dnsDomainIs(host, "www.beach-net.com") +|| dnsDomainIs(host, "www.beachboys.com") +|| dnsDomainIs(host, "www.beakman.com") +|| dnsDomainIs(host, "www.beano.co.uk") +|| dnsDomainIs(host, "www.beans.demon.co.uk") +|| dnsDomainIs(host, "www.beartime.com") +|| dnsDomainIs(host, "www.bearyspecial.co.uk") +|| dnsDomainIs(host, "www.bedtime.com") +|| dnsDomainIs(host, "www.beingme.com") +|| dnsDomainIs(host, "www.belizeexplorer.com") +|| dnsDomainIs(host, "www.bell-labs.com") +|| dnsDomainIs(host, "www.bemorecreative.com") +|| dnsDomainIs(host, "www.bengals.com") +|| dnsDomainIs(host, "www.benjerry.com") +|| dnsDomainIs(host, "www.bennygoodsport.com") +|| dnsDomainIs(host, "www.berenstainbears.com") +|| dnsDomainIs(host, "www.beringia.com") +|| dnsDomainIs(host, "www.beritsbest.com") +|| dnsDomainIs(host, "www.berksweb.com") +|| dnsDomainIs(host, "www.best.com") +|| dnsDomainIs(host, "www.betsybyars.com") +|| dnsDomainIs(host, "www.bfro.net") +|| dnsDomainIs(host, "www.bgmm.com") +|| dnsDomainIs(host, "www.bibliography.com") +|| dnsDomainIs(host, "www.bigblue.com.au") +|| dnsDomainIs(host, "www.bigchalk.com") +|| dnsDomainIs(host, "www.bigidea.com") +|| dnsDomainIs(host, "www.bigtop.com") +|| dnsDomainIs(host, "www.bikecrawler.com") +|| dnsDomainIs(host, "www.billboard.com") +|| dnsDomainIs(host, "www.billybear4kids.com") +|| dnsDomainIs(host, "www.biography.com") +|| dnsDomainIs(host, "www.birdnature.com") +|| dnsDomainIs(host, "www.birdsnways.com") +|| dnsDomainIs(host, "www.birdtimes.com") +|| dnsDomainIs(host, "www.birminghamzoo.com") +|| dnsDomainIs(host, "www.birthdaypartyideas.com") +|| dnsDomainIs(host, "www.bis.arachsys.com") +|| dnsDomainIs(host, "www.bkgm.com") +|| dnsDomainIs(host, "www.blackbaseball.com") +|| dnsDomainIs(host, "www.blackbeardthepirate.com") +|| dnsDomainIs(host, "www.blackbeltmag.com") +|| dnsDomainIs(host, "www.blackfacts.com") +|| dnsDomainIs(host, "www.blackfeetnation.com") +|| dnsDomainIs(host, "www.blackhills-info.com") +|| dnsDomainIs(host, "www.blackholegang.com") +|| dnsDomainIs(host, "www.blaque.net") +|| dnsDomainIs(host, "www.blarg.net") +|| dnsDomainIs(host, "www.blasternaut.com") +|| dnsDomainIs(host, "www.blizzard.com") +|| dnsDomainIs(host, "www.blocksite.com") +|| dnsDomainIs(host, "www.bluejackets.com") +|| dnsDomainIs(host, "www.bluejays.ca") +|| dnsDomainIs(host, "www.bluemountain.com") +|| dnsDomainIs(host, "www.blupete.com") +|| dnsDomainIs(host, "www.blyton.co.uk") +|| dnsDomainIs(host, "www.boatnerd.com") +|| dnsDomainIs(host, "www.boatsafe.com") +|| dnsDomainIs(host, "www.bonus.com") +|| dnsDomainIs(host, "www.boowakwala.com") +|| dnsDomainIs(host, "www.bostonbruins.com") +|| dnsDomainIs(host, "www.braceface.com") +|| dnsDomainIs(host, "www.bracesinfo.com") +|| dnsDomainIs(host, "www.bradkent.com") +|| dnsDomainIs(host, "www.brainium.com") +|| dnsDomainIs(host, "www.brainmania.com") +|| dnsDomainIs(host, "www.brainpop.com") +|| dnsDomainIs(host, "www.bridalcave.com") +|| dnsDomainIs(host, "www.brightmoments.com") +|| dnsDomainIs(host, "www.britannia.com") +|| dnsDomainIs(host, "www.britannica.com") +|| dnsDomainIs(host, "www.british-museum.ac.uk") +|| dnsDomainIs(host, "www.brookes.ac.uk") +|| dnsDomainIs(host, "www.brookfieldreader.com") +|| dnsDomainIs(host, "www.btinternet.com") +|| dnsDomainIs(host, "www.bubbledome.co.nz") +|| dnsDomainIs(host, "www.buccaneers.com") +|| dnsDomainIs(host, "www.buffy.com") +|| dnsDomainIs(host, "www.bullying.co.uk") +|| dnsDomainIs(host, "www.bumply.com") +|| dnsDomainIs(host, "www.bungi.com") +|| dnsDomainIs(host, "www.burlco.lib.nj.us") +|| dnsDomainIs(host, "www.burlingamepezmuseum.com") +|| dnsDomainIs(host, "www.bus.ualberta.ca") +|| dnsDomainIs(host, "www.busprod.com") +|| dnsDomainIs(host, "www.butlerart.com") +|| dnsDomainIs(host, "www.butterflies.com") +|| dnsDomainIs(host, "www.butterflyfarm.co.cr") +|| dnsDomainIs(host, "www.bway.net") +|| dnsDomainIs(host, "www.bydonovan.com") +|| dnsDomainIs(host, "www.ca-mall.com") +|| dnsDomainIs(host, "www.cabinessence.com") +|| dnsDomainIs(host, "www.cablecarmuseum.com") +|| dnsDomainIs(host, "www.cadbury.co.uk") +|| dnsDomainIs(host, "www.calendarzone.com") +|| dnsDomainIs(host, "www.calgaryflames.com") +|| dnsDomainIs(host, "www.californiamissions.com") +|| dnsDomainIs(host, "www.camalott.com") +|| dnsDomainIs(host, "www.camelotintl.com") +|| dnsDomainIs(host, "www.campbellsoup.com") +|| dnsDomainIs(host, "www.camvista.com") +|| dnsDomainIs(host, "www.canadiens.com") +|| dnsDomainIs(host, "www.canals.state.ny.us") +|| dnsDomainIs(host, "www.candlelightstories.com") +|| dnsDomainIs(host, "www.candles-museum.com") +|| dnsDomainIs(host, "www.candystand.com") +|| dnsDomainIs(host, "www.caneshockey.com") +|| dnsDomainIs(host, "www.canismajor.com") +|| dnsDomainIs(host, "www.canucks.com") +|| dnsDomainIs(host, "www.capecod.net") +|| dnsDomainIs(host, "www.capital.net") +|| dnsDomainIs(host, "www.capstonestudio.com") +|| dnsDomainIs(host, "www.cardblvd.com") +|| dnsDomainIs(host, "www.caro.net") +|| dnsDomainIs(host, "www.carolhurst.com") +|| dnsDomainIs(host, "www.carr.lib.md.us") +|| dnsDomainIs(host, "www.cartooncorner.com") +|| dnsDomainIs(host, "www.cartooncritters.com") +|| dnsDomainIs(host, "www.cartoonnetwork.com") +|| dnsDomainIs(host, "www.carvingpatterns.com") +|| dnsDomainIs(host, "www.cashuniversity.com") +|| dnsDomainIs(host, "www.castles-of-britain.com") +|| dnsDomainIs(host, "www.castlewales.com") +|| dnsDomainIs(host, "www.catholic-forum.com") +|| dnsDomainIs(host, "www.catholic.net") +|| dnsDomainIs(host, "www.cattle.guelph.on.ca") +|| dnsDomainIs(host, "www.cavedive.com") +|| dnsDomainIs(host, "www.caveofthewinds.com") +|| dnsDomainIs(host, "www.cbc4kids.ca") +|| dnsDomainIs(host, "www.ccer.ggl.ruu.nl") +|| dnsDomainIs(host, "www.ccnet.com") +|| dnsDomainIs(host, "www.celineonline.com") +|| dnsDomainIs(host, "www.cellsalive.com") +|| dnsDomainIs(host, "www.centuryinshoes.com") +|| dnsDomainIs(host, "www.cfl.ca") +|| dnsDomainIs(host, "www.channel4.com") +|| dnsDomainIs(host, "www.channel8.net") +|| dnsDomainIs(host, "www.chanukah99.com") +|| dnsDomainIs(host, "www.charged.com") +|| dnsDomainIs(host, "www.chargers.com") +|| dnsDomainIs(host, "www.charlotte.com") +|| dnsDomainIs(host, "www.chaseday.com") +|| dnsDomainIs(host, "www.chateauversailles.fr") +|| dnsDomainIs(host, "www.cheatcc.com") +|| dnsDomainIs(host, "www.cheerleading.net") +|| dnsDomainIs(host, "www.cheese.com") +|| dnsDomainIs(host, "www.chem4kids.com") +|| dnsDomainIs(host, "www.chemicool.com") +|| dnsDomainIs(host, "www.cherbearsden.com") +|| dnsDomainIs(host, "www.chesskids.com") +|| dnsDomainIs(host, "www.chessvariants.com") +|| dnsDomainIs(host, "www.cheungswingchun.com") +|| dnsDomainIs(host, "www.chevroncars.com") +|| dnsDomainIs(host, "www.chibi.simplenet.com") +|| dnsDomainIs(host, "www.chicagobears.com") +|| dnsDomainIs(host, "www.chicagoblackhawks.com") +|| dnsDomainIs(host, "www.chickasaw.net") +|| dnsDomainIs(host, "www.childrensmusic.co.uk") +|| dnsDomainIs(host, "www.childrenssoftware.com") +|| dnsDomainIs(host, "www.childrenstory.com") +|| dnsDomainIs(host, "www.childrenwithdiabetes.com") +|| dnsDomainIs(host, "www.chinapage.com") +|| dnsDomainIs(host, "www.chinatoday.com") +|| dnsDomainIs(host, "www.chinavista.com") +|| dnsDomainIs(host, "www.chinnet.net") +|| dnsDomainIs(host, "www.chiquita.com") +|| dnsDomainIs(host, "www.chisox.com") +|| dnsDomainIs(host, "www.chivalry.com") +|| dnsDomainIs(host, "www.christiananswers.net") +|| dnsDomainIs(host, "www.christianity.com") +|| dnsDomainIs(host, "www.christmas.com") +|| dnsDomainIs(host, "www.christmas98.com") +|| dnsDomainIs(host, "www.chron.com") +|| dnsDomainIs(host, "www.chronique.com") +|| dnsDomainIs(host, "www.chuckecheese.com") +|| dnsDomainIs(host, "www.chucklebait.com") +|| dnsDomainIs(host, "www.chunkymonkey.com") +|| dnsDomainIs(host, "www.ci.chi.il.us") +|| dnsDomainIs(host, "www.ci.nyc.ny.us") +|| dnsDomainIs(host, "www.ci.phoenix.az.us") +|| dnsDomainIs(host, "www.ci.san-diego.ca.us") +|| dnsDomainIs(host, "www.cibc.com") +|| dnsDomainIs(host, "www.ciderpresspottery.com") +|| dnsDomainIs(host, "www.cincinnatireds.com") +|| dnsDomainIs(host, "www.circusparade.com") +|| dnsDomainIs(host, "www.circusweb.com") +|| dnsDomainIs(host, "www.cirquedusoleil.com") +|| dnsDomainIs(host, "www.cit.state.vt.us") +|| dnsDomainIs(host, "www.citycastles.com") +|| dnsDomainIs(host, "www.cityu.edu.hk") +|| dnsDomainIs(host, "www.civicmind.com") +|| dnsDomainIs(host, "www.civil-war.net") +|| dnsDomainIs(host, "www.civilization.ca") +|| dnsDomainIs(host, "www.cl.cam.ac.uk") +|| dnsDomainIs(host, "www.clantongang.com") +|| dnsDomainIs(host, "www.clark.net") +|| dnsDomainIs(host, "www.classicgaming.com") +|| dnsDomainIs(host, "www.claus.com") +|| dnsDomainIs(host, "www.clayz.com") +|| dnsDomainIs(host, "www.clearcf.uvic.ca") +|| dnsDomainIs(host, "www.clearlight.com") +|| dnsDomainIs(host, "www.clemusart.com") +|| dnsDomainIs(host, "www.clevelandbrowns.com") +|| dnsDomainIs(host, "www.clipartcastle.com") +|| dnsDomainIs(host, "www.clubi.ie") +|| dnsDomainIs(host, "www.cnn.com") +|| dnsDomainIs(host, "www.co.henrico.va.us") +|| dnsDomainIs(host, "www.coax.net") +|| dnsDomainIs(host, "www.cocacola.com") +|| dnsDomainIs(host, "www.cocori.com") +|| dnsDomainIs(host, "www.codesmiths.com") +|| dnsDomainIs(host, "www.codetalk.fed.us") +|| dnsDomainIs(host, "www.coin-gallery.com") +|| dnsDomainIs(host, "www.colinthompson.com") +|| dnsDomainIs(host, "www.collectoronline.com") +|| dnsDomainIs(host, "www.colonialhall.com") +|| dnsDomainIs(host, "www.coloradoavalanche.com") +|| dnsDomainIs(host, "www.coloradorockies.com") +|| dnsDomainIs(host, "www.colormathpink.com") +|| dnsDomainIs(host, "www.colts.com") +|| dnsDomainIs(host, "www.comet.net") +|| dnsDomainIs(host, "www.cometsystems.com") +|| dnsDomainIs(host, "www.comicbookresources.com") +|| dnsDomainIs(host, "www.comicspage.com") +|| dnsDomainIs(host, "www.compassnet.com") +|| dnsDomainIs(host, "www.compleatbellairs.com") +|| dnsDomainIs(host, "www.comptons.com") +|| dnsDomainIs(host, "www.concentric.net") +|| dnsDomainIs(host, "www.congogorillaforest.com") +|| dnsDomainIs(host, "www.conjuror.com") +|| dnsDomainIs(host, "www.conk.com") +|| dnsDomainIs(host, "www.conservation.state.mo.us") +|| dnsDomainIs(host, "www.contracostatimes.com") +|| dnsDomainIs(host, "www.control.chalmers.se") +|| dnsDomainIs(host, "www.cookierecipe.com") +|| dnsDomainIs(host, "www.cooljapanesetoys.com") +|| dnsDomainIs(host, "www.cooper.com") +|| dnsDomainIs(host, "www.corpcomm.net") +|| dnsDomainIs(host, "www.corrietenboom.com") +|| dnsDomainIs(host, "www.corynet.com") +|| dnsDomainIs(host, "www.corypaints.com") +|| dnsDomainIs(host, "www.cosmosmith.com") +|| dnsDomainIs(host, "www.countdown2000.com") +|| dnsDomainIs(host, "www.cowboy.net") +|| dnsDomainIs(host, "www.cowboypal.com") +|| dnsDomainIs(host, "www.cowcreek.com") +|| dnsDomainIs(host, "www.cowgirl.net") +|| dnsDomainIs(host, "www.cowgirls.com") +|| dnsDomainIs(host, "www.cp.duluth.mn.us") +|| dnsDomainIs(host, "www.cpsweb.com") +|| dnsDomainIs(host, "www.craftideas.com") +|| dnsDomainIs(host, "www.craniamania.com") +|| dnsDomainIs(host, "www.crater.lake.national-park.com") +|| dnsDomainIs(host, "www.crayoncrawler.com") +|| dnsDomainIs(host, "www.crazybone.com") +|| dnsDomainIs(host, "www.crazybones.com") +|| dnsDomainIs(host, "www.crd.ge.com") +|| dnsDomainIs(host, "www.create4kids.com") +|| dnsDomainIs(host, "www.creativemusic.com") +|| dnsDomainIs(host, "www.crocodilian.com") +|| dnsDomainIs(host, "www.crop.cri.nz") +|| dnsDomainIs(host, "www.cruzio.com") +|| dnsDomainIs(host, "www.crwflags.com") +|| dnsDomainIs(host, "www.cryptograph.com") +|| dnsDomainIs(host, "www.cryst.bbk.ac.uk") +|| dnsDomainIs(host, "www.cs.bilkent.edu.tr") +|| dnsDomainIs(host, "www.cs.man.ac.uk") +|| dnsDomainIs(host, "www.cs.sfu.ca") +|| dnsDomainIs(host, "www.cs.ubc.ca") +|| dnsDomainIs(host, "www.csd.uu.se") +|| dnsDomainIs(host, "www.csmonitor.com") +|| dnsDomainIs(host, "www.csse.monash.edu.au") +|| dnsDomainIs(host, "www.cstone.net") +|| dnsDomainIs(host, "www.csu.edu.au") +|| dnsDomainIs(host, "www.cubs.com") +|| dnsDomainIs(host, "www.culture.fr") +|| dnsDomainIs(host, "www.cultures.com") +|| dnsDomainIs(host, "www.curtis-collection.com") +|| dnsDomainIs(host, "www.cut-the-knot.com") +|| dnsDomainIs(host, "www.cws-scf.ec.gc.ca") +|| dnsDomainIs(host, "www.cyber-dyne.com") +|| dnsDomainIs(host, "www.cyberbee.com") +|| dnsDomainIs(host, "www.cyberbee.net") +|| dnsDomainIs(host, "www.cybercom.net") +|| dnsDomainIs(host, "www.cybercomm.net") +|| dnsDomainIs(host, "www.cybercomm.nl") +|| dnsDomainIs(host, "www.cybercorp.co.nz") +|| dnsDomainIs(host, "www.cybercs.com") +|| dnsDomainIs(host, "www.cybergoal.com") +|| dnsDomainIs(host, "www.cyberkids.com") +|| dnsDomainIs(host, "www.cyberspaceag.com") +|| dnsDomainIs(host, "www.cyberteens.com") +|| dnsDomainIs(host, "www.cybertours.com") +|| dnsDomainIs(host, "www.cybiko.com") +|| dnsDomainIs(host, "www.czweb.com") +|| dnsDomainIs(host, "www.d91.k12.id.us") +|| dnsDomainIs(host, "www.dailygrammar.com") +|| dnsDomainIs(host, "www.dakidz.com") +|| dnsDomainIs(host, "www.dalejarrettonline.com") +|| dnsDomainIs(host, "www.dallascowboys.com") +|| dnsDomainIs(host, "www.dallasdogndisc.com") +|| dnsDomainIs(host, "www.dallasstars.com") +|| dnsDomainIs(host, "www.damnyankees.com") +|| dnsDomainIs(host, "www.danceart.com") +|| dnsDomainIs(host, "www.daniellesplace.com") +|| dnsDomainIs(host, "www.dare-america.com") +|| dnsDomainIs(host, "www.darkfish.com") +|| dnsDomainIs(host, "www.darsbydesign.com") +|| dnsDomainIs(host, "www.datadragon.com") +|| dnsDomainIs(host, "www.davidreilly.com") +|| dnsDomainIs(host, "www.dccomics.com") +|| dnsDomainIs(host, "www.dcn.davis.ca.us") +|| dnsDomainIs(host, "www.deepseaworld.com") +|| dnsDomainIs(host, "www.delawaretribeofindians.nsn.us") +|| dnsDomainIs(host, "www.demon.co.uk") +|| dnsDomainIs(host, "www.denverbroncos.com") +|| dnsDomainIs(host, "www.denverpost.com") +|| dnsDomainIs(host, "www.dep.state.pa.us") +|| dnsDomainIs(host, "www.desert-fairy.com") +|| dnsDomainIs(host, "www.desert-storm.com") +|| dnsDomainIs(host, "www.desertusa.com") +|| dnsDomainIs(host, "www.designltd.com") +|| dnsDomainIs(host, "www.designsbykat.com") +|| dnsDomainIs(host, "www.detnews.com") +|| dnsDomainIs(host, "www.detroitlions.com") +|| dnsDomainIs(host, "www.detroitredwings.com") +|| dnsDomainIs(host, "www.detroittigers.com") +|| dnsDomainIs(host, "www.deutsches-museum.de") +|| dnsDomainIs(host, "www.devilray.com") +|| dnsDomainIs(host, "www.dhorse.com") +|| dnsDomainIs(host, "www.diana-ross.co.uk") +|| dnsDomainIs(host, "www.dianarossandthesupremes.net") +|| dnsDomainIs(host, "www.diaryproject.com") +|| dnsDomainIs(host, "www.dickbutkus.com") +|| dnsDomainIs(host, "www.dickshovel.com") +|| dnsDomainIs(host, "www.dictionary.com") +|| dnsDomainIs(host, "www.didyouknow.com") +|| dnsDomainIs(host, "www.diegorivera.com") +|| dnsDomainIs(host, "www.digitalcentury.com") +|| dnsDomainIs(host, "www.digitaldog.com") +|| dnsDomainIs(host, "www.digiweb.com") +|| dnsDomainIs(host, "www.dimdima.com") +|| dnsDomainIs(host, "www.dinodon.com") +|| dnsDomainIs(host, "www.dinosauria.com") +|| dnsDomainIs(host, "www.discovereso.com") +|| dnsDomainIs(host, "www.discovergalapagos.com") +|| dnsDomainIs(host, "www.discovergames.com") +|| dnsDomainIs(host, "www.discoveringarchaeology.com") +|| dnsDomainIs(host, "www.discoveringmontana.com") +|| dnsDomainIs(host, "www.discoverlearning.com") +|| dnsDomainIs(host, "www.discovery.com") +|| dnsDomainIs(host, "www.disknet.com") +|| dnsDomainIs(host, "www.disney.go.com") +|| dnsDomainIs(host, "www.distinguishedwomen.com") +|| dnsDomainIs(host, "www.dkonline.com") +|| dnsDomainIs(host, "www.dltk-kids.com") +|| dnsDomainIs(host, "www.dmgi.com") +|| dnsDomainIs(host, "www.dnr.state.md.us") +|| dnsDomainIs(host, "www.dnr.state.mi.us") +|| dnsDomainIs(host, "www.dnr.state.wi.us") +|| dnsDomainIs(host, "www.dodgers.com") +|| dnsDomainIs(host, "www.dodoland.com") +|| dnsDomainIs(host, "www.dog-play.com") +|| dnsDomainIs(host, "www.dogbreedinfo.com") +|| dnsDomainIs(host, "www.doginfomat.com") +|| dnsDomainIs(host, "www.dole5aday.com") +|| dnsDomainIs(host, "www.dollart.com") +|| dnsDomainIs(host, "www.dolliedish.com") +|| dnsDomainIs(host, "www.dome2000.co.uk") +|| dnsDomainIs(host, "www.domtar.com") +|| dnsDomainIs(host, "www.donegal.k12.pa.us") +|| dnsDomainIs(host, "www.dorneypark.com") +|| dnsDomainIs(host, "www.dorothyhinshawpatent.com") +|| dnsDomainIs(host, "www.dougweb.com") +|| dnsDomainIs(host, "www.dps.state.ak.us") +|| dnsDomainIs(host, "www.draw3d.com") +|| dnsDomainIs(host, "www.dreamgate.com") +|| dnsDomainIs(host, "www.dreamkitty.com") +|| dnsDomainIs(host, "www.dreamscape.com") +|| dnsDomainIs(host, "www.dreamtime.net.au") +|| dnsDomainIs(host, "www.drpeppermuseum.com") +|| dnsDomainIs(host, "www.drscience.com") +|| dnsDomainIs(host, "www.drseward.com") +|| dnsDomainIs(host, "www.drtoy.com") +|| dnsDomainIs(host, "www.dse.nl") +|| dnsDomainIs(host, "www.dtic.mil") +|| dnsDomainIs(host, "www.duracell.com") +|| dnsDomainIs(host, "www.dustbunny.com") +|| dnsDomainIs(host, "www.dynanet.com") +|| dnsDomainIs(host, "www.eagerreaders.com") +|| dnsDomainIs(host, "www.eaglekids.com") +|| dnsDomainIs(host, "www.earthcalendar.net") +|| dnsDomainIs(host, "www.earthday.net") +|| dnsDomainIs(host, "www.earthdog.com") +|| dnsDomainIs(host, "www.earthwatch.com") +|| dnsDomainIs(host, "www.ease.com") +|| dnsDomainIs(host, "www.eastasia.ws") +|| dnsDomainIs(host, "www.easytype.com") +|| dnsDomainIs(host, "www.eblewis.com") +|| dnsDomainIs(host, "www.ebs.hw.ac.uk") +|| dnsDomainIs(host, "www.eclipse.net") +|| dnsDomainIs(host, "www.eco-pros.com") +|| dnsDomainIs(host, "www.edbydesign.com") +|| dnsDomainIs(host, "www.eddytheeco-dog.com") +|| dnsDomainIs(host, "www.edgate.com") +|| dnsDomainIs(host, "www.edmontonoilers.com") +|| dnsDomainIs(host, "www.edu-source.com") +|| dnsDomainIs(host, "www.edu.gov.on.ca") +|| dnsDomainIs(host, "www.edu4kids.com") +|| dnsDomainIs(host, "www.educ.uvic.ca") +|| dnsDomainIs(host, "www.educate.org.uk") +|| dnsDomainIs(host, "www.education-world.com") +|| dnsDomainIs(host, "www.edunet.com") +|| dnsDomainIs(host, "www.eduplace.com") +|| dnsDomainIs(host, "www.edupuppy.com") +|| dnsDomainIs(host, "www.eduweb.com") +|| dnsDomainIs(host, "www.ee.ryerson.ca") +|| dnsDomainIs(host, "www.ee.surrey.ac.uk") +|| dnsDomainIs(host, "www.eeggs.com") +|| dnsDomainIs(host, "www.efes.com") +|| dnsDomainIs(host, "www.egalvao.com") +|| dnsDomainIs(host, "www.egypt.com") +|| dnsDomainIs(host, "www.egyptology.com") +|| dnsDomainIs(host, "www.ehobbies.com") +|| dnsDomainIs(host, "www.ehow.com") +|| dnsDomainIs(host, "www.eia.brad.ac.uk") +|| dnsDomainIs(host, "www.elbalero.gob.mx") +|| dnsDomainIs(host, "www.eliki.com") +|| dnsDomainIs(host, "www.elnino.com") +|| dnsDomainIs(host, "www.elok.com") +|| dnsDomainIs(host, "www.emf.net") +|| dnsDomainIs(host, "www.emsphone.com") +|| dnsDomainIs(host, "www.emulateme.com") +|| dnsDomainIs(host, "www.en.com") +|| dnsDomainIs(host, "www.enature.com") +|| dnsDomainIs(host, "www.enchantedlearning.com") +|| dnsDomainIs(host, "www.encyclopedia.com") +|| dnsDomainIs(host, "www.endex.com") +|| dnsDomainIs(host, "www.enjoyillinois.com") +|| dnsDomainIs(host, "www.enn.com") +|| dnsDomainIs(host, "www.enriqueig.com") +|| dnsDomainIs(host, "www.enteract.com") +|| dnsDomainIs(host, "www.epals.com") +|| dnsDomainIs(host, "www.equine-world.co.uk") +|| dnsDomainIs(host, "www.eric-carle.com") +|| dnsDomainIs(host, "www.ericlindros.net") +|| dnsDomainIs(host, "www.escape.com") +|| dnsDomainIs(host, "www.eskimo.com") +|| dnsDomainIs(host, "www.essentialsofmusic.com") +|| dnsDomainIs(host, "www.etch-a-sketch.com") +|| dnsDomainIs(host, "www.ethanallen.together.com") +|| dnsDomainIs(host, "www.etoys.com") +|| dnsDomainIs(host, "www.eurekascience.com") +|| dnsDomainIs(host, "www.euronet.nl") +|| dnsDomainIs(host, "www.everyrule.com") +|| dnsDomainIs(host, "www.ex.ac.uk") +|| dnsDomainIs(host, "www.excite.com") +|| dnsDomainIs(host, "www.execpc.com") +|| dnsDomainIs(host, "www.execulink.com") +|| dnsDomainIs(host, "www.exn.net") +|| dnsDomainIs(host, "www.expa.hvu.nl") +|| dnsDomainIs(host, "www.expage.com") +|| dnsDomainIs(host, "www.explode.to") +|| dnsDomainIs(host, "www.explorescience.com") +|| dnsDomainIs(host, "www.explorezone.com") +|| dnsDomainIs(host, "www.extremescience.com") +|| dnsDomainIs(host, "www.eyelid.co.uk") +|| dnsDomainIs(host, "www.eyeneer.com") +|| dnsDomainIs(host, "www.eyesofachild.com") +|| dnsDomainIs(host, "www.eyesofglory.com") +|| dnsDomainIs(host, "www.ezschool.com") +|| dnsDomainIs(host, "www.f1-live.com") +|| dnsDomainIs(host, "www.fables.co.uk") +|| dnsDomainIs(host, "www.factmonster.com") +|| dnsDomainIs(host, "www.fairygodmother.com") +|| dnsDomainIs(host, "www.familybuzz.com") +|| dnsDomainIs(host, "www.familygames.com") +|| dnsDomainIs(host, "www.familygardening.com") +|| dnsDomainIs(host, "www.familyinternet.com") +|| dnsDomainIs(host, "www.familymoney.com") +|| dnsDomainIs(host, "www.familyplay.com") +|| dnsDomainIs(host, "www.famousbirthdays.com") +|| dnsDomainIs(host, "www.fandom.com") +|| dnsDomainIs(host, "www.fansites.com") +|| dnsDomainIs(host, "www.faoschwarz.com") +|| dnsDomainIs(host, "www.fbe.unsw.edu.au") +|| dnsDomainIs(host, "www.fcps.k12.va.us") +|| dnsDomainIs(host, "www.fellersartsfactory.com") +|| dnsDomainIs(host, "www.ferrari.it") +|| dnsDomainIs(host, "www.fertnel.com") +|| dnsDomainIs(host, "www.fh-konstanz.de") +|| dnsDomainIs(host, "www.fhw.gr") +|| dnsDomainIs(host, "www.fibblesnork.com") +|| dnsDomainIs(host, "www.fidnet.com") +|| dnsDomainIs(host, "www.fieldhockey.com") +|| dnsDomainIs(host, "www.fieldhockeytraining.com") +|| dnsDomainIs(host, "www.fieler.com") +|| dnsDomainIs(host, "www.finalfour.net") +|| dnsDomainIs(host, "www.finifter.com") +|| dnsDomainIs(host, "www.fireworks-safety.com") +|| dnsDomainIs(host, "www.firstcut.com") +|| dnsDomainIs(host, "www.firstnations.com") +|| dnsDomainIs(host, "www.fishbc.com") +|| dnsDomainIs(host, "www.fisher-price.com") +|| dnsDomainIs(host, "www.fisheyeview.com") +|| dnsDomainIs(host, "www.fishgeeks.com") +|| dnsDomainIs(host, "www.fishindex.com") +|| dnsDomainIs(host, "www.fitzgeraldstudio.com") +|| dnsDomainIs(host, "www.flags.net") +|| dnsDomainIs(host, "www.flail.com") +|| dnsDomainIs(host, "www.flamarlins.com") +|| dnsDomainIs(host, "www.flausa.com") +|| dnsDomainIs(host, "www.floodlight-findings.com") +|| dnsDomainIs(host, "www.floridahistory.com") +|| dnsDomainIs(host, "www.floridapanthers.com") +|| dnsDomainIs(host, "www.fng.fi") +|| dnsDomainIs(host, "www.foodsci.uoguelph.ca") +|| dnsDomainIs(host, "www.foremost.com") +|| dnsDomainIs(host, "www.fortress.am") +|| dnsDomainIs(host, "www.fortunecity.com") +|| dnsDomainIs(host, "www.fosterclub.com") +|| dnsDomainIs(host, "www.foundus.com") +|| dnsDomainIs(host, "www.fourmilab.ch") +|| dnsDomainIs(host, "www.fox.com") +|| dnsDomainIs(host, "www.foxfamilychannel.com") +|| dnsDomainIs(host, "www.foxhome.com") +|| dnsDomainIs(host, "www.foxkids.com") +|| dnsDomainIs(host, "www.franceway.com") +|| dnsDomainIs(host, "www.fred.net") +|| dnsDomainIs(host, "www.fredpenner.com") +|| dnsDomainIs(host, "www.freedomknot.com") +|| dnsDomainIs(host, "www.freejigsawpuzzles.com") +|| dnsDomainIs(host, "www.freenet.edmonton.ab.ca") +|| dnsDomainIs(host, "www.frii.com") +|| dnsDomainIs(host, "www.frisbee.com") +|| dnsDomainIs(host, "www.fritolay.com") +|| dnsDomainIs(host, "www.frogsonice.com") +|| dnsDomainIs(host, "www.frontiernet.net") +|| dnsDomainIs(host, "www.fs.fed.us") +|| dnsDomainIs(host, "www.funattic.com") +|| dnsDomainIs(host, ".funbrain.com") +|| dnsDomainIs(host, "www.fundango.com") +|| dnsDomainIs(host, "www.funisland.com") +|| dnsDomainIs(host, "www.funkandwagnalls.com") +|| dnsDomainIs(host, "www.funorama.com") +|| dnsDomainIs(host, "www.funschool.com") +|| dnsDomainIs(host, "www.funster.com") +|| dnsDomainIs(host, "www.furby.com") +|| dnsDomainIs(host, "www.fusion.org.uk") +|| dnsDomainIs(host, "www.futcher.com") +|| dnsDomainIs(host, "www.futurescan.com") +|| dnsDomainIs(host, "www.fyi.net") +|| dnsDomainIs(host, "www.gailgibbons.com") +|| dnsDomainIs(host, "www.galegroup.com") +|| dnsDomainIs(host, "www.gambia.com") +|| dnsDomainIs(host, "www.gamecabinet.com") +|| dnsDomainIs(host, "www.gamecenter.com") +|| dnsDomainIs(host, "www.gamefaqs.com") +|| dnsDomainIs(host, "www.garfield.com") +|| dnsDomainIs(host, "www.garyharbo.com") +|| dnsDomainIs(host, "www.gatefish.com") +|| dnsDomainIs(host, "www.gateway-va.com") +|| dnsDomainIs(host, "www.gazillionaire.com") +|| dnsDomainIs(host, "www.gearhead.com") +|| dnsDomainIs(host, "www.genesplicing.com") +|| dnsDomainIs(host, "www.genhomepage.com") +|| dnsDomainIs(host, "www.geobop.com") +|| dnsDomainIs(host, "www.geocities.com") +|| dnsDomainIs(host, "www.geographia.com") +|| dnsDomainIs(host, "www.georgeworld.com") +|| dnsDomainIs(host, "www.georgian.net") +|| dnsDomainIs(host, "www.german-way.com") +|| dnsDomainIs(host, "www.germanfortravellers.com") +|| dnsDomainIs(host, "www.germantown.k12.il.us") +|| dnsDomainIs(host, "www.germany-tourism.de") +|| dnsDomainIs(host, "www.getmusic.com") +|| dnsDomainIs(host, "www.gettysburg.com") +|| dnsDomainIs(host, "www.ghirardellisq.com") +|| dnsDomainIs(host, "www.ghosttowngallery.com") +|| dnsDomainIs(host, "www.ghosttownsusa.com") +|| dnsDomainIs(host, "www.giants.com") +|| dnsDomainIs(host, "www.gibraltar.gi") +|| dnsDomainIs(host, "www.gigglepoetry.com") +|| dnsDomainIs(host, "www.gilchriststudios.com") +|| dnsDomainIs(host, "www.gillslap.freeserve.co.uk") +|| dnsDomainIs(host, "www.gilmer.net") +|| dnsDomainIs(host, "www.gio.gov.tw") +|| dnsDomainIs(host, "www.girltech.com") +|| dnsDomainIs(host, "www.girlzone.com") +|| dnsDomainIs(host, "www.globalgang.org.uk") +|| dnsDomainIs(host, "www.globalindex.com") +|| dnsDomainIs(host, "www.globalinfo.com") +|| dnsDomainIs(host, "www.gloriafan.com") +|| dnsDomainIs(host, "www.gms.ocps.k12.fl.us") +|| dnsDomainIs(host, "www.go-go-diggity.com") +|| dnsDomainIs(host, "www.goals.com") +|| dnsDomainIs(host, "www.godiva.com") +|| dnsDomainIs(host, "www.golden-retriever.com") +|| dnsDomainIs(host, "www.goldenbooks.com") +|| dnsDomainIs(host, "www.goldeneggs.com.au") +|| dnsDomainIs(host, "www.golfonline.com") +|| dnsDomainIs(host, "www.goobo.com") +|| dnsDomainIs(host, "www.goodearthgraphics.com") +|| dnsDomainIs(host, "www.goodyear.com") +|| dnsDomainIs(host, "www.gopbi.com") +|| dnsDomainIs(host, "www.gorge.net") +|| dnsDomainIs(host, "www.gorp.com") +|| dnsDomainIs(host, "www.got-milk.com") +|| dnsDomainIs(host, "www.gov.ab.ca") +|| dnsDomainIs(host, "www.gov.nb.ca") +|| dnsDomainIs(host, "www.grammarbook.com") +|| dnsDomainIs(host, "www.grammarlady.com") +|| dnsDomainIs(host, "www.grandparents-day.com") +|| dnsDomainIs(host, "www.granthill.com") +|| dnsDomainIs(host, "www.grayweb.com") +|| dnsDomainIs(host, "www.greatbuildings.com") +|| dnsDomainIs(host, "www.greatkids.com") +|| dnsDomainIs(host, "www.greatscience.com") +|| dnsDomainIs(host, "www.greeceny.com") +|| dnsDomainIs(host, "www.greenkeepers.com") +|| dnsDomainIs(host, "www.greylabyrinth.com") +|| dnsDomainIs(host, "www.grimmy.com") +|| dnsDomainIs(host, "www.gsrg.nmh.ac.uk") +|| dnsDomainIs(host, "www.gti.net") +|| dnsDomainIs(host, "www.guinnessworldrecords.com") +|| dnsDomainIs(host, "www.guitar.net") +|| dnsDomainIs(host, "www.guitarplaying.com") +|| dnsDomainIs(host, "www.gumbyworld.com") +|| dnsDomainIs(host, "www.gurlwurld.com") +|| dnsDomainIs(host, "www.gwi.net") +|| dnsDomainIs(host, "www.gymn-forum.com") +|| dnsDomainIs(host, "www.gzkidzone.com") +|| dnsDomainIs(host, "www.haemibalgassi.com") +|| dnsDomainIs(host, "www.hairstylist.com") +|| dnsDomainIs(host, "www.halcyon.com") +|| dnsDomainIs(host, "www.halifax.cbc.ca") +|| dnsDomainIs(host, "www.halloween-online.com") +|| dnsDomainIs(host, "www.halloweenkids.com") +|| dnsDomainIs(host, "www.halloweenmagazine.com") +|| dnsDomainIs(host, "www.hamill.co.uk") +|| dnsDomainIs(host, "www.hamsterdance2.com") +|| dnsDomainIs(host, "www.hamsters.co.uk") +|| dnsDomainIs(host, "www.hamstertours.com") +|| dnsDomainIs(host, "www.handsonmath.com") +|| dnsDomainIs(host, "www.handspeak.com") +|| dnsDomainIs(host, "www.hansonline.com") +|| dnsDomainIs(host, "www.happychild.org.uk") +|| dnsDomainIs(host, "www.happyfamilies.com") +|| dnsDomainIs(host, "www.happytoy.com") +|| dnsDomainIs(host, "www.harley-davidson.com") +|| dnsDomainIs(host, "www.harmonicalessons.com") +|| dnsDomainIs(host, "www.harperchildrens.com") +|| dnsDomainIs(host, "www.harvey.com") +|| dnsDomainIs(host, "www.hasbro-interactive.com") +|| dnsDomainIs(host, "www.haynet.net") +|| dnsDomainIs(host, "www.hbc.com") +|| dnsDomainIs(host, "www.hblewis.com") +|| dnsDomainIs(host, "www.hbook.com") +|| dnsDomainIs(host, "www.he.net") +|| dnsDomainIs(host, "www.headbone.com") +|| dnsDomainIs(host, "www.healthatoz.com") +|| dnsDomainIs(host, "www.healthypet.com") +|| dnsDomainIs(host, "www.heartfoundation.com.au") +|| dnsDomainIs(host, "www.heatersworld.com") +|| dnsDomainIs(host, "www.her-online.com") +|| dnsDomainIs(host, "www.heroesofhistory.com") +|| dnsDomainIs(host, "www.hersheypa.com") +|| dnsDomainIs(host, "www.hersheys.com") +|| dnsDomainIs(host, "www.hevanet.com") +|| dnsDomainIs(host, "www.heynetwork.com") +|| dnsDomainIs(host, "www.hgo.com") +|| dnsDomainIs(host, "www.hhof.com") +|| dnsDomainIs(host, "www.hideandseekpuppies.com") +|| dnsDomainIs(host, "www.hifusion.com") +|| dnsDomainIs(host, "www.highbridgepress.com") +|| dnsDomainIs(host, "www.his.com") +|| dnsDomainIs(host, "www.history.navy.mil") +|| dnsDomainIs(host, "www.historychannel.com") +|| dnsDomainIs(host, "www.historyhouse.com") +|| dnsDomainIs(host, "www.historyplace.com") +|| dnsDomainIs(host, "www.hisurf.com") +|| dnsDomainIs(host, "www.hiyah.com") +|| dnsDomainIs(host, "www.hmnet.com") +|| dnsDomainIs(host, "www.hoboes.com") +|| dnsDomainIs(host, "www.hockeydb.com") +|| dnsDomainIs(host, "www.hohnerusa.com") +|| dnsDomainIs(host, "www.holidaychannel.com") +|| dnsDomainIs(host, "www.holidayfestival.com") +|| dnsDomainIs(host, "www.holidays.net") +|| dnsDomainIs(host, "www.hollywood.com") +|| dnsDomainIs(host, "www.holoworld.com") +|| dnsDomainIs(host, "www.homepagers.com") +|| dnsDomainIs(host, "www.homeschoolzone.com") +|| dnsDomainIs(host, "www.homestead.com") +|| dnsDomainIs(host, "www.homeworkspot.com") +|| dnsDomainIs(host, "www.hompro.com") +|| dnsDomainIs(host, "www.honey.com") +|| dnsDomainIs(host, "www.hooked.net") +|| dnsDomainIs(host, "www.hoophall.com") +|| dnsDomainIs(host, "www.hooverdam.com") +|| dnsDomainIs(host, "www.hopepaul.com") +|| dnsDomainIs(host, "www.horse-country.com") +|| dnsDomainIs(host, "www.horsechat.com") +|| dnsDomainIs(host, "www.horsefun.com") +|| dnsDomainIs(host, "www.horus.ics.org.eg") +|| dnsDomainIs(host, "www.hotbraille.com") +|| dnsDomainIs(host, "www.hotwheels.com") +|| dnsDomainIs(host, "www.howstuffworks.com") +|| dnsDomainIs(host, "www.hpdigitalbookclub.com") +|| dnsDomainIs(host, "www.hpj.com") +|| dnsDomainIs(host, "www.hpl.hp.com") +|| dnsDomainIs(host, "www.hpl.lib.tx.us") +|| dnsDomainIs(host, "www.hpnetwork.f2s.com") +|| dnsDomainIs(host, "www.hsswp.com") +|| dnsDomainIs(host, "www.hsx.com") +|| dnsDomainIs(host, "www.humboldt1.com") +|| dnsDomainIs(host, "www.humongous.com") +|| dnsDomainIs(host, "www.humph3.freeserve.co.uk") +|| dnsDomainIs(host, "www.humphreybear.com ") +|| dnsDomainIs(host, "www.hurricanehunters.com") +|| dnsDomainIs(host, "www.hyperhistory.com") +|| dnsDomainIs(host, "www.i2k.com") +|| dnsDomainIs(host, "www.ibhof.com") +|| dnsDomainIs(host, "www.ibiscom.com") +|| dnsDomainIs(host, "www.ibm.com") +|| dnsDomainIs(host, "www.icangarden.com") +|| dnsDomainIs(host, "www.icecreamusa.com") +|| dnsDomainIs(host, "www.icn.co.uk") +|| dnsDomainIs(host, "www.icomm.ca") +|| dnsDomainIs(host, "www.idfishnhunt.com") +|| dnsDomainIs(host, "www.iditarod.com") +|| dnsDomainIs(host, "www.iei.net") +|| dnsDomainIs(host, "www.iemily.com") +|| dnsDomainIs(host, "www.iir.com") +|| dnsDomainIs(host, "www.ika.com") +|| dnsDomainIs(host, "www.ikoala.com") +|| dnsDomainIs(host, "www.iln.net") +|| dnsDomainIs(host, "www.imagine5.com") +|| dnsDomainIs(host, "www.imes.boj.or.jp") +|| dnsDomainIs(host, "www.inch.com") +|| dnsDomainIs(host, "www.incwell.com") +|| dnsDomainIs(host, "www.indian-river.fl.us") +|| dnsDomainIs(host, "www.indians.com") +|| dnsDomainIs(host, "www.indo.com") +|| dnsDomainIs(host, "www.indyracingleague.com") +|| dnsDomainIs(host, "www.indyzoo.com") +|| dnsDomainIs(host, "www.info-canada.com") +|| dnsDomainIs(host, "www.infomagic.net") +|| dnsDomainIs(host, "www.infoplease.com") +|| dnsDomainIs(host, "www.infoporium.com") +|| dnsDomainIs(host, "www.infostuff.com") +|| dnsDomainIs(host, "www.inhandmuseum.com") +|| dnsDomainIs(host, "www.inil.com") +|| dnsDomainIs(host, "www.inkspot.com") +|| dnsDomainIs(host, "www.inkyfingers.com") +|| dnsDomainIs(host, "www.innerauto.com") +|| dnsDomainIs(host, "www.innerbody.com") +|| dnsDomainIs(host, "www.inqpub.com") +|| dnsDomainIs(host, "www.insecta-inspecta.com") +|| dnsDomainIs(host, "www.insectclopedia.com") +|| dnsDomainIs(host, "www.inside-mexico.com") +|| dnsDomainIs(host, "www.insiders.com") +|| dnsDomainIs(host, "www.insteam.com") +|| dnsDomainIs(host, "www.intel.com") +|| dnsDomainIs(host, "www.intellicast.com") +|| dnsDomainIs(host, "www.interads.co.uk") +|| dnsDomainIs(host, "www.intercot.com") +|| dnsDomainIs(host, "www.intergraffix.com") +|| dnsDomainIs(host, "www.interknowledge.com") +|| dnsDomainIs(host, "www.interlog.com") +|| dnsDomainIs(host, "www.internet4kids.com") +|| dnsDomainIs(host, "www.intersurf.com") +|| dnsDomainIs(host, "www.inthe80s.com") +|| dnsDomainIs(host, "www.inventorsmuseum.com") +|| dnsDomainIs(host, "www.inwap.com") +|| dnsDomainIs(host, "www.ioa.com") +|| dnsDomainIs(host, "www.ionet.net") +|| dnsDomainIs(host, "www.iowacity.com") +|| dnsDomainIs(host, "www.ireland-now.com") +|| dnsDomainIs(host, "www.ireland.com") +|| dnsDomainIs(host, "www.irelandseye.com") +|| dnsDomainIs(host, "www.irlgov.ie") +|| dnsDomainIs(host, "www.isd.net") +|| dnsDomainIs(host, "www.islandnet.com") +|| dnsDomainIs(host, "www.isomedia.com") +|| dnsDomainIs(host, "www.itftennis.com") +|| dnsDomainIs(host, "www.itpi.dpi.state.nc.us") +|| dnsDomainIs(host, "www.itskwanzaatime.com") +|| dnsDomainIs(host, "www.itss.raytheon.com") +|| dnsDomainIs(host, "www.iuma.com") +|| dnsDomainIs(host, "www.iwaynet.net") +|| dnsDomainIs(host, "www.iwc.com") +|| dnsDomainIs(host, "www.iwight.gov.uk") +|| dnsDomainIs(host, "www.ixpres.com") +|| dnsDomainIs(host, "www.j.b.allen.btinternet.co.uk") +|| dnsDomainIs(host, "www.jabuti.com") +|| dnsDomainIs(host, "www.jackinthebox.com") +|| dnsDomainIs(host, "www.jaffebros.com") +|| dnsDomainIs(host, "www.jaguars.com") +|| dnsDomainIs(host, "www.jamaica-gleaner.com") +|| dnsDomainIs(host, "www.jamm.com") +|| dnsDomainIs(host, "www.janbrett.com") +|| dnsDomainIs(host, "www.janetstevens.com") +|| dnsDomainIs(host, "www.japan-guide.com") +|| dnsDomainIs(host, "www.jargon.net") +|| dnsDomainIs(host, "www.javelinamx.com") +|| dnsDomainIs(host, "www.jayjay.com") +|| dnsDomainIs(host, "www.jazclass.aust.com") +|| dnsDomainIs(host, "www.jedinet.com") +|| dnsDomainIs(host, "www.jenniferlopez.com") +|| dnsDomainIs(host, "www.jlpanagopoulos.com") +|| dnsDomainIs(host, "www.jmarshall.com") +|| dnsDomainIs(host, "www.jmccall.demon.co.uk") +|| dnsDomainIs(host, "www.jmts.com") +|| dnsDomainIs(host, "www.joesherlock.com") +|| dnsDomainIs(host, "www.jorvik-viking-centre.co.uk") +|| dnsDomainIs(host, "www.joycecarolthomas.com") +|| dnsDomainIs(host, "www.joycone.com") +|| dnsDomainIs(host, "www.joyrides.com") +|| dnsDomainIs(host, "www.jps.net") +|| dnsDomainIs(host, "www.jspub.com") +|| dnsDomainIs(host, "www.judaica.com") +|| dnsDomainIs(host, "www.judyblume.com") +|| dnsDomainIs(host, "www.julen.net") +|| dnsDomainIs(host, "www.june29.com") +|| dnsDomainIs(host, "www.juneteenth.com") +|| dnsDomainIs(host, "www.justuskidz.com") +|| dnsDomainIs(host, "www.justwomen.com") +|| dnsDomainIs(host, "www.jwindow.net") +|| dnsDomainIs(host, "www.k9web.com") +|| dnsDomainIs(host, "www.kaercher.de") +|| dnsDomainIs(host, "www.kaleidoscapes.com") +|| dnsDomainIs(host, "www.kapili.com") +|| dnsDomainIs(host, "www.kcchiefs.com") +|| dnsDomainIs(host, "www.kcpl.lib.mo.us") +|| dnsDomainIs(host, "www.kcroyals.com") +|| dnsDomainIs(host, "www.kcsd.k12.pa.us") +|| dnsDomainIs(host, "www.kdu.com") +|| dnsDomainIs(host, "www.kelloggs.com") +|| dnsDomainIs(host, "www.kentuckyfriedchicken.com") +|| dnsDomainIs(host, "www.kenyaweb.com") +|| dnsDomainIs(host, "www.keypals.com") +|| dnsDomainIs(host, "www.kfn.com") +|| dnsDomainIs(host, "www.kid-at-art.com") +|| dnsDomainIs(host, "www.kid-channel.com") +|| dnsDomainIs(host, "www.kidallergy.com") +|| dnsDomainIs(host, "www.kidbibs.com") +|| dnsDomainIs(host, "www.kidcomics.com") +|| dnsDomainIs(host, "www.kiddesafety.com") +|| dnsDomainIs(host, "www.kiddiecampus.com") +|| dnsDomainIs(host, "www.kididdles.com") +|| dnsDomainIs(host, "www.kidnews.com") +|| dnsDomainIs(host, "www.kidocracy.com") +|| dnsDomainIs(host, "www.kidport.com") +|| dnsDomainIs(host, "www.kids-channel.co.uk") +|| dnsDomainIs(host, "www.kids-drawings.com") +|| dnsDomainIs(host, "www.kids-in-mind.com") +|| dnsDomainIs(host, "www.kids4peace.com") +|| dnsDomainIs(host, "www.kidsandcomputers.com") +|| dnsDomainIs(host, "www.kidsart.co.uk") +|| dnsDomainIs(host, "www.kidsastronomy.com") +|| dnsDomainIs(host, "www.kidsbank.com") +|| dnsDomainIs(host, "www.kidsbookshelf.com") +|| dnsDomainIs(host, "www.kidsclick.com") +|| dnsDomainIs(host, "www.kidscom.com") +|| dnsDomainIs(host, "www.kidscook.com") +|| dnsDomainIs(host, "www.kidsdoctor.com") +|| dnsDomainIs(host, "www.kidsdomain.com") +|| dnsDomainIs(host, "www.kidsfarm.com") +|| dnsDomainIs(host, "www.kidsfreeware.com") +|| dnsDomainIs(host, "www.kidsfun.tv") +|| dnsDomainIs(host, "www.kidsgolf.com") +|| dnsDomainIs(host, "www.kidsgowild.com") +|| dnsDomainIs(host, "www.kidsjokes.com") +|| dnsDomainIs(host, "www.kidsloveamystery.com") +|| dnsDomainIs(host, "www.kidsmoneycents.com") +|| dnsDomainIs(host, "www.kidsnewsroom.com") +|| dnsDomainIs(host, "www.kidsource.com") +|| dnsDomainIs(host, "www.kidsparties.com") +|| dnsDomainIs(host, "www.kidsplaytown.com") +|| dnsDomainIs(host, "www.kidsreads.com") +|| dnsDomainIs(host, "www.kidsreport.com") +|| dnsDomainIs(host, "www.kidsrunning.com") +|| dnsDomainIs(host, "www.kidstamps.com") +|| dnsDomainIs(host, "www.kidsvideogames.com") +|| dnsDomainIs(host, "www.kidsway.com") +|| dnsDomainIs(host, "www.kidswithcancer.com") +|| dnsDomainIs(host, "www.kidszone.ourfamily.com") +|| dnsDomainIs(host, "www.kidzup.com") +|| dnsDomainIs(host, "www.kinderart.com") +|| dnsDomainIs(host, "www.kineticcity.com") +|| dnsDomainIs(host, "www.kings.k12.ca.us") +|| dnsDomainIs(host, "www.kiplinger.com") +|| dnsDomainIs(host, "www.kiwirecovery.org.nz") +|| dnsDomainIs(host, "www.klipsan.com") +|| dnsDomainIs(host, "www.klutz.com") +|| dnsDomainIs(host, "www.kn.pacbell.com") +|| dnsDomainIs(host, "www.knex.com") +|| dnsDomainIs(host, "www.knowledgeadventure.com") +|| dnsDomainIs(host, "www.knto.or.kr") +|| dnsDomainIs(host, "www.kodak.com") +|| dnsDomainIs(host, "www.konica.co.jp") +|| dnsDomainIs(host, "www.kraftfoods.com") +|| dnsDomainIs(host, "www.kudzukids.com") +|| dnsDomainIs(host, "www.kulichki.com") +|| dnsDomainIs(host, "www.kuttu.com") +|| dnsDomainIs(host, "www.kv5.com") +|| dnsDomainIs(host, "www.kyes-world.com") +|| dnsDomainIs(host, "www.kyohaku.go.jp") +|| dnsDomainIs(host, "www.kyrene.k12.az.us") +|| dnsDomainIs(host, "www.kz") +|| dnsDomainIs(host, "www.la-hq.org.uk") +|| dnsDomainIs(host, "www.labs.net") +|| dnsDomainIs(host, "www.labyrinth.net.au") +|| dnsDomainIs(host, "www.laffinthedark.com") +|| dnsDomainIs(host, "www.lakhota.com") +|| dnsDomainIs(host, "www.lakings.com") +|| dnsDomainIs(host, "www.lam.mus.ca.us") +|| dnsDomainIs(host, "www.lampstras.k12.pa.us") +|| dnsDomainIs(host, "www.lams.losalamos.k12.nm.us") +|| dnsDomainIs(host, "www.landofcadbury.ca") +|| dnsDomainIs(host, "www.larry-boy.com") +|| dnsDomainIs(host, "www.lasersite.com") +|| dnsDomainIs(host, "www.last-word.com") +|| dnsDomainIs(host, "www.latimes.com") +|| dnsDomainIs(host, "www.laughon.com") +|| dnsDomainIs(host, "www.laurasmidiheaven.com") +|| dnsDomainIs(host, "www.lausd.k12.ca.us") +|| dnsDomainIs(host, "www.learn2.com") +|| dnsDomainIs(host, "www.learn2type.com") +|| dnsDomainIs(host, "www.learnfree-hobbies.com") +|| dnsDomainIs(host, "www.learningkingdom.com") +|| dnsDomainIs(host, "www.learningplanet.com") +|| dnsDomainIs(host, "www.leftjustified.com") +|| dnsDomainIs(host, "www.legalpadjr.com") +|| dnsDomainIs(host, "www.legendarysurfers.com") +|| dnsDomainIs(host, "www.legends.dm.net") +|| dnsDomainIs(host, "www.legis.state.wi.us") +|| dnsDomainIs(host, "www.legis.state.wv.us") +|| dnsDomainIs(host, "www.lego.com") +|| dnsDomainIs(host, "www.leje.com") +|| dnsDomainIs(host, "www.leonardodicaprio.com") +|| dnsDomainIs(host, "www.lessonplanspage.com") +|| dnsDomainIs(host, "www.letour.fr") +|| dnsDomainIs(host, "www.levins.com") +|| dnsDomainIs(host, "www.levistrauss.com") +|| dnsDomainIs(host, "www.libertystatepark.com") +|| dnsDomainIs(host, "www.libraryspot.com") +|| dnsDomainIs(host, "www.lifelong.com") +|| dnsDomainIs(host, "www.lighthouse.cc") +|| dnsDomainIs(host, "www.lightlink.com") +|| dnsDomainIs(host, "www.lightspan.com") +|| dnsDomainIs(host, "www.lil-fingers.com") +|| dnsDomainIs(host, "www.linc.or.jp") +|| dnsDomainIs(host, "www.lindsaysbackyard.com") +|| dnsDomainIs(host, "www.lindtchocolate.com") +|| dnsDomainIs(host, "www.lineone.net") +|| dnsDomainIs(host, "www.lionel.com") +|| dnsDomainIs(host, "www.lisafrank.com") +|| dnsDomainIs(host, "www.lissaexplains.com") +|| dnsDomainIs(host, "www.literacycenter.net") +|| dnsDomainIs(host, "www.littleartist.com") +|| dnsDomainIs(host, "www.littlechiles.com") +|| dnsDomainIs(host, "www.littlecritter.com") +|| dnsDomainIs(host, "www.littlecrowtoys.com") +|| dnsDomainIs(host, "www.littlehousebooks.com") +|| dnsDomainIs(host, "www.littlejason.com") +|| dnsDomainIs(host, "www.littleplanettimes.com") +|| dnsDomainIs(host, "www.liveandlearn.com") +|| dnsDomainIs(host, "www.loadstar.prometeus.net") +|| dnsDomainIs(host, "www.localaccess.com") +|| dnsDomainIs(host, "www.lochness.co.uk") +|| dnsDomainIs(host, "www.lochness.scotland.net") +|| dnsDomainIs(host, "www.logos.it") +|| dnsDomainIs(host, "www.lonelyplanet.com") +|| dnsDomainIs(host, "www.looklearnanddo.com") +|| dnsDomainIs(host, "www.loosejocks.com") +|| dnsDomainIs(host, "www.lost-worlds.com") +|| dnsDomainIs(host, "www.love-story.com") +|| dnsDomainIs(host, "www.lpga.com") +|| dnsDomainIs(host, "www.lsjunction.com") +|| dnsDomainIs(host, "www.lucasarts.com") +|| dnsDomainIs(host, "www.lucent.com") +|| dnsDomainIs(host, "www.lucie.com") +|| dnsDomainIs(host, "www.lunaland.co.za") +|| dnsDomainIs(host, "www.luth.se") +|| dnsDomainIs(host, "www.lyricalworks.com") +|| dnsDomainIs(host, "www.infoporium.com") +|| dnsDomainIs(host, "www.infostuff.com") +|| dnsDomainIs(host, "www.inhandmuseum.com") +|| dnsDomainIs(host, "www.inil.com") +|| dnsDomainIs(host, "www.inkspot.com") +|| dnsDomainIs(host, "www.inkyfingers.com") +|| dnsDomainIs(host, "www.innerauto.com") +|| dnsDomainIs(host, "www.innerbody.com") +|| dnsDomainIs(host, "www.inqpub.com") +|| dnsDomainIs(host, "www.insecta-inspecta.com") +|| dnsDomainIs(host, "www.insectclopedia.com") +|| dnsDomainIs(host, "www.inside-mexico.com") +|| dnsDomainIs(host, "www.insiders.com") +|| dnsDomainIs(host, "www.insteam.com") +|| dnsDomainIs(host, "www.intel.com") +|| dnsDomainIs(host, "www.intellicast.com") +|| dnsDomainIs(host, "www.interads.co.uk") +|| dnsDomainIs(host, "www.intercot.com") +|| dnsDomainIs(host, "www.intergraffix.com") +|| dnsDomainIs(host, "www.interknowledge.com") +|| dnsDomainIs(host, "www.interlog.com") +|| dnsDomainIs(host, "www.internet4kids.com") +|| dnsDomainIs(host, "www.intersurf.com") +|| dnsDomainIs(host, "www.inthe80s.com") +|| dnsDomainIs(host, "www.inventorsmuseum.com") +|| dnsDomainIs(host, "www.inwap.com") +|| dnsDomainIs(host, "www.ioa.com") +|| dnsDomainIs(host, "www.ionet.net") +|| dnsDomainIs(host, "www.iowacity.com") +|| dnsDomainIs(host, "www.ireland-now.com") +|| dnsDomainIs(host, "www.ireland.com") +|| dnsDomainIs(host, "www.irelandseye.com") +|| dnsDomainIs(host, "www.irlgov.ie") +|| dnsDomainIs(host, "www.isd.net") +|| dnsDomainIs(host, "www.islandnet.com") +|| dnsDomainIs(host, "www.isomedia.com") +|| dnsDomainIs(host, "www.itftennis.com") +|| dnsDomainIs(host, "www.itpi.dpi.state.nc.us") +|| dnsDomainIs(host, "www.itskwanzaatime.com") +|| dnsDomainIs(host, "www.itss.raytheon.com") +|| dnsDomainIs(host, "www.iuma.com") +|| dnsDomainIs(host, "www.iwaynet.net") +|| dnsDomainIs(host, "www.iwc.com") +|| dnsDomainIs(host, "www.iwight.gov.uk") +|| dnsDomainIs(host, "www.ixpres.com") +|| dnsDomainIs(host, "www.j.b.allen.btinternet.co.uk") +|| dnsDomainIs(host, "www.jabuti.com") +|| dnsDomainIs(host, "www.jackinthebox.com") +|| dnsDomainIs(host, "www.jaffebros.com") +|| dnsDomainIs(host, "www.jaguars.com") +|| dnsDomainIs(host, "www.jamaica-gleaner.com") +|| dnsDomainIs(host, "www.jamm.com") +|| dnsDomainIs(host, "www.janbrett.com") +|| dnsDomainIs(host, "www.janetstevens.com") +|| dnsDomainIs(host, "www.japan-guide.com") +|| dnsDomainIs(host, "www.jargon.net") +|| dnsDomainIs(host, "www.javelinamx.com") +|| dnsDomainIs(host, "www.jayjay.com") +|| dnsDomainIs(host, "www.jazclass.aust.com") + +) +return "PROXY proxy.hclib.org:80"; +else +return "PROXY 172.16.100.20:8080"; +} diff --git a/tests/mozilla/js1_5/Regress/regress-89474.js b/tests/mozilla/js1_5/Regress/regress-89474.js new file mode 100644 index 0000000..4ed9f67 --- /dev/null +++ b/tests/mozilla/js1_5/Regress/regress-89474.js @@ -0,0 +1,62 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributors:darren.deridder@icarusproject.com, +* pschwartau@netscape.com +* Date: 07 July 2001 +* +* SUMMARY: Regression test for Bugzilla bug 89474 +* See http://bugzilla.mozilla.org/show_bug.cgi?id=89474 +* +* This test used to crash the JS shell. This was discovered +* by Darren DeRidder = V[i][1]) && (mois <= V[i][2]))) && + ((region == 0) || (region == V[i][3] )) && + ((confort == 0) || (confort == V[i][4] )) && + ((encadrement == 0) || + ((encadrement==3)&&((V[i][5]==1)||(V[i][5]==2)||(V[i][5] == 3))) || + ((encadrement==2)&&((V[i][5]==1)||(V[i][5]==2) )) || + ((encadrement==1)&&(encadrement==V[i][5]) ) || + ((encadrement>3)&&(encadrement==V[i][5]) )) && + ((typeVillage == 0) || (typeVillage == V[i][6] )) && + ((budget == 0) || (budget == V[i][7] ))) { + + bl = 1; + if ((sport1 != 0) || (sport2 != 0) || (sport3 != 0)) { + bl = 0; + liste = V[i][8]; + taille = liste.length; + for (j=0; j0, we end up calling inner() N+1 times: + * inner(N), inner(N-1), ... , inner(0). + * + * Each call to inner() increments |outer_d| by 1. + * The last call, inner(0), returns the final value + * of |outer_d|, which should be N+1. + */ +function outer(N) +{ + var outer_d = 0; + return inner(N); + + function inner(level) + { + outer_d++; + + if (level > 0) + return inner(level - 1); + else + return outer_d; + } +} + + +/* + * This only has meaning in Rhino - + */ +setDynamicScope(true); + +/* + * Recompile the function |outer| via eval() in order to + * feel the effect of the dynamic scope mode we have set. + */ +var s = outer.toString(); +eval(s); + +status = inSection(1); +actual = outer(-5); +expect = 1; +addThis(); + +status = inSection(2); +actual = outer(0); +expect = 1; +addThis(); + +status = inSection(3); +actual = outer(5); +expect = 6; +addThis(); + + +/* + * Sanity check: do same steps with the dynamic flag off + */ +setDynamicScope(false); + +/* + * Recompile the function |outer| via eval() in order to + * feel the effect of the dynamic scope mode we have set. + */ +eval(s); + +status = inSection(4); +actual = outer(-5); +expect = 1; +addThis(); + +status = inSection(5); +actual = outer(0); +expect = 1; +addThis(); + +status = inSection(6); +actual = outer(5); +expect = 6; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function setDynamicScope(flag) +{ + if (this.Packages) + { + var cx = this.Packages.org.mozilla.javascript.Context.getCurrentContext(); + cx.setCompileFunctionsWithDynamicScope(flag); + } +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(bug); + printStatus(summary); + + for (var i=0; i
\n" . + "

Test results, $opt_engine_type


\n" . + "

\n" . + "Test List: $list_name
\n" . + "Skip List: $neglist_name
\n" . + ($#test_list + 1) . " test(s) selected, $tests_completed test(s) " . + "completed, $failures_reported failures reported " . + "($failure_pct% failed)
\n" . + "Engine command line: $engine_command
\n" . + "OS type: $os_type
\n"); + + if ($opt_engine_type =~ /^rhino/) { + open (JAVAOUTPUT, $opt_java_path . "java -fullversion " . + $redirect_command . " |"); + print OUTPUT ; + print OUTPUT "
"; + close (JAVAOUTPUT); + } + + print OUTPUT + ("Testcase execution time: $exec_time_string.
\n" . + "Tests completed on $completion_date.

\n"); + + if ($failures_reported > 0) { + print OUTPUT + ("[ Failure Details | " . + "Retest List | " . + "Test Selection Page ]
\n" . + "


\n" . + "\n" . + "

Failure Details


\n
" . + $html . + "
\n[ Top of Page | " . + "Top of Failures ]
\n" . + "
\n
\n" .
+         "\n" .
+         "

Retest List


\n" . + "# Retest List, $opt_engine_type, " . + "generated $completion_date.\n" . + "# Original test base was: $list_name.\n" . + "# $tests_completed of " . ($#test_list + 1) . + " test(s) were completed, " . + "$failures_reported failures reported.\n" . + join ("\n", @failed_tests) ); +#"
\n" . +# "[ Top of Page | " . +# "Top of Retest List ]
\n"); + } else { + print OUTPUT + ("

Whoop-de-doo, nothing failed!

\n"); + } + +#print OUTPUT ""; + +close (OUTPUT); + +&status ("Wrote results to '$opt_output_file'."); + +if ($opt_console_failures) { + &status ("$failures_reported test(s) failed"); +} + +} + +sub parse_args { + my ($option, $value, $lastopt); + + &dd ("checking command line options."); + + Getopt::Mixed::init ($options); + $Getopt::Mixed::order = $Getopt::Mixed::RETURN_IN_ORDER; + + while (($option, $value) = nextOption()) { + + if ($option eq "b") { + &dd ("opt: setting bugurl to '$value'."); + $opt_bug_url = $value; + + } elsif ($option eq "c") { + &dd ("opt: setting classpath to '$value'."); + $opt_classpath = $value; + + } elsif (($option eq "e") || (($option eq "") && ($lastopt eq "e"))) { + &dd ("opt: adding engine $value."); + push (@opt_engine_list, $value); + + } elsif ($option eq "f") { + if (!$value) { + die ("Output file cannot be null.\n"); + } + &dd ("opt: setting output file to '$value'."); + $opt_user_output_file = 1; + $opt_output_file = $value; + + } elsif ($option eq "h") { + &usage; + + } elsif ($option eq "j") { + if (!($value =~ /[\/\\]$/)) { + $value .= "/"; + } + &dd ("opt: setting java path to '$value'."); + $opt_java_path = $value; + + } elsif ($option eq "k") { + &dd ("opt: displaying failures on console."); + $opt_console_failures=1; + + } elsif ($option eq "l" || (($option eq "") && ($lastopt eq "l"))) { + $option = "l"; + &dd ("opt: adding test list '$value'."); + push (@opt_test_list_files, $value); + + } elsif ($option eq "L" || (($option eq "") && ($lastopt eq "L"))) { + $option = "L"; + &dd ("opt: adding negative list '$value'."); + push (@opt_neg_list_files, $value); + + } elsif ($option eq "o") { + $opt_engine_params = $value; + &dd ("opt: setting engine params to '$opt_engine_params'."); + + } elsif ($option eq "p") { + $opt_suite_path = $value; + + if ($os_type eq "MAC") { + if (!($opt_suite_path =~ /\:$/)) { + $opt_suite_path .= ":"; + } + } else { + if (!($opt_suite_path =~ /[\/\\]$/)) { + $opt_suite_path .= "/"; + } + } + + &dd ("opt: setting suite path to '$opt_suite_path'."); + + } elsif ($option eq "s") { + $opt_shell_path = $value; + &dd ("opt: setting shell path to '$opt_shell_path'."); + + } elsif ($option eq "t") { + &dd ("opt: tracing output. (console failures at no extra charge.)"); + $opt_console_failures = 1; + $opt_trace = 1; + + } elsif ($option eq "u") { + &dd ("opt: setting lxr url to '$value'."); + $opt_lxr_url = $value; + + } elsif ($option eq "x") { + &dd ("opt: turning off exit munging."); + $opt_exit_munge = 0; + + } else { + &usage; + } + + $lastopt = $option; + + } + + Getopt::Mixed::cleanup(); + + if ($#opt_engine_list == -1) { + die "You must select a shell to test in.\n"; + } + +} + +# +# print the arguments that this script expects +# +sub usage { + print STDERR + ("\nusage: $0 [] \n" . + "(-b|--bugurl) Bugzilla URL.\n" . + " (default is $opt_bug_url)\n" . + "(-c|--classpath) Classpath (Rhino only.)\n" . + "(-e|--engine) ... Specify the type of engine(s) to test.\n" . + " is one or more of\n" . + " (kjs|smopt|smdebug|lcopt|lcdebug|xpcshell|" . + "rhino|rhinoi|rhinoms|rhinomsi|rhino9|rhinoms9).\n" . + "(-f|--file) Redirect output to file named .\n" . + " (default is " . + "results--.html)\n" . + "(-h|--help) Print this message.\n" . + "(-j|--javapath) Location of java executable.\n" . + "(-k|--confail) Log failures to console (also.)\n" . + "(-l|--list) ... List of tests to execute.\n" . + "(-L|--neglist) ... List of tests to skip.\n" . + "(-o|--opt) Options to pass to the JavaScript engine.\n" . + " (Make sure to quote them!)\n" . + "(-p|--testpath) Root of the test suite. (default is ./)\n" . + "(-s|--shellpath) Location of JavaScript shell.\n" . + "(-t|--trace) Trace script execution.\n" . + "(-u|--lxrurl) Complete URL to tests subdirectory on lxr.\n" . + " (default is $opt_lxr_url)\n" . + "(-x|--noexitmunge) Don't do exit code munging (try this if it\n" . + " seems like your exit codes are turning up\n" . + " as exit signals.)\n"); + exit (1); + +} + +# +# get the shell command used to start the (either) engine +# +sub get_engine_command { + + my $retval; + + if ($opt_engine_type eq "rhino") { + &dd ("getting rhino engine command."); + $opt_rhino_opt = 0; + $opt_rhino_ms = 0; + $retval = &get_rhino_engine_command; + } elsif ($opt_engine_type eq "rhinoi") { + &dd ("getting rhinoi engine command."); + $opt_rhino_opt = -1; + $opt_rhino_ms = 0; + $retval = &get_rhino_engine_command; + } elsif ($opt_engine_type eq "rhino9") { + &dd ("getting rhino engine command."); + $opt_rhino_opt = 9; + $opt_rhino_ms = 0; + $retval = &get_rhino_engine_command; + } elsif ($opt_engine_type eq "rhinoms") { + &dd ("getting rhinoms engine command."); + $opt_rhino_opt = 0; + $opt_rhino_ms = 1; + $retval = &get_rhino_engine_command; + } elsif ($opt_engine_type eq "rhinomsi") { + &dd ("getting rhinomsi engine command."); + $opt_rhino_opt = -1; + $opt_rhino_ms = 1; + $retval = &get_rhino_engine_command; + } elsif ($opt_engine_type eq "rhinoms9") { + &dd ("getting rhinomsi engine command."); + $opt_rhino_opt = 9; + $opt_rhino_ms = 1; + $retval = &get_rhino_engine_command; + } elsif ($opt_engine_type eq "xpcshell") { + &dd ("getting xpcshell engine command."); + $retval = &get_xpc_engine_command; + } elsif ($opt_engine_type =~ /^lc(opt|debug)$/) { + &dd ("getting liveconnect engine command."); + $retval = &get_lc_engine_command; + } elsif ($opt_engine_type =~ /^sm(opt|debug)$/) { + &dd ("getting spidermonkey engine command."); + $retval = &get_sm_engine_command; + } elsif ($opt_engine_type =~ /^ep(opt|debug)$/) { + &dd ("getting epimetheus engine command."); + $retval = &get_ep_engine_command; + } elsif ($opt_engine_type eq "kjs") { + &dd ("getting kjs engine command."); + $retval = &get_kjs_engine_command; + + } else { + die ("Unknown engine type selected, '$opt_engine_type'.\n"); + } + + $retval .= " $opt_engine_params"; + + &dd ("got '$retval'"); + + return $retval; + +} + +# +# get the shell command used to run rhino +# +sub get_rhino_engine_command { + my $retval = $opt_java_path . ($opt_rhino_ms ? "jview " : "java "); + + if ($opt_shell_path) { + $opt_classpath = ($opt_classpath) ? + $opt_classpath . ":" . $opt_shell_path : + $opt_shell_path; + } + + if ($opt_classpath) { + $retval .= ($opt_rhino_ms ? "/cp:p" : "-classpath") . " $opt_classpath "; + } + + $retval .= "org.mozilla.javascript.tools.shell.Main"; + + if ($opt_rhino_opt) { + $retval .= " -opt $opt_rhino_opt"; + } + + return $retval; + +} + +# +# get the shell command used to run xpcshell +# +sub get_xpc_engine_command { + my $retval; + my $m5_home = @ENV{"MOZILLA_FIVE_HOME"} || + die ("You must set MOZILLA_FIVE_HOME to use the xpcshell" , + (!$unixish) ? "." : ", also " . + "setting LD_LIBRARY_PATH to the same directory may get rid of " . + "any 'library not found' errors.\n"); + + if (($unixish) && (!@ENV{"LD_LIBRARY_PATH"})) { + print STDERR "-#- WARNING: LD_LIBRARY_PATH is not set, xpcshell may " . + "not be able to find the required components.\n"; + } + + if (!($m5_home =~ /[\/\\]$/)) { + $m5_home .= "/"; + } + + $retval = $m5_home . "xpcshell"; + + if ($os_type eq "WIN") { + $retval .= ".exe"; + } + + $retval = &xp_path($retval); + + if (($os_type ne "MAC") && !(-x $retval)) { +# mac doesn't seem to deal with -x correctly + die ($retval . " is not a valid executable on this system.\n"); + } + + return $retval; + +} + +# +# get the shell command used to run kjs +# +sub get_kjs_engine_command { + my $retval; + + if ($opt_shell_path) { + $retval = $opt_shell_path; + } else { + die "Please specify a full path to the kjs testing engine"; + } + + return $retval; +} + +# +# get the shell command used to run spidermonkey +# +sub get_sm_engine_command { + my $retval; + +# Look for Makefile.ref style make first. +# (On Windows, spidermonkey can be made by two makefiles, each putting the +# executable in a diferent directory, under a different name.) + + if ($opt_shell_path) { +# if the user provided a path to the shell, return that. + $retval = $opt_shell_path; + + } else { + + if ($os_type eq "MAC") { + $retval = $opt_suite_path . ":src:macbuild:JS"; + } else { + $retval = $opt_suite_path . "../src/"; + opendir (SRC_DIR_FILES, $retval); + my @src_dir_files = readdir(SRC_DIR_FILES); + closedir (SRC_DIR_FILES); + + my ($dir, $object_dir); + my $pattern = ($opt_engine_type eq "smdebug") ? + 'DBG.OBJ' : 'OPT.OBJ'; + +# scan for the first directory matching +# the pattern expected to hold this type (debug or opt) of engine + foreach $dir (@src_dir_files) { + if ($dir =~ $pattern) { + $object_dir = $dir; + last; + } + } + + if (!$object_dir && $os_type ne "WIN") { + die ("Could not locate an object directory in $retval " . + "matching the pattern *$pattern. Have you built the " . + "engine?\n"); + } + + if (!(-x $retval . $object_dir . "/js.exe") && ($os_type eq "WIN")) { +# On windows, you can build with js.mak as well as Makefile.ref +# (Can you say WTF boys and girls? I knew you could.) +# So, if the exe the would have been built by Makefile.ref isn't +# here, check for the js.mak version before dying. + if ($opt_shell_path) { + $retval = $opt_shell_path; + if (!($retval =~ /[\/\\]$/)) { + $retval .= "/"; + } + } else { + if ($opt_engine_type eq "smopt") { + $retval = "../src/Release/"; + } else { + $retval = "../src/Debug/"; + } + } + + $retval .= "jsshell.exe"; + + } else { + $retval .= $object_dir . "/js"; + if ($os_type eq "WIN") { + $retval .= ".exe"; + } + } + } # mac/ not mac + + $retval = &xp_path($retval); + + } # (user provided a path) + + + if (($os_type ne "MAC") && !(-x $retval)) { +# mac doesn't seem to deal with -x correctly + die ($retval . " is not a valid executable on this system.\n"); + } + + return $retval; + +} + +# +# get the shell command used to run epimetheus +# +sub get_ep_engine_command { + my $retval; + + if ($opt_shell_path) { +# if the user provided a path to the shell, return that - + $retval = $opt_shell_path; + + } else { + my $dir; + my $os; + my $debug; + my $opt; + my $exe; + + $dir = $opt_suite_path . "../../js2/src/"; + + if ($os_type eq "MAC") { +# +# On the Mac, the debug and opt builds lie in the same directory - +# + $os = "macbuild:"; + $debug = ""; + $opt = ""; + $exe = "JS2"; + } elsif ($os_type eq "WIN") { + $os = "winbuild/Epimetheus/"; + $debug = "Debug/"; + $opt = "Release/"; + $exe = "Epimetheus.exe"; + } else { + $os = ""; + $debug = ""; + $opt = ""; # <<<----- XXX THIS IS NOT RIGHT! CHANGE IT! + $exe = "epimetheus"; + } + + + if ($opt_engine_type eq "epdebug") { + $retval = $dir . $os . $debug . $exe; + } else { + $retval = $dir . $os . $opt . $exe; + } + + $retval = &xp_path($retval); + + }# (user provided a path) + + + if (($os_type ne "MAC") && !(-x $retval)) { +# mac doesn't seem to deal with -x correctly + die ($retval . " is not a valid executable on this system.\n"); + } + + return $retval; +} + +# +# get the shell command used to run the liveconnect shell +# +sub get_lc_engine_command { + my $retval; + + if ($opt_shell_path) { + $retval = $opt_shell_path; + } else { + if ($os_type eq "MAC") { + die "Don't know how to run the lc shell on the mac yet.\n"; + } else { + $retval = $opt_suite_path . "../src/liveconnect/"; + opendir (SRC_DIR_FILES, $retval); + my @src_dir_files = readdir(SRC_DIR_FILES); + closedir (SRC_DIR_FILES); + + my ($dir, $object_dir); + my $pattern = ($opt_engine_type eq "lcdebug") ? + 'DBG.OBJ' : 'OPT.OBJ'; + + foreach $dir (@src_dir_files) { + if ($dir =~ $pattern) { + $object_dir = $dir; + last; + } + } + + if (!$object_dir) { + die ("Could not locate an object directory in $retval " . + "matching the pattern *$pattern. Have you built the " . + "engine?\n"); + } + + $retval .= $object_dir . "/"; + + if ($os_type eq "WIN") { + $retval .= "lcshell.exe"; + } else { + $retval .= "lcshell"; + } + } # mac/ not mac + + $retval = &xp_path($retval); + + } # (user provided a path) + + + if (($os_type ne "MAC") && !(-x $retval)) { +# mac doesn't seem to deal with -x correctly + die ("$retval is not a valid executable on this system.\n"); + } + + return $retval; + +} + +sub get_os_type { + + if ("\n" eq "\015") { + return "MAC"; + } + + my $uname = `uname -a`; + + if ($uname =~ /WIN/) { + $uname = "WIN"; + } else { + chop $uname; + } + + &dd ("get_os_type returning '$uname'."); + return $uname; + +} + +sub get_test_list { + my @test_list; + my @neg_list; + + if ($#opt_test_list_files > -1) { + my $list_file; + + &dd ("getting test list from user specified source."); + + foreach $list_file (@opt_test_list_files) { + push (@test_list, &expand_user_test_list($list_file)); + } + } else { + &dd ("no list file, groveling in '$opt_suite_path'."); + + @test_list = &get_default_test_list($opt_suite_path); + } + + if ($#opt_neg_list_files > -1) { + my $list_file; + my $orig_size = $#test_list + 1; + my $actually_skipped; + + &dd ("getting negative list from user specified source."); + + foreach $list_file (@opt_neg_list_files) { + push (@neg_list, &expand_user_test_list($list_file)); + } + + @test_list = &subtract_arrays (\@test_list, \@neg_list); + + $actually_skipped = $orig_size - ($#test_list + 1); + + &dd ($actually_skipped . " of " . $orig_size . + " tests will be skipped."); + &dd ((($#neg_list + 1) - $actually_skipped) . " skip tests were " . + "not actually part of the test list."); + + + } + + return @test_list; + +} + +# +# reads $list_file, storing non-comment lines into an array. +# lines in the form suite_dir/[*] or suite_dir/test_dir/[*] are expanded +# to include all test files under the specified directory +# +sub expand_user_test_list { + my ($list_file) = @_; + my @retval = (); + +# +# Trim off the leading path separator that begins relative paths on the Mac. +# Each path will get concatenated with $opt_suite_path, which ends in one. +# +# Also note: +# +# We will call expand_test_list_entry(), which does pattern-matching on $list_file. +# This will make the pattern-matching the same as it would be on Linux/Windows - +# + if ($os_type eq "MAC") { + $list_file =~ s/^$path_sep//; + } + + if ($list_file =~ /\.js$/ || -d $opt_suite_path . $list_file) { + + push (@retval, &expand_test_list_entry($list_file)); + + } else { + + open (TESTLIST, $list_file) || + die("Error opening test list file '$list_file': $!\n"); + + while () { + s/\r*\n*$//; + if (!(/\s*\#/)) { +# It's not a comment, so process it + push (@retval, &expand_test_list_entry($_)); + } + } + + close (TESTLIST); + + } + + return @retval; + +} + + +# +# Currently expect all paths to be RELATIVE to the top-level tests directory. +# One day, this should be improved to allow absolute paths as well - +# +sub expand_test_list_entry { + my ($entry) = @_; + my @retval; + + if ($entry =~ /\.js$/) { +# it's a regular entry, add it to the list + if (-f $opt_suite_path . $entry) { + push (@retval, $entry); + } else { + status ("testcase '$entry' not found."); + } + } elsif ($entry =~ /(.*$path_sep[^\*][^$path_sep]*)$path_sep?\*?$/) { +# Entry is in the form suite_dir/test_dir[/*] +# so iterate all tests under it + my $suite_and_test_dir = $1; + my @test_files = &get_js_files ($opt_suite_path . + $suite_and_test_dir); + my $i; + + foreach $i (0 .. $#test_files) { + $test_files[$i] = $suite_and_test_dir . $path_sep . + $test_files[$i]; + } + + splice (@retval, $#retval + 1, 0, @test_files); + + } elsif ($entry =~ /([^\*][^$path_sep]*)$path_sep?\*?$/) { +# Entry is in the form suite_dir[/*] +# so iterate all test dirs and tests under it + my $suite = $1; + my @test_dirs = &get_subdirs ($opt_suite_path . $suite); + my $test_dir; + + foreach $test_dir (@test_dirs) { + my @test_files = &get_js_files ($opt_suite_path . $suite . + $path_sep . $test_dir); + my $i; + + foreach $i (0 .. $#test_files) { + $test_files[$i] = $suite . $path_sep . $test_dir . $path_sep . + $test_files[$i]; + } + + splice (@retval, $#retval + 1, 0, @test_files); + } + + } else { + die ("Dont know what to do with list entry '$entry'.\n"); + } + + return @retval; + +} + +# +# Grovels through $suite_path, searching for *all* test files. Used when the +# user doesn't supply a test list. +# +sub get_default_test_list { + my ($suite_path) = @_; + my @suite_list = &get_subdirs($suite_path); + my $suite; + my @retval; + + foreach $suite (@suite_list) { + my @test_dir_list = get_subdirs ($suite_path . $suite); + my $test_dir; + + foreach $test_dir (@test_dir_list) { + my @test_list = get_js_files ($suite_path . $suite . $path_sep . + $test_dir); + my $test; + + foreach $test (@test_list) { + $retval[$#retval + 1] = $suite . $path_sep . $test_dir . + $path_sep . $test; + } + } + } + + return @retval; + +} + +# +# generate an output file name based on the date +# +sub get_tempfile_name { + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = + &get_padded_time (localtime); + my $rv; + + if ($os_type ne "MAC") { + $rv = "results-" . $year . "-" . $mon . "-" . $mday . "-" . $hour . + $min . $sec . "-" . $opt_engine_type; + } else { + $rv = "res-" . $year . $mon . $mday . $hour . $min . $sec . "-" . + $opt_engine_type + } + + return $rv . ".html"; +} + +sub get_padded_time { + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = @_; + + $mon++; + $mon = &zero_pad($mon); + $year += 1900; + $mday= &zero_pad($mday); + $sec = &zero_pad($sec); + $min = &zero_pad($min); + $hour = &zero_pad($hour); + + return ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); + +} + +sub zero_pad { + my ($string) = @_; + + $string = ($string < 10) ? "0" . $string : $string; + return $string; +} + +sub subtract_arrays { + my ($whole_ref, $part_ref) = @_; + my @whole = @$whole_ref; + my @part = @$part_ref; + my $line; + + foreach $line (@part) { + @whole = grep (!/$line/, @whole); + } + + return @whole; + +} + +# +# Convert unix path to mac style. +# +sub unix_to_mac { + my ($path) = @_; + my @path_elements = split ("/", $path); + my $rv = ""; + my $i; + + foreach $i (0 .. $#path_elements) { + if ($path_elements[$i] eq ".") { + if (!($rv =~ /\:$/)) { + $rv .= ":"; + } + } elsif ($path_elements[$i] eq "..") { + if (!($rv =~ /\:$/)) { + $rv .= "::"; + } else { + $rv .= ":"; + } + } elsif ($path_elements[$i] ne "") { + $rv .= $path_elements[$i] . ":"; + } + + } + + $rv =~ s/\:$//; + + return $rv; +} + +# +# Convert unix path to win style. +# +sub unix_to_win { + my ($path) = @_; + + if ($path_sep ne $win_sep) { + $path =~ s/$path_sep/$win_sep/g; + } + + return $path; +} + +# +# Windows shells require "/" or "\" as path separator. +# Find out the one used in the current Windows shell. +# +sub get_win_sep { + my $path = $ENV{"PATH"} || $ENV{"Path"} || $ENV{"path"}; + $path =~ /\\|\//; + return $&; +} + +# +# Convert unix path to correct style based on platform. +# +sub xp_path { + my ($path) = @_; + + if ($os_type eq "MAC") { + return &unix_to_mac($path); + } elsif($os_type eq "WIN") { + return &unix_to_win($path); + } else { + return $path; + } +} + +sub numericcmp($$) +{ + my ($aa, $bb) = @_; + + my @a = split /(\d+)/, $aa; + my @b = split /(\d+)/, $bb; + + while (@a && @b) { + my $a = shift @a; + my $b = shift @b; + return $a <=> $b if $a =~ /^\d/ && $b =~ /^\d/ && $a != $b; + return $a cmp $b if $a ne $b; + } + + return @a <=> @b; +} + +# +# given a directory, return an array of all subdirectories +# +sub get_subdirs { + my ($dir) = @_; + my @subdirs; + + if ($os_type ne "MAC") { + if (!($dir =~ /\/$/)) { + $dir = $dir . "/"; + } + } else { + if (!($dir =~ /\:$/)) { + $dir = $dir . ":"; + } + } + opendir (DIR, $dir) || die ("couldn't open directory $dir: $!"); + my @testdir_contents = sort numericcmp readdir(DIR); + closedir(DIR); + + foreach (@testdir_contents) { + if ((-d ($dir . $_)) && ($_ ne 'CVS') && ($_ ne '.') && ($_ ne '..')) { + @subdirs[$#subdirs + 1] = $_; + } + } + + return @subdirs; +} + +# +# given a directory, return an array of all the js files that are in it. +# +sub get_js_files { + my ($test_subdir) = @_; + my (@js_file_array, @subdir_files); + + opendir (TEST_SUBDIR, $test_subdir) || die ("couldn't open directory " . + "$test_subdir: $!"); + @subdir_files = sort numericcmp readdir(TEST_SUBDIR); + closedir( TEST_SUBDIR ); + + foreach (@subdir_files) { + if ($_ =~ /\.js$/) { + $js_file_array[$#js_file_array+1] = $_; + } + } + + return @js_file_array; +} + +sub report_failure { + my ($test, $message, $bug_number) = @_; + my $bug_line = ""; + + $failures_reported++; + + $message =~ s/\n+/\n/g; + $test =~ s/\:/\//g; + + if ($opt_console_failures) { + if($bug_number) { + print STDERR ("*-* Testcase $test failed:\nBug Number $bug_number". + "\n$message\n"); + } else { + print STDERR ("*-* Testcase $test failed:\n$message\n"); + } + } + + $message =~ s/\n/
\n/g; + $html .= ""; + + if ($bug_number) { + $bug_line = "". + "Bug Number $bug_number"; + } + + if ($opt_lxr_url) { + $test =~ /\/?([^\/]+\/[^\/]+\/[^\/]+)$/; + $test = $1; + $html .= "
". + "Testcase $1 " . + "failed $bug_line
\n"; + } else { + $html .= "
". + "Testcase $test failed $bug_line
\n"; + } + + $html .= " [ "; + if ($failures_reported > 1) { + $html .= "" . + "Previous Failure | "; + } + + $html .= "" . + "Next Failure | " . + "Top of Page ]
\n" . + "$message
\n"; + + @failed_tests[$#failed_tests + 1] = $test; + +} + +sub dd { + + if ($opt_trace) { + print ("-*- ", @_ , "\n"); + } + +} + +sub status { + + print ("-#- ", @_ , "\n"); + +} + +sub int_handler { + my $resp; + + do { + print ("\n*** User Break: Just [Q]uit, Quit and [R]eport, [C]ontinue ?"); + $resp = ; + } until ($resp =~ /[QqRrCc]/); + + if ($resp =~ /[Qq]/) { + print ("User Exit. No results were generated.\n"); + exit 1; + } elsif ($resp =~ /[Rr]/) { + $user_exit = 1; + } + +} diff --git a/tests/mozilla/menufoot.html b/tests/mozilla/menufoot.html new file mode 100644 index 0000000..da7902e --- /dev/null +++ b/tests/mozilla/menufoot.html @@ -0,0 +1,8 @@ + + + +
+
+ + + diff --git a/tests/mozilla/menuhead.html b/tests/mozilla/menuhead.html new file mode 100644 index 0000000..827dc43 --- /dev/null +++ b/tests/mozilla/menuhead.html @@ -0,0 +1,138 @@ + + + + Core JavaScript Tests + + + + + + + +

Core JavaScript Tests

+ +
+ + diff --git a/tests/mozilla/mkhtml.pl b/tests/mozilla/mkhtml.pl new file mode 100644 index 0000000..99cb2c5 --- /dev/null +++ b/tests/mozilla/mkhtml.pl @@ -0,0 +1,84 @@ +#!/ns/tools/bin/perl5 + +# mkhtml.pl cruises through your $MOZ_SRC/mozilla/js/tests/ subdirectories, +# and for any .js file it finds, creates an HTML file that includes: +# $MOZ_SRC/mozilla/js/tests/$suite/shell.js, $ +# MOZ_SRC/mozilla/js/tests/$suite/browser.js, +# and the test.js file. +# +# + +$moz_src = $ENV{"MOZ_SRC"} || + die ("You need to set your MOZ_SRC environment variable.\n"); + +$test_home = $moz_src ."/js/tests/"; + +opendir (TEST_HOME, $test_home); +@__suites = readdir (TEST_HOME); +closedir TEST_HOME; + +foreach (@__suites ) { + if ( -d $_ && $_ !~ /\./ && $_ !~ 'CVS' ) { + $suites[$#suites+1] = $_; + } +} +if ( ! $ARGV[0] ) { + die ( "Specify a directory: ". join(" ", @suites) ."\n" ); +} + +$js_test_dir = $moz_src . "/js/tests/" . $ARGV[0] ."/"; + +print "Generating html files for the tests in $js_test_dir\n"; + +$shell_js = $js_test_dir . "shell.js"; +$browser_js = $js_test_dir . "browser.js"; + +# cd to the test directory +chdir $js_test_dir || + die "Couldn't chdir to js_test_dir, which is $js_test_dir\n"; + +print ( "js_test_dir is $js_test_dir\n" ); + +# read the test directory +opendir ( JS_TEST_DIR, $js_test_dir ); +# || die "Couldn't open js_test_dir, which is $js_test_dir\n"; +@js_test_dir_items = readdir( JS_TEST_DIR ); +# || die "Couldn't read js_test_dir, which is $js_test_dir\n"; +closedir( JS_TEST_DIR ); + +print ("The js_test_dir_items are: " . join( ",", @js_test_dir_items ) . "\n"); + +# figure out which of the items are directories +foreach $js_test_subdir ( @js_test_dir_items ) { + if ( -d $js_test_subdir ) { + + $js_test_subdir = $js_test_dir ."/" . $js_test_subdir; + chdir $js_test_subdir + || die "Couldn't chdir to js_test_subdir $js_test_subdir\n"; + print "Just chdir'd to $js_test_subdir \n"; + + opendir( JS_TEST_SUBDIR, $js_test_subdir ); + @subdir_tests = readdir( JS_TEST_SUBDIR ); + closedir( JS_TEST_SUBDIR ); + + foreach ( @subdir_tests ) { + $js_test = $_; + + if ( $_ =~ /\.js$/ ) { + s/\.js$/\.html/; + print $_ ."\n"; + open( HTML_TEST, "> $_") + || die "Can't open html file $test_html\n"; + print HTML_TEST + ''; + print HTML_TEST + ''; + print HTML_TEST + ''; + close HTML_TEST; + } + } + } + chdir $js_test_dir; +} + diff --git a/tests/mozilla/mklistpage.pl b/tests/mozilla/mklistpage.pl new file mode 100644 index 0000000..9479abf --- /dev/null +++ b/tests/mozilla/mklistpage.pl @@ -0,0 +1,261 @@ +#!/usr/bin/perl +# +# The contents of this file are subject to the Netscape Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/NPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is JavaScript Core Tests. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1997-1999 Netscape Communications Corporation. All +# Rights Reserved. +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU Public License (the "GPL"), in which case the +# provisions of the GPL are applicable instead of those above. +# If you wish to allow use of your version of this file only +# under the terms of the GPL and not to allow others to use your +# version of this file under the NPL, indicate your decision by +# deleting the provisions above and replace them with the notice +# and other provisions required by the GPL. If you do not delete +# the provisions above, a recipient may use your version of this +# file under either the NPL or the GPL. +# +# Contributers: +# Robert Ginda +# +# Creates the meat of a test suite manager page, requites menuhead.html and menufoot.html +# to create the complete page. The test suite manager lets you choose a subset of tests +# to run under the runtests2.pl script. +# + +local $lxr_url = "http://lxr.mozilla.org/mozilla/source/js/tests/"; +local $suite_path = $ARGV[0] || "./"; +local $uid = 0; # radio button unique ID +local $html = ""; # html output +local $javascript = ""; # script output + +&main; + +print (&scriptTag($javascript) . "\n"); +print ($html); + +sub main { + local $i, @suite_list; + + if (!($suite_path =~ /\/$/)) { + $suite_path = $suite_path . "/"; + } + + @suite_list = sort(&get_subdirs ($suite_path)); + + $javascript .= "suites = new Object();\n"; + + $html .= "

Test Suites:

\n"; + $html .= "
\n"; + $html .= " "; + $html .= " "; + + # suite menu + $html .= "\n"; + foreach $suite (@suite_list) { + local @readme_text = ("No description available."); + if (open (README, $suite_path . $suite . "/README")) { + @readme_text = ; + close (README); + } + $html .= "" . + ""; + $html .= ""; + $html .= ""; + $html .= ""; + } + $html .= "
$suite@readme_text "; + $html .= "
\n"; + $html .= ""; + $html .= "
"; + $html .= "
\n"; + + foreach $i (0 .. $#suite_list) { + local $prev_href = ($i > 0) ? "\#SUITE_" . $suite_list[$i - 1] : ""; + local $next_href = ($i < $#suite_list) ? "\#SUITE_" . $suite_list[$i + 1] : ""; + &process_suite ($suite_path, $suite_list[$i], $prev_href, $next_href); + } + + $html .= "
\n"; + +} + +# +# Append detail from a 'suite' directory (eg: ecma, ecma_2, js1_1, etc.), calling +# process_test_dir for subordinate categories. +# +sub process_suite { + local ($suite_path, $suite, $prev_href, $next_href) = @_; + local $i, @test_dir_list; + + # suite js object + $javascript .= "suites[\"$suite\"] = {testDirs: {}};\n"; + + @test_dir_list = sort(&get_subdirs ($test_home . $suite)); + + # suite header + $html .= "
$suite " . + "(" . ($#test_dir_list + 1) . " Sub-Categories)
\n"; + $html .= " \n"; + $html .= " " . + "[ Top of page "; + if ($prev_href) { + $html .= " | Previous Suite "; + } + if ($next_href) { + $html .= " | Next Suite "; + } + $html .= "]\n"; + + $html .= "
\n
\n"; + + foreach $i (0 .. $#test_dir_list) { + local $prev_href = ($i > 0) ? "\#TESTDIR_" . $suite . $test_dir_list[$i - 1] : + ""; + local $next_href = ($i < $#test_dir_list) ? + "\#TESTDIR_" . $suite . $test_dir_list[$i + 1] : ""; + &process_test_dir ($suite_path . $suite . "/", $test_dir_list[$i], $suite, + $prev_href, $next_href); + } + + $html .= "
\n"; + +} + +# +# Append detail from a test directory, calling process_test for subordinate js files +# +sub process_test_dir { + local ($test_dir_path, $test_dir, $suite, $prev_href, $next_href) = @_; + + @test_list = sort(&get_js_files ($test_dir_path . $test_dir)); + + $javascript .= "suites[\"$suite\"].testDirs[\"$test_dir\"] = {tests: {}};\n"; + + $html .= " \n"; + $html .= "
$test_dir (" . ($#test_list + 1) . + " tests)
\n"; + $html .= " \n"; + $html .= " "; + $html .= "[ Top of $suite Suite "; + if ($prev_href) { + $html .= "| Previous Category "; + } + if ($next_href) { + $html .= " | Next Category "; + } + $html .= "]
\n"; + $html .= "
\n"; + + $html .= "
\n"; + + foreach $test (@test_list) { + &process_test ($test_dir_path . $test_dir, $test); + } + + $html .= "
\n"; +} + + +# +# Append detail from a single JavaScript file. +# +sub process_test { + local ($test_dir_path, $test) = @_; + local $title = ""; + + $uid++; + + open (TESTCASE, $test_dir_path . "/" . $test) || + die ("Error opening " . $test_dir_path . "/" . $test); + + while () { + if (/.*TITLE\s+\=\s+\"(.*)\"/) { + $title = $1; + break; + } + } + close (TESTCASE); + + $javascript .= "suites[\"$suite\"].testDirs[\"$test_dir\"].tests" . + "[\"$test\"] = \"radio$uid\"\n"; + $html .= " " . + "" . + "$test $title
\n"; + +} + +sub scriptTag { + + return (""); + +} + +# +# given a directory, return an array of all subdirectories +# +sub get_subdirs { + local ($dir) = @_; + local @subdirs; + + if (!($dir =~ /\/$/)) { + $dir = $dir . "/"; + } + + opendir (DIR, $dir) || die ("couldn't open directory $dir: $!"); + local @testdir_contents = readdir(DIR); + closedir(DIR); + + foreach (@testdir_contents) { + if ((-d ($dir . $_)) && ($_ ne 'CVS') && ($_ ne '.') && ($_ ne '..')) { + @subdirs[$#subdirs + 1] = $_; + } + } + + return @subdirs; +} + +# +# given a directory, return an array of all the js files that are in it. +# +sub get_js_files { + local ($test_subdir) = @_; + local @js_file_array; + + opendir ( TEST_SUBDIR, $test_subdir) || die ("couldn't open directory " . + "$test_subdir: $!"); + @subdir_files = readdir( TEST_SUBDIR ); + closedir( TEST_SUBDIR ); + + foreach ( @subdir_files ) { + if ( $_ =~ /\.js$/ ) { + $js_file_array[$#js_file_array+1] = $_; + } + } + + return @js_file_array; +} + + diff --git a/tests/mozilla/runtests.pl b/tests/mozilla/runtests.pl new file mode 100644 index 0000000..f6f05fb --- /dev/null +++ b/tests/mozilla/runtests.pl @@ -0,0 +1,495 @@ +#!/tools/ns/bin/perl5 +# +# simple script that executes JavaScript tests. you have to build the +# stand-alone, js shell executable (which is not the same as the dll that gets +# built for mozilla). see the readme at +# http://lxr.mozilla.org/mozilla/source/js/src/README.html for instructions on +# how to build the jsshell. +# +# this is just a quick-n-dirty script. for full reporting, you need to run +# the test driver, which requires java and is currently not available on +# mozilla.org. +# +# this test looks for an executable JavaScript shell in +# %MOZ_SRC/mozilla/js/src/[platform]-[platform-version]-OPT.OBJ/js, +# which is the default build location when you build using the instructions +# at http://lxr.mozilla.org/mozilla/source/js/src/README.html +# +# +# christine@netscape.com +# + +&parse_args; +&setup_env; +&main_test_loop; +&cleanup_env; + +# +# given a main directory, assume that there is a file called 'shell.js' +# in it. then, open all the subdirectories, and look for js files. +# for each test.js that is found, execute the shell, and pass shell.js +# and the test.js as file arguments. redirect all process output to a +# file. +# +sub main_test_loop { + foreach $suite ( &get_subdirs( $test_dir )) { + foreach $subdir (&get_subdirs( $suite, $test_dir )) { + @jsfiles = &get_js_files($subdir); + execute_js_tests(@jsfiles); + } + } +} + +# +# given a directory, return an array of all subdirectories +# +sub get_subdirs{ + local ($dir, $path) = @_; + local @subdirs; + + local $dir_path = $path . $dir; + chdir $dir_path; + + opendir ( DIR, ${dir_path} ); + local @testdir_contents = readdir( DIR ); + closedir( DIR ); + + foreach (@testdir_contents) { + if ( (-d $_) && ($_ !~ 'CVS') && ( $_ ne '.') && ($_ ne '..')) { + @subdirs[$#subdirs+1] = $_; + } + } + chdir $path; + return @subdirs; +} + +# +# given a directory, return an array of all the js files that are in it. +# +sub get_js_files { + ( $test_subdir ) = @_; + local @js_file_array; + + $current_test_dir = $test_dir ."/". $suite . "/" .$test_subdir; + chdir $current_test_dir; + + opendir ( TEST_SUBDIR, ${current_test_dir} ); + @subdir_files = readdir( TEST_SUBDIR ); + closedir( TOP_LEVEL_BUILD_DIR ); + + foreach ( @subdir_files ) { + if ( $_ =~ /\.js$/ ) { + $js_file_array[$#js_file_array+1] = $_; + } + } + + return @js_file_array; +} + +# +# given an array of test.js files, execute the shell command and pass +# the shell.js and test.js files as file arguments. redirect process +# output to a file. if $js_verbose is set (not recommended), write all +# testcase output to the output file. if $js_quiet is set, only write +# failed test case information to the output file. the default setting +# is to write a line for each test file, and whether each file passed +# or failed. +# +sub execute_js_tests { + (@js_file_array) = @_; + + $js_printed_suitename = 0; + if ( !$js_quiet ) { + &js_print_suitename; + } + + foreach $js_test (@js_file_array) { + $js_printed_filename = 0; + $js_test_bugnumber = 0; + $runtime_error = ""; + + local $passed = -1; + + # create the test command + $test_command = + $shell_command . + " -f $test_dir/$suite/shell.js " . + " -f $test_dir/$suite/$subdir/$js_test"; + + if ( !$js_quiet ) { + &js_print_filename; + } else { + print '.'; + } + + $test_path = $test_dir ."/" . $suite ."/". $test_subdir ."/". $js_test; + + + if ( !-e $test_path ) { + &js_print( " FAILED! file not found\n", + "", "
\n"); + } else { + open( RUNNING_TEST, "$test_command" . ' 2>&1 |'); + + + # this is where we want the tests to provide a lot more information + # that this script must parse so that we can + + while( ){ + if ( $js_verbose && !$js_quiet ) { + &js_print ($_ ."\n", "", "
\n"); + } + if ( $_ =~ /BUGNUMBER/ ) { + $js_test_bugnumber = $_; + } + if ( $_ =~ /PASSED/ && $passed == -1 ) { + $passed = 1; + } + if ( $_ =~ /FAILED/ && $_ =~ /expected/) { + &js_print_suitename; + &js_print_filename; + &js_print_bugnumber; + + local @msg = split ( "FAILED", $_ ); + &js_print ( $passed ? "\n" : "" ); + &js_print( " " . $msg[0], "  " ); + &js_print( "FAILED", "", ""); + &js_print( $msg[1], "", "
\n" ); + $passed = 0; + } + if ( $_ =~ /$js_test/ ) { + $runtime_error .= $_; + } + } + close( RUNNING_TEST ); + + # + # figure out whether the test passed or failed. print out an + # appropriate level of output based on the value of $js_quiet + # + if ( $js_test =~ /-n\.js$/ ) { + if ( $runtime_error ) { + if ( !$js_quiet ) { + &js_print( " PASSED!\n ", + "  ", + "
" ); + if ( $js_errors ) { + &js_print( $runtime_error, "
", "
"); + } + } + } else { + &js_print_suitename; + &js_print_filename; + &js_print_bugnumber; + &js_print( " FAILED! ", "  ", + ""); + &js_print( " Should have resulted in an error\n", + "","
" ); + } + } else { + if ( $passed == 1 && !$js_quiet) { + &js_print( " PASSED!\n " , "  ", + "
" ); + } else { + if ($passed == -1) { + &js_print_suitename; + &js_print_filename; + &js_print_bugnumber; + &js_print( " FAILED!\n " , "  ", + "
" ); + &js_print( " Missing 'PASSED' in output\n", "","
" ); + &js_print( $log, "output:
", "
" ); + } + } + + } + } + } +} + +# +# figure out what os we're on, the default name of the object directory +# +sub setup_env { + # MOZ_SRC must be set, so we can figure out where the + # JavaScript executable is + $moz_src = $ENV{"MOZ_SRC"} + || die( "You need to set your MOZ_SRC environment variable.\n" ); + $src_dir = $moz_src . '/mozilla/js/src/'; + + # JS_TEST_DIR must be set so we can figure out where the tests are. + $test_dir = $ENV{"JS_TEST_DIR"}; + + # if it's not set, look for it relative to $moz_src + if ( !$test_dir ) { + $test_dir = $moz_src . '/mozilla/js/tests/'; + } + + # make sure that the test dir exists + if ( ! -e $test_dir ) { + die "The JavaScript Test Library could not be found at $test_dir.\n" . + "Check the tests out from /mozilla/js/tests or\n" . + "Set the value of your JS_TEST_DIR environment variable\n " . + "to the location of the test library.\n"; + } + + # make sure that the test dir ends with a trailing slash + $test_dir .= '/'; + + chdir $src_dir; + + # figure out which platform we're on, and figure out where the object + # directory is + + $machine_os = `uname -s`; + + if ( $machine_os =~ /WIN/ ) { + $machine_os = 'WIN'; + $object_dir = ($js_debug) ? 'Debug' : 'Release'; + $js_exe = 'jsshell.exe'; + } else { + chop $machine_os; + $js_exe = 'js'; + + # figure out what the object directory is. on all platforms, + # it's the directory that ends in OBJ. if $js_debug is set, + # look the directory that ends with or DBG.OBJ; otherwise + # look for the directory that ends with OPT.OBJ + + opendir ( SRC_DIR_FILES, $src_dir ); + @src_dir_files = readdir( SRC_DIR_FILES ); + closedir ( SRC_DIR_FILES ); + + $object_pattern = $js_debug ? 'DBG.OBJ' : 'OPT.OBJ'; + + foreach (@src_dir_files) { + if ( $_ =~ /$object_pattern/ && $_ =~ $machine_os) { + $object_dir = $_; + } + } + } + if ( ! $object_dir ) { + die( "Couldn't find an object directory in $src_dir.\n" ); + } + + # figure out what the name of the javascript executable should be, and + # make sure it's there. if it's not there, give a helpful message so + # the user can figure out what they need to do next. + + + if ( ! $js_exe_full_path ) { + $shell_command = $src_dir . $object_dir .'/'. $js_exe; + } else { + $shell_command = $js_exe_full_path; + } + + if ( !-e $shell_command ) { + die ("Could not find JavaScript shell executable $shell_command.\n" . + "Check the value of your MOZ_SRC environment variable.\n" . + "Currently, MOZ_SRC is set to $ENV{\"MOZ_SRC\"}\n". + "See the readme at http://lxr.mozilla.org/mozilla/src/js/src/ " . + "for instructions on building the JavaScript shell.\n" ); + } + + # set the output file name. let's base its name on the date and platform, + # and give it a sequence number. + + if ( $get_output ) { + $js_output = &get_output; + } + if ($js_output) { + print( "Writing results to $js_output\n" ); + chdir $test_dir; + open( JS_OUTPUT, "> ${js_output}" ) || + die "Can't open log file $js_output\n"; + close JS_OUTPUT; + } + + # get the start time + $start_time = time; + + # print out some nice stuff + $start_date = &get_date; + &js_print( "JavaScript tests started: " . $start_date, "

", "

" ); + + &js_print ("Executing all the tests under $test_dir\n against " . + "$shell_command\n", "

", "

" ); +} + +# +# parse arguments. see usage for what arguments are expected. +# +sub parse_args { + $i = 0; + while( $i < @ARGV ){ + if ( $ARGV[$i] eq '--threaded' ) { + $js_threaded = 1; + } elsif ( $ARGV[$i] eq '--d' ) { + $js_debug = 1; + } elsif ( $ARGV[$i] eq '--14' ) { + $js_version = '14'; + } elsif ( $ARGV[$i] eq '--v' ) { + $js_verbose = 1; + } elsif ( $ARGV[$i] eq '-f' ) { + $js_output = $ARGV[++$i]; + } elsif ( $ARGV[$i] eq '--o' ) { + $get_output = 1; + } elsif ($ARGV[$i] eq '--e' ) { + $js_errors = 1; + } elsif ($ARGV[$i] eq '--q' ) { + $js_quiet = 1; + } elsif ($ARGV[$i] eq '--h' ) { + die &usage; + } elsif ( $ARGV[$i] eq '-E' ) { + $js_exe_full_path = $ARGV[$i+1]; + $i++; + } else { + die &usage; + } + $i++; + } + + # + # if no output options are provided, show some output and write to file + # + if ( !$js_verbose && !$js_output && !$get_output ) { + $get_output = 1; + } +} + +# +# print the arguments that this script expects +# +sub usage { + die ("usage: $0\n" . + "--q Quiet mode -- only show information for tests that failed\n". + "--e Show runtime error messages for negative tests\n" . + "--v Verbose output -- show all test cases (not recommended)\n" . + "--o Send output to file whose generated name is based on date\n". + "--d Look for a debug JavaScript executable (default is optimized)\n" . + "-f Redirect output to file named \n" + ); +} + +# +# if $js_output is set, print to file as well as stdout +# +sub js_print { + ($string, $start_tag, $end_tag) = @_; + + if ($js_output) { + open( JS_OUTPUT, ">> ${js_output}" ) || + die "Can't open log file $js_output\n"; + + print JS_OUTPUT "$start_tag $string $end_tag"; + close JS_OUTPUT; + } + print $string; +} + +# +# close open files +# +sub cleanup_env { + # print out some nice stuff + $end_date = &get_date; + &js_print( "\nTests complete at $end_date", "
", "" ); + + # print out how long it took to complete + $end_time = time; + + $test_seconds = ( $end_time - $start_time ); + + &js_print( "Start Date: $start_date\n", "
" ); + &js_print( "End Date: $end_date\n", "
" ); + &js_print( "Test Time: $test_seconds seconds\n", "
" ); + + if ($js_output ) { + if ( !$js_verbose) { + &js_print( "Results were written to " . $js_output ."\n", + "
", "
" ); + } + close JS_OUTPUT; + } +} + + +# +# get the current date and time +# +sub get_date { + &get_localtime; + $now = $year ."/". $mon ."/". $mday ." ". $hour .":". + $min .":". $sec ."\n"; + return $now; + +} +sub get_localtime { + ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = + localtime; + $mon++; + $mon = &zero_pad($mon); + $year= ($year < 2000) ? "19" . $year : $year; + $mday= &zero_pad($mday); + $sec = &zero_pad($sec); + $min = &zero_pad($min); + $hour = &zero_pad($hour); +} +sub zero_pad { + local ($string) = @_; + $string = ($string < 10) ? "0" . $string : $string; + return $string; +} + +# +# generate an output file name based on the date +# +sub get_output { + &get_localtime; + + chdir $test_dir; + + $js_output = $test_dir ."/". $year .'-'. $mon .'-'. $mday ."\.1.html"; + + $output_file_found = 0; + + while ( !$output_file_found ) { + if ( -e $js_output ) { + # get the last sequence number - everything after the dot + @seq_no = split( /\./, $js_output, 2 ); + $js_output = $seq_no[0] .".". (++$seq_no[1]) . "\.html"; + } else { + $output_file_found = 1; + } + } + return $js_output; +} + +sub js_print_suitename { + if ( !$js_printed_suitename ) { + &js_print( "$suite\\$subdir\n", "
", + "
" ); + } + $js_printed_suitename = 1; +} + +sub js_print_filename { + if ( !$js_printed_filename ) { + &js_print( "$js_test\n", "", "
" ); + $js_printed_filename = 1; + } +} + +sub js_print_bugnumber { + if ( !$js_printed_bugnumber ) { + if ( $js_bugnumber =~ /^http/ ) { + &js_print( "$js_bugnumber", "", "" ); + } else { + &js_print( "$js_bugnumber", + "", + "" ); + } + $js_printed_bugnumber = 1; + } +} diff --git a/tests/mozilla/template.js b/tests/mozilla/template.js new file mode 100644 index 0000000..e953183 --- /dev/null +++ b/tests/mozilla/template.js @@ -0,0 +1,55 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/** + * File Name: template.js + * Reference: ** replace with bugzilla URL or document reference ** + * Description: ** replace with description of test ** + * Author: ** replace with your e-mail address ** + */ + + var SECTION = ""; // provide a document reference (ie, ECMA section) + var VERSION = "ECMA_2"; // Version of JavaScript or ECMA + var TITLE = ""; // Provide ECMA section title or a description + var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + /* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + + test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/wtf/ASCIICType.h b/wtf/ASCIICType.h new file mode 100644 index 0000000..d93acc5 --- /dev/null +++ b/wtf/ASCIICType.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_ASCIICType_h +#define WTF_ASCIICType_h + +#include + +// The behavior of many of the functions in the header is dependent +// on the current locale. But in the WebKit project, all uses of those functions +// are in code processing something that's not locale-specific. These equivalents +// for some of the functions are named more explicitly, not dependent +// on the C library locale, and we should also optimize them as needed. + +// All functions return false or leave the character unchanged if passed a character +// that is outside the range 0-7F. So they can be used on Unicode strings or +// characters if the intent is to do processing only if the character is ASCII. + +namespace WTF { + + inline bool isASCIIAlpha(char c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } + inline bool isASCIIAlpha(unsigned short c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } +#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) + inline bool isASCIIAlpha(wchar_t c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } +#endif + inline bool isASCIIAlpha(int c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } + + inline bool isASCIIAlphanumeric(char c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } + inline bool isASCIIAlphanumeric(unsigned short c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } +#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) + inline bool isASCIIAlphanumeric(wchar_t c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } +#endif + inline bool isASCIIAlphanumeric(int c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } + + inline bool isASCIIDigit(char c) { return (c >= '0') & (c <= '9'); } + inline bool isASCIIDigit(unsigned short c) { return (c >= '0') & (c <= '9'); } +#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) + inline bool isASCIIDigit(wchar_t c) { return (c >= '0') & (c <= '9'); } +#endif + inline bool isASCIIDigit(int c) { return (c >= '0') & (c <= '9'); } + + inline bool isASCIIHexDigit(char c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'f'; } + inline bool isASCIIHexDigit(unsigned short c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'f'; } +#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) + inline bool isASCIIHexDigit(wchar_t c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'f'; } +#endif + inline bool isASCIIHexDigit(int c) { return c >= '0' && c <= '9' || (c | 0x20) >= 'a' && (c | 0x20) <= 'f'; } + + inline bool isASCIILower(char c) { return c >= 'a' && c <= 'z'; } + inline bool isASCIILower(unsigned short c) { return c >= 'a' && c <= 'z'; } +#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) + inline bool isASCIILower(wchar_t c) { return c >= 'a' && c <= 'z'; } +#endif + inline bool isASCIILower(int c) { return c >= 'a' && c <= 'z'; } + + inline bool isASCIIUpper(char c) { return c >= 'A' && c <= 'Z'; } + inline bool isASCIIUpper(unsigned short c) { return c >= 'A' && c <= 'Z'; } +#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) + inline bool isASCIIUpper(wchar_t c) { return c >= 'A' && c <= 'Z'; } +#endif + inline bool isASCIIUpper(int c) { return c >= 'A' && c <= 'Z'; } + + /* + Statistics from a run of the PLT on the usage of isASCIISpace: + Hex Name Count + --- ---- ----- + ALL OTHER VALUES 689383 + x20 SPACE 294720 + x0A NEWLINE 89059 + x09 TAB 28320 + x0D CARRIAGE RETURN 0 + x0C FORMFEED 0 + x0B VERTICAL TAB 0 + + */ + + inline bool isASCIISpace(char c) { return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); } + inline bool isASCIISpace(unsigned short c) { return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); } +#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) + inline bool isASCIISpace(wchar_t c) { return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); } +#endif + inline bool isASCIISpace(int c) { return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); } + + inline char toASCIILower(char c) { return c | ((c >= 'A' && c <= 'Z') << 5); } + inline unsigned short toASCIILower(unsigned short c) { return c | ((c >= 'A' && c <= 'Z') << 5); } +#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) + inline wchar_t toASCIILower(wchar_t c) { return c | ((c >= 'A' && c <= 'Z') << 5); } +#endif + inline int toASCIILower(int c) { return c | ((c >= 'A' && c <= 'Z') << 5); } + + inline char toASCIIUpper(char c) { return static_cast(c & ~((c >= 'a' && c <= 'z') << 5)); } + inline unsigned short toASCIIUpper(unsigned short c) { return static_cast(c & ~((c >= 'a' && c <= 'z') << 5)); } +#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) + inline wchar_t toASCIIUpper(wchar_t c) { return static_cast(c & ~((c >= 'a' && c <= 'z') << 5)); } +#endif + inline int toASCIIUpper(int c) { return static_cast(c & ~((c >= 'a' && c <= 'z') << 5)); } + +} + +#endif diff --git a/wtf/AlwaysInline.h b/wtf/AlwaysInline.h new file mode 100644 index 0000000..3f54815 --- /dev/null +++ b/wtf/AlwaysInline.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef ALWAYS_INLINE +#if COMPILER(GCC) && defined(NDEBUG) +#define ALWAYS_INLINE inline __attribute__ ((__always_inline__)) +#elif COMPILER(MSVC) && defined(NDEBUG) +#define ALWAYS_INLINE __forceinline +#else +#define ALWAYS_INLINE inline +#endif +#endif + +#ifndef NEVER_INLINE +#if COMPILER(GCC) +#define NEVER_INLINE __attribute__ ((__noinline__)) +#else +#define NEVER_INLINE +#endif +#endif diff --git a/wtf/Assertions.cpp b/wtf/Assertions.cpp new file mode 100644 index 0000000..0f996db --- /dev/null +++ b/wtf/Assertions.cpp @@ -0,0 +1,163 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Assertions.h" + +#include +#include +#include + +#include + +#if COMPILER(MSVC) +#ifndef WINVER +#define WINVER 0x0500 +#endif +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 +#endif +#include +#include +#endif + +extern "C" { + +WTF_ATTRIBUTE_PRINTF(1, 0) +static void vprintf_stderr_common(const char* format, va_list args) +{ + if (strstr(format, "%@")) { + CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8); + CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args); + + int length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8); + char* buffer = (char*)malloc(length + 1); + + CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8); + + fputs(buffer, stderr); + + free(buffer); + CFRelease(str); + CFRelease(cfFormat); + } else + vfprintf(stderr, format, args); +} + +WTF_ATTRIBUTE_PRINTF(1, 2) +static void printf_stderr_common(const char* format, ...) +{ + va_list args; + va_start(args, format); + vprintf_stderr_common(format, args); + va_end(args); +} + +static void printCallSite(const char* file, int line, const char* function) +{ +#if PLATFORM(WIN) && defined _DEBUG + _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function); +#else + printf_stderr_common("(%s:%d %s)\n", file, line, function); +#endif +} + +void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion) +{ + if (assertion) + printf_stderr_common("ASSERTION FAILED: %s\n", assertion); + else + printf_stderr_common("SHOULD NEVER BE REACHED\n"); + printCallSite(file, line, function); +} + +void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) +{ + printf_stderr_common("ASSERTION FAILED: "); + va_list args; + va_start(args, format); + vprintf_stderr_common(format, args); + va_end(args); + printf_stderr_common("\n%s\n", assertion); + printCallSite(file, line, function); +} + +void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion) +{ + printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion); + printCallSite(file, line, function); +} + +void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) +{ + printf_stderr_common("FATAL ERROR: "); + va_list args; + va_start(args, format); + vprintf_stderr_common(format, args); + va_end(args); + printf_stderr_common("\n"); + printCallSite(file, line, function); +} + +void WTFReportError(const char* file, int line, const char* function, const char* format, ...) +{ + printf_stderr_common("ERROR: "); + va_list args; + va_start(args, format); + vprintf_stderr_common(format, args); + va_end(args); + printf_stderr_common("\n"); + printCallSite(file, line, function); +} + +void WTFLog(WTFLogChannel* channel, const char* format, ...) +{ + if (channel->state != WTFLogChannelOn) + return; + + va_list args; + va_start(args, format); + vprintf_stderr_common(format, args); + va_end(args); + if (format[strlen(format) - 1] != '\n') + printf_stderr_common("\n"); +} + +void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel* channel, const char* format, ...) +{ + if (channel->state != WTFLogChannelOn) + return; + + va_list args; + va_start(args, format); + vprintf_stderr_common(format, args); + va_end(args); + if (format[strlen(format) - 1] != '\n') + printf_stderr_common("\n"); + printCallSite(file, line, function); +} + +} // extern "C" diff --git a/wtf/Assertions.h b/wtf/Assertions.h new file mode 100644 index 0000000..74ea91c --- /dev/null +++ b/wtf/Assertions.h @@ -0,0 +1,232 @@ +/* -*- mode: c++; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_Assertions_h +#define WTF_Assertions_h + +/* + no namespaces because this file has to be includable from C and Objective-C + + Note, this file uses many GCC extensions, but it should be compatible with + C, Objective C, C++, and Objective C++. + + For non-debug builds, everything is disabled by default. + Defining any of the symbols explicitly prevents this from having any effect. + + MSVC7 note: variadic macro support was added in MSVC8, so for now we disable + those macros in MSVC7. For more info, see the MSDN document on variadic + macros here: + + http://msdn2.microsoft.com/en-us/library/ms177415(VS.80).aspx +*/ + +#include "Platform.h" + +#if COMPILER(MSVC) +#include +#else +#include +#endif + +#ifdef NDEBUG +#define ASSERTIONS_DISABLED_DEFAULT 1 +#else +#define ASSERTIONS_DISABLED_DEFAULT 0 +#endif + +#ifndef ASSERT_DISABLED +#define ASSERT_DISABLED ASSERTIONS_DISABLED_DEFAULT +#endif + +#ifndef ASSERT_ARG_DISABLED +#define ASSERT_ARG_DISABLED ASSERTIONS_DISABLED_DEFAULT +#endif + +#ifndef FATAL_DISABLED +#define FATAL_DISABLED ASSERTIONS_DISABLED_DEFAULT +#endif + +#ifndef ERROR_DISABLED +#define ERROR_DISABLED ASSERTIONS_DISABLED_DEFAULT +#endif + +#ifndef LOG_DISABLED +#define LOG_DISABLED ASSERTIONS_DISABLED_DEFAULT +#endif + +#if COMPILER(GCC) +#define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__ +#else +#define WTF_PRETTY_FUNCTION __FUNCTION__ +#endif + +// WTF logging functions can process %@ in the format string to log a NSObject* but the printf format attribute +// emits a warning when %@ is used in the format string. Until is resolved we can't include +// the attribute when being used from Objective-C code in case it decides to use %@. +#if COMPILER(GCC) && !defined(__OBJC__) +#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) __attribute__((__format__(printf, formatStringArgument, extraArguments))) +#else +#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) +#endif + +/* These helper functions are always declared, but not necessarily always defined if the corresponding function is disabled. */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState; + +typedef struct { + unsigned mask; + const char *defaultName; + WTFLogChannelState state; +} WTFLogChannel; + +void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion); +void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6); +void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion); +void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5); +void WTFReportError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5); +void WTFLog(WTFLogChannel* channel, const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3); +void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel* channel, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6); + +#ifdef __cplusplus +} +#endif + +/* CRASH -- gets us into the debugger or the crash reporter -- signals are ignored by the crash reporter so we must do better */ + +#ifndef CRASH +#define CRASH() *(int *)(uintptr_t)0xbbadbeef = 0 +#endif + +/* ASSERT, ASSERT_WITH_MESSAGE, ASSERT_NOT_REACHED */ + +#if PLATFORM(WIN_OS) +/* FIXME: Change to use something other than ASSERT to avoid this conflict with win32. */ +#undef ASSERT +#endif + +#if ASSERT_DISABLED + +#define ASSERT(assertion) ((void)0) +#define ASSERT_WITH_MESSAGE(assertion, ...) ((void)0) +#define ASSERT_NOT_REACHED() ((void)0) + +#else + +#define ASSERT(assertion) do \ + if (!(assertion)) { \ + WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion); \ + CRASH(); \ + } \ +while (0) +#if COMPILER(MSVC7) +#define ASSERT_WITH_MESSAGE(assertion) ((void)0) +#else +#define ASSERT_WITH_MESSAGE(assertion, ...) do \ + if (!(assertion)) { \ + WTFReportAssertionFailureWithMessage(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion, __VA_ARGS__); \ + CRASH(); \ + } \ +while (0) +#endif // COMPILER(MSVC7) +#define ASSERT_NOT_REACHED() do { \ + WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \ + CRASH(); \ +} while (0) + +#endif + +/* ASSERT_ARG */ + +#if ASSERT_ARG_DISABLED + +#define ASSERT_ARG(argName, assertion) ((void)0) + +#else + +#define ASSERT_ARG(argName, assertion) do \ + if (!(assertion)) { \ + WTFReportArgumentAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #argName, #assertion); \ + CRASH(); \ + } \ +while (0) + +#endif + +/* COMPILE_ASSERT */ +#ifndef COMPILE_ASSERT +#define COMPILE_ASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; +#endif + +/* FATAL */ + +#if FATAL_DISABLED +#define FATAL(...) ((void)0) +#elif COMPILER(MSVC7) +#define FATAL() ((void)0) +#else +#define FATAL(...) do { \ + WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__); \ + CRASH(); \ +} while (0) +#endif + +/* LOG_ERROR */ + +#if ERROR_DISABLED +#define LOG_ERROR(...) ((void)0) +#elif COMPILER(MSVC7) +#define LOG_ERROR() ((void)0) +#else +#define LOG_ERROR(...) WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__) +#endif + +/* LOG */ + +#if LOG_DISABLED +#define LOG(channel, ...) ((void)0) +#elif COMPILER(MSVC7) +#define LOG() ((void)0) +#else +#define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__) +#define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) +#define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel +#endif + +/* LOG_VERBOSE */ + +#if LOG_DISABLED +#define LOG_VERBOSE(channel, ...) ((void)0) +#elif COMPILER(MSVC7) +#define LOG_VERBOSE(channel) ((void)0) +#else +#define LOG_VERBOSE(channel, ...) WTFLogVerbose(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, &JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__) +#endif + +#endif // WTF_Assertions_h diff --git a/wtf/Deque.h b/wtf/Deque.h new file mode 100644 index 0000000..f8cf4fe --- /dev/null +++ b/wtf/Deque.h @@ -0,0 +1,583 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_Deque_h +#define WTF_Deque_h + +// FIXME: Could move what Vector and Deque share into a separate file. +// Deque doesn't actually use Vector. + +#include "Vector.h" + +namespace WTF { + + template class DequeIteratorBase; + template class DequeIterator; + template class DequeConstIterator; + template class DequeReverseIterator; + template class DequeConstReverseIterator; + + template + class Deque { + public: + typedef DequeIterator iterator; + typedef DequeConstIterator const_iterator; + typedef DequeReverseIterator reverse_iterator; + typedef DequeConstReverseIterator const_reverse_iterator; + + Deque(); + Deque(const Deque&); + Deque& operator=(const Deque&); + ~Deque(); + + void swap(Deque&); + + size_t size() const { return m_start <= m_end ? m_end - m_start : m_end + m_buffer.capacity() - m_start; } + bool isEmpty() const { return m_start == m_end; } + + iterator begin() { return iterator(this, m_start); } + iterator end() { return iterator(this, m_end); } + const_iterator begin() const { return const_iterator(this, m_start); } + const_iterator end() const { return const_iterator(this, m_end); } + reverse_iterator rbegin() { return reverse_iterator(this, m_end); } + reverse_iterator rend() { return reverse_iterator(this, m_start); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(this, m_end); } + const_reverse_iterator rend() const { return const_reverse_iterator(this, m_start); } + + T& first() { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start]; } + const T& first() const { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start]; } + + template void append(const U&); + template void prepend(const U&); + void removeFirst(); + + void clear(); + + private: + friend class DequeIteratorBase; + + typedef VectorBuffer Buffer; + typedef VectorTypeOperations TypeOperations; + typedef DequeIteratorBase IteratorBase; + + void invalidateIterators(); + void destroyAll(); + void checkValidity() const; + void checkIndexValidity(size_t) const; + void expandCapacityIfNeeded(); + void expandCapacity(); + + size_t m_start; + size_t m_end; + Buffer m_buffer; +#ifndef NDEBUG + mutable IteratorBase* m_iterators; +#endif + }; + + template + class DequeIteratorBase { + private: + typedef DequeIteratorBase Base; + + protected: + DequeIteratorBase(); + DequeIteratorBase(const Deque*, size_t); + DequeIteratorBase(const Base&); + Base& operator=(const Base&); + ~DequeIteratorBase(); + + void assign(const Base& other) { *this = other; } + + void increment(); + void decrement(); + + T* before() const; + T* after() const; + + bool isEqual(const Base&) const; + + private: + void addToIteratorsList(); + void checkValidity() const; + void checkValidity(const Base&) const; + + Deque* m_deque; + size_t m_index; + + friend class Deque; + +#ifndef NDEBUG + mutable DequeIteratorBase* m_next; + mutable DequeIteratorBase* m_previous; +#endif + }; + + template + class DequeIterator : public DequeIteratorBase { + private: + typedef DequeIteratorBase Base; + typedef DequeIterator Iterator; + + public: + DequeIterator(Deque* deque, size_t index) : Base(deque, index) { } + + DequeIterator(const Iterator& other) : Base(other) { } + DequeIterator& operator=(const Iterator& other) { Base::assign(other); return *this; } + + T& operator*() const { return *Base::after(); } + T* operator->() const { return Base::after(); } + + bool operator==(const Iterator& other) const { return Base::isEqual(other); } + bool operator!=(const Iterator& other) const { return !Base::isEqual(other); } + + Iterator& operator++() { Base::increment(); return *this; } + // postfix ++ intentionally omitted + Iterator& operator--() { Base::decrement(); return *this; } + // postfix -- intentionally omitted + }; + + template + class DequeConstIterator : public DequeIteratorBase { + private: + typedef DequeIteratorBase Base; + typedef DequeConstIterator Iterator; + typedef DequeIterator NonConstIterator; + + public: + DequeConstIterator(const Deque* deque, size_t index) : Base(deque, index) { } + + DequeConstIterator(const Iterator& other) : Base(other) { } + DequeConstIterator(const NonConstIterator& other) : Base(other) { } + DequeConstIterator& operator=(const Iterator& other) { Base::assign(other); return *this; } + DequeConstIterator& operator=(const NonConstIterator& other) { Base::assign(other); return *this; } + + const T& operator*() const { return *Base::after(); } + const T* operator->() const { return Base::after(); } + + bool operator==(const Iterator& other) const { return Base::isEqual(other); } + bool operator!=(const Iterator& other) const { return !Base::isEqual(other); } + + Iterator& operator++() { Base::increment(); return *this; } + // postfix ++ intentionally omitted + Iterator& operator--() { Base::decrement(); return *this; } + // postfix -- intentionally omitted + }; + + template + class DequeReverseIterator : public DequeIteratorBase { + private: + typedef DequeIteratorBase Base; + typedef DequeReverseIterator Iterator; + + public: + DequeReverseIterator(const Deque* deque, size_t index) : Base(deque, index) { } + + DequeReverseIterator(const Iterator& other) : Base(other) { } + DequeReverseIterator& operator=(const Iterator& other) { Base::assign(other); return *this; } + + T& operator*() const { return *Base::before(); } + T* operator->() const { return Base::before(); } + + bool operator==(const Iterator& other) const { return Base::isEqual(other); } + bool operator!=(const Iterator& other) const { return !Base::isEqual(other); } + + Iterator& operator++() { Base::decrement(); return *this; } + // postfix ++ intentionally omitted + Iterator& operator--() { Base::increment(); return *this; } + // postfix -- intentionally omitted + }; + + template + class DequeConstReverseIterator : public DequeIteratorBase { + private: + typedef DequeIteratorBase Base; + typedef DequeConstReverseIterator Iterator; + typedef DequeReverseIterator NonConstIterator; + + public: + DequeConstReverseIterator(const Deque* deque, size_t index) : Base(deque, index) { } + + DequeConstReverseIterator(const Iterator& other) : Base(other) { } + DequeConstReverseIterator(const NonConstIterator& other) : Base(other) { } + DequeConstReverseIterator& operator=(const Iterator& other) { Base::assign(other); return *this; } + DequeConstReverseIterator& operator=(const NonConstIterator& other) { Base::assign(other); return *this; } + + const T& operator*() const { return *Base::before(); } + const T* operator->() const { return Base::before(); } + + bool operator==(const Iterator& other) const { return Base::isEqual(other); } + bool operator!=(const Iterator& other) const { return !Base::isEqual(other); } + + Iterator& operator++() { Base::decrement(); return *this; } + // postfix ++ intentionally omitted + Iterator& operator--() { Base::increment(); return *this; } + // postfix -- intentionally omitted + }; + +#ifdef NDEBUG + template inline void Deque::checkValidity() const { } + template inline void Deque::checkIndexValidity(size_t) const { } + template inline void Deque::invalidateIterators() { } +#else + template + void Deque::checkValidity() const + { + if (!m_buffer.capacity()) { + ASSERT(!m_start); + ASSERT(!m_end); + } else { + ASSERT(m_start < m_buffer.capacity()); + ASSERT(m_end < m_buffer.capacity()); + } + } + + template + void Deque::checkIndexValidity(size_t index) const + { + ASSERT(index <= m_buffer.capacity()); + if (m_start <= m_end) { + ASSERT(index >= m_start); + ASSERT(index <= m_end); + } else { + ASSERT(index >= m_start || index <= m_end); + } + } + + template + void Deque::invalidateIterators() + { + IteratorBase* next; + for (IteratorBase* p = m_iterators; p; p = next) { + next = p->m_next; + p->m_deque = 0; + p->m_next = 0; + p->m_previous = 0; + } + m_iterators = 0; + } +#endif + + template + inline Deque::Deque() + : m_start(0) + , m_end(0) +#ifndef NDEBUG + , m_iterators(0) +#endif + { + checkValidity(); + } + + template + inline Deque::Deque(const Deque& other) + : m_start(other.m_start) + , m_end(other.m_end) + , m_buffer(other.m_buffer.capacity()) +#ifndef NDEBUG + , m_iterators(0) +#endif + { + const T* otherBuffer = other.m_buffer.buffer(); + if (m_start <= m_end) + TypeOperations::uninitializedCopy(otherBuffer + m_start, otherBuffer + m_end, m_buffer.buffer() + m_start); + else { + TypeOperations::uninitializedCopy(otherBuffer, otherBuffer + m_end, m_buffer.buffer()); + TypeOperations::uninitializedCopy(otherBuffer + m_start, otherBuffer + m_buffer.capacity(), m_buffer.buffer() + m_start); + } + } + + template + inline Deque& Deque::operator=(const Deque& other) + { + Deque copy(other); + swap(copy); + return *this; + } + + template + inline void Deque::destroyAll() + { + if (m_start <= m_end) + TypeOperations::destruct(m_buffer.buffer() + m_start, m_buffer.buffer() + m_end); + else { + TypeOperations::destruct(m_buffer.buffer(), m_buffer.buffer() + m_end); + TypeOperations::destruct(m_buffer.buffer() + m_start, m_buffer.buffer() + m_buffer.capacity()); + } + } + + template + inline Deque::~Deque() + { + checkValidity(); + invalidateIterators(); + destroyAll(); + } + + template + inline void Deque::swap(Deque& other) + { + checkValidity(); + other.checkValidity(); + invalidateIterators(); + std::swap(m_start, other.m_start); + std::swap(m_end, other.m_end); + m_buffer.swap(other.m_buffer); + checkValidity(); + other.checkValidity(); + } + + template + inline void Deque::clear() + { + checkValidity(); + invalidateIterators(); + destroyAll(); + m_start = 0; + m_end = 0; + checkValidity(); + } + + template + inline void Deque::expandCapacityIfNeeded() + { + if (m_start) { + if (m_end + 1 != m_start) + return; + } else if (m_end) { + if (m_end != m_buffer.capacity() - 1) + return; + } else if (m_buffer.capacity()) + return; + + expandCapacity(); + } + + template + void Deque::expandCapacity() + { + checkValidity(); + size_t oldCapacity = m_buffer.capacity(); + size_t newCapacity = max(static_cast(16), oldCapacity + oldCapacity / 4 + 1); + T* oldBuffer = m_buffer.buffer(); + m_buffer.allocateBuffer(newCapacity); + if (m_start <= m_end) + TypeOperations::move(oldBuffer + m_start, oldBuffer + m_end, m_buffer.buffer() + m_start); + else { + TypeOperations::move(oldBuffer, oldBuffer + m_end, m_buffer.buffer()); + size_t newStart = newCapacity - (oldCapacity - m_start); + TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity, m_buffer.buffer() + newStart); + m_start = newStart; + } + m_buffer.deallocateBuffer(oldBuffer); + checkValidity(); + } + + template template + inline void Deque::append(const U& value) + { + checkValidity(); + expandCapacityIfNeeded(); + new (&m_buffer.buffer()[m_end]) T(value); + if (m_end == m_buffer.capacity() - 1) + m_end = 0; + else + ++m_end; + checkValidity(); + } + + template template + inline void Deque::prepend(const U& value) + { + checkValidity(); + expandCapacityIfNeeded(); + if (!m_start) + m_start = m_buffer.capacity() - 1; + else + --m_start; + new (&m_buffer.buffer()[m_start]) T(value); + checkValidity(); + } + + template + inline void Deque::removeFirst() + { + checkValidity(); + invalidateIterators(); + ASSERT(!isEmpty()); + TypeOperations::destruct(&m_buffer.buffer()[m_start], &m_buffer.buffer()[m_start + 1]); + if (m_start == m_buffer.capacity() - 1) + m_start = 0; + else + ++m_start; + checkValidity(); + } + +#ifdef NDEBUG + template inline void DequeIteratorBase::checkValidity() const { } + template inline void DequeIteratorBase::checkValidity(const DequeIteratorBase&) const { } + template inline void DequeIteratorBase::addToIteratorsList() { } +#else + template + void DequeIteratorBase::checkValidity() const + { + ASSERT(m_deque); + m_deque->checkIndexValidity(m_index); + } + + template + void DequeIteratorBase::checkValidity(const Base& other) const + { + checkValidity(); + other.checkValidity(); + ASSERT(m_deque == other.m_deque); + } + + template + void DequeIteratorBase::addToIteratorsList() + { + if (!m_deque) + m_next = 0; + else { + m_next = m_deque->m_iterators; + m_deque->m_iterators = this; + if (m_next) + m_next->m_previous = this; + } + m_previous = 0; + } +#endif + + template + inline DequeIteratorBase::DequeIteratorBase() + : m_deque(0) + { + } + + template + inline DequeIteratorBase::DequeIteratorBase(const Deque* deque, size_t index) + : m_deque(const_cast*>(deque)) + , m_index(index) + { + addToIteratorsList(); + checkValidity(); + } + + template + inline DequeIteratorBase::DequeIteratorBase(const Base& other) + : m_deque(other.m_deque) + , m_index(other.m_index) + { + addToIteratorsList(); + checkValidity(); + } + + template + inline DequeIteratorBase::~DequeIteratorBase() + { +#ifndef NDEBUG + // Delete iterator from doubly-linked list of iterators. + if (!m_deque) { + ASSERT(!m_next); + ASSERT(!m_previous); + } else { + if (m_next) { + ASSERT(m_next->m_previous == this); + m_next->m_previous = m_previous; + } + if (m_previous) { + ASSERT(m_deque->m_iterators != this); + ASSERT(m_previous->m_next == this); + m_previous->m_next = m_next; + } else { + ASSERT(m_deque->m_iterators == this); + m_deque->m_iterators = m_next; + } + } + m_deque = 0; + m_next = 0; + m_previous = 0; +#endif + } + + template + inline bool DequeIteratorBase::isEqual(const Base& other) const + { + checkValidity(other); + return m_index == other.m_index; + } + + template + inline void DequeIteratorBase::increment() + { + checkValidity(); + ASSERT(m_index != m_deque->m_end); + ASSERT(m_deque->m_buffer.capacity()); + if (m_index == m_deque->m_buffer.capacity() - 1) + m_index = 0; + else + ++m_index; + checkValidity(); + } + + template + inline void DequeIteratorBase::decrement() + { + checkValidity(); + ASSERT(m_index != m_deque->m_start); + ASSERT(m_deque->m_buffer.capacity()); + if (!m_index) + m_index = m_deque->m_buffer.capacity() - 1; + else + --m_index; + checkValidity(); + } + + template + inline T* DequeIteratorBase::after() const + { + checkValidity(); + ASSERT(m_index != m_deque->m_end); + return &m_deque->m_buffer.buffer()[m_index]; + } + + template + inline T* DequeIteratorBase::before() const + { + checkValidity(); + ASSERT(m_index != m_deque->m_start); + if (!m_index) + return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1]; + return &m_deque->m_buffer.buffer()[m_index - 1]; + } + +} // namespace WTF + +using WTF::Deque; + +#endif // WTF_Deque_h diff --git a/wtf/DisallowCType.h b/wtf/DisallowCType.h new file mode 100644 index 0000000..5dccb0e --- /dev/null +++ b/wtf/DisallowCType.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_DisallowCType_h +#define WTF_DisallowCType_h + +// The behavior of many of the functions in the header is dependent +// on the current locale. But almost all uses of these functions are for +// locale-independent, ASCII-specific purposes. In WebKit code we use our own +// ASCII-specific functions instead. This header makes sure we get a compile-time +// error if we use one of the functions by accident. + +#include + +#undef isalnum +#undef isalpha +#undef isascii +#undef isblank +#undef iscntrl +#undef isdigit +#undef isgraph +#undef islower +#undef isprint +#undef ispunct +#undef isspace +#undef isupper +#undef isxdigit +#undef toascii +#undef tolower +#undef toupper + +#define isalnum WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define isalpha WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define isascii WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define isblank WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define iscntrl WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define isdigit WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define isgraph WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define islower WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define isprint WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define ispunct WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define isspace WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define isupper WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define isxdigit WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define toascii WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define tolower WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h +#define toupper WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h + +#endif diff --git a/wtf/FastMalloc.cpp b/wtf/FastMalloc.cpp new file mode 100644 index 0000000..7d17907 --- /dev/null +++ b/wtf/FastMalloc.cpp @@ -0,0 +1,3649 @@ +// Copyright (c) 2005, 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- +// Author: Sanjay Ghemawat +// +// A malloc that uses a per-thread cache to satisfy small malloc requests. +// (The time for malloc/free of a small object drops from 300 ns to 50 ns.) +// +// See doc/tcmalloc.html for a high-level +// description of how this malloc works. +// +// SYNCHRONIZATION +// 1. The thread-specific lists are accessed without acquiring any locks. +// This is safe because each such list is only accessed by one thread. +// 2. We have a lock per central free-list, and hold it while manipulating +// the central free list for a particular size. +// 3. The central page allocator is protected by "pageheap_lock". +// 4. The pagemap (which maps from page-number to descriptor), +// can be read without holding any locks, and written while holding +// the "pageheap_lock". +// 5. To improve performance, a subset of the information one can get +// from the pagemap is cached in a data structure, pagemap_cache_, +// that atomically reads and writes its entries. This cache can be +// read and written without locking. +// +// This multi-threaded access to the pagemap is safe for fairly +// subtle reasons. We basically assume that when an object X is +// allocated by thread A and deallocated by thread B, there must +// have been appropriate synchronization in the handoff of object +// X from thread A to thread B. The same logic applies to pagemap_cache_. +// +// THE PAGEID-TO-SIZECLASS CACHE +// Hot PageID-to-sizeclass mappings are held by pagemap_cache_. If this cache +// returns 0 for a particular PageID then that means "no information," not that +// the sizeclass is 0. The cache may have stale information for pages that do +// not hold the beginning of any free()'able object. Staleness is eliminated +// in Populate() for pages with sizeclass > 0 objects, and in do_malloc() and +// do_memalign() for all other relevant pages. +// +// TODO: Bias reclamation to larger addresses +// TODO: implement mallinfo/mallopt +// TODO: Better testing +// +// 9/28/2003 (new page-level allocator replaces ptmalloc2): +// * malloc/free of small objects goes from ~300 ns to ~50 ns. +// * allocation of a reasonably complicated struct +// goes from about 1100 ns to about 300 ns. + +#include "config.h" +#include "FastMalloc.h" + +#include "Assertions.h" +#if USE(MULTIPLE_THREADS) +#include +#endif + +#ifndef NO_TCMALLOC_SAMPLES +#ifdef WTF_CHANGES +#define NO_TCMALLOC_SAMPLES +#endif +#endif + +#if !defined(USE_SYSTEM_MALLOC) && defined(NDEBUG) +#define FORCE_SYSTEM_MALLOC 0 +#else +#define FORCE_SYSTEM_MALLOC 1 +#endif + +#ifndef NDEBUG +namespace WTF { + +#if USE(MULTIPLE_THREADS) +static pthread_key_t isForbiddenKey; +static pthread_once_t isForbiddenKeyOnce = PTHREAD_ONCE_INIT; +static void initializeIsForbiddenKey() +{ + pthread_key_create(&isForbiddenKey, 0); +} + +static bool isForbidden() +{ + pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey); + return !!pthread_getspecific(isForbiddenKey); +} + +void fastMallocForbid() +{ + pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey); + pthread_setspecific(isForbiddenKey, &isForbiddenKey); +} + +void fastMallocAllow() +{ + pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey); + pthread_setspecific(isForbiddenKey, 0); +} + +#else + +static bool staticIsForbidden; +static bool isForbidden() +{ + return staticIsForbidden; +} + +void fastMallocForbid() +{ + staticIsForbidden = true; +} + +void fastMallocAllow() +{ + staticIsForbidden = false; +} +#endif // USE(MULTIPLE_THREADS) + +} // namespace WTF +#endif // NDEBUG + +#include + +namespace WTF { +void *fastZeroedMalloc(size_t n) +{ + void *result = fastMalloc(n); + if (!result) + return 0; + memset(result, 0, n); +#ifndef WTF_CHANGES + MallocHook::InvokeNewHook(result, n); +#endif + return result; +} + +} + +#if FORCE_SYSTEM_MALLOC + +#include +#if !PLATFORM(WIN_OS) + #include +#endif + +namespace WTF { + +void *fastMalloc(size_t n) +{ + ASSERT(!isForbidden()); + return malloc(n); +} + +void *fastCalloc(size_t n_elements, size_t element_size) +{ + ASSERT(!isForbidden()); + return calloc(n_elements, element_size); +} + +void fastFree(void* p) +{ + ASSERT(!isForbidden()); + free(p); +} + +void *fastRealloc(void* p, size_t n) +{ + ASSERT(!isForbidden()); + return realloc(p, n); +} + +} // namespace WTF + +extern "C" { +void releaseFastMallocFreeMemory() { } +} + +#if PLATFORM(DARWIN) +// This symbol is present in the JavaScriptCore exports file even when FastMalloc is disabled. +// It will never be used in this case, so it's type and value are less interesting than its presence. +extern "C" const int jscore_fastmalloc_introspection = 0; +#endif + +#else + +#if HAVE(STDINT_H) +#include +#elif HAVE(INTTYPES_H) +#include +#else +#include +#endif + +#include "AlwaysInline.h" +#include "Assertions.h" +#include "TCPackedCache.h" +#include "TCPageMap.h" +#include "TCSpinLock.h" +#include "TCSystemAlloc.h" +#include +#include +#include +#include +#include +#include +#include +#if COMPILER(MSVC) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#endif + +#if WTF_CHANGES + +#if PLATFORM(DARWIN) +#include "MallocZoneSupport.h" +#endif + +#ifndef PRIuS +#define PRIuS "zu" +#endif + +// Calling pthread_getspecific through a global function pointer is faster than a normal +// call to the function on Mac OS X, and it's used in performance-critical code. So we +// use a function pointer. But that's not necessarily faster on other platforms, and we had +// problems with this technique on Windows, so we'll do this only on Mac OS X. +#if PLATFORM(DARWIN) +static void* (*pthread_getspecific_function_pointer)(pthread_key_t) = pthread_getspecific; +#define pthread_getspecific(key) pthread_getspecific_function_pointer(key) +#endif + +#define DEFINE_VARIABLE(type, name, value, meaning) \ + namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead { \ + type FLAGS_##name(value); \ + char FLAGS_no##name; \ + } \ + using FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead::FLAGS_##name + +#define DEFINE_int64(name, value, meaning) \ + DEFINE_VARIABLE(int64_t, name, value, meaning) + +#define DEFINE_double(name, value, meaning) \ + DEFINE_VARIABLE(double, name, value, meaning) + +namespace WTF { + +#define malloc fastMalloc +#define calloc fastCalloc +#define free fastFree +#define realloc fastRealloc + +#define MESSAGE LOG_ERROR +#define CHECK_CONDITION ASSERT + +#if PLATFORM(DARWIN) +class TCMalloc_PageHeap; +class TCMalloc_ThreadCache; +class TCMalloc_Central_FreeListPadded; + +class FastMallocZone { +public: + static void init(); + + static kern_return_t enumerate(task_t, void*, unsigned typeMmask, vm_address_t zoneAddress, memory_reader_t, vm_range_recorder_t); + static size_t goodSize(malloc_zone_t*, size_t size) { return size; } + static boolean_t check(malloc_zone_t*) { return true; } + static void print(malloc_zone_t*, boolean_t) { } + static void log(malloc_zone_t*, void*) { } + static void forceLock(malloc_zone_t*) { } + static void forceUnlock(malloc_zone_t*) { } + static void statistics(malloc_zone_t*, malloc_statistics_t*) { } + +private: + FastMallocZone(TCMalloc_PageHeap*, TCMalloc_ThreadCache**, TCMalloc_Central_FreeListPadded*); + static size_t size(malloc_zone_t*, const void*); + static void* zoneMalloc(malloc_zone_t*, size_t); + static void* zoneCalloc(malloc_zone_t*, size_t numItems, size_t size); + static void zoneFree(malloc_zone_t*, void*); + static void* zoneRealloc(malloc_zone_t*, void*, size_t); + static void* zoneValloc(malloc_zone_t*, size_t) { LOG_ERROR("valloc is not supported"); return 0; } + static void zoneDestroy(malloc_zone_t*) { } + + malloc_zone_t m_zone; + TCMalloc_PageHeap* m_pageHeap; + TCMalloc_ThreadCache** m_threadHeaps; + TCMalloc_Central_FreeListPadded* m_centralCaches; +}; + +#endif + +#endif + +#ifndef WTF_CHANGES +// This #ifdef should almost never be set. Set NO_TCMALLOC_SAMPLES if +// you're porting to a system where you really can't get a stacktrace. +#ifdef NO_TCMALLOC_SAMPLES +// We use #define so code compiles even if you #include stacktrace.h somehow. +# define GetStackTrace(stack, depth, skip) (0) +#else +# include +#endif +#endif + +// Even if we have support for thread-local storage in the compiler +// and linker, the OS may not support it. We need to check that at +// runtime. Right now, we have to keep a manual set of "bad" OSes. +#if defined(HAVE_TLS) + static bool kernel_supports_tls = false; // be conservative + static inline bool KernelSupportsTLS() { + return kernel_supports_tls; + } +# if !HAVE_DECL_UNAME // if too old for uname, probably too old for TLS + static void CheckIfKernelSupportsTLS() { + kernel_supports_tls = false; + } +# else +# include // DECL_UNAME checked for too + static void CheckIfKernelSupportsTLS() { + struct utsname buf; + if (uname(&buf) != 0) { // should be impossible + MESSAGE("uname failed assuming no TLS support (errno=%d)\n", errno); + kernel_supports_tls = false; + } else if (strcasecmp(buf.sysname, "linux") == 0) { + // The linux case: the first kernel to support TLS was 2.6.0 + if (buf.release[0] < '2' && buf.release[1] == '.') // 0.x or 1.x + kernel_supports_tls = false; + else if (buf.release[0] == '2' && buf.release[1] == '.' && + buf.release[2] >= '0' && buf.release[2] < '6' && + buf.release[3] == '.') // 2.0 - 2.5 + kernel_supports_tls = false; + else + kernel_supports_tls = true; + } else { // some other kernel, we'll be optimisitic + kernel_supports_tls = true; + } + // TODO(csilvers): VLOG(1) the tls status once we support RAW_VLOG + } +# endif // HAVE_DECL_UNAME +#endif // HAVE_TLS + +// __THROW is defined in glibc systems. It means, counter-intuitively, +// "This function will never throw an exception." It's an optional +// optimization tool, but we may need to use it to match glibc prototypes. +#ifndef __THROW // I guess we're not on a glibc system +# define __THROW // __THROW is just an optimization, so ok to make it "" +#endif + +//------------------------------------------------------------------- +// Configuration +//------------------------------------------------------------------- + +// Not all possible combinations of the following parameters make +// sense. In particular, if kMaxSize increases, you may have to +// increase kNumClasses as well. +static const size_t kPageShift = 12; +static const size_t kPageSize = 1 << kPageShift; +static const size_t kMaxSize = 8u * kPageSize; +static const size_t kAlignShift = 3; +static const size_t kAlignment = 1 << kAlignShift; +static const size_t kNumClasses = 68; + +// Allocates a big block of memory for the pagemap once we reach more than +// 128MB +static const size_t kPageMapBigAllocationThreshold = 128 << 20; + +// Minimum number of pages to fetch from system at a time. Must be +// significantly bigger than kBlockSize to amortize system-call +// overhead, and also to reduce external fragementation. Also, we +// should keep this value big because various incarnations of Linux +// have small limits on the number of mmap() regions per +// address-space. +static const size_t kMinSystemAlloc = 1 << (20 - kPageShift); + +// Number of objects to move between a per-thread list and a central +// list in one shot. We want this to be not too small so we can +// amortize the lock overhead for accessing the central list. Making +// it too big may temporarily cause unnecessary memory wastage in the +// per-thread free list until the scavenger cleans up the list. +static int num_objects_to_move[kNumClasses]; + +// Maximum length we allow a per-thread free-list to have before we +// move objects from it into the corresponding central free-list. We +// want this big to avoid locking the central free-list too often. It +// should not hurt to make this list somewhat big because the +// scavenging code will shrink it down when its contents are not in use. +static const int kMaxFreeListLength = 256; + +// Lower and upper bounds on the per-thread cache sizes +static const size_t kMinThreadCacheSize = kMaxSize * 2; +static const size_t kMaxThreadCacheSize = 2 << 20; + +// Default bound on the total amount of thread caches +static const size_t kDefaultOverallThreadCacheSize = 16 << 20; + +// For all span-lengths < kMaxPages we keep an exact-size list. +// REQUIRED: kMaxPages >= kMinSystemAlloc; +static const size_t kMaxPages = kMinSystemAlloc; + +/* The smallest prime > 2^n */ +static int primes_list[] = { + // Small values might cause high rates of sampling + // and hence commented out. + // 2, 5, 11, 17, 37, 67, 131, 257, + // 521, 1031, 2053, 4099, 8209, 16411, + 32771, 65537, 131101, 262147, 524309, 1048583, + 2097169, 4194319, 8388617, 16777259, 33554467 }; + +// Twice the approximate gap between sampling actions. +// I.e., we take one sample approximately once every +// tcmalloc_sample_parameter/2 +// bytes of allocation, i.e., ~ once every 128KB. +// Must be a prime number. +#ifdef NO_TCMALLOC_SAMPLES +DEFINE_int64(tcmalloc_sample_parameter, 0, + "Unused: code is compiled with NO_TCMALLOC_SAMPLES"); +static size_t sample_period = 0; +#else +DEFINE_int64(tcmalloc_sample_parameter, 262147, + "Twice the approximate gap between sampling actions." + " Must be a prime number. Otherwise will be rounded up to a " + " larger prime number"); +static size_t sample_period = 262147; +#endif + +// Protects sample_period above +static SpinLock sample_period_lock = SPINLOCK_INITIALIZER; + +// Parameters for controlling how fast memory is returned to the OS. + +DEFINE_double(tcmalloc_release_rate, 1, + "Rate at which we release unused memory to the system. " + "Zero means we never release memory back to the system. " + "Increase this flag to return memory faster; decrease it " + "to return memory slower. Reasonable rates are in the " + "range [0,10]"); + +//------------------------------------------------------------------- +// Mapping from size to size_class and vice versa +//------------------------------------------------------------------- + +// Sizes <= 1024 have an alignment >= 8. So for such sizes we have an +// array indexed by ceil(size/8). Sizes > 1024 have an alignment >= 128. +// So for these larger sizes we have an array indexed by ceil(size/128). +// +// We flatten both logical arrays into one physical array and use +// arithmetic to compute an appropriate index. The constants used by +// ClassIndex() were selected to make the flattening work. +// +// Examples: +// Size Expression Index +// ------------------------------------------------------- +// 0 (0 + 7) / 8 0 +// 1 (1 + 7) / 8 1 +// ... +// 1024 (1024 + 7) / 8 128 +// 1025 (1025 + 127 + (120<<7)) / 128 129 +// ... +// 32768 (32768 + 127 + (120<<7)) / 128 376 +static const size_t kMaxSmallSize = 1024; +static const int shift_amount[2] = { 3, 7 }; // For divides by 8 or 128 +static const int add_amount[2] = { 7, 127 + (120 << 7) }; +static unsigned char class_array[377]; + +// Compute index of the class_array[] entry for a given size +static inline int ClassIndex(size_t s) { + const int i = (s > kMaxSmallSize); + return static_cast((s + add_amount[i]) >> shift_amount[i]); +} + +// Mapping from size class to max size storable in that class +static size_t class_to_size[kNumClasses]; + +// Mapping from size class to number of pages to allocate at a time +static size_t class_to_pages[kNumClasses]; + +// TransferCache is used to cache transfers of num_objects_to_move[size_class] +// back and forth between thread caches and the central cache for a given size +// class. +struct TCEntry { + void *head; // Head of chain of objects. + void *tail; // Tail of chain of objects. +}; +// A central cache freelist can have anywhere from 0 to kNumTransferEntries +// slots to put link list chains into. To keep memory usage bounded the total +// number of TCEntries across size classes is fixed. Currently each size +// class is initially given one TCEntry which also means that the maximum any +// one class can have is kNumClasses. +static const int kNumTransferEntries = kNumClasses; + +// Note: the following only works for "n"s that fit in 32-bits, but +// that is fine since we only use it for small sizes. +static inline int LgFloor(size_t n) { + int log = 0; + for (int i = 4; i >= 0; --i) { + int shift = (1 << i); + size_t x = n >> shift; + if (x != 0) { + n = x; + log += shift; + } + } + ASSERT(n == 1); + return log; +} + +// Some very basic linked list functions for dealing with using void * as +// storage. + +static inline void *SLL_Next(void *t) { + return *(reinterpret_cast(t)); +} + +static inline void SLL_SetNext(void *t, void *n) { + *(reinterpret_cast(t)) = n; +} + +static inline void SLL_Push(void **list, void *element) { + SLL_SetNext(element, *list); + *list = element; +} + +static inline void *SLL_Pop(void **list) { + void *result = *list; + *list = SLL_Next(*list); + return result; +} + + +// Remove N elements from a linked list to which head points. head will be +// modified to point to the new head. start and end will point to the first +// and last nodes of the range. Note that end will point to NULL after this +// function is called. +static inline void SLL_PopRange(void **head, int N, void **start, void **end) { + if (N == 0) { + *start = NULL; + *end = NULL; + return; + } + + void *tmp = *head; + for (int i = 1; i < N; ++i) { + tmp = SLL_Next(tmp); + } + + *start = *head; + *end = tmp; + *head = SLL_Next(tmp); + // Unlink range from list. + SLL_SetNext(tmp, NULL); +} + +static inline void SLL_PushRange(void **head, void *start, void *end) { + if (!start) return; + SLL_SetNext(end, *head); + *head = start; +} + +static inline size_t SLL_Size(void *head) { + int count = 0; + while (head) { + count++; + head = SLL_Next(head); + } + return count; +} + +// Setup helper functions. + +static ALWAYS_INLINE size_t SizeClass(size_t size) { + return class_array[ClassIndex(size)]; +} + +// Get the byte-size for a specified class +static ALWAYS_INLINE size_t ByteSizeForClass(size_t cl) { + return class_to_size[cl]; +} +static int NumMoveSize(size_t size) { + if (size == 0) return 0; + // Use approx 64k transfers between thread and central caches. + int num = static_cast(64.0 * 1024.0 / size); + if (num < 2) num = 2; + // Clamp well below kMaxFreeListLength to avoid ping pong between central + // and thread caches. + if (num > static_cast(0.8 * kMaxFreeListLength)) + num = static_cast(0.8 * kMaxFreeListLength); + + // Also, avoid bringing in too many objects into small object free + // lists. There are lots of such lists, and if we allow each one to + // fetch too many at a time, we end up having to scavenge too often + // (especially when there are lots of threads and each thread gets a + // small allowance for its thread cache). + // + // TODO: Make thread cache free list sizes dynamic so that we do not + // have to equally divide a fixed resource amongst lots of threads. + if (num > 32) num = 32; + + return num; +} + +// Initialize the mapping arrays +static void InitSizeClasses() { + // Do some sanity checking on add_amount[]/shift_amount[]/class_array[] + if (ClassIndex(0) < 0) { + MESSAGE("Invalid class index %d for size 0\n", ClassIndex(0)); + abort(); + } + if (static_cast(ClassIndex(kMaxSize)) >= sizeof(class_array)) { + MESSAGE("Invalid class index %d for kMaxSize\n", ClassIndex(kMaxSize)); + abort(); + } + + // Compute the size classes we want to use + size_t sc = 1; // Next size class to assign + unsigned char alignshift = kAlignShift; + int last_lg = -1; + for (size_t size = kAlignment; size <= kMaxSize; size += (1 << alignshift)) { + int lg = LgFloor(size); + if (lg > last_lg) { + // Increase alignment every so often. + // + // Since we double the alignment every time size doubles and + // size >= 128, this means that space wasted due to alignment is + // at most 16/128 i.e., 12.5%. Plus we cap the alignment at 256 + // bytes, so the space wasted as a percentage starts falling for + // sizes > 2K. + if ((lg >= 7) && (alignshift < 8)) { + alignshift++; + } + last_lg = lg; + } + + // Allocate enough pages so leftover is less than 1/8 of total. + // This bounds wasted space to at most 12.5%. + size_t psize = kPageSize; + while ((psize % size) > (psize >> 3)) { + psize += kPageSize; + } + const size_t my_pages = psize >> kPageShift; + + if (sc > 1 && my_pages == class_to_pages[sc-1]) { + // See if we can merge this into the previous class without + // increasing the fragmentation of the previous class. + const size_t my_objects = (my_pages << kPageShift) / size; + const size_t prev_objects = (class_to_pages[sc-1] << kPageShift) + / class_to_size[sc-1]; + if (my_objects == prev_objects) { + // Adjust last class to include this size + class_to_size[sc-1] = size; + continue; + } + } + + // Add new class + class_to_pages[sc] = my_pages; + class_to_size[sc] = size; + sc++; + } + if (sc != kNumClasses) { + MESSAGE("wrong number of size classes: found %" PRIuS " instead of %d\n", + sc, int(kNumClasses)); + abort(); + } + + // Initialize the mapping arrays + int next_size = 0; + for (unsigned char c = 1; c < kNumClasses; c++) { + const size_t max_size_in_class = class_to_size[c]; + for (size_t s = next_size; s <= max_size_in_class; s += kAlignment) { + class_array[ClassIndex(s)] = c; + } + next_size = static_cast(max_size_in_class + kAlignment); + } + + // Double-check sizes just to be safe + for (size_t size = 0; size <= kMaxSize; size++) { + const size_t sc = SizeClass(size); + if (sc == 0) { + MESSAGE("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size); + abort(); + } + if (sc > 1 && size <= class_to_size[sc-1]) { + MESSAGE("Allocating unnecessarily large class %" PRIuS " for %" PRIuS + "\n", sc, size); + abort(); + } + if (sc >= kNumClasses) { + MESSAGE("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size); + abort(); + } + const size_t s = class_to_size[sc]; + if (size > s) { + MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc); + abort(); + } + if (s == 0) { + MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc); + abort(); + } + } + + // Initialize the num_objects_to_move array. + for (size_t cl = 1; cl < kNumClasses; ++cl) { + num_objects_to_move[cl] = NumMoveSize(ByteSizeForClass(cl)); + } + +#ifndef WTF_CHANGES + if (false) { + // Dump class sizes and maximum external wastage per size class + for (size_t cl = 1; cl < kNumClasses; ++cl) { + const int alloc_size = class_to_pages[cl] << kPageShift; + const int alloc_objs = alloc_size / class_to_size[cl]; + const int min_used = (class_to_size[cl-1] + 1) * alloc_objs; + const int max_waste = alloc_size - min_used; + MESSAGE("SC %3d [ %8d .. %8d ] from %8d ; %2.0f%% maxwaste\n", + int(cl), + int(class_to_size[cl-1] + 1), + int(class_to_size[cl]), + int(class_to_pages[cl] << kPageShift), + max_waste * 100.0 / alloc_size + ); + } + } +#endif +} + +// ------------------------------------------------------------------------- +// Simple allocator for objects of a specified type. External locking +// is required before accessing one of these objects. +// ------------------------------------------------------------------------- + +// Metadata allocator -- keeps stats about how many bytes allocated +static uint64_t metadata_system_bytes = 0; +static void* MetaDataAlloc(size_t bytes) { + void* result = TCMalloc_SystemAlloc(bytes, 0); + if (result != NULL) { + metadata_system_bytes += bytes; + } + return result; +} + +template +class PageHeapAllocator { + private: + // How much to allocate from system at a time + static const size_t kAllocIncrement = 32 << 10; + + // Aligned size of T + static const size_t kAlignedSize + = (((sizeof(T) + kAlignment - 1) / kAlignment) * kAlignment); + + // Free area from which to carve new objects + char* free_area_; + size_t free_avail_; + + // Free list of already carved objects + void* free_list_; + + // Number of allocated but unfreed objects + int inuse_; + + public: + void Init() { + ASSERT(kAlignedSize <= kAllocIncrement); + inuse_ = 0; + free_area_ = NULL; + free_avail_ = 0; + free_list_ = NULL; + } + + T* New() { + // Consult free list + void* result; + if (free_list_ != NULL) { + result = free_list_; + free_list_ = *(reinterpret_cast(result)); + } else { + if (free_avail_ < kAlignedSize) { + // Need more room + free_area_ = reinterpret_cast(MetaDataAlloc(kAllocIncrement)); + if (free_area_ == NULL) abort(); + free_avail_ = kAllocIncrement; + } + result = free_area_; + free_area_ += kAlignedSize; + free_avail_ -= kAlignedSize; + } + inuse_++; + return reinterpret_cast(result); + } + + void Delete(T* p) { + *(reinterpret_cast(p)) = free_list_; + free_list_ = p; + inuse_--; + } + + int inuse() const { return inuse_; } +}; + +// ------------------------------------------------------------------------- +// Span - a contiguous run of pages +// ------------------------------------------------------------------------- + +// Type that can hold a page number +typedef uintptr_t PageID; + +// Type that can hold the length of a run of pages +typedef uintptr_t Length; + +static const Length kMaxValidPages = (~static_cast(0)) >> kPageShift; + +// Convert byte size into pages. This won't overflow, but may return +// an unreasonably large value if bytes is huge enough. +static inline Length pages(size_t bytes) { + return (bytes >> kPageShift) + + ((bytes & (kPageSize - 1)) > 0 ? 1 : 0); +} + +// Convert a user size into the number of bytes that will actually be +// allocated +static size_t AllocationSize(size_t bytes) { + if (bytes > kMaxSize) { + // Large object: we allocate an integral number of pages + ASSERT(bytes <= (kMaxValidPages << kPageShift)); + return pages(bytes) << kPageShift; + } else { + // Small object: find the size class to which it belongs + return ByteSizeForClass(SizeClass(bytes)); + } +} + +// Information kept for a span (a contiguous run of pages). +struct Span { + PageID start; // Starting page number + Length length; // Number of pages in span + Span* next; // Used when in link list + Span* prev; // Used when in link list + void* objects; // Linked list of free objects + unsigned int free : 1; // Is the span free + unsigned int sample : 1; // Sampled object? + unsigned int sizeclass : 8; // Size-class for small objects (or 0) + unsigned int refcount : 11; // Number of non-free objects + +#undef SPAN_HISTORY +#ifdef SPAN_HISTORY + // For debugging, we can keep a log events per span + int nexthistory; + char history[64]; + int value[64]; +#endif +}; + +#ifdef SPAN_HISTORY +void Event(Span* span, char op, int v = 0) { + span->history[span->nexthistory] = op; + span->value[span->nexthistory] = v; + span->nexthistory++; + if (span->nexthistory == sizeof(span->history)) span->nexthistory = 0; +} +#else +#define Event(s,o,v) ((void) 0) +#endif + +// Allocator/deallocator for spans +static PageHeapAllocator span_allocator; +static Span* NewSpan(PageID p, Length len) { + Span* result = span_allocator.New(); + memset(result, 0, sizeof(*result)); + result->start = p; + result->length = len; +#ifdef SPAN_HISTORY + result->nexthistory = 0; +#endif + return result; +} + +static inline void DeleteSpan(Span* span) { +#ifndef NDEBUG + // In debug mode, trash the contents of deleted Spans + memset(span, 0x3f, sizeof(*span)); +#endif + span_allocator.Delete(span); +} + +// ------------------------------------------------------------------------- +// Doubly linked list of spans. +// ------------------------------------------------------------------------- + +static inline void DLL_Init(Span* list) { + list->next = list; + list->prev = list; +} + +static inline void DLL_Remove(Span* span) { + span->prev->next = span->next; + span->next->prev = span->prev; + span->prev = NULL; + span->next = NULL; +} + +static ALWAYS_INLINE bool DLL_IsEmpty(const Span* list) { + return list->next == list; +} + +#ifndef WTF_CHANGES +static int DLL_Length(const Span* list) { + int result = 0; + for (Span* s = list->next; s != list; s = s->next) { + result++; + } + return result; +} +#endif + +#if 0 /* Not needed at the moment -- causes compiler warnings if not used */ +static void DLL_Print(const char* label, const Span* list) { + MESSAGE("%-10s %p:", label, list); + for (const Span* s = list->next; s != list; s = s->next) { + MESSAGE(" <%p,%u,%u>", s, s->start, s->length); + } + MESSAGE("\n"); +} +#endif + +static inline void DLL_Prepend(Span* list, Span* span) { + ASSERT(span->next == NULL); + ASSERT(span->prev == NULL); + span->next = list->next; + span->prev = list; + list->next->prev = span; + list->next = span; +} + +// ------------------------------------------------------------------------- +// Stack traces kept for sampled allocations +// The following state is protected by pageheap_lock_. +// ------------------------------------------------------------------------- + +// size/depth are made the same size as a pointer so that some generic +// code below can conveniently cast them back and forth to void*. +static const int kMaxStackDepth = 31; +struct StackTrace { + uintptr_t size; // Size of object + uintptr_t depth; // Number of PC values stored in array below + void* stack[kMaxStackDepth]; +}; +static PageHeapAllocator stacktrace_allocator; +static Span sampled_objects; + +// ------------------------------------------------------------------------- +// Map from page-id to per-page data +// ------------------------------------------------------------------------- + +// We use PageMap2<> for 32-bit and PageMap3<> for 64-bit machines. +// We also use a simple one-level cache for hot PageID-to-sizeclass mappings, +// because sometimes the sizeclass is all the information we need. + +// Selector class -- general selector uses 3-level map +template class MapSelector { + public: + typedef TCMalloc_PageMap3 Type; + typedef PackedCache CacheType; +}; + +// A two-level map for 32-bit machines +template <> class MapSelector<32> { + public: + typedef TCMalloc_PageMap2<32-kPageShift> Type; + typedef PackedCache<32-kPageShift, uint16_t> CacheType; +}; + +// ------------------------------------------------------------------------- +// Page-level allocator +// * Eager coalescing +// +// Heap for page-level allocation. We allow allocating and freeing a +// contiguous runs of pages (called a "span"). +// ------------------------------------------------------------------------- + +class TCMalloc_PageHeap { + public: + void init(); + + // Allocate a run of "n" pages. Returns zero if out of memory. + Span* New(Length n); + + // Delete the span "[p, p+n-1]". + // REQUIRES: span was returned by earlier call to New() and + // has not yet been deleted. + void Delete(Span* span); + + // Mark an allocated span as being used for small objects of the + // specified size-class. + // REQUIRES: span was returned by an earlier call to New() + // and has not yet been deleted. + void RegisterSizeClass(Span* span, size_t sc); + + // Split an allocated span into two spans: one of length "n" pages + // followed by another span of length "span->length - n" pages. + // Modifies "*span" to point to the first span of length "n" pages. + // Returns a pointer to the second span. + // + // REQUIRES: "0 < n < span->length" + // REQUIRES: !span->free + // REQUIRES: span->sizeclass == 0 + Span* Split(Span* span, Length n); + + // Return the descriptor for the specified page. + inline Span* GetDescriptor(PageID p) const { + return reinterpret_cast(pagemap_.get(p)); + } + +#ifdef WTF_CHANGES + inline Span* GetDescriptorEnsureSafe(PageID p) + { + pagemap_.Ensure(p, 1); + return GetDescriptor(p); + } +#endif + + // Dump state to stderr +#ifndef WTF_CHANGES + void Dump(TCMalloc_Printer* out); +#endif + + // Return number of bytes allocated from system + inline uint64_t SystemBytes() const { return system_bytes_; } + + // Return number of free bytes in heap + uint64_t FreeBytes() const { + return (static_cast(free_pages_) << kPageShift); + } + + bool Check(); + bool CheckList(Span* list, Length min_pages, Length max_pages); + + // Release all pages on the free list for reuse by the OS: + void ReleaseFreePages(); + + // Return 0 if we have no information, or else the correct sizeclass for p. + // Reads and writes to pagemap_cache_ do not require locking. + // The entries are 64 bits on 64-bit hardware and 16 bits on + // 32-bit hardware, and we don't mind raciness as long as each read of + // an entry yields a valid entry, not a partially updated entry. + size_t GetSizeClassIfCached(PageID p) const { + return pagemap_cache_.GetOrDefault(p, 0); + } + void CacheSizeClass(PageID p, size_t cl) const { pagemap_cache_.Put(p, cl); } + + private: + // Pick the appropriate map and cache types based on pointer size + typedef MapSelector<8*sizeof(uintptr_t)>::Type PageMap; + typedef MapSelector<8*sizeof(uintptr_t)>::CacheType PageMapCache; + PageMap pagemap_; + mutable PageMapCache pagemap_cache_; + + // We segregate spans of a given size into two circular linked + // lists: one for normal spans, and one for spans whose memory + // has been returned to the system. + struct SpanList { + Span normal; + Span returned; + }; + + // List of free spans of length >= kMaxPages + SpanList large_; + + // Array mapping from span length to a doubly linked list of free spans + SpanList free_[kMaxPages]; + + // Number of pages kept in free lists + uintptr_t free_pages_; + + // Bytes allocated from system + uint64_t system_bytes_; + + bool GrowHeap(Length n); + + // REQUIRES span->length >= n + // Remove span from its free list, and move any leftover part of + // span into appropriate free lists. Also update "span" to have + // length exactly "n" and mark it as non-free so it can be returned + // to the client. + // + // "released" is true iff "span" was found on a "returned" list. + void Carve(Span* span, Length n, bool released); + + void RecordSpan(Span* span) { + pagemap_.set(span->start, span); + if (span->length > 1) { + pagemap_.set(span->start + span->length - 1, span); + } + } + + // Allocate a large span of length == n. If successful, returns a + // span of exactly the specified length. Else, returns NULL. + Span* AllocLarge(Length n); + + // Incrementally release some memory to the system. + // IncrementalScavenge(n) is called whenever n pages are freed. + void IncrementalScavenge(Length n); + + // Number of pages to deallocate before doing more scavenging + int64_t scavenge_counter_; + + // Index of last free list we scavenged + size_t scavenge_index_; + +#if defined(WTF_CHANGES) && PLATFORM(DARWIN) + friend class FastMallocZone; +#endif +}; + +void TCMalloc_PageHeap::init() +{ + pagemap_.init(MetaDataAlloc); + pagemap_cache_ = PageMapCache(0); + free_pages_ = 0; + system_bytes_ = 0; + scavenge_counter_ = 0; + // Start scavenging at kMaxPages list + scavenge_index_ = kMaxPages-1; + COMPILE_ASSERT(kNumClasses <= (1 << PageMapCache::kValuebits), valuebits); + DLL_Init(&large_.normal); + DLL_Init(&large_.returned); + for (size_t i = 0; i < kMaxPages; i++) { + DLL_Init(&free_[i].normal); + DLL_Init(&free_[i].returned); + } +} + +inline Span* TCMalloc_PageHeap::New(Length n) { + ASSERT(Check()); + ASSERT(n > 0); + + // Find first size >= n that has a non-empty list + for (Length s = n; s < kMaxPages; s++) { + Span* ll = NULL; + bool released = false; + if (!DLL_IsEmpty(&free_[s].normal)) { + // Found normal span + ll = &free_[s].normal; + } else if (!DLL_IsEmpty(&free_[s].returned)) { + // Found returned span; reallocate it + ll = &free_[s].returned; + released = true; + } else { + // Keep looking in larger classes + continue; + } + + Span* result = ll->next; + Carve(result, n, released); + ASSERT(Check()); + free_pages_ -= n; + return result; + } + + Span* result = AllocLarge(n); + if (result != NULL) return result; + + // Grow the heap and try again + if (!GrowHeap(n)) { + ASSERT(Check()); + return NULL; + } + + return AllocLarge(n); +} + +Span* TCMalloc_PageHeap::AllocLarge(Length n) { + // find the best span (closest to n in size). + // The following loops implements address-ordered best-fit. + bool from_released = false; + Span *best = NULL; + + // Search through normal list + for (Span* span = large_.normal.next; + span != &large_.normal; + span = span->next) { + if (span->length >= n) { + if ((best == NULL) + || (span->length < best->length) + || ((span->length == best->length) && (span->start < best->start))) { + best = span; + from_released = false; + } + } + } + + // Search through released list in case it has a better fit + for (Span* span = large_.returned.next; + span != &large_.returned; + span = span->next) { + if (span->length >= n) { + if ((best == NULL) + || (span->length < best->length) + || ((span->length == best->length) && (span->start < best->start))) { + best = span; + from_released = true; + } + } + } + + if (best != NULL) { + Carve(best, n, from_released); + ASSERT(Check()); + free_pages_ -= n; + return best; + } + return NULL; +} + +Span* TCMalloc_PageHeap::Split(Span* span, Length n) { + ASSERT(0 < n); + ASSERT(n < span->length); + ASSERT(!span->free); + ASSERT(span->sizeclass == 0); + Event(span, 'T', n); + + const Length extra = span->length - n; + Span* leftover = NewSpan(span->start + n, extra); + Event(leftover, 'U', extra); + RecordSpan(leftover); + pagemap_.set(span->start + n - 1, span); // Update map from pageid to span + span->length = n; + + return leftover; +} + +inline void TCMalloc_PageHeap::Carve(Span* span, Length n, bool released) { + ASSERT(n > 0); + DLL_Remove(span); + span->free = 0; + Event(span, 'A', n); + + const int extra = static_cast(span->length - n); + ASSERT(extra >= 0); + if (extra > 0) { + Span* leftover = NewSpan(span->start + n, extra); + leftover->free = 1; + Event(leftover, 'S', extra); + RecordSpan(leftover); + + // Place leftover span on appropriate free list + SpanList* listpair = (static_cast(extra) < kMaxPages) ? &free_[extra] : &large_; + Span* dst = released ? &listpair->returned : &listpair->normal; + DLL_Prepend(dst, leftover); + + span->length = n; + pagemap_.set(span->start + n - 1, span); + } +} + +inline void TCMalloc_PageHeap::Delete(Span* span) { + ASSERT(Check()); + ASSERT(!span->free); + ASSERT(span->length > 0); + ASSERT(GetDescriptor(span->start) == span); + ASSERT(GetDescriptor(span->start + span->length - 1) == span); + span->sizeclass = 0; + span->sample = 0; + + // Coalesce -- we guarantee that "p" != 0, so no bounds checking + // necessary. We do not bother resetting the stale pagemap + // entries for the pieces we are merging together because we only + // care about the pagemap entries for the boundaries. + // + // Note that the spans we merge into "span" may come out of + // a "returned" list. For simplicity, we move these into the + // "normal" list of the appropriate size class. + const PageID p = span->start; + const Length n = span->length; + Span* prev = GetDescriptor(p-1); + if (prev != NULL && prev->free) { + // Merge preceding span into this span + ASSERT(prev->start + prev->length == p); + const Length len = prev->length; + DLL_Remove(prev); + DeleteSpan(prev); + span->start -= len; + span->length += len; + pagemap_.set(span->start, span); + Event(span, 'L', len); + } + Span* next = GetDescriptor(p+n); + if (next != NULL && next->free) { + // Merge next span into this span + ASSERT(next->start == p+n); + const Length len = next->length; + DLL_Remove(next); + DeleteSpan(next); + span->length += len; + pagemap_.set(span->start + span->length - 1, span); + Event(span, 'R', len); + } + + Event(span, 'D', span->length); + span->free = 1; + if (span->length < kMaxPages) { + DLL_Prepend(&free_[span->length].normal, span); + } else { + DLL_Prepend(&large_.normal, span); + } + free_pages_ += n; + + IncrementalScavenge(n); + ASSERT(Check()); +} + +void TCMalloc_PageHeap::IncrementalScavenge(Length n) { + // Fast path; not yet time to release memory + scavenge_counter_ -= n; + if (scavenge_counter_ >= 0) return; // Not yet time to scavenge + + // If there is nothing to release, wait for so many pages before + // scavenging again. With 4K pages, this comes to 16MB of memory. + static const size_t kDefaultReleaseDelay = 1 << 8; + + // Find index of free list to scavenge + size_t index = scavenge_index_ + 1; + for (size_t i = 0; i < kMaxPages+1; i++) { + if (index > kMaxPages) index = 0; + SpanList* slist = (index == kMaxPages) ? &large_ : &free_[index]; + if (!DLL_IsEmpty(&slist->normal)) { + // Release the last span on the normal portion of this list + Span* s = slist->normal.prev; + DLL_Remove(s); + TCMalloc_SystemRelease(reinterpret_cast(s->start << kPageShift), + static_cast(s->length << kPageShift)); + DLL_Prepend(&slist->returned, s); + + scavenge_counter_ = std::max(64UL, std::min(kDefaultReleaseDelay, kDefaultReleaseDelay - (free_pages_ / kDefaultReleaseDelay))); + + if (index == kMaxPages && !DLL_IsEmpty(&slist->normal)) + scavenge_index_ = index - 1; + else + scavenge_index_ = index; + return; + } + index++; + } + + // Nothing to scavenge, delay for a while + scavenge_counter_ = kDefaultReleaseDelay; +} + +void TCMalloc_PageHeap::RegisterSizeClass(Span* span, size_t sc) { + // Associate span object with all interior pages as well + ASSERT(!span->free); + ASSERT(GetDescriptor(span->start) == span); + ASSERT(GetDescriptor(span->start+span->length-1) == span); + Event(span, 'C', sc); + span->sizeclass = static_cast(sc); + for (Length i = 1; i < span->length-1; i++) { + pagemap_.set(span->start+i, span); + } +} + +#ifndef WTF_CHANGES +static double PagesToMB(uint64_t pages) { + return (pages << kPageShift) / 1048576.0; +} + +void TCMalloc_PageHeap::Dump(TCMalloc_Printer* out) { + int nonempty_sizes = 0; + for (int s = 0; s < kMaxPages; s++) { + if (!DLL_IsEmpty(&free_[s].normal) || !DLL_IsEmpty(&free_[s].returned)) { + nonempty_sizes++; + } + } + out->printf("------------------------------------------------\n"); + out->printf("PageHeap: %d sizes; %6.1f MB free\n", + nonempty_sizes, PagesToMB(free_pages_)); + out->printf("------------------------------------------------\n"); + uint64_t total_normal = 0; + uint64_t total_returned = 0; + for (int s = 0; s < kMaxPages; s++) { + const int n_length = DLL_Length(&free_[s].normal); + const int r_length = DLL_Length(&free_[s].returned); + if (n_length + r_length > 0) { + uint64_t n_pages = s * n_length; + uint64_t r_pages = s * r_length; + total_normal += n_pages; + total_returned += r_pages; + out->printf("%6u pages * %6u spans ~ %6.1f MB; %6.1f MB cum" + "; unmapped: %6.1f MB; %6.1f MB cum\n", + s, + (n_length + r_length), + PagesToMB(n_pages + r_pages), + PagesToMB(total_normal + total_returned), + PagesToMB(r_pages), + PagesToMB(total_returned)); + } + } + + uint64_t n_pages = 0; + uint64_t r_pages = 0; + int n_spans = 0; + int r_spans = 0; + out->printf("Normal large spans:\n"); + for (Span* s = large_.normal.next; s != &large_.normal; s = s->next) { + out->printf(" [ %6" PRIuS " pages ] %6.1f MB\n", + s->length, PagesToMB(s->length)); + n_pages += s->length; + n_spans++; + } + out->printf("Unmapped large spans:\n"); + for (Span* s = large_.returned.next; s != &large_.returned; s = s->next) { + out->printf(" [ %6" PRIuS " pages ] %6.1f MB\n", + s->length, PagesToMB(s->length)); + r_pages += s->length; + r_spans++; + } + total_normal += n_pages; + total_returned += r_pages; + out->printf(">255 large * %6u spans ~ %6.1f MB; %6.1f MB cum" + "; unmapped: %6.1f MB; %6.1f MB cum\n", + (n_spans + r_spans), + PagesToMB(n_pages + r_pages), + PagesToMB(total_normal + total_returned), + PagesToMB(r_pages), + PagesToMB(total_returned)); +} +#endif + +bool TCMalloc_PageHeap::GrowHeap(Length n) { + ASSERT(kMaxPages >= kMinSystemAlloc); + if (n > kMaxValidPages) return false; + Length ask = (n>kMinSystemAlloc) ? n : static_cast(kMinSystemAlloc); + size_t actual_size; + void* ptr = TCMalloc_SystemAlloc(ask << kPageShift, &actual_size, kPageSize); + if (ptr == NULL) { + if (n < ask) { + // Try growing just "n" pages + ask = n; + ptr = TCMalloc_SystemAlloc(ask << kPageShift, &actual_size, kPageSize);; + } + if (ptr == NULL) return false; + } + ask = actual_size >> kPageShift; + + uint64_t old_system_bytes = system_bytes_; + system_bytes_ += (ask << kPageShift); + const PageID p = reinterpret_cast(ptr) >> kPageShift; + ASSERT(p > 0); + + // If we have already a lot of pages allocated, just pre allocate a bunch of + // memory for the page map. This prevents fragmentation by pagemap metadata + // when a program keeps allocating and freeing large blocks. + + if (old_system_bytes < kPageMapBigAllocationThreshold + && system_bytes_ >= kPageMapBigAllocationThreshold) { + pagemap_.PreallocateMoreMemory(); + } + + // Make sure pagemap_ has entries for all of the new pages. + // Plus ensure one before and one after so coalescing code + // does not need bounds-checking. + if (pagemap_.Ensure(p-1, ask+2)) { + // Pretend the new area is allocated and then Delete() it to + // cause any necessary coalescing to occur. + // + // We do not adjust free_pages_ here since Delete() will do it for us. + Span* span = NewSpan(p, ask); + RecordSpan(span); + Delete(span); + ASSERT(Check()); + return true; + } else { + // We could not allocate memory within "pagemap_" + // TODO: Once we can return memory to the system, return the new span + return false; + } +} + +bool TCMalloc_PageHeap::Check() { + ASSERT(free_[0].normal.next == &free_[0].normal); + ASSERT(free_[0].returned.next == &free_[0].returned); + CheckList(&large_.normal, kMaxPages, 1000000000); + CheckList(&large_.returned, kMaxPages, 1000000000); + for (Length s = 1; s < kMaxPages; s++) { + CheckList(&free_[s].normal, s, s); + CheckList(&free_[s].returned, s, s); + } + return true; +} + +#if ASSERT_DISABLED +bool TCMalloc_PageHeap::CheckList(Span*, Length, Length) { + return true; +} +#else +bool TCMalloc_PageHeap::CheckList(Span* list, Length min_pages, Length max_pages) { + for (Span* s = list->next; s != list; s = s->next) { + CHECK_CONDITION(s->free); + CHECK_CONDITION(s->length >= min_pages); + CHECK_CONDITION(s->length <= max_pages); + CHECK_CONDITION(GetDescriptor(s->start) == s); + CHECK_CONDITION(GetDescriptor(s->start+s->length-1) == s); + } + return true; +} +#endif + +static void ReleaseFreeList(Span* list, Span* returned) { + // Walk backwards through list so that when we push these + // spans on the "returned" list, we preserve the order. + while (!DLL_IsEmpty(list)) { + Span* s = list->prev; + DLL_Remove(s); + DLL_Prepend(returned, s); + TCMalloc_SystemRelease(reinterpret_cast(s->start << kPageShift), + static_cast(s->length << kPageShift)); + } +} + +void TCMalloc_PageHeap::ReleaseFreePages() { + for (Length s = 0; s < kMaxPages; s++) { + ReleaseFreeList(&free_[s].normal, &free_[s].returned); + } + ReleaseFreeList(&large_.normal, &large_.returned); + ASSERT(Check()); +} + +//------------------------------------------------------------------- +// Free list +//------------------------------------------------------------------- + +class TCMalloc_ThreadCache_FreeList { + private: + void* list_; // Linked list of nodes + uint16_t length_; // Current length + uint16_t lowater_; // Low water mark for list length + + public: + void Init() { + list_ = NULL; + length_ = 0; + lowater_ = 0; + } + + // Return current length of list + int length() const { + return length_; + } + + // Is list empty? + bool empty() const { + return list_ == NULL; + } + + // Low-water mark management + int lowwatermark() const { return lowater_; } + void clear_lowwatermark() { lowater_ = length_; } + + ALWAYS_INLINE void Push(void* ptr) { + SLL_Push(&list_, ptr); + length_++; + } + + void PushRange(int N, void *start, void *end) { + SLL_PushRange(&list_, start, end); + length_ = length_ + static_cast(N); + } + + void PopRange(int N, void **start, void **end) { + SLL_PopRange(&list_, N, start, end); + ASSERT(length_ >= N); + length_ = length_ - static_cast(N); + if (length_ < lowater_) lowater_ = length_; + } + + ALWAYS_INLINE void* Pop() { + ASSERT(list_ != NULL); + length_--; + if (length_ < lowater_) lowater_ = length_; + return SLL_Pop(&list_); + } + +#ifdef WTF_CHANGES + template + void enumerateFreeObjects(Finder& finder, const Reader& reader) + { + for (void* nextObject = list_; nextObject; nextObject = *reader(reinterpret_cast(nextObject))) + finder.visit(nextObject); + } +#endif +}; + +//------------------------------------------------------------------- +// Data kept per thread +//------------------------------------------------------------------- + +class TCMalloc_ThreadCache { + private: + typedef TCMalloc_ThreadCache_FreeList FreeList; +#if COMPILER(MSVC) + typedef DWORD ThreadIdentifier; +#else + typedef pthread_t ThreadIdentifier; +#endif + + size_t size_; // Combined size of data + ThreadIdentifier tid_; // Which thread owns it + bool in_setspecific_; // Called pthread_setspecific? + FreeList list_[kNumClasses]; // Array indexed by size-class + + // We sample allocations, biased by the size of the allocation + uint32_t rnd_; // Cheap random number generator + size_t bytes_until_sample_; // Bytes until we sample next + + // Allocate a new heap. REQUIRES: pageheap_lock is held. + static inline TCMalloc_ThreadCache* NewHeap(ThreadIdentifier tid); + + // Use only as pthread thread-specific destructor function. + static void DestroyThreadCache(void* ptr); + public: + // All ThreadCache objects are kept in a linked list (for stats collection) + TCMalloc_ThreadCache* next_; + TCMalloc_ThreadCache* prev_; + + void Init(ThreadIdentifier tid); + void Cleanup(); + + // Accessors (mostly just for printing stats) + int freelist_length(size_t cl) const { return list_[cl].length(); } + + // Total byte size in cache + size_t Size() const { return size_; } + + void* Allocate(size_t size); + void Deallocate(void* ptr, size_t size_class); + + void FetchFromCentralCache(size_t cl, size_t allocationSize); + void ReleaseToCentralCache(size_t cl, int N); + void Scavenge(); + void Print() const; + + // Record allocation of "k" bytes. Return true iff allocation + // should be sampled + bool SampleAllocation(size_t k); + + // Pick next sampling point + void PickNextSample(size_t k); + + static void InitModule(); + static void InitTSD(); + static TCMalloc_ThreadCache* GetThreadHeap(); + static TCMalloc_ThreadCache* GetCache(); + static TCMalloc_ThreadCache* GetCacheIfPresent(); + static TCMalloc_ThreadCache* CreateCacheIfNecessary(); + static void DeleteCache(TCMalloc_ThreadCache* heap); + static void BecomeIdle(); + static void RecomputeThreadCacheSize(); + +#ifdef WTF_CHANGES + template + void enumerateFreeObjects(Finder& finder, const Reader& reader) + { + for (unsigned sizeClass = 0; sizeClass < kNumClasses; sizeClass++) + list_[sizeClass].enumerateFreeObjects(finder, reader); + } +#endif +}; + +//------------------------------------------------------------------- +// Data kept per size-class in central cache +//------------------------------------------------------------------- + +class TCMalloc_Central_FreeList { + public: + void Init(size_t cl); + + // These methods all do internal locking. + + // Insert the specified range into the central freelist. N is the number of + // elements in the range. + void InsertRange(void *start, void *end, int N); + + // Returns the actual number of fetched elements into N. + void RemoveRange(void **start, void **end, int *N); + + // Returns the number of free objects in cache. + size_t length() { + SpinLockHolder h(&lock_); + return counter_; + } + + // Returns the number of free objects in the transfer cache. + int tc_length() { + SpinLockHolder h(&lock_); + return used_slots_ * num_objects_to_move[size_class_]; + } + +#ifdef WTF_CHANGES + template + void enumerateFreeObjects(Finder& finder, const Reader& reader) + { + for (Span* span = &empty_; span && span != &empty_; span = (span->next ? reader(span->next) : 0)) + ASSERT(!span->objects); + + ASSERT(!nonempty_.objects); + for (Span* span = reader(nonempty_.next); span && span != &nonempty_; span = (span->next ? reader(span->next) : 0)) { + for (void* nextObject = span->objects; nextObject; nextObject = *reader(reinterpret_cast(nextObject))) + finder.visit(nextObject); + } + } +#endif + + private: + // REQUIRES: lock_ is held + // Remove object from cache and return. + // Return NULL if no free entries in cache. + void* FetchFromSpans(); + + // REQUIRES: lock_ is held + // Remove object from cache and return. Fetches + // from pageheap if cache is empty. Only returns + // NULL on allocation failure. + void* FetchFromSpansSafe(); + + // REQUIRES: lock_ is held + // Release a linked list of objects to spans. + // May temporarily release lock_. + void ReleaseListToSpans(void *start); + + // REQUIRES: lock_ is held + // Release an object to spans. + // May temporarily release lock_. + void ReleaseToSpans(void* object); + + // REQUIRES: lock_ is held + // Populate cache by fetching from the page heap. + // May temporarily release lock_. + void Populate(); + + // REQUIRES: lock is held. + // Tries to make room for a TCEntry. If the cache is full it will try to + // expand it at the cost of some other cache size. Return false if there is + // no space. + bool MakeCacheSpace(); + + // REQUIRES: lock_ for locked_size_class is held. + // Picks a "random" size class to steal TCEntry slot from. In reality it + // just iterates over the sizeclasses but does so without taking a lock. + // Returns true on success. + // May temporarily lock a "random" size class. + static bool EvictRandomSizeClass(size_t locked_size_class, bool force); + + // REQUIRES: lock_ is *not* held. + // Tries to shrink the Cache. If force is true it will relase objects to + // spans if it allows it to shrink the cache. Return false if it failed to + // shrink the cache. Decrements cache_size_ on succeess. + // May temporarily take lock_. If it takes lock_, the locked_size_class + // lock is released to the thread from holding two size class locks + // concurrently which could lead to a deadlock. + bool ShrinkCache(int locked_size_class, bool force); + + // This lock protects all the data members. cached_entries and cache_size_ + // may be looked at without holding the lock. + SpinLock lock_; + + // We keep linked lists of empty and non-empty spans. + size_t size_class_; // My size class + Span empty_; // Dummy header for list of empty spans + Span nonempty_; // Dummy header for list of non-empty spans + size_t counter_; // Number of free objects in cache entry + + // Here we reserve space for TCEntry cache slots. Since one size class can + // end up getting all the TCEntries quota in the system we just preallocate + // sufficient number of entries here. + TCEntry tc_slots_[kNumTransferEntries]; + + // Number of currently used cached entries in tc_slots_. This variable is + // updated under a lock but can be read without one. + int32_t used_slots_; + // The current number of slots for this size class. This is an + // adaptive value that is increased if there is lots of traffic + // on a given size class. + int32_t cache_size_; +}; + +// Pad each CentralCache object to multiple of 64 bytes +class TCMalloc_Central_FreeListPadded : public TCMalloc_Central_FreeList { + private: + char pad_[(64 - (sizeof(TCMalloc_Central_FreeList) % 64)) % 64]; +}; + +//------------------------------------------------------------------- +// Global variables +//------------------------------------------------------------------- + +// Central cache -- a collection of free-lists, one per size-class. +// We have a separate lock per free-list to reduce contention. +static TCMalloc_Central_FreeListPadded central_cache[kNumClasses]; + +// Page-level allocator +static SpinLock pageheap_lock = SPINLOCK_INITIALIZER; + +#if PLATFORM(ARM) +static void* pageheap_memory[(sizeof(TCMalloc_PageHeap) + sizeof(void*) - 1) / sizeof(void*)] __attribute__((aligned)); +#else +static void* pageheap_memory[(sizeof(TCMalloc_PageHeap) + sizeof(void*) - 1) / sizeof(void*)]; +#endif +static bool phinited = false; + +// Avoid extra level of indirection by making "pageheap" be just an alias +// of pageheap_memory. +typedef union { + void* m_memory; + TCMalloc_PageHeap* m_pageHeap; +} PageHeapUnion; + +static inline TCMalloc_PageHeap* getPageHeap() +{ + PageHeapUnion u = { &pageheap_memory[0] }; + return u.m_pageHeap; +} + +#define pageheap getPageHeap() + +// If TLS is available, we also store a copy +// of the per-thread object in a __thread variable +// since __thread variables are faster to read +// than pthread_getspecific(). We still need +// pthread_setspecific() because __thread +// variables provide no way to run cleanup +// code when a thread is destroyed. +#ifdef HAVE_TLS +static __thread TCMalloc_ThreadCache *threadlocal_heap; +#endif +// Thread-specific key. Initialization here is somewhat tricky +// because some Linux startup code invokes malloc() before it +// is in a good enough state to handle pthread_keycreate(). +// Therefore, we use TSD keys only after tsd_inited is set to true. +// Until then, we use a slow path to get the heap object. +static bool tsd_inited = false; +static pthread_key_t heap_key; +#if COMPILER(MSVC) +DWORD tlsIndex = TLS_OUT_OF_INDEXES; +#endif + +static ALWAYS_INLINE void setThreadHeap(TCMalloc_ThreadCache* heap) +{ + // still do pthread_setspecific when using MSVC fast TLS to + // benefit from the delete callback. + pthread_setspecific(heap_key, heap); +#if COMPILER(MSVC) + TlsSetValue(tlsIndex, heap); +#endif +} + +// Allocator for thread heaps +static PageHeapAllocator threadheap_allocator; + +// Linked list of heap objects. Protected by pageheap_lock. +static TCMalloc_ThreadCache* thread_heaps = NULL; +static int thread_heap_count = 0; + +// Overall thread cache size. Protected by pageheap_lock. +static size_t overall_thread_cache_size = kDefaultOverallThreadCacheSize; + +// Global per-thread cache size. Writes are protected by +// pageheap_lock. Reads are done without any locking, which should be +// fine as long as size_t can be written atomically and we don't place +// invariants between this variable and other pieces of state. +static volatile size_t per_thread_cache_size = kMaxThreadCacheSize; + +//------------------------------------------------------------------- +// Central cache implementation +//------------------------------------------------------------------- + +void TCMalloc_Central_FreeList::Init(size_t cl) { + lock_.Init(); + size_class_ = cl; + DLL_Init(&empty_); + DLL_Init(&nonempty_); + counter_ = 0; + + cache_size_ = 1; + used_slots_ = 0; + ASSERT(cache_size_ <= kNumTransferEntries); +} + +void TCMalloc_Central_FreeList::ReleaseListToSpans(void* start) { + while (start) { + void *next = SLL_Next(start); + ReleaseToSpans(start); + start = next; + } +} + +ALWAYS_INLINE void TCMalloc_Central_FreeList::ReleaseToSpans(void* object) { + const PageID p = reinterpret_cast(object) >> kPageShift; + Span* span = pageheap->GetDescriptor(p); + ASSERT(span != NULL); + ASSERT(span->refcount > 0); + + // If span is empty, move it to non-empty list + if (span->objects == NULL) { + DLL_Remove(span); + DLL_Prepend(&nonempty_, span); + Event(span, 'N', 0); + } + + // The following check is expensive, so it is disabled by default + if (false) { + // Check that object does not occur in list + int got = 0; + for (void* p = span->objects; p != NULL; p = *((void**) p)) { + ASSERT(p != object); + got++; + } + ASSERT(got + span->refcount == + (span->length<sizeclass)); + } + + counter_++; + span->refcount--; + if (span->refcount == 0) { + Event(span, '#', 0); + counter_ -= (span->length<sizeclass); + DLL_Remove(span); + + // Release central list lock while operating on pageheap + lock_.Unlock(); + { + SpinLockHolder h(&pageheap_lock); + pageheap->Delete(span); + } + lock_.Lock(); + } else { + *(reinterpret_cast(object)) = span->objects; + span->objects = object; + } +} + +ALWAYS_INLINE bool TCMalloc_Central_FreeList::EvictRandomSizeClass( + size_t locked_size_class, bool force) { + static int race_counter = 0; + int t = race_counter++; // Updated without a lock, but who cares. + if (t >= static_cast(kNumClasses)) { + while (t >= static_cast(kNumClasses)) { + t -= kNumClasses; + } + race_counter = t; + } + ASSERT(t >= 0); + ASSERT(t < static_cast(kNumClasses)); + if (t == static_cast(locked_size_class)) return false; + return central_cache[t].ShrinkCache(static_cast(locked_size_class), force); +} + +bool TCMalloc_Central_FreeList::MakeCacheSpace() { + // Is there room in the cache? + if (used_slots_ < cache_size_) return true; + // Check if we can expand this cache? + if (cache_size_ == kNumTransferEntries) return false; + // Ok, we'll try to grab an entry from some other size class. + if (EvictRandomSizeClass(size_class_, false) || + EvictRandomSizeClass(size_class_, true)) { + // Succeeded in evicting, we're going to make our cache larger. + cache_size_++; + return true; + } + return false; +} + + +namespace { +class LockInverter { + private: + SpinLock *held_, *temp_; + public: + inline explicit LockInverter(SpinLock* held, SpinLock *temp) + : held_(held), temp_(temp) { held_->Unlock(); temp_->Lock(); } + inline ~LockInverter() { temp_->Unlock(); held_->Lock(); } +}; +} + +bool TCMalloc_Central_FreeList::ShrinkCache(int locked_size_class, bool force) { + // Start with a quick check without taking a lock. + if (cache_size_ == 0) return false; + // We don't evict from a full cache unless we are 'forcing'. + if (force == false && used_slots_ == cache_size_) return false; + + // Grab lock, but first release the other lock held by this thread. We use + // the lock inverter to ensure that we never hold two size class locks + // concurrently. That can create a deadlock because there is no well + // defined nesting order. + LockInverter li(¢ral_cache[locked_size_class].lock_, &lock_); + ASSERT(used_slots_ <= cache_size_); + ASSERT(0 <= cache_size_); + if (cache_size_ == 0) return false; + if (used_slots_ == cache_size_) { + if (force == false) return false; + // ReleaseListToSpans releases the lock, so we have to make all the + // updates to the central list before calling it. + cache_size_--; + used_slots_--; + ReleaseListToSpans(tc_slots_[used_slots_].head); + return true; + } + cache_size_--; + return true; +} + +void TCMalloc_Central_FreeList::InsertRange(void *start, void *end, int N) { + SpinLockHolder h(&lock_); + if (N == num_objects_to_move[size_class_] && + MakeCacheSpace()) { + int slot = used_slots_++; + ASSERT(slot >=0); + ASSERT(slot < kNumTransferEntries); + TCEntry *entry = &tc_slots_[slot]; + entry->head = start; + entry->tail = end; + return; + } + ReleaseListToSpans(start); +} + +void TCMalloc_Central_FreeList::RemoveRange(void **start, void **end, int *N) { + int num = *N; + ASSERT(num > 0); + + SpinLockHolder h(&lock_); + if (num == num_objects_to_move[size_class_] && used_slots_ > 0) { + int slot = --used_slots_; + ASSERT(slot >= 0); + TCEntry *entry = &tc_slots_[slot]; + *start = entry->head; + *end = entry->tail; + return; + } + + // TODO: Prefetch multiple TCEntries? + void *tail = FetchFromSpansSafe(); + if (!tail) { + // We are completely out of memory. + *start = *end = NULL; + *N = 0; + return; + } + + SLL_SetNext(tail, NULL); + void *head = tail; + int count = 1; + while (count < num) { + void *t = FetchFromSpans(); + if (!t) break; + SLL_Push(&head, t); + count++; + } + *start = head; + *end = tail; + *N = count; +} + + +void* TCMalloc_Central_FreeList::FetchFromSpansSafe() { + void *t = FetchFromSpans(); + if (!t) { + Populate(); + t = FetchFromSpans(); + } + return t; +} + +void* TCMalloc_Central_FreeList::FetchFromSpans() { + if (DLL_IsEmpty(&nonempty_)) return NULL; + Span* span = nonempty_.next; + + ASSERT(span->objects != NULL); + span->refcount++; + void* result = span->objects; + span->objects = *(reinterpret_cast(result)); + if (span->objects == NULL) { + // Move to empty list + DLL_Remove(span); + DLL_Prepend(&empty_, span); + Event(span, 'E', 0); + } + counter_--; + return result; +} + +// Fetch memory from the system and add to the central cache freelist. +ALWAYS_INLINE void TCMalloc_Central_FreeList::Populate() { + // Release central list lock while operating on pageheap + lock_.Unlock(); + const size_t npages = class_to_pages[size_class_]; + + Span* span; + { + SpinLockHolder h(&pageheap_lock); + span = pageheap->New(npages); + if (span) pageheap->RegisterSizeClass(span, size_class_); + } + if (span == NULL) { + MESSAGE("allocation failed: %d\n", errno); + lock_.Lock(); + return; + } + ASSERT(span->length == npages); + // Cache sizeclass info eagerly. Locking is not necessary. + // (Instead of being eager, we could just replace any stale info + // about this span, but that seems to be no better in practice.) + for (size_t i = 0; i < npages; i++) { + pageheap->CacheSizeClass(span->start + i, size_class_); + } + + // Split the block into pieces and add to the free-list + // TODO: coloring of objects to avoid cache conflicts? + void** tail = &span->objects; + char* ptr = reinterpret_cast(span->start << kPageShift); + char* limit = ptr + (npages << kPageShift); + const size_t size = ByteSizeForClass(size_class_); + int num = 0; + char* nptr; + while ((nptr = ptr + size) <= limit) { + *tail = ptr; + tail = reinterpret_cast(ptr); + ptr = nptr; + num++; + } + ASSERT(ptr <= limit); + *tail = NULL; + span->refcount = 0; // No sub-object in use yet + + // Add span to list of non-empty spans + lock_.Lock(); + DLL_Prepend(&nonempty_, span); + counter_ += num; +} + +//------------------------------------------------------------------- +// TCMalloc_ThreadCache implementation +//------------------------------------------------------------------- + +inline bool TCMalloc_ThreadCache::SampleAllocation(size_t k) { + if (bytes_until_sample_ < k) { + PickNextSample(k); + return true; + } else { + bytes_until_sample_ -= k; + return false; + } +} + +void TCMalloc_ThreadCache::Init(ThreadIdentifier tid) { + size_ = 0; + next_ = NULL; + prev_ = NULL; + tid_ = tid; + in_setspecific_ = false; + for (size_t cl = 0; cl < kNumClasses; ++cl) { + list_[cl].Init(); + } + + // Initialize RNG -- run it for a bit to get to good values + bytes_until_sample_ = 0; + rnd_ = static_cast(reinterpret_cast(this)); + for (int i = 0; i < 100; i++) { + PickNextSample(static_cast(FLAGS_tcmalloc_sample_parameter * 2)); + } +} + +void TCMalloc_ThreadCache::Cleanup() { + // Put unused memory back into central cache + for (size_t cl = 0; cl < kNumClasses; ++cl) { + if (list_[cl].length() > 0) { + ReleaseToCentralCache(cl, list_[cl].length()); + } + } +} + +ALWAYS_INLINE void* TCMalloc_ThreadCache::Allocate(size_t size) { + ASSERT(size <= kMaxSize); + const size_t cl = SizeClass(size); + FreeList* list = &list_[cl]; + size_t allocationSize = ByteSizeForClass(cl); + if (list->empty()) { + FetchFromCentralCache(cl, allocationSize); + if (list->empty()) return NULL; + } + size_ -= allocationSize; + return list->Pop(); +} + +inline void TCMalloc_ThreadCache::Deallocate(void* ptr, size_t cl) { + size_ += ByteSizeForClass(cl); + FreeList* list = &list_[cl]; + list->Push(ptr); + // If enough data is free, put back into central cache + if (list->length() > kMaxFreeListLength) { + ReleaseToCentralCache(cl, num_objects_to_move[cl]); + } + if (size_ >= per_thread_cache_size) Scavenge(); +} + +// Remove some objects of class "cl" from central cache and add to thread heap +ALWAYS_INLINE void TCMalloc_ThreadCache::FetchFromCentralCache(size_t cl, size_t allocationSize) { + int fetch_count = num_objects_to_move[cl]; + void *start, *end; + central_cache[cl].RemoveRange(&start, &end, &fetch_count); + list_[cl].PushRange(fetch_count, start, end); + size_ += allocationSize * fetch_count; +} + +// Remove some objects of class "cl" from thread heap and add to central cache +inline void TCMalloc_ThreadCache::ReleaseToCentralCache(size_t cl, int N) { + ASSERT(N > 0); + FreeList* src = &list_[cl]; + if (N > src->length()) N = src->length(); + size_ -= N*ByteSizeForClass(cl); + + // We return prepackaged chains of the correct size to the central cache. + // TODO: Use the same format internally in the thread caches? + int batch_size = num_objects_to_move[cl]; + while (N > batch_size) { + void *tail, *head; + src->PopRange(batch_size, &head, &tail); + central_cache[cl].InsertRange(head, tail, batch_size); + N -= batch_size; + } + void *tail, *head; + src->PopRange(N, &head, &tail); + central_cache[cl].InsertRange(head, tail, N); +} + +// Release idle memory to the central cache +inline void TCMalloc_ThreadCache::Scavenge() { + // If the low-water mark for the free list is L, it means we would + // not have had to allocate anything from the central cache even if + // we had reduced the free list size by L. We aim to get closer to + // that situation by dropping L/2 nodes from the free list. This + // may not release much memory, but if so we will call scavenge again + // pretty soon and the low-water marks will be high on that call. + //int64 start = CycleClock::Now(); + + for (size_t cl = 0; cl < kNumClasses; cl++) { + FreeList* list = &list_[cl]; + const int lowmark = list->lowwatermark(); + if (lowmark > 0) { + const int drop = (lowmark > 1) ? lowmark/2 : 1; + ReleaseToCentralCache(cl, drop); + } + list->clear_lowwatermark(); + } + + //int64 finish = CycleClock::Now(); + //CycleTimer ct; + //MESSAGE("GC: %.0f ns\n", ct.CyclesToUsec(finish-start)*1000.0); +} + +void TCMalloc_ThreadCache::PickNextSample(size_t k) { + // Make next "random" number + // x^32+x^22+x^2+x^1+1 is a primitive polynomial for random numbers + static const uint32_t kPoly = (1 << 22) | (1 << 2) | (1 << 1) | (1 << 0); + uint32_t r = rnd_; + rnd_ = (r << 1) ^ ((static_cast(r) >> 31) & kPoly); + + // Next point is "rnd_ % (sample_period)". I.e., average + // increment is "sample_period/2". + const int flag_value = static_cast(FLAGS_tcmalloc_sample_parameter); + static int last_flag_value = -1; + + if (flag_value != last_flag_value) { + SpinLockHolder h(&sample_period_lock); + int i; + for (i = 0; i < (static_cast(sizeof(primes_list)/sizeof(primes_list[0])) - 1); i++) { + if (primes_list[i] >= flag_value) { + break; + } + } + sample_period = primes_list[i]; + last_flag_value = flag_value; + } + + bytes_until_sample_ += rnd_ % sample_period; + + if (k > (static_cast(-1) >> 2)) { + // If the user has asked for a huge allocation then it is possible + // for the code below to loop infinitely. Just return (note that + // this throws off the sampling accuracy somewhat, but a user who + // is allocating more than 1G of memory at a time can live with a + // minor inaccuracy in profiling of small allocations, and also + // would rather not wait for the loop below to terminate). + return; + } + + while (bytes_until_sample_ < k) { + // Increase bytes_until_sample_ by enough average sampling periods + // (sample_period >> 1) to allow us to sample past the current + // allocation. + bytes_until_sample_ += (sample_period >> 1); + } + + bytes_until_sample_ -= k; +} + +void TCMalloc_ThreadCache::InitModule() { + // There is a slight potential race here because of double-checked + // locking idiom. However, as long as the program does a small + // allocation before switching to multi-threaded mode, we will be + // fine. We increase the chances of doing such a small allocation + // by doing one in the constructor of the module_enter_exit_hook + // object declared below. + SpinLockHolder h(&pageheap_lock); + if (!phinited) { +#ifdef WTF_CHANGES + InitTSD(); +#endif + InitSizeClasses(); + threadheap_allocator.Init(); + span_allocator.Init(); + span_allocator.New(); // Reduce cache conflicts + span_allocator.New(); // Reduce cache conflicts + stacktrace_allocator.Init(); + DLL_Init(&sampled_objects); + for (size_t i = 0; i < kNumClasses; ++i) { + central_cache[i].Init(i); + } + pageheap->init(); + phinited = 1; +#if defined(WTF_CHANGES) && PLATFORM(DARWIN) + FastMallocZone::init(); +#endif + } +} + +inline TCMalloc_ThreadCache* TCMalloc_ThreadCache::NewHeap(ThreadIdentifier tid) { + // Create the heap and add it to the linked list + TCMalloc_ThreadCache *heap = threadheap_allocator.New(); + heap->Init(tid); + heap->next_ = thread_heaps; + heap->prev_ = NULL; + if (thread_heaps != NULL) thread_heaps->prev_ = heap; + thread_heaps = heap; + thread_heap_count++; + RecomputeThreadCacheSize(); + return heap; +} + +inline TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetThreadHeap() { +#ifdef HAVE_TLS + // __thread is faster, but only when the kernel supports it + if (KernelSupportsTLS()) + return threadlocal_heap; +#elif COMPILER(MSVC) + return static_cast(TlsGetValue(tlsIndex)); +#else + return static_cast(pthread_getspecific(heap_key)); +#endif +} + +inline TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetCache() { + TCMalloc_ThreadCache* ptr = NULL; + if (!tsd_inited) { + InitModule(); + } else { + ptr = GetThreadHeap(); + } + if (ptr == NULL) ptr = CreateCacheIfNecessary(); + return ptr; +} + +// In deletion paths, we do not try to create a thread-cache. This is +// because we may be in the thread destruction code and may have +// already cleaned up the cache for this thread. +inline TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetCacheIfPresent() { + if (!tsd_inited) return NULL; + void* const p = GetThreadHeap(); + return reinterpret_cast(p); +} + +void TCMalloc_ThreadCache::InitTSD() { + ASSERT(!tsd_inited); + pthread_key_create(&heap_key, DestroyThreadCache); +#if COMPILER(MSVC) + tlsIndex = TlsAlloc(); +#endif + tsd_inited = true; + +#if !COMPILER(MSVC) + // We may have used a fake pthread_t for the main thread. Fix it. + pthread_t zero; + memset(&zero, 0, sizeof(zero)); +#endif +#ifndef WTF_CHANGES + SpinLockHolder h(&pageheap_lock); +#else + ASSERT(pageheap_lock.IsHeld()); +#endif + for (TCMalloc_ThreadCache* h = thread_heaps; h != NULL; h = h->next_) { +#if COMPILER(MSVC) + if (h->tid_ == 0) { + h->tid_ = GetCurrentThreadId(); + } +#else + if (pthread_equal(h->tid_, zero)) { + h->tid_ = pthread_self(); + } +#endif + } +} + +TCMalloc_ThreadCache* TCMalloc_ThreadCache::CreateCacheIfNecessary() { + // Initialize per-thread data if necessary + TCMalloc_ThreadCache* heap = NULL; + { + SpinLockHolder h(&pageheap_lock); + +#if COMPILER(MSVC) + DWORD me; + if (!tsd_inited) { + me = 0; + } else { + me = GetCurrentThreadId(); + } +#else + // Early on in glibc's life, we cannot even call pthread_self() + pthread_t me; + if (!tsd_inited) { + memset(&me, 0, sizeof(me)); + } else { + me = pthread_self(); + } +#endif + + // This may be a recursive malloc call from pthread_setspecific() + // In that case, the heap for this thread has already been created + // and added to the linked list. So we search for that first. + for (TCMalloc_ThreadCache* h = thread_heaps; h != NULL; h = h->next_) { +#if COMPILER(MSVC) + if (h->tid_ == me) { +#else + if (pthread_equal(h->tid_, me)) { +#endif + heap = h; + break; + } + } + + if (heap == NULL) heap = NewHeap(me); + } + + // We call pthread_setspecific() outside the lock because it may + // call malloc() recursively. The recursive call will never get + // here again because it will find the already allocated heap in the + // linked list of heaps. + if (!heap->in_setspecific_ && tsd_inited) { + heap->in_setspecific_ = true; + setThreadHeap(heap); + } + return heap; +} + +void TCMalloc_ThreadCache::BecomeIdle() { + if (!tsd_inited) return; // No caches yet + TCMalloc_ThreadCache* heap = GetThreadHeap(); + if (heap == NULL) return; // No thread cache to remove + if (heap->in_setspecific_) return; // Do not disturb the active caller + + heap->in_setspecific_ = true; + pthread_setspecific(heap_key, NULL); +#ifdef HAVE_TLS + // Also update the copy in __thread + threadlocal_heap = NULL; +#endif + heap->in_setspecific_ = false; + if (GetThreadHeap() == heap) { + // Somehow heap got reinstated by a recursive call to malloc + // from pthread_setspecific. We give up in this case. + return; + } + + // We can now get rid of the heap + DeleteCache(heap); +} + +void TCMalloc_ThreadCache::DestroyThreadCache(void* ptr) { + // Note that "ptr" cannot be NULL since pthread promises not + // to invoke the destructor on NULL values, but for safety, + // we check anyway. + if (ptr == NULL) return; +#ifdef HAVE_TLS + // Prevent fast path of GetThreadHeap() from returning heap. + threadlocal_heap = NULL; +#endif + DeleteCache(reinterpret_cast(ptr)); +} + +void TCMalloc_ThreadCache::DeleteCache(TCMalloc_ThreadCache* heap) { + // Remove all memory from heap + heap->Cleanup(); + + // Remove from linked list + SpinLockHolder h(&pageheap_lock); + if (heap->next_ != NULL) heap->next_->prev_ = heap->prev_; + if (heap->prev_ != NULL) heap->prev_->next_ = heap->next_; + if (thread_heaps == heap) thread_heaps = heap->next_; + thread_heap_count--; + RecomputeThreadCacheSize(); + + threadheap_allocator.Delete(heap); +} + +void TCMalloc_ThreadCache::RecomputeThreadCacheSize() { + // Divide available space across threads + int n = thread_heap_count > 0 ? thread_heap_count : 1; + size_t space = overall_thread_cache_size / n; + + // Limit to allowed range + if (space < kMinThreadCacheSize) space = kMinThreadCacheSize; + if (space > kMaxThreadCacheSize) space = kMaxThreadCacheSize; + + per_thread_cache_size = space; +} + +void TCMalloc_ThreadCache::Print() const { + for (size_t cl = 0; cl < kNumClasses; ++cl) { + MESSAGE(" %5" PRIuS " : %4d len; %4d lo\n", + ByteSizeForClass(cl), + list_[cl].length(), + list_[cl].lowwatermark()); + } +} + +// Extract interesting stats +struct TCMallocStats { + uint64_t system_bytes; // Bytes alloced from system + uint64_t thread_bytes; // Bytes in thread caches + uint64_t central_bytes; // Bytes in central cache + uint64_t transfer_bytes; // Bytes in central transfer cache + uint64_t pageheap_bytes; // Bytes in page heap + uint64_t metadata_bytes; // Bytes alloced for metadata +}; + +#ifndef WTF_CHANGES +// Get stats into "r". Also get per-size-class counts if class_count != NULL +static void ExtractStats(TCMallocStats* r, uint64_t* class_count) { + r->central_bytes = 0; + r->transfer_bytes = 0; + for (int cl = 0; cl < kNumClasses; ++cl) { + const int length = central_cache[cl].length(); + const int tc_length = central_cache[cl].tc_length(); + r->central_bytes += static_cast(ByteSizeForClass(cl)) * length; + r->transfer_bytes += + static_cast(ByteSizeForClass(cl)) * tc_length; + if (class_count) class_count[cl] = length + tc_length; + } + + // Add stats from per-thread heaps + r->thread_bytes = 0; + { // scope + SpinLockHolder h(&pageheap_lock); + for (TCMalloc_ThreadCache* h = thread_heaps; h != NULL; h = h->next_) { + r->thread_bytes += h->Size(); + if (class_count) { + for (size_t cl = 0; cl < kNumClasses; ++cl) { + class_count[cl] += h->freelist_length(cl); + } + } + } + } + + { //scope + SpinLockHolder h(&pageheap_lock); + r->system_bytes = pageheap->SystemBytes(); + r->metadata_bytes = metadata_system_bytes; + r->pageheap_bytes = pageheap->FreeBytes(); + } +} +#endif + +#ifndef WTF_CHANGES +// WRITE stats to "out" +static void DumpStats(TCMalloc_Printer* out, int level) { + TCMallocStats stats; + uint64_t class_count[kNumClasses]; + ExtractStats(&stats, (level >= 2 ? class_count : NULL)); + + if (level >= 2) { + out->printf("------------------------------------------------\n"); + uint64_t cumulative = 0; + for (int cl = 0; cl < kNumClasses; ++cl) { + if (class_count[cl] > 0) { + uint64_t class_bytes = class_count[cl] * ByteSizeForClass(cl); + cumulative += class_bytes; + out->printf("class %3d [ %8" PRIuS " bytes ] : " + "%8" PRIu64 " objs; %5.1f MB; %5.1f cum MB\n", + cl, ByteSizeForClass(cl), + class_count[cl], + class_bytes / 1048576.0, + cumulative / 1048576.0); + } + } + + SpinLockHolder h(&pageheap_lock); + pageheap->Dump(out); + } + + const uint64_t bytes_in_use = stats.system_bytes + - stats.pageheap_bytes + - stats.central_bytes + - stats.transfer_bytes + - stats.thread_bytes; + + out->printf("------------------------------------------------\n" + "MALLOC: %12" PRIu64 " Heap size\n" + "MALLOC: %12" PRIu64 " Bytes in use by application\n" + "MALLOC: %12" PRIu64 " Bytes free in page heap\n" + "MALLOC: %12" PRIu64 " Bytes free in central cache\n" + "MALLOC: %12" PRIu64 " Bytes free in transfer cache\n" + "MALLOC: %12" PRIu64 " Bytes free in thread caches\n" + "MALLOC: %12" PRIu64 " Spans in use\n" + "MALLOC: %12" PRIu64 " Thread heaps in use\n" + "MALLOC: %12" PRIu64 " Metadata allocated\n" + "------------------------------------------------\n", + stats.system_bytes, + bytes_in_use, + stats.pageheap_bytes, + stats.central_bytes, + stats.transfer_bytes, + stats.thread_bytes, + uint64_t(span_allocator.inuse()), + uint64_t(threadheap_allocator.inuse()), + stats.metadata_bytes); +} + +static void PrintStats(int level) { + const int kBufferSize = 16 << 10; + char* buffer = new char[kBufferSize]; + TCMalloc_Printer printer(buffer, kBufferSize); + DumpStats(&printer, level); + write(STDERR_FILENO, buffer, strlen(buffer)); + delete[] buffer; +} + +static void** DumpStackTraces() { + // Count how much space we need + int needed_slots = 0; + { + SpinLockHolder h(&pageheap_lock); + for (Span* s = sampled_objects.next; s != &sampled_objects; s = s->next) { + StackTrace* stack = reinterpret_cast(s->objects); + needed_slots += 3 + stack->depth; + } + needed_slots += 100; // Slop in case sample grows + needed_slots += needed_slots/8; // An extra 12.5% slop + } + + void** result = new void*[needed_slots]; + if (result == NULL) { + MESSAGE("tcmalloc: could not allocate %d slots for stack traces\n", + needed_slots); + return NULL; + } + + SpinLockHolder h(&pageheap_lock); + int used_slots = 0; + for (Span* s = sampled_objects.next; s != &sampled_objects; s = s->next) { + ASSERT(used_slots < needed_slots); // Need to leave room for terminator + StackTrace* stack = reinterpret_cast(s->objects); + if (used_slots + 3 + stack->depth >= needed_slots) { + // No more room + break; + } + + result[used_slots+0] = reinterpret_cast(static_cast(1)); + result[used_slots+1] = reinterpret_cast(stack->size); + result[used_slots+2] = reinterpret_cast(stack->depth); + for (int d = 0; d < stack->depth; d++) { + result[used_slots+3+d] = stack->stack[d]; + } + used_slots += 3 + stack->depth; + } + result[used_slots] = reinterpret_cast(static_cast(0)); + return result; +} +#endif + +#ifndef WTF_CHANGES + +// TCMalloc's support for extra malloc interfaces +class TCMallocImplementation : public MallocExtension { + public: + virtual void GetStats(char* buffer, int buffer_length) { + ASSERT(buffer_length > 0); + TCMalloc_Printer printer(buffer, buffer_length); + + // Print level one stats unless lots of space is available + if (buffer_length < 10000) { + DumpStats(&printer, 1); + } else { + DumpStats(&printer, 2); + } + } + + virtual void** ReadStackTraces() { + return DumpStackTraces(); + } + + virtual bool GetNumericProperty(const char* name, size_t* value) { + ASSERT(name != NULL); + + if (strcmp(name, "generic.current_allocated_bytes") == 0) { + TCMallocStats stats; + ExtractStats(&stats, NULL); + *value = stats.system_bytes + - stats.thread_bytes + - stats.central_bytes + - stats.pageheap_bytes; + return true; + } + + if (strcmp(name, "generic.heap_size") == 0) { + TCMallocStats stats; + ExtractStats(&stats, NULL); + *value = stats.system_bytes; + return true; + } + + if (strcmp(name, "tcmalloc.slack_bytes") == 0) { + // We assume that bytes in the page heap are not fragmented too + // badly, and are therefore available for allocation. + SpinLockHolder l(&pageheap_lock); + *value = pageheap->FreeBytes(); + return true; + } + + if (strcmp(name, "tcmalloc.max_total_thread_cache_bytes") == 0) { + SpinLockHolder l(&pageheap_lock); + *value = overall_thread_cache_size; + return true; + } + + if (strcmp(name, "tcmalloc.current_total_thread_cache_bytes") == 0) { + TCMallocStats stats; + ExtractStats(&stats, NULL); + *value = stats.thread_bytes; + return true; + } + + return false; + } + + virtual bool SetNumericProperty(const char* name, size_t value) { + ASSERT(name != NULL); + + if (strcmp(name, "tcmalloc.max_total_thread_cache_bytes") == 0) { + // Clip the value to a reasonable range + if (value < kMinThreadCacheSize) value = kMinThreadCacheSize; + if (value > (1<<30)) value = (1<<30); // Limit to 1GB + + SpinLockHolder l(&pageheap_lock); + overall_thread_cache_size = static_cast(value); + TCMalloc_ThreadCache::RecomputeThreadCacheSize(); + return true; + } + + return false; + } + + virtual void MarkThreadIdle() { + TCMalloc_ThreadCache::BecomeIdle(); + } + + virtual void ReleaseFreeMemory() { + SpinLockHolder h(&pageheap_lock); + pageheap->ReleaseFreePages(); + } +}; +#endif + +// The constructor allocates an object to ensure that initialization +// runs before main(), and therefore we do not have a chance to become +// multi-threaded before initialization. We also create the TSD key +// here. Presumably by the time this constructor runs, glibc is in +// good enough shape to handle pthread_key_create(). +// +// The constructor also takes the opportunity to tell STL to use +// tcmalloc. We want to do this early, before construct time, so +// all user STL allocations go through tcmalloc (which works really +// well for STL). +// +// The destructor prints stats when the program exits. +class TCMallocGuard { + public: + + TCMallocGuard() { +#ifdef HAVE_TLS // this is true if the cc/ld/libc combo support TLS + // Check whether the kernel also supports TLS (needs to happen at runtime) + CheckIfKernelSupportsTLS(); +#endif +#ifndef WTF_CHANGES +#ifdef WIN32 // patch the windows VirtualAlloc, etc. + PatchWindowsFunctions(); // defined in windows/patch_functions.cc +#endif +#endif + free(malloc(1)); + TCMalloc_ThreadCache::InitTSD(); + free(malloc(1)); +#ifndef WTF_CHANGES + MallocExtension::Register(new TCMallocImplementation); +#endif + } + +#ifndef WTF_CHANGES + ~TCMallocGuard() { + const char* env = getenv("MALLOCSTATS"); + if (env != NULL) { + int level = atoi(env); + if (level < 1) level = 1; + PrintStats(level); + } +#ifdef WIN32 + UnpatchWindowsFunctions(); +#endif + } +#endif +}; + +#ifndef WTF_CHANGES +static TCMallocGuard module_enter_exit_hook; +#endif + + +//------------------------------------------------------------------- +// Helpers for the exported routines below +//------------------------------------------------------------------- + +#ifndef WTF_CHANGES + +static Span* DoSampledAllocation(size_t size) { + + // Grab the stack trace outside the heap lock + StackTrace tmp; + tmp.depth = GetStackTrace(tmp.stack, kMaxStackDepth, 1); + tmp.size = size; + + SpinLockHolder h(&pageheap_lock); + // Allocate span + Span *span = pageheap->New(pages(size == 0 ? 1 : size)); + if (span == NULL) { + return NULL; + } + + // Allocate stack trace + StackTrace *stack = stacktrace_allocator.New(); + if (stack == NULL) { + // Sampling failed because of lack of memory + return span; + } + + *stack = tmp; + span->sample = 1; + span->objects = stack; + DLL_Prepend(&sampled_objects, span); + + return span; +} +#endif + +static inline bool CheckCachedSizeClass(void *ptr) { + PageID p = reinterpret_cast(ptr) >> kPageShift; + size_t cached_value = pageheap->GetSizeClassIfCached(p); + return cached_value == 0 || + cached_value == pageheap->GetDescriptor(p)->sizeclass; +} + +static inline void* CheckedMallocResult(void *result) +{ + ASSERT(result == 0 || CheckCachedSizeClass(result)); + return result; +} + +static inline void* SpanToMallocResult(Span *span) { + pageheap->CacheSizeClass(span->start, 0); + return + CheckedMallocResult(reinterpret_cast(span->start << kPageShift)); +} + +static ALWAYS_INLINE void* do_malloc(size_t size) { + void* ret = NULL; + +#ifdef WTF_CHANGES + ASSERT(!isForbidden()); +#endif + + // The following call forces module initialization + TCMalloc_ThreadCache* heap = TCMalloc_ThreadCache::GetCache(); +#ifndef WTF_CHANGES + if ((FLAGS_tcmalloc_sample_parameter > 0) && heap->SampleAllocation(size)) { + Span* span = DoSampledAllocation(size); + if (span != NULL) { + ret = SpanToMallocResult(span); + } + } else +#endif + if (size > kMaxSize) { + // Use page-level allocator + SpinLockHolder h(&pageheap_lock); + Span* span = pageheap->New(pages(size)); + if (span != NULL) { + ret = SpanToMallocResult(span); + } + } else { + // The common case, and also the simplest. This just pops the + // size-appropriate freelist, afer replenishing it if it's empty. + ret = CheckedMallocResult(heap->Allocate(size)); + } + if (ret == NULL) errno = ENOMEM; + return ret; +} + +static ALWAYS_INLINE void do_free(void* ptr) { + if (ptr == NULL) return; + ASSERT(pageheap != NULL); // Should not call free() before malloc() + const PageID p = reinterpret_cast(ptr) >> kPageShift; + Span* span = NULL; + size_t cl = pageheap->GetSizeClassIfCached(p); + + if (cl == 0) { + span = pageheap->GetDescriptor(p); + cl = span->sizeclass; + pageheap->CacheSizeClass(p, cl); + } + if (cl != 0) { + ASSERT(!pageheap->GetDescriptor(p)->sample); + TCMalloc_ThreadCache* heap = TCMalloc_ThreadCache::GetCacheIfPresent(); + if (heap != NULL) { + heap->Deallocate(ptr, cl); + } else { + // Delete directly into central cache + SLL_SetNext(ptr, NULL); + central_cache[cl].InsertRange(ptr, ptr, 1); + } + } else { + SpinLockHolder h(&pageheap_lock); + ASSERT(reinterpret_cast(ptr) % kPageSize == 0); + ASSERT(span != NULL && span->start == p); + if (span->sample) { + DLL_Remove(span); + stacktrace_allocator.Delete(reinterpret_cast(span->objects)); + span->objects = NULL; + } + pageheap->Delete(span); + } +} + +#ifndef WTF_CHANGES +// For use by exported routines below that want specific alignments +// +// Note: this code can be slow, and can significantly fragment memory. +// The expectation is that memalign/posix_memalign/valloc/pvalloc will +// not be invoked very often. This requirement simplifies our +// implementation and allows us to tune for expected allocation +// patterns. +static void* do_memalign(size_t align, size_t size) { + ASSERT((align & (align - 1)) == 0); + ASSERT(align > 0); + if (pageheap == NULL) TCMalloc_ThreadCache::InitModule(); + + // Allocate at least one byte to avoid boundary conditions below + if (size == 0) size = 1; + + if (size <= kMaxSize && align < kPageSize) { + // Search through acceptable size classes looking for one with + // enough alignment. This depends on the fact that + // InitSizeClasses() currently produces several size classes that + // are aligned at powers of two. We will waste time and space if + // we miss in the size class array, but that is deemed acceptable + // since memalign() should be used rarely. + size_t cl = SizeClass(size); + while (cl < kNumClasses && ((class_to_size[cl] & (align - 1)) != 0)) { + cl++; + } + if (cl < kNumClasses) { + TCMalloc_ThreadCache* heap = TCMalloc_ThreadCache::GetCache(); + return CheckedMallocResult(heap->Allocate(class_to_size[cl])); + } + } + + // We will allocate directly from the page heap + SpinLockHolder h(&pageheap_lock); + + if (align <= kPageSize) { + // Any page-level allocation will be fine + // TODO: We could put the rest of this page in the appropriate + // TODO: cache but it does not seem worth it. + Span* span = pageheap->New(pages(size)); + return span == NULL ? NULL : SpanToMallocResult(span); + } + + // Allocate extra pages and carve off an aligned portion + const Length alloc = pages(size + align); + Span* span = pageheap->New(alloc); + if (span == NULL) return NULL; + + // Skip starting portion so that we end up aligned + Length skip = 0; + while ((((span->start+skip) << kPageShift) & (align - 1)) != 0) { + skip++; + } + ASSERT(skip < alloc); + if (skip > 0) { + Span* rest = pageheap->Split(span, skip); + pageheap->Delete(span); + span = rest; + } + + // Skip trailing portion that we do not need to return + const Length needed = pages(size); + ASSERT(span->length >= needed); + if (span->length > needed) { + Span* trailer = pageheap->Split(span, needed); + pageheap->Delete(trailer); + } + return SpanToMallocResult(span); +} +#endif + +// Helpers for use by exported routines below: + +#ifndef WTF_CHANGES +static inline void do_malloc_stats() { + PrintStats(1); +} +#endif + +static inline int do_mallopt(int, int) { + return 1; // Indicates error +} + +#ifdef HAVE_STRUCT_MALLINFO // mallinfo isn't defined on freebsd, for instance +static inline struct mallinfo do_mallinfo() { + TCMallocStats stats; + ExtractStats(&stats, NULL); + + // Just some of the fields are filled in. + struct mallinfo info; + memset(&info, 0, sizeof(info)); + + // Unfortunately, the struct contains "int" field, so some of the + // size values will be truncated. + info.arena = static_cast(stats.system_bytes); + info.fsmblks = static_cast(stats.thread_bytes + + stats.central_bytes + + stats.transfer_bytes); + info.fordblks = static_cast(stats.pageheap_bytes); + info.uordblks = static_cast(stats.system_bytes + - stats.thread_bytes + - stats.central_bytes + - stats.transfer_bytes + - stats.pageheap_bytes); + + return info; +} +#endif + +//------------------------------------------------------------------- +// Exported routines +//------------------------------------------------------------------- + +// CAVEAT: The code structure below ensures that MallocHook methods are always +// called from the stack frame of the invoked allocation function. +// heap-checker.cc depends on this to start a stack trace from +// the call to the (de)allocation function. + +#ifndef WTF_CHANGES +extern "C" +#endif +void* malloc(size_t size) { + void* result = do_malloc(size); +#ifndef WTF_CHANGES + MallocHook::InvokeNewHook(result, size); +#endif + return result; +} + +#ifndef WTF_CHANGES +extern "C" +#endif +void free(void* ptr) { +#ifndef WTF_CHANGES + MallocHook::InvokeDeleteHook(ptr); +#endif + do_free(ptr); +} + +#ifndef WTF_CHANGES +extern "C" +#endif +void* calloc(size_t n, size_t elem_size) { + const size_t totalBytes = n * elem_size; + + // Protect against overflow + if (n > 1 && elem_size && (totalBytes / elem_size) != n) + return 0; + + void* result = do_malloc(totalBytes); + if (result != NULL) { + memset(result, 0, totalBytes); + } +#ifndef WTF_CHANGES + MallocHook::InvokeNewHook(result, totalBytes); +#endif + return result; +} + +#ifndef WTF_CHANGES +extern "C" +#endif +void cfree(void* ptr) { +#ifndef WTF_CHANGES + MallocHook::InvokeDeleteHook(ptr); +#endif + do_free(ptr); +} + +#ifndef WTF_CHANGES +extern "C" +#endif +void* realloc(void* old_ptr, size_t new_size) { + if (old_ptr == NULL) { + void* result = do_malloc(new_size); +#ifndef WTF_CHANGES + MallocHook::InvokeNewHook(result, new_size); +#endif + return result; + } + if (new_size == 0) { +#ifndef WTF_CHANGES + MallocHook::InvokeDeleteHook(old_ptr); +#endif + free(old_ptr); + return NULL; + } + + // Get the size of the old entry + const PageID p = reinterpret_cast(old_ptr) >> kPageShift; + size_t cl = pageheap->GetSizeClassIfCached(p); + Span *span = NULL; + size_t old_size; + if (cl == 0) { + span = pageheap->GetDescriptor(p); + cl = span->sizeclass; + pageheap->CacheSizeClass(p, cl); + } + if (cl != 0) { + old_size = ByteSizeForClass(cl); + } else { + ASSERT(span != NULL); + old_size = span->length << kPageShift; + } + + // Reallocate if the new size is larger than the old size, + // or if the new size is significantly smaller than the old size. + if ((new_size > old_size) || (AllocationSize(new_size) < old_size)) { + // Need to reallocate + void* new_ptr = do_malloc(new_size); + if (new_ptr == NULL) { + return NULL; + } +#ifndef WTF_CHANGES + MallocHook::InvokeNewHook(new_ptr, new_size); +#endif + memcpy(new_ptr, old_ptr, ((old_size < new_size) ? old_size : new_size)); +#ifndef WTF_CHANGES + MallocHook::InvokeDeleteHook(old_ptr); +#endif + // We could use a variant of do_free() that leverages the fact + // that we already know the sizeclass of old_ptr. The benefit + // would be small, so don't bother. + do_free(old_ptr); + return new_ptr; + } else { + return old_ptr; + } +} + +#ifndef WTF_CHANGES + +static SpinLock set_new_handler_lock = SPINLOCK_INITIALIZER; + +static inline void* cpp_alloc(size_t size, bool nothrow) { + for (;;) { + void* p = do_malloc(size); +#ifdef PREANSINEW + return p; +#else + if (p == NULL) { // allocation failed + // Get the current new handler. NB: this function is not + // thread-safe. We make a feeble stab at making it so here, but + // this lock only protects against tcmalloc interfering with + // itself, not with other libraries calling set_new_handler. + std::new_handler nh; + { + SpinLockHolder h(&set_new_handler_lock); + nh = std::set_new_handler(0); + (void) std::set_new_handler(nh); + } + // If no new_handler is established, the allocation failed. + if (!nh) { + if (nothrow) return 0; + throw std::bad_alloc(); + } + // Otherwise, try the new_handler. If it returns, retry the + // allocation. If it throws std::bad_alloc, fail the allocation. + // if it throws something else, don't interfere. + try { + (*nh)(); + } catch (const std::bad_alloc&) { + if (!nothrow) throw; + return p; + } + } else { // allocation success + return p; + } +#endif + } +} + +void* operator new(size_t size) { + void* p = cpp_alloc(size, false); + // We keep this next instruction out of cpp_alloc for a reason: when + // it's in, and new just calls cpp_alloc, the optimizer may fold the + // new call into cpp_alloc, which messes up our whole section-based + // stacktracing (see ATTRIBUTE_SECTION, above). This ensures cpp_alloc + // isn't the last thing this fn calls, and prevents the folding. + MallocHook::InvokeNewHook(p, size); + return p; +} + +void* operator new(size_t size, const std::nothrow_t&) __THROW { + void* p = cpp_alloc(size, true); + MallocHook::InvokeNewHook(p, size); + return p; +} + +void operator delete(void* p) __THROW { + MallocHook::InvokeDeleteHook(p); + do_free(p); +} + +void operator delete(void* p, const std::nothrow_t&) __THROW { + MallocHook::InvokeDeleteHook(p); + do_free(p); +} + +void* operator new[](size_t size) { + void* p = cpp_alloc(size, false); + // We keep this next instruction out of cpp_alloc for a reason: when + // it's in, and new just calls cpp_alloc, the optimizer may fold the + // new call into cpp_alloc, which messes up our whole section-based + // stacktracing (see ATTRIBUTE_SECTION, above). This ensures cpp_alloc + // isn't the last thing this fn calls, and prevents the folding. + MallocHook::InvokeNewHook(p, size); + return p; +} + +void* operator new[](size_t size, const std::nothrow_t&) __THROW { + void* p = cpp_alloc(size, true); + MallocHook::InvokeNewHook(p, size); + return p; +} + +void operator delete[](void* p) __THROW { + MallocHook::InvokeDeleteHook(p); + do_free(p); +} + +void operator delete[](void* p, const std::nothrow_t&) __THROW { + MallocHook::InvokeDeleteHook(p); + do_free(p); +} + +extern "C" void* memalign(size_t align, size_t size) __THROW { + void* result = do_memalign(align, size); + MallocHook::InvokeNewHook(result, size); + return result; +} + +extern "C" int posix_memalign(void** result_ptr, size_t align, size_t size) + __THROW { + if (((align % sizeof(void*)) != 0) || + ((align & (align - 1)) != 0) || + (align == 0)) { + return EINVAL; + } + + void* result = do_memalign(align, size); + MallocHook::InvokeNewHook(result, size); + if (result == NULL) { + return ENOMEM; + } else { + *result_ptr = result; + return 0; + } +} + +static size_t pagesize = 0; + +extern "C" void* valloc(size_t size) __THROW { + // Allocate page-aligned object of length >= size bytes + if (pagesize == 0) pagesize = getpagesize(); + void* result = do_memalign(pagesize, size); + MallocHook::InvokeNewHook(result, size); + return result; +} + +extern "C" void* pvalloc(size_t size) __THROW { + // Round up size to a multiple of pagesize + if (pagesize == 0) pagesize = getpagesize(); + size = (size + pagesize - 1) & ~(pagesize - 1); + void* result = do_memalign(pagesize, size); + MallocHook::InvokeNewHook(result, size); + return result; +} + +extern "C" void malloc_stats(void) { + do_malloc_stats(); +} + +extern "C" int mallopt(int cmd, int value) { + return do_mallopt(cmd, value); +} + +#ifdef HAVE_STRUCT_MALLINFO +extern "C" struct mallinfo mallinfo(void) { + return do_mallinfo(); +} +#endif + +//------------------------------------------------------------------- +// Some library routines on RedHat 9 allocate memory using malloc() +// and free it using __libc_free() (or vice-versa). Since we provide +// our own implementations of malloc/free, we need to make sure that +// the __libc_XXX variants (defined as part of glibc) also point to +// the same implementations. +//------------------------------------------------------------------- + +#if defined(__GLIBC__) +extern "C" { +# if defined(__GNUC__) && !defined(__MACH__) && defined(HAVE___ATTRIBUTE__) + // Potentially faster variants that use the gcc alias extension. + // Mach-O (Darwin) does not support weak aliases, hence the __MACH__ check. +# define ALIAS(x) __attribute__ ((weak, alias (x))) + void* __libc_malloc(size_t size) ALIAS("malloc"); + void __libc_free(void* ptr) ALIAS("free"); + void* __libc_realloc(void* ptr, size_t size) ALIAS("realloc"); + void* __libc_calloc(size_t n, size_t size) ALIAS("calloc"); + void __libc_cfree(void* ptr) ALIAS("cfree"); + void* __libc_memalign(size_t align, size_t s) ALIAS("memalign"); + void* __libc_valloc(size_t size) ALIAS("valloc"); + void* __libc_pvalloc(size_t size) ALIAS("pvalloc"); + int __posix_memalign(void** r, size_t a, size_t s) ALIAS("posix_memalign"); +# undef ALIAS +# else /* not __GNUC__ */ + // Portable wrappers + void* __libc_malloc(size_t size) { return malloc(size); } + void __libc_free(void* ptr) { free(ptr); } + void* __libc_realloc(void* ptr, size_t size) { return realloc(ptr, size); } + void* __libc_calloc(size_t n, size_t size) { return calloc(n, size); } + void __libc_cfree(void* ptr) { cfree(ptr); } + void* __libc_memalign(size_t align, size_t s) { return memalign(align, s); } + void* __libc_valloc(size_t size) { return valloc(size); } + void* __libc_pvalloc(size_t size) { return pvalloc(size); } + int __posix_memalign(void** r, size_t a, size_t s) { + return posix_memalign(r, a, s); + } +# endif /* __GNUC__ */ +} +#endif /* __GLIBC__ */ + +// Override __libc_memalign in libc on linux boxes specially. +// They have a bug in libc that causes them to (very rarely) allocate +// with __libc_memalign() yet deallocate with free() and the +// definitions above don't catch it. +// This function is an exception to the rule of calling MallocHook method +// from the stack frame of the allocation function; +// heap-checker handles this special case explicitly. +static void *MemalignOverride(size_t align, size_t size, const void *caller) + __THROW { + void* result = do_memalign(align, size); + MallocHook::InvokeNewHook(result, size); + return result; +} +void *(*__memalign_hook)(size_t, size_t, const void *) = MemalignOverride; + +#endif + +#if defined(WTF_CHANGES) && PLATFORM(DARWIN) +#include + +class FreeObjectFinder { + const RemoteMemoryReader& m_reader; + HashSet m_freeObjects; + +public: + FreeObjectFinder(const RemoteMemoryReader& reader) : m_reader(reader) { } + + void visit(void* ptr) { m_freeObjects.add(ptr); } + bool isFreeObject(void* ptr) const { return m_freeObjects.contains(ptr); } + size_t freeObjectCount() const { return m_freeObjects.size(); } + + void findFreeObjects(TCMalloc_ThreadCache* threadCache) + { + for (; threadCache; threadCache = (threadCache->next_ ? m_reader(threadCache->next_) : 0)) + threadCache->enumerateFreeObjects(*this, m_reader); + } + + void findFreeObjects(TCMalloc_Central_FreeListPadded* centralFreeList, size_t numSizes) + { + for (unsigned i = 0; i < numSizes; i++) + centralFreeList[i].enumerateFreeObjects(*this, m_reader); + } +}; + +class PageMapFreeObjectFinder { + const RemoteMemoryReader& m_reader; + FreeObjectFinder& m_freeObjectFinder; + +public: + PageMapFreeObjectFinder(const RemoteMemoryReader& reader, FreeObjectFinder& freeObjectFinder) + : m_reader(reader) + , m_freeObjectFinder(freeObjectFinder) + { } + + int visit(void* ptr) const + { + if (!ptr) + return 1; + + Span* span = m_reader(reinterpret_cast(ptr)); + if (span->free) { + void* ptr = reinterpret_cast(span->start << kPageShift); + m_freeObjectFinder.visit(ptr); + } else if (span->sizeclass) { + // Walk the free list of the small-object span, keeping track of each object seen + for (void* nextObject = span->objects; nextObject; nextObject = *m_reader(reinterpret_cast(nextObject))) + m_freeObjectFinder.visit(nextObject); + } + return span->length; + } +}; + +class PageMapMemoryUsageRecorder { + task_t m_task; + void* m_context; + unsigned m_typeMask; + vm_range_recorder_t* m_recorder; + const RemoteMemoryReader& m_reader; + const FreeObjectFinder& m_freeObjectFinder; + mutable HashSet m_seenPointers; + +public: + PageMapMemoryUsageRecorder(task_t task, void* context, unsigned typeMask, vm_range_recorder_t* recorder, const RemoteMemoryReader& reader, const FreeObjectFinder& freeObjectFinder) + : m_task(task) + , m_context(context) + , m_typeMask(typeMask) + , m_recorder(recorder) + , m_reader(reader) + , m_freeObjectFinder(freeObjectFinder) + { } + + int visit(void* ptr) const + { + if (!ptr) + return 1; + + Span* span = m_reader(reinterpret_cast(ptr)); + if (m_seenPointers.contains(ptr)) + return span->length; + m_seenPointers.add(ptr); + + // Mark the memory used for the Span itself as an administrative region + vm_range_t ptrRange = { reinterpret_cast(ptr), sizeof(Span) }; + if (m_typeMask & (MALLOC_PTR_REGION_RANGE_TYPE | MALLOC_ADMIN_REGION_RANGE_TYPE)) + (*m_recorder)(m_task, m_context, MALLOC_ADMIN_REGION_RANGE_TYPE, &ptrRange, 1); + + ptrRange.address = span->start << kPageShift; + ptrRange.size = span->length * kPageSize; + + // Mark the memory region the span represents as candidates for containing pointers + if (m_typeMask & (MALLOC_PTR_REGION_RANGE_TYPE | MALLOC_ADMIN_REGION_RANGE_TYPE)) + (*m_recorder)(m_task, m_context, MALLOC_PTR_REGION_RANGE_TYPE, &ptrRange, 1); + + if (!span->free && (m_typeMask & MALLOC_PTR_IN_USE_RANGE_TYPE)) { + // If it's an allocated large object span, mark it as in use + if (span->sizeclass == 0 && !m_freeObjectFinder.isFreeObject(reinterpret_cast(ptrRange.address))) + (*m_recorder)(m_task, m_context, MALLOC_PTR_IN_USE_RANGE_TYPE, &ptrRange, 1); + else if (span->sizeclass) { + const size_t byteSize = ByteSizeForClass(span->sizeclass); + unsigned totalObjects = (span->length << kPageShift) / byteSize; + ASSERT(span->refcount <= totalObjects); + char* ptr = reinterpret_cast(span->start << kPageShift); + + // Mark each allocated small object within the span as in use + for (unsigned i = 0; i < totalObjects; i++) { + char* thisObject = ptr + (i * byteSize); + if (m_freeObjectFinder.isFreeObject(thisObject)) + continue; + + vm_range_t objectRange = { reinterpret_cast(thisObject), byteSize }; + (*m_recorder)(m_task, m_context, MALLOC_PTR_IN_USE_RANGE_TYPE, &objectRange, 1); + } + } + } + + return span->length; + } +}; + +kern_return_t FastMallocZone::enumerate(task_t task, void* context, unsigned typeMask, vm_address_t zoneAddress, memory_reader_t reader, vm_range_recorder_t recorder) +{ + RemoteMemoryReader memoryReader(task, reader); + + InitSizeClasses(); + + FastMallocZone* mzone = memoryReader(reinterpret_cast(zoneAddress)); + TCMalloc_PageHeap* pageHeap = memoryReader(mzone->m_pageHeap); + TCMalloc_ThreadCache** threadHeapsPointer = memoryReader(mzone->m_threadHeaps); + TCMalloc_ThreadCache* threadHeaps = memoryReader(*threadHeapsPointer); + + TCMalloc_Central_FreeListPadded* centralCaches = memoryReader(mzone->m_centralCaches, sizeof(TCMalloc_Central_FreeListPadded) * kNumClasses); + + FreeObjectFinder finder(memoryReader); + finder.findFreeObjects(threadHeaps); + finder.findFreeObjects(centralCaches, kNumClasses); + + TCMalloc_PageHeap::PageMap* pageMap = &pageHeap->pagemap_; + PageMapFreeObjectFinder pageMapFinder(memoryReader, finder); + pageMap->visit(pageMapFinder, memoryReader); + + PageMapMemoryUsageRecorder usageRecorder(task, context, typeMask, recorder, memoryReader, finder); + pageMap->visit(usageRecorder, memoryReader); + + return 0; +} + +size_t FastMallocZone::size(malloc_zone_t*, const void*) +{ + return 0; +} + +void* FastMallocZone::zoneMalloc(malloc_zone_t*, size_t) +{ + return 0; +} + +void* FastMallocZone::zoneCalloc(malloc_zone_t*, size_t, size_t) +{ + return 0; +} + +void FastMallocZone::zoneFree(malloc_zone_t*, void* ptr) +{ + // Due to zoneFree may be called by the system free even if the pointer + // is not in this zone. When this happens, the pointer being freed was not allocated by any + // zone so we need to print a useful error for the application developer. + malloc_printf("*** error for object %p: pointer being freed was not allocated\n", ptr); +} + +void* FastMallocZone::zoneRealloc(malloc_zone_t*, void*, size_t) +{ + return 0; +} + + +#undef malloc +#undef free +#undef realloc +#undef calloc + +extern "C" { +malloc_introspection_t jscore_fastmalloc_introspection = { &FastMallocZone::enumerate, &FastMallocZone::goodSize, &FastMallocZone::check, &FastMallocZone::print, + &FastMallocZone::log, &FastMallocZone::forceLock, &FastMallocZone::forceUnlock, &FastMallocZone::statistics }; +} + +FastMallocZone::FastMallocZone(TCMalloc_PageHeap* pageHeap, TCMalloc_ThreadCache** threadHeaps, TCMalloc_Central_FreeListPadded* centralCaches) + : m_pageHeap(pageHeap) + , m_threadHeaps(threadHeaps) + , m_centralCaches(centralCaches) +{ + memset(&m_zone, 0, sizeof(m_zone)); + m_zone.zone_name = "JavaScriptCore FastMalloc"; + m_zone.size = &FastMallocZone::size; + m_zone.malloc = &FastMallocZone::zoneMalloc; + m_zone.calloc = &FastMallocZone::zoneCalloc; + m_zone.realloc = &FastMallocZone::zoneRealloc; + m_zone.free = &FastMallocZone::zoneFree; + m_zone.valloc = &FastMallocZone::zoneValloc; + m_zone.destroy = &FastMallocZone::zoneDestroy; + m_zone.introspect = &jscore_fastmalloc_introspection; + malloc_zone_register(&m_zone); +} + + +void FastMallocZone::init() +{ + static FastMallocZone zone(pageheap, &thread_heaps, static_cast(central_cache)); +} + +extern "C" { +void releaseFastMallocFreeMemory() +{ + SpinLockHolder h(&pageheap_lock); + pageheap->ReleaseFreePages(); +} +} + +#endif + +#if WTF_CHANGES +} // namespace WTF +#endif + +#endif // USE_SYSTEM_MALLOC diff --git a/wtf/FastMalloc.h b/wtf/FastMalloc.h new file mode 100644 index 0000000..ecce312 --- /dev/null +++ b/wtf/FastMalloc.h @@ -0,0 +1,81 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2005 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_FastMalloc_h +#define WTF_FastMalloc_h + +#include "Platform.h" +#include +#include + +namespace WTF { + + void *fastMalloc(size_t n); + void *fastZeroedMalloc(size_t n); + void *fastCalloc(size_t n_elements, size_t element_size); + void fastFree(void* p); + void *fastRealloc(void* p, size_t n); + +#ifndef NDEBUG + void fastMallocForbid(); + void fastMallocAllow(); +#endif + +} // namespace WTF + +using WTF::fastMalloc; +using WTF::fastZeroedMalloc; +using WTF::fastCalloc; +using WTF::fastRealloc; +using WTF::fastFree; + +#ifndef NDEBUG +using WTF::fastMallocForbid; +using WTF::fastMallocAllow; +#endif + +#if COMPILER(GCC) && PLATFORM(DARWIN) +#define WTF_PRIVATE_INLINE __private_extern__ inline __attribute__((always_inline)) +#elif COMPILER(GCC) +#define WTF_PRIVATE_INLINE inline __attribute__((always_inline)) +#elif COMPILER(MSVC) +#define WTF_PRIVATE_INLINE __forceinline +#else +#define WTF_PRIVATE_INLINE inline +#endif + +#ifndef _CRTDBG_MAP_ALLOC + +#if !defined(USE_SYSTEM_MALLOC) || !(USE_SYSTEM_MALLOC) +WTF_PRIVATE_INLINE void* operator new(size_t s) { return fastMalloc(s); } +WTF_PRIVATE_INLINE void operator delete(void* p) { fastFree(p); } +WTF_PRIVATE_INLINE void* operator new[](size_t s) { return fastMalloc(s); } +WTF_PRIVATE_INLINE void operator delete[](void* p) { fastFree(p); } + +extern "C" { +void releaseFastMallocFreeMemory(); +} +#endif + +#endif // _CRTDBG_MAP_ALLOC + +#endif /* WTF_FastMalloc_h */ diff --git a/wtf/Forward.h b/wtf/Forward.h new file mode 100644 index 0000000..67dc3be --- /dev/null +++ b/wtf/Forward.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_Forward_h +#define WTF_Forward_h + +#include + +namespace WTF { + template class ListRefPtr; + template class OwnArrayPtr; + template class OwnPtr; + template class PassRefPtr; + template class RefPtr; + template class Vector; +} + +using WTF::ListRefPtr; +using WTF::OwnArrayPtr; +using WTF::OwnPtr; +using WTF::PassRefPtr; +using WTF::RefPtr; +using WTF::Vector; + +#endif // WTF_Forward_h + diff --git a/wtf/GetPtr.h b/wtf/GetPtr.h new file mode 100644 index 0000000..25a0e6d --- /dev/null +++ b/wtf/GetPtr.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_GetPtr_h +#define WTF_GetPtr_h + +namespace WTF { + + template inline T* getPtr(T* p) + { + return p; + } + +} // namespace WTF + +#endif // WTF_GetPtr_h diff --git a/wtf/HashCountedSet.h b/wtf/HashCountedSet.h new file mode 100644 index 0000000..202577a --- /dev/null +++ b/wtf/HashCountedSet.h @@ -0,0 +1,178 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2005 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_HashCountedSet_h +#define WTF_HashCountedSet_h + +#include "Assertions.h" +#include "HashMap.h" + +namespace WTF { + + template::Hash, + typename Traits = HashTraits > class HashCountedSet { + private: + typedef HashMap ImplType; + public: + typedef Value ValueType; + typedef typename ImplType::iterator iterator; + typedef typename ImplType::const_iterator const_iterator; + + HashCountedSet() {} + + int size() const; + int capacity() const; + bool isEmpty() const; + + // iterators iterate over pairs of values and counts + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + + iterator find(const ValueType& value); + const_iterator find(const ValueType& value) const; + bool contains(const ValueType& value) const; + unsigned count(const ValueType& value) const; + + // increases the count if an equal value is already present + // the return value is a pair of an interator to the new value's location, + // and a bool that is true if an new entry was added + std::pair add(const ValueType &value); + + // reduces the count of the value, and removes it if count + // goes down to zero + void remove(const ValueType& value); + void remove(iterator it); + + void clear(); + + private: + ImplType m_impl; + }; + + template + inline int HashCountedSet::size() const + { + return m_impl.size(); + } + + template + inline int HashCountedSet::capacity() const + { + return m_impl.capacity(); + } + + template + inline bool HashCountedSet::isEmpty() const + { + return size() == 0; + } + + template + inline typename HashCountedSet::iterator HashCountedSet::begin() + { + return m_impl.begin(); + } + + template + inline typename HashCountedSet::iterator HashCountedSet::end() + { + return m_impl.end(); + } + + template + inline typename HashCountedSet::const_iterator HashCountedSet::begin() const + { + return m_impl.begin(); + } + + template + inline typename HashCountedSet::const_iterator HashCountedSet::end() const + { + return m_impl.end(); + } + + template + inline typename HashCountedSet::iterator HashCountedSet::find(const ValueType& value) + { + return m_impl.find(value); + } + + template + inline typename HashCountedSet::const_iterator HashCountedSet::find(const ValueType& value) const + { + return m_impl.find(value); + } + + template + inline bool HashCountedSet::contains(const ValueType& value) const + { + return m_impl.contains(value); + } + + template + inline unsigned HashCountedSet::count(const ValueType& value) const + { + return m_impl.get(value); + } + + template + inline std::pair::iterator, bool> HashCountedSet::add(const ValueType &value) + { + pair result = m_impl.add(value, 0); + ++result.first->second; + return result; + } + + template + inline void HashCountedSet::remove(const ValueType& value) + { + remove(find(value)); + } + + template + inline void HashCountedSet::remove(iterator it) + { + if (it == end()) + return; + + unsigned oldVal = it->second; + ASSERT(oldVal != 0); + unsigned newVal = oldVal - 1; + if (newVal == 0) + m_impl.remove(it); + else + it->second = newVal; + } + + template + inline void HashCountedSet::clear() + { + m_impl.clear(); + } + +} // namespace khtml + +using WTF::HashCountedSet; + +#endif /* WTF_HashCountedSet_h */ diff --git a/wtf/HashFunctions.h b/wtf/HashFunctions.h new file mode 100644 index 0000000..bf85dc0 --- /dev/null +++ b/wtf/HashFunctions.h @@ -0,0 +1,127 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2005, 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_HashFunctions_h +#define WTF_HashFunctions_h + +#include "RefPtr.h" +#include + +namespace WTF { + + template struct IntTypes; + template<> struct IntTypes<1> { typedef int8_t SignedType; typedef uint8_t UnsignedType; }; + template<> struct IntTypes<2> { typedef int16_t SignedType; typedef uint16_t UnsignedType; }; + template<> struct IntTypes<4> { typedef int32_t SignedType; typedef uint32_t UnsignedType; }; + template<> struct IntTypes<8> { typedef int64_t SignedType; typedef uint64_t UnsignedType; }; + + // integer hash function + + // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm + inline unsigned intHash(uint32_t key) + { + key += ~(key << 15); + key ^= (key >> 10); + key += (key << 3); + key ^= (key >> 6); + key += ~(key << 11); + key ^= (key >> 16); + return key; + } + + // Thomas Wang's 64 bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm + inline unsigned intHash(uint64_t key) + { + key += ~(key << 32); + key ^= (key >> 22); + key += ~(key << 13); + key ^= (key >> 8); + key += (key << 3); + key ^= (key >> 15); + key += ~(key << 27); + key ^= (key >> 31); + return static_cast(key); + } + + template struct IntHash { + static unsigned hash(T key) { return intHash(static_cast::UnsignedType>(key)); } + static bool equal(T a, T b) { return a == b; } + static const bool safeToCompareToEmptyOrDeleted = true; + }; + + template struct FloatHash { + static unsigned hash(T key) { return intHash(*reinterpret_cast::UnsignedType*>(&key)); } + static bool equal(T a, T b) { return a == b; } + static const bool safeToCompareToEmptyOrDeleted = true; + }; + + // pointer identity hash function + + template struct PtrHash { + static unsigned hash(T key) + { +#if COMPILER(MSVC) +#pragma warning(push) +#pragma warning(disable: 4244) // work around what seems to be a bug in MSVC's conversion warnings +#endif + return IntHash::hash(reinterpret_cast(key)); +#if COMPILER(MSVC) +#pragma warning(pop) +#endif + } + static bool equal(T a, T b) { return a == b; } + static const bool safeToCompareToEmptyOrDeleted = true; + }; + template struct PtrHash > { + static unsigned hash(const RefPtr

& key) { return PtrHash::hash(key.get()); } + static bool equal(const RefPtr

& a, const RefPtr

& b) { return a == b; } + static const bool safeToCompareToEmptyOrDeleted = true; + }; + + // default hash function for each type + + template struct DefaultHash; + + // make IntHash the default hash function for many integer types + + template<> struct DefaultHash { typedef IntHash Hash; }; + template<> struct DefaultHash { typedef IntHash Hash; }; + template<> struct DefaultHash { typedef IntHash Hash; }; + template<> struct DefaultHash { typedef IntHash Hash; }; + template<> struct DefaultHash { typedef IntHash Hash; }; + template<> struct DefaultHash { typedef IntHash Hash; }; + + template<> struct DefaultHash { typedef FloatHash Hash; }; + template<> struct DefaultHash { typedef FloatHash Hash; }; + + // make PtrHash the default hash function for pointer types that don't specialize + + template struct DefaultHash { typedef PtrHash Hash; }; + template struct DefaultHash > { typedef PtrHash > Hash; }; + +} // namespace WTF + +using WTF::DefaultHash; +using WTF::IntHash; +using WTF::PtrHash; + +#endif // WTF_HashFunctions_h diff --git a/wtf/HashIterators.h b/wtf/HashIterators.h new file mode 100644 index 0000000..c449112 --- /dev/null +++ b/wtf/HashIterators.h @@ -0,0 +1,217 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_HashIterators_h +#define WTF_HashIterators_h + +namespace WTF { + + template struct HashTableConstKeysIterator; + template struct HashTableConstValuesIterator; + template struct HashTableKeysIterator; + template struct HashTableValuesIterator; + + template struct HashTableConstIteratorAdapter > { + private: + typedef std::pair ValueType; + public: + typedef HashTableConstKeysIterator Keys; + typedef HashTableConstValuesIterator Values; + + HashTableConstIteratorAdapter(const typename HashTableType::const_iterator& impl) : m_impl(impl) {} + + const ValueType* get() const { return (const ValueType*)m_impl.get(); } + const ValueType& operator*() const { return *get(); } + const ValueType* operator->() const { return get(); } + + HashTableConstIteratorAdapter& operator++() { ++m_impl; return *this; } + // postfix ++ intentionally omitted + + Keys keys() { return Keys(*this); } + Values values() { return Values(*this); } + + typename HashTableType::const_iterator m_impl; + }; + + template struct HashTableIteratorAdapter > { + private: + typedef std::pair ValueType; + public: + typedef HashTableKeysIterator Keys; + typedef HashTableValuesIterator Values; + + HashTableIteratorAdapter(const typename HashTableType::iterator& impl) : m_impl(impl) {} + + ValueType* get() const { return (ValueType*)m_impl.get(); } + ValueType& operator*() const { return *get(); } + ValueType* operator->() const { return get(); } + + HashTableIteratorAdapter& operator++() { ++m_impl; return *this; } + // postfix ++ intentionally omitted + + operator HashTableConstIteratorAdapter() { + typename HashTableType::const_iterator i = m_impl; + return i; + } + + Keys keys() { return Keys(*this); } + Values values() { return Values(*this); } + + typename HashTableType::iterator m_impl; + }; + + template struct HashTableConstKeysIterator { + private: + typedef HashTableConstIteratorAdapter > ConstIterator; + + public: + HashTableConstKeysIterator(const ConstIterator& impl) : m_impl(impl) {} + + const KeyType* get() const { return &(m_impl.get()->first); } + const KeyType& operator*() const { return *get(); } + const KeyType* operator->() const { return get(); } + + HashTableConstKeysIterator& operator++() { ++m_impl; return *this; } + // postfix ++ intentionally omitted + + ConstIterator m_impl; + }; + + template struct HashTableConstValuesIterator { + private: + typedef HashTableConstIteratorAdapter > ConstIterator; + + public: + HashTableConstValuesIterator(const ConstIterator& impl) : m_impl(impl) {} + + const MappedType* get() const { return &(m_impl.get()->second); } + const MappedType& operator*() const { return *get(); } + const MappedType* operator->() const { return get(); } + + HashTableConstValuesIterator& operator++() { ++m_impl; return *this; } + // postfix ++ intentionally omitted + + ConstIterator m_impl; + }; + + template struct HashTableKeysIterator { + private: + typedef HashTableIteratorAdapter > Iterator; + typedef HashTableConstIteratorAdapter > ConstIterator; + + public: + HashTableKeysIterator(const Iterator& impl) : m_impl(impl) {} + + KeyType* get() const { return &(m_impl.get()->first); } + KeyType& operator*() const { return *get(); } + KeyType* operator->() const { return get(); } + + HashTableKeysIterator& operator++() { ++m_impl; return *this; } + // postfix ++ intentionally omitted + + operator HashTableConstKeysIterator() { + ConstIterator i = m_impl; + return i; + } + + Iterator m_impl; + }; + + template struct HashTableValuesIterator { + private: + typedef HashTableIteratorAdapter > Iterator; + typedef HashTableConstIteratorAdapter > ConstIterator; + + public: + HashTableValuesIterator(const Iterator& impl) : m_impl(impl) {} + + MappedType* get() const { return &(m_impl.get()->second); } + MappedType& operator*() const { return *get(); } + MappedType* operator->() const { return get(); } + + HashTableValuesIterator& operator++() { ++m_impl; return *this; } + // postfix ++ intentionally omitted + + operator HashTableConstValuesIterator() { + ConstIterator i = m_impl; + return i; + } + + Iterator m_impl; + }; + + template + inline bool operator==(const HashTableConstKeysIterator& a, const HashTableConstKeysIterator& b) + { + return a.m_impl == b.m_impl; + } + + template + inline bool operator!=(const HashTableConstKeysIterator& a, const HashTableConstKeysIterator& b) + { + return a.m_impl != b.m_impl; + } + + template + inline bool operator==(const HashTableConstValuesIterator& a, const HashTableConstValuesIterator& b) + { + return a.m_impl == b.m_impl; + } + + template + inline bool operator!=(const HashTableConstValuesIterator& a, const HashTableConstValuesIterator& b) + { + return a.m_impl != b.m_impl; + } + + template + inline bool operator==(const HashTableKeysIterator& a, const HashTableKeysIterator& b) + { + return a.m_impl == b.m_impl; + } + + template + inline bool operator!=(const HashTableKeysIterator& a, const HashTableKeysIterator& b) + { + return a.m_impl != b.m_impl; + } + + template + inline bool operator==(const HashTableValuesIterator& a, const HashTableValuesIterator& b) + { + return a.m_impl == b.m_impl; + } + + template + inline bool operator!=(const HashTableValuesIterator& a, const HashTableValuesIterator& b) + { + return a.m_impl != b.m_impl; + } + + +} // namespace WTF + +#endif // WTF_HashIterators_h diff --git a/wtf/HashMap.h b/wtf/HashMap.h new file mode 100644 index 0000000..66d49d7 --- /dev/null +++ b/wtf/HashMap.h @@ -0,0 +1,427 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_HashMap_h +#define WTF_HashMap_h + +#include "HashTable.h" + +namespace WTF { + + template struct PairFirstExtractor; + + template::Hash, + typename KeyTraitsArg = HashTraits, typename MappedTraitsArg = HashTraits > + class HashMap { + private: + typedef KeyTraitsArg KeyTraits; + typedef MappedTraitsArg MappedTraits; + typedef PairBaseHashTraits ValueTraits; + + public: + typedef typename KeyTraits::TraitType KeyType; + typedef typename MappedTraits::TraitType MappedType; + typedef typename ValueTraits::TraitType ValueType; + + private: + typedef HashArg HashFunctions; + + typedef typename HashKeyStorageTraits::Hash StorageHashFunctions; + + typedef typename HashKeyStorageTraits::Traits KeyStorageTraits; + typedef typename MappedTraits::StorageTraits MappedStorageTraits; + typedef PairHashTraits ValueStorageTraits; + + typedef typename KeyStorageTraits::TraitType KeyStorageType; + typedef typename MappedStorageTraits::TraitType MappedStorageType; + typedef typename ValueStorageTraits::TraitType ValueStorageType; + + typedef HashTable, + StorageHashFunctions, ValueStorageTraits, KeyStorageTraits> HashTableType; + + public: + typedef HashTableIteratorAdapter iterator; + typedef HashTableConstIteratorAdapter const_iterator; + + HashMap(); + HashMap(const HashMap&); + HashMap& operator=(const HashMap&); + ~HashMap(); + + void swap(HashMap&); + + int size() const; + int capacity() const; + bool isEmpty() const; + + // iterators iterate over pairs of keys and values + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + + iterator find(const KeyType&); + const_iterator find(const KeyType&) const; + bool contains(const KeyType&) const; + MappedType get(const KeyType&) const; + + // replaces value but not key if key is already present + // return value is a pair of the iterator to the key location, + // and a boolean that's true if a new value was actually added + pair set(const KeyType&, const MappedType&); + + // does nothing if key is already present + // return value is a pair of the iterator to the key location, + // and a boolean that's true if a new value was actually added + pair add(const KeyType&, const MappedType&); + + void remove(const KeyType&); + void remove(iterator); + void clear(); + + MappedType take(const KeyType&); // efficient combination of get with remove + + private: + pair inlineAdd(const KeyType&, const MappedType&); + void refAll(); + void derefAll(); + + HashTableType m_impl; + }; + + template struct PairFirstExtractor { + static const typename PairType::first_type& extract(const PairType& p) { return p.first; } + }; + + template + struct HashMapTranslator; + + template + struct HashMapTranslator { + typedef typename ValueType::first_type KeyType; + typedef typename ValueType::second_type MappedType; + typedef typename ValueStorageTraits::TraitType ValueStorageType; + typedef typename ValueStorageTraits::FirstTraits KeyStorageTraits; + typedef typename KeyStorageTraits::TraitType KeyStorageType; + typedef typename ValueStorageTraits::SecondTraits MappedStorageTraits; + typedef typename MappedStorageTraits::TraitType MappedStorageType; + typedef typename ValueTraits::FirstTraits KeyTraits; + typedef typename ValueTraits::SecondTraits MappedTraits; + + static unsigned hash(const KeyType& key) { return HashFunctions::hash(key); } + static bool equal(const KeyStorageType& a, const KeyType& b) { return HashFunctions::equal(*(KeyType*)&a, b); } + static void translate(ValueStorageType& location, const KeyType& key, const MappedType& mapped) + { + Assigner::assign(key, location.first); + Assigner::assign(mapped, location.second); + } + }; + + template + struct HashMapTranslator { + typedef typename ValueType::first_type KeyType; + typedef typename ValueType::second_type MappedType; + typedef typename ValueStorageTraits::TraitType ValueStorageType; + typedef typename ValueStorageTraits::FirstTraits KeyStorageTraits; + typedef typename KeyStorageTraits::TraitType KeyStorageType; + typedef typename ValueStorageTraits::SecondTraits MappedStorageTraits; + typedef typename MappedStorageTraits::TraitType MappedStorageType; + typedef typename ValueTraits::FirstTraits KeyTraits; + typedef typename ValueTraits::SecondTraits MappedTraits; + + static unsigned hash(const KeyType& key) { return HashFunctions::hash(key); } + static bool equal(const KeyStorageType& a, const KeyType& b) { return HashFunctions::equal(*(KeyType*)&a, b); } + static void translate(ValueStorageType& location, const KeyType& key, const MappedType& mapped) + { + if (location.first == KeyStorageTraits::deletedValue()) + location.first = KeyStorageTraits::emptyValue(); + Assigner::assign(key, location.first); + Assigner::assign(mapped, location.second); + } + }; + + template + inline void HashMap::refAll() + { + HashTableRefCounter::refAll(m_impl); + } + + template + inline void HashMap::derefAll() + { + HashTableRefCounter::derefAll(m_impl); + } + + template + inline HashMap::HashMap() + { + } + + template + inline HashMap::HashMap(const HashMap& other) + : m_impl(other.m_impl) + { + refAll(); + } + + template + inline HashMap& HashMap::operator=(const HashMap& other) + { + HashMap tmp(other); + swap(tmp); + return *this; + } + + template + inline void HashMap::swap(HashMap& other) + { + m_impl.swap(other.m_impl); + } + + template + inline HashMap::~HashMap() + { + derefAll(); + } + + template + inline int HashMap::size() const + { + return m_impl.size(); + } + + template + inline int HashMap::capacity() const + { + return m_impl.capacity(); + } + + template + inline bool HashMap::isEmpty() const + { + return m_impl.isEmpty(); + } + + template + inline typename HashMap::iterator HashMap::begin() + { + return m_impl.begin(); + } + + template + inline typename HashMap::iterator HashMap::end() + { + return m_impl.end(); + } + + template + inline typename HashMap::const_iterator HashMap::begin() const + { + return m_impl.begin(); + } + + template + inline typename HashMap::const_iterator HashMap::end() const + { + return m_impl.end(); + } + + template + inline typename HashMap::iterator HashMap::find(const KeyType& key) + { + return m_impl.find(*(const KeyStorageType*)&key); + } + + template + inline typename HashMap::const_iterator HashMap::find(const KeyType& key) const + { + return m_impl.find(*(const KeyStorageType*)&key); + } + + template + inline bool HashMap::contains(const KeyType& key) const + { + return m_impl.contains(*(const KeyStorageType*)&key); + } + + template + inline pair::iterator, bool> + HashMap::inlineAdd(const KeyType& key, const MappedType& mapped) + { + const bool canReplaceDeletedKey = !KeyTraits::needsDestruction || KeyStorageTraits::needsDestruction; + typedef HashMapTranslator TranslatorType; + return m_impl.template add(key, mapped); + } + + template + pair::iterator, bool> + HashMap::set(const KeyType& key, const MappedType& mapped) + { + pair result = inlineAdd(key, mapped); + if (!result.second) + // add call above didn't change anything, so set the mapped value + result.first->second = mapped; + return result; + } + + template + pair::iterator, bool> + HashMap::add(const KeyType& key, const MappedType& mapped) + { + return inlineAdd(key, mapped); + } + + template + typename HashMap::MappedType + HashMap::get(const KeyType& key) const + { + if (m_impl.isEmpty()) + return MappedTraits::emptyValue(); + ValueStorageType* entry = const_cast(m_impl).lookup(*(const KeyStorageType*)&key); + if (!entry) + return MappedTraits::emptyValue(); + return ((ValueType *)entry)->second; + } + + template + inline void HashMap::remove(iterator it) + { + if (it.m_impl == m_impl.end()) + return; + m_impl.checkTableConsistency(); + RefCounter::deref(*it.m_impl); + m_impl.removeWithoutEntryConsistencyCheck(it.m_impl); + } + + template + inline void HashMap::remove(const KeyType& key) + { + remove(find(key)); + } + + template + inline void HashMap::clear() + { + derefAll(); + m_impl.clear(); + } + + template + typename HashMap::MappedType + HashMap::take(const KeyType& key) + { + // This can probably be made more efficient to avoid ref/deref churn. + iterator it = find(key); + if (it == end()) + return MappedTraits::emptyValue(); + typename HashMap::MappedType result = it->second; + remove(it); + return result; + } + + template + bool operator==(const HashMap& a, const HashMap& b) + { + if (a.size() != b.size()) + return false; + + typedef typename HashMap::const_iterator const_iterator; + + const_iterator end = a.end(); + const_iterator notFound = b.end(); + for (const_iterator it = a.begin(); it != end; ++it) { + const_iterator bPos = b.find(it->first); + if (bPos == notFound || it->second != bPos->second) + return false; + } + + return true; + } + + template + inline bool operator!=(const HashMap& a, const HashMap& b) + { + return !(a == b); + } + + template + void deleteAllPairSeconds(HashTableType& collection) + { + typedef typename HashTableType::const_iterator iterator; + iterator end = collection.end(); + for (iterator it = collection.begin(); it != end; ++it) + delete *(MappedType*)&it->second; + } + + template + inline void deleteAllValues(const HashMap& collection) + { + deleteAllPairSeconds::MappedType>(collection); + } + + template + void deleteAllPairFirsts(HashTableType& collection) + { + typedef typename HashTableType::const_iterator iterator; + iterator end = collection.end(); + for (iterator it = collection.begin(); it != end; ++it) + delete *(KeyType*)&it->first; + } + + template + inline void deleteAllKeys(const HashMap& collection) + { + deleteAllPairFirsts::KeyType>(collection); + } + + template + inline void copyKeysToVector(const HashMap& collection, Y& vector) + { + typedef typename HashMap::const_iterator::Keys iterator; + + vector.resize(collection.size()); + + iterator it = collection.begin().keys(); + iterator end = collection.end().keys(); + for (unsigned i = 0; it != end; ++it, ++i) + vector[i] = *it; + } + + template + inline void copyValuesToVector(const HashMap& collection, Y& vector) + { + typedef typename HashMap::const_iterator::Values iterator; + + vector.resize(collection.size()); + + iterator it = collection.begin().values(); + iterator end = collection.end().values(); + for (unsigned i = 0; it != end; ++it, ++i) + vector[i] = *it; + } + +} // namespace WTF + +using WTF::HashMap; + +#include "RefPtrHashMap.h" + +#endif /* WTF_HashMap_h */ diff --git a/wtf/HashSet.h b/wtf/HashSet.h new file mode 100644 index 0000000..f690956 --- /dev/null +++ b/wtf/HashSet.h @@ -0,0 +1,334 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_HashSet_h +#define WTF_HashSet_h + +#include "HashTable.h" + +namespace WTF { + + template struct IdentityExtractor; + + template class HashSet; + template + void deleteAllValues(const HashSet&); + + template::Hash, + typename TraitsArg = HashTraits > class HashSet { + private: + typedef HashArg HashFunctions; + typedef TraitsArg ValueTraits; + + typedef typename HashKeyStorageTraits::Hash StorageHashFunctions; + + typedef typename HashKeyStorageTraits::Traits StorageTraits; + typedef typename StorageTraits::TraitType StorageType; + + typedef HashTable, + StorageHashFunctions, StorageTraits, StorageTraits> HashTableType; + + public: + typedef typename ValueTraits::TraitType ValueType; + typedef HashTableIteratorAdapter iterator; + typedef HashTableConstIteratorAdapter const_iterator; + + HashSet(); + HashSet(const HashSet&); + HashSet& operator=(const HashSet&); + ~HashSet(); + + void swap(HashSet&); + + int size() const; + int capacity() const; + bool isEmpty() const; + + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + + iterator find(const ValueType&); + const_iterator find(const ValueType&) const; + bool contains(const ValueType&) const; + + // the return value is a pair of an interator to the new value's location, + // and a bool that is true if an new entry was added + pair add(const ValueType&); + + // a special version of add() that finds the object by hashing and comparing + // with some other type, to avoid the cost of type conversion if the object is already + // in the table. HashTranslator should have the following methods: + // static unsigned hash(const T&); + // static bool equal(const ValueType&, const T&); + // static translate(ValueType&, const T&, unsigned hashCode); + template pair add(const T&); + + void remove(const ValueType&); + void remove(iterator); + void clear(); + + private: + void refAll(); + void derefAll(); + + friend void deleteAllValues<>(const HashSet&); + + HashTableType m_impl; + }; + + template struct IdentityExtractor { + static const T& extract(const T& t) { return t; } + }; + + template + struct HashSetTranslator; + + template + struct HashSetTranslator { + typedef typename StorageTraits::TraitType StorageType; + static unsigned hash(const ValueType& key) { return HashFunctions::hash(key); } + static bool equal(const StorageType& a, const ValueType& b) { return HashFunctions::equal(*(const ValueType*)&a, b); } + static void translate(StorageType& location, const ValueType& key, const ValueType&) + { + Assigner::assign(key, location); + } + }; + + template + struct HashSetTranslator { + typedef typename StorageTraits::TraitType StorageType; + static unsigned hash(const ValueType& key) { return HashFunctions::hash(key); } + static bool equal(const StorageType& a, const ValueType& b) { return HashFunctions::equal(*(const ValueType*)&a, b); } + static void translate(StorageType& location, const ValueType& key, const ValueType&) + { + if (location == StorageTraits::deletedValue()) + location = StorageTraits::emptyValue(); + Assigner::assign(key, location); + } + }; + + template + struct HashSetTranslatorAdapter; + + template + struct HashSetTranslatorAdapter { + typedef typename StorageTraits::TraitType StorageType; + static unsigned hash(const T& key) { return Translator::hash(key); } + static bool equal(const StorageType& a, const T& b) { return Translator::equal(*(const ValueType*)&a, b); } + static void translate(StorageType& location, const T& key, const T&, unsigned hashCode) + { + Translator::translate(*(ValueType*)&location, key, hashCode); + } + }; + + template + struct HashSetTranslatorAdapter { + typedef typename StorageTraits::TraitType StorageType; + static unsigned hash(const T& key) { return Translator::hash(key); } + static bool equal(const StorageType& a, const T& b) { return Translator::equal(*(const ValueType*)&a, b); } + static void translate(StorageType& location, const T& key, const T&, unsigned hashCode) + { + if (location == StorageTraits::deletedValue()) + location = StorageTraits::emptyValue(); + Translator::translate(*(ValueType*)&location, key, hashCode); + } + }; + + template + inline void HashSet::refAll() + { + HashTableRefCounter::refAll(m_impl); + } + + template + inline void HashSet::derefAll() + { + HashTableRefCounter::derefAll(m_impl); + } + + template + inline HashSet::HashSet() + { + } + + template + inline HashSet::HashSet(const HashSet& other) + : m_impl(other.m_impl) + { + refAll(); + } + + template + inline HashSet& HashSet::operator=(const HashSet& other) + { + HashSet tmp(other); + swap(tmp); + return *this; + } + + template + inline void HashSet::swap(HashSet& other) + { + m_impl.swap(other.m_impl); + } + + template + inline HashSet::~HashSet() + { + derefAll(); + } + + template + inline int HashSet::size() const + { + return m_impl.size(); + } + + template + inline int HashSet::capacity() const + { + return m_impl.capacity(); + } + + template + inline bool HashSet::isEmpty() const + { + return m_impl.isEmpty(); + } + + template + inline typename HashSet::iterator HashSet::begin() + { + return m_impl.begin(); + } + + template + inline typename HashSet::iterator HashSet::end() + { + return m_impl.end(); + } + + template + inline typename HashSet::const_iterator HashSet::begin() const + { + return m_impl.begin(); + } + + template + inline typename HashSet::const_iterator HashSet::end() const + { + return m_impl.end(); + } + + template + inline typename HashSet::iterator HashSet::find(const ValueType& value) + { + return m_impl.find(*(const StorageType*)&value); + } + + template + inline typename HashSet::const_iterator HashSet::find(const ValueType& value) const + { + return m_impl.find(*(const StorageType*)&value); + } + + template + inline bool HashSet::contains(const ValueType& value) const + { + return m_impl.contains(*(const StorageType*)&value); + } + + template + pair::iterator, bool> HashSet::add(const ValueType &value) + { + const bool canReplaceDeletedValue = !ValueTraits::needsDestruction || StorageTraits::needsDestruction; + typedef HashSetTranslator Translator; + return m_impl.template add(value, value); + } + + template + template + pair::iterator, bool> + HashSet::add(const T& value) + { + const bool canReplaceDeletedValue = !ValueTraits::needsDestruction || StorageTraits::needsDestruction; + typedef HashSetTranslatorAdapter Adapter; + return m_impl.template addPassingHashCode(value, value); + } + + template + inline void HashSet::remove(iterator it) + { + if (it.m_impl == m_impl.end()) + return; + m_impl.checkTableConsistency(); + RefCounter::deref(*it.m_impl); + m_impl.removeWithoutEntryConsistencyCheck(it.m_impl); + } + + template + inline void HashSet::remove(const ValueType& value) + { + remove(find(value)); + } + + template + inline void HashSet::clear() + { + derefAll(); + m_impl.clear(); + } + + template + void deleteAllValues(HashTableType& collection) + { + typedef typename HashTableType::const_iterator iterator; + iterator end = collection.end(); + for (iterator it = collection.begin(); it != end; ++it) + delete *(ValueType*)&*it; + } + + template + inline void deleteAllValues(const HashSet& collection) + { + deleteAllValues::ValueType>(collection.m_impl); + } + + template + inline void copyToVector(const HashSet& collection, W& vector) + { + typedef typename HashSet::const_iterator iterator; + + vector.resize(collection.size()); + + iterator it = collection.begin(); + iterator end = collection.end(); + for (unsigned i = 0; it != end; ++it, ++i) + vector[i] = *it; + } + +} // namespace WTF + +using WTF::HashSet; + +#endif /* WTF_HashSet_h */ diff --git a/wtf/HashTable.cpp b/wtf/HashTable.cpp new file mode 100644 index 0000000..ba45aee --- /dev/null +++ b/wtf/HashTable.cpp @@ -0,0 +1,62 @@ +/* + This file is part of the KDE libraries + + Copyright (C) 2005 Apple Computer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "HashTable.h" + +namespace WTF { + +#if DUMP_HASHTABLE_STATS + +int HashTableStats::numAccesses; +int HashTableStats::numCollisions; +int HashTableStats::collisionGraph[4096]; +int HashTableStats::maxCollisions; +int HashTableStats::numRehashes; +int HashTableStats::numRemoves; +int HashTableStats::numReinserts; + +static HashTableStats logger; + +HashTableStats::~HashTableStats() +{ + printf("\nkhtml::HashTable statistics\n\n"); + printf("%d accesses\n", numAccesses); + printf("%d total collisions, average %.2f probes per access\n", numCollisions, 1.0 * (numAccesses + numCollisions) / numAccesses); + printf("longest collision chain: %d\n", maxCollisions); + for (int i = 1; i <= maxCollisions; i++) { + printf(" %d lookups with exactly %d collisions (%.2f%% , %.2f%% with this many or more)\n", collisionGraph[i], i, 100.0 * (collisionGraph[i] - collisionGraph[i+1]) / numAccesses, 100.0 * collisionGraph[i] / numAccesses); + } + printf("%d rehashes\n", numRehashes); + printf("%d reinserts\n", numReinserts); +} + +void HashTableStats::recordCollisionAtCount(int count) +{ + if (count > maxCollisions) + maxCollisions = count; + numCollisions++; + collisionGraph[count]++; +} + +#endif + +} // namespace WTF diff --git a/wtf/HashTable.h b/wtf/HashTable.h new file mode 100644 index 0000000..3b87490 --- /dev/null +++ b/wtf/HashTable.h @@ -0,0 +1,1253 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2005, 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_HashTable_h +#define WTF_HashTable_h + +#include "FastMalloc.h" +#include "HashTraits.h" +#include + +namespace WTF { + +#define DUMP_HASHTABLE_STATS 0 +#define CHECK_HASHTABLE_CONSISTENCY 0 + +#ifdef NDEBUG +#define CHECK_HASHTABLE_ITERATORS 0 +#define CHECK_HASHTABLE_USE_AFTER_DESTRUCTION 0 +#else +#define CHECK_HASHTABLE_ITERATORS 1 +#define CHECK_HASHTABLE_USE_AFTER_DESTRUCTION 1 +#endif + +#if DUMP_HASHTABLE_STATS + + struct HashTableStats { + ~HashTableStats(); + static int numAccesses; + static int numCollisions; + static int collisionGraph[4096]; + static int maxCollisions; + static int numRehashes; + static int numRemoves; + static int numReinserts; + static void recordCollisionAtCount(int count); + }; + +#endif + + template + class HashTable; + template + class HashTableIterator; + template + class HashTableConstIterator; + +#if CHECK_HASHTABLE_ITERATORS + template + void addIterator(const HashTable*, + HashTableConstIterator*); + + template + void removeIterator(HashTableConstIterator*); +#else + template + inline void addIterator(const HashTable*, + HashTableConstIterator*) { } + + template + inline void removeIterator(HashTableConstIterator*) { } +#endif + + typedef enum { HashItemKnownGood } HashItemKnownGoodTag; + + + template + class HashTableConstIterator { + private: + typedef HashTable HashTableType; + typedef HashTableIterator iterator; + typedef HashTableConstIterator const_iterator; + typedef Value ValueType; + typedef const ValueType& ReferenceType; + typedef const ValueType* PointerType; + + friend class HashTable; + friend class HashTableIterator; + + void skipEmptyBuckets() + { + while (m_position != m_endPosition && HashTableType::isEmptyOrDeletedBucket(*m_position)) + ++m_position; + } + + HashTableConstIterator(const HashTableType* table, PointerType position, PointerType endPosition) + : m_position(position), m_endPosition(endPosition) + { + addIterator(table, this); + skipEmptyBuckets(); + } + + HashTableConstIterator(const HashTableType* table, PointerType position, PointerType endPosition, HashItemKnownGoodTag) + : m_position(position), m_endPosition(endPosition) + { + addIterator(table, this); + } + + public: + HashTableConstIterator() + { + addIterator(0, this); + } + + // default copy, assignment and destructor are OK if CHECK_HASHTABLE_ITERATORS is 0 + +#if CHECK_HASHTABLE_ITERATORS + ~HashTableConstIterator() + { + removeIterator(this); + } + + HashTableConstIterator(const const_iterator& other) + : m_position(other.m_position), m_endPosition(other.m_endPosition) + { + addIterator(other.m_table, this); + } + + const_iterator& operator=(const const_iterator& other) + { + m_position = other.m_position; + m_endPosition = other.m_endPosition; + + removeIterator(this); + addIterator(other.m_table, this); + + return *this; + } +#endif + + PointerType get() const + { + checkValidity(); + return m_position; + } + ReferenceType operator*() const { return *get(); } + PointerType operator->() const { return get(); } + + const_iterator& operator++() + { + checkValidity(); + ASSERT(m_position != m_endPosition); + ++m_position; + skipEmptyBuckets(); + return *this; + } + + // postfix ++ intentionally omitted + + // Comparison. + bool operator==(const const_iterator& other) const + { + checkValidity(other); + return m_position == other.m_position; + } + bool operator!=(const const_iterator& other) const + { + checkValidity(other); + return m_position != other.m_position; + } + + private: + void checkValidity() const + { +#if CHECK_HASHTABLE_ITERATORS + ASSERT(m_table); +#endif + } + + +#if CHECK_HASHTABLE_ITERATORS + void checkValidity(const const_iterator& other) const + { + ASSERT(m_table); + ASSERT(other.m_table); + ASSERT(m_table == other.m_table); + } +#else + void checkValidity(const const_iterator&) const { } +#endif + + PointerType m_position; + PointerType m_endPosition; + +#if CHECK_HASHTABLE_ITERATORS + public: + mutable const HashTableType* m_table; + mutable const_iterator* m_next; + mutable const_iterator* m_previous; +#endif + }; + + template + class HashTableIterator { + private: + typedef HashTable HashTableType; + typedef HashTableIterator iterator; + typedef HashTableConstIterator const_iterator; + typedef Value ValueType; + typedef ValueType& ReferenceType; + typedef ValueType* PointerType; + + friend class HashTable; + + HashTableIterator(HashTableType* table, PointerType pos, PointerType end) : m_iterator(table, pos, end) { } + HashTableIterator(HashTableType* table, PointerType pos, PointerType end, HashItemKnownGoodTag tag) : m_iterator(table, pos, end, tag) { } + + public: + HashTableIterator() { } + + // default copy, assignment and destructor are OK + + PointerType get() const { return const_cast(m_iterator.get()); } + ReferenceType operator*() const { return *get(); } + PointerType operator->() const { return get(); } + + iterator& operator++() { ++m_iterator; return *this; } + + // postfix ++ intentionally omitted + + // Comparison. + bool operator==(const iterator& other) const { return m_iterator == other.m_iterator; } + bool operator!=(const iterator& other) const { return m_iterator != other.m_iterator; } + + operator const_iterator() const { return m_iterator; } + + private: + const_iterator m_iterator; + }; + + using std::swap; + +#if !COMPILER(MSVC) + // Visual C++ has a swap for pairs defined. + + // swap pairs by component, in case of pair members that specialize swap + template inline void swap(pair& a, pair& b) + { + swap(a.first, b.first); + swap(a.second, b.second); + } +#endif + + template struct Mover; + template struct Mover { static void move(T& from, T& to) { swap(from, to); } }; + template struct Mover { static void move(T& from, T& to) { to = from; } }; + + template class IdentityHashTranslator { + public: + static unsigned hash(const Key& key) { return HashFunctions::hash(key); } + static bool equal(const Key& a, const Key& b) { return HashFunctions::equal(a, b); } + static void translate(Value& location, const Key&, const Value& value) { location = value; } + }; + + template + class HashTable { + public: + typedef HashTableIterator iterator; + typedef HashTableConstIterator const_iterator; + typedef Traits ValueTraits; + typedef Key KeyType; + typedef Value ValueType; + typedef IdentityHashTranslator IdentityTranslatorType; + + HashTable(); + ~HashTable() + { + invalidateIterators(); + deallocateTable(m_table, m_tableSize); +#if CHECK_HASHTABLE_USE_AFTER_DESTRUCTION + m_table = (ValueType*)(uintptr_t)0xbbadbeef; +#endif + } + + HashTable(const HashTable&); + void swap(HashTable&); + HashTable& operator=(const HashTable&); + + iterator begin() { return makeIterator(m_table); } + iterator end() { return makeKnownGoodIterator(m_table + m_tableSize); } + const_iterator begin() const { return makeConstIterator(m_table); } + const_iterator end() const { return makeKnownGoodConstIterator(m_table + m_tableSize); } + + int size() const { return m_keyCount; } + int capacity() const { return m_tableSize; } + bool isEmpty() const { return !m_keyCount; } + + pair add(const ValueType& value) { return add(Extractor::extract(value), value); } + + // A special version of add() that finds the object by hashing and comparing + // with some other type, to avoid the cost of type conversion if the object is already + // in the table. + template pair add(const T& key, const Extra&); + template pair addPassingHashCode(const T& key, const Extra&); + + iterator find(const KeyType& key) { return find(key); } + const_iterator find(const KeyType& key) const { return find(key); } + bool contains(const KeyType& key) const { return contains(key); } + + template iterator find(const T&); + template const_iterator find(const T&) const; + template bool contains(const T&) const; + + void remove(const KeyType&); + void remove(iterator); + void removeWithoutEntryConsistencyCheck(iterator); + void clear(); + + static bool isEmptyBucket(const ValueType& value) { return Extractor::extract(value) == KeyTraits::emptyValue(); } + static bool isDeletedBucket(const ValueType& value) { return Extractor::extract(value) == KeyTraits::deletedValue(); } + static bool isEmptyOrDeletedBucket(const ValueType& value) { return isEmptyBucket(value) || isDeletedBucket(value); } + + ValueType* lookup(const Key& key) { return lookup(key); } + +#if CHECK_HASHTABLE_CONSISTENCY + void checkTableConsistency() const; +#else + static void checkTableConsistency() { } +#endif + + private: + static ValueType* allocateTable(int size); + static void deallocateTable(ValueType* table, int size); + + typedef pair LookupType; + typedef pair FullLookupType; + + template ValueType* lookup(const T&); + LookupType lookupForWriting(const Key& key) { return lookupForWriting(key); }; + template FullLookupType fullLookupForWriting(const T&); + template LookupType lookupForWriting(const T&); + + void removeAndInvalidateWithoutEntryConsistencyCheck(ValueType*); + void removeAndInvalidate(ValueType*); + void remove(ValueType*); + + bool shouldExpand() const { return (m_keyCount + m_deletedCount) * m_maxLoad >= m_tableSize; } + bool mustRehashInPlace() const { return m_keyCount * m_minLoad < m_tableSize * 2; } + bool shouldShrink() const { return m_keyCount * m_minLoad < m_tableSize && m_tableSize > m_minTableSize; } + void expand(); + void shrink() { rehash(m_tableSize / 2); } + + void rehash(int newTableSize); + void reinsert(ValueType&); + + static void initializeBucket(ValueType& bucket) { new (&bucket) ValueType(Traits::emptyValue()); } + static void deleteBucket(ValueType& bucket) { assignDeleted(bucket); } + + FullLookupType makeLookupResult(ValueType* position, bool found, unsigned hash) + { return FullLookupType(LookupType(position, found), hash); } + + iterator makeIterator(ValueType* pos) { return iterator(this, pos, m_table + m_tableSize); } + const_iterator makeConstIterator(ValueType* pos) const { return const_iterator(this, pos, m_table + m_tableSize); } + iterator makeKnownGoodIterator(ValueType* pos) { return iterator(this, pos, m_table + m_tableSize, HashItemKnownGood); } + const_iterator makeKnownGoodConstIterator(ValueType* pos) const { return const_iterator(this, pos, m_table + m_tableSize, HashItemKnownGood); } + +#if CHECK_HASHTABLE_CONSISTENCY + void checkTableConsistencyExceptSize() const; +#else + static void checkTableConsistencyExceptSize() { } +#endif + +#if CHECK_HASHTABLE_ITERATORS + void invalidateIterators(); +#else + static void invalidateIterators() { } +#endif + + static const int m_minTableSize = 64; + static const int m_maxLoad = 2; + static const int m_minLoad = 6; + + ValueType* m_table; + int m_tableSize; + int m_tableSizeMask; + int m_keyCount; + int m_deletedCount; + +#if CHECK_HASHTABLE_ITERATORS + public: + mutable const_iterator* m_iterators; +#endif + }; + + template + inline HashTable::HashTable() + : m_table(0) + , m_tableSize(0) + , m_tableSizeMask(0) + , m_keyCount(0) + , m_deletedCount(0) +#if CHECK_HASHTABLE_ITERATORS + , m_iterators(0) +#endif + { + } + + static inline unsigned doubleHash(unsigned key) + { + key = ~key + (key >> 23); + key ^= (key << 12); + key ^= (key >> 7); + key ^= (key << 2); + key ^= (key >> 20); + return key; + } + + template + template + inline Value* HashTable::lookup(const T& key) + { + ASSERT(m_table); +#if !ASSERT_DISABLED + if (HashFunctions::safeToCompareToEmptyOrDeleted) { + ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key)); + ASSERT(!HashTranslator::equal(KeyTraits::deletedValue(), key)); + } +#endif + + int k = 0; + int sizeMask = m_tableSizeMask; + ValueType* table = m_table; + unsigned h = HashTranslator::hash(key); + int i = h & sizeMask; + +#if DUMP_HASHTABLE_STATS + ++HashTableStats::numAccesses; + int probeCount = 0; +#endif + + while (1) { + ValueType* entry = table + i; + + // we count on the compiler to optimize out this branch + if (HashFunctions::safeToCompareToEmptyOrDeleted) { + if (HashTranslator::equal(Extractor::extract(*entry), key)) + return entry; + + if (isEmptyBucket(*entry)) + return 0; + } else { + if (isEmptyBucket(*entry)) + return 0; + + if (!isDeletedBucket(*entry) && HashTranslator::equal(Extractor::extract(*entry), key)) + return entry; + } +#if DUMP_HASHTABLE_STATS + ++probeCount; + HashTableStats::recordCollisionAtCount(probeCount); +#endif + if (k == 0) + k = 1 | doubleHash(h); + i = (i + k) & sizeMask; + } + } + + template + template + inline typename HashTable::LookupType HashTable::lookupForWriting(const T& key) + { + ASSERT(m_table); +#if !ASSERT_DISABLED + if (HashFunctions::safeToCompareToEmptyOrDeleted) { + ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key)); + ASSERT(!HashTranslator::equal(KeyTraits::deletedValue(), key)); + } +#endif + + int k = 0; + ValueType* table = m_table; + int sizeMask = m_tableSizeMask; + unsigned h = HashTranslator::hash(key); + int i = h & sizeMask; + +#if DUMP_HASHTABLE_STATS + ++HashTableStats::numAccesses; + int probeCount = 0; +#endif + + ValueType* deletedEntry = 0; + + while (1) { + ValueType* entry = table + i; + + // we count on the compiler to optimize out this branch + if (HashFunctions::safeToCompareToEmptyOrDeleted) { + if (isEmptyBucket(*entry)) + return LookupType(deletedEntry ? deletedEntry : entry, false); + + if (HashTranslator::equal(Extractor::extract(*entry), key)) + return LookupType(entry, true); + + if (isDeletedBucket(*entry)) + deletedEntry = entry; + } else { + if (isEmptyBucket(*entry)) + return LookupType(deletedEntry ? deletedEntry : entry, false); + + if (isDeletedBucket(*entry)) + deletedEntry = entry; + else if (HashTranslator::equal(Extractor::extract(*entry), key)) + return LookupType(entry, true); + } +#if DUMP_HASHTABLE_STATS + ++probeCount; + HashTableStats::recordCollisionAtCount(probeCount); +#endif + if (k == 0) + k = 1 | doubleHash(h); + i = (i + k) & sizeMask; + } + } + + template + template + inline typename HashTable::FullLookupType HashTable::fullLookupForWriting(const T& key) + { + ASSERT(m_table); +#if !ASSERT_DISABLED + if (HashFunctions::safeToCompareToEmptyOrDeleted) { + ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key)); + ASSERT(!HashTranslator::equal(KeyTraits::deletedValue(), key)); + } +#endif + + int k = 0; + ValueType* table = m_table; + int sizeMask = m_tableSizeMask; + unsigned h = HashTranslator::hash(key); + int i = h & sizeMask; + +#if DUMP_HASHTABLE_STATS + ++HashTableStats::numAccesses; + int probeCount = 0; +#endif + + ValueType* deletedEntry = 0; + + while (1) { + ValueType* entry = table + i; + + // we count on the compiler to optimize out this branch + if (HashFunctions::safeToCompareToEmptyOrDeleted) { + if (isEmptyBucket(*entry)) + return makeLookupResult(deletedEntry ? deletedEntry : entry, false, h); + + if (HashTranslator::equal(Extractor::extract(*entry), key)) + return makeLookupResult(entry, true, h); + + if (isDeletedBucket(*entry)) + deletedEntry = entry; + } else { + if (isEmptyBucket(*entry)) + return makeLookupResult(deletedEntry ? deletedEntry : entry, false, h); + + if (isDeletedBucket(*entry)) + deletedEntry = entry; + else if (HashTranslator::equal(Extractor::extract(*entry), key)) + return makeLookupResult(entry, true, h); + } +#if DUMP_HASHTABLE_STATS + ++probeCount; + HashTableStats::recordCollisionAtCount(probeCount); +#endif + if (k == 0) + k = 1 | doubleHash(h); + i = (i + k) & sizeMask; + } + } + + template + template + inline pair::iterator, bool> HashTable::add(const T& key, const Extra& extra) + { +#if !ASSERT_DISABLED + if (HashFunctions::safeToCompareToEmptyOrDeleted) { + ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key)); + ASSERT(!HashTranslator::equal(KeyTraits::deletedValue(), key)); + } +#endif + + invalidateIterators(); + + if (!m_table) + expand(); + + checkTableConsistency(); + + ASSERT(m_table); + + int k = 0; + ValueType* table = m_table; + int sizeMask = m_tableSizeMask; + unsigned h = HashTranslator::hash(key); + int i = h & sizeMask; + +#if DUMP_HASHTABLE_STATS + ++HashTableStats::numAccesses; + int probeCount = 0; +#endif + + ValueType* deletedEntry = 0; + ValueType* entry; + while (1) { + entry = table + i; + + // we count on the compiler to optimize out this branch + if (HashFunctions::safeToCompareToEmptyOrDeleted) { + if (isEmptyBucket(*entry)) + break; + + if (HashTranslator::equal(Extractor::extract(*entry), key)) + return std::make_pair(makeKnownGoodIterator(entry), false); + + if (isDeletedBucket(*entry)) + deletedEntry = entry; + } else { + if (isEmptyBucket(*entry)) + break; + + if (isDeletedBucket(*entry)) + deletedEntry = entry; + else if (HashTranslator::equal(Extractor::extract(*entry), key)) + return std::make_pair(makeKnownGoodIterator(entry), false); + } +#if DUMP_HASHTABLE_STATS + ++probeCount; + HashTableStats::recordCollisionAtCount(probeCount); +#endif + if (k == 0) + k = 1 | doubleHash(h); + i = (i + k) & sizeMask; + } + + if (deletedEntry) { + entry = deletedEntry; + --m_deletedCount; + } + + HashTranslator::translate(*entry, key, extra); + + ++m_keyCount; + + if (shouldExpand()) { + // FIXME: this makes an extra copy on expand. Probably not that bad since + // expand is rare, but would be better to have a version of expand that can + // follow a pivot entry and return the new position + KeyType enteredKey = Extractor::extract(*entry); + expand(); + return std::make_pair(find(enteredKey), true); + } + + checkTableConsistency(); + + return std::make_pair(makeKnownGoodIterator(entry), true); + } + + template + template + inline pair::iterator, bool> HashTable::addPassingHashCode(const T& key, const Extra& extra) + { + invalidateIterators(); + + if (!m_table) + expand(); + + checkTableConsistency(); + + FullLookupType lookupResult = fullLookupForWriting(key); + + ValueType *entry = lookupResult.first.first; + bool found = lookupResult.first.second; + unsigned h = lookupResult.second; + + if (found) + return std::make_pair(makeKnownGoodIterator(entry), false); + + if (isDeletedBucket(*entry)) + --m_deletedCount; + + HashTranslator::translate(*entry, key, extra, h); + ++m_keyCount; + if (shouldExpand()) { + // FIXME: this makes an extra copy on expand. Probably not that bad since + // expand is rare, but would be better to have a version of expand that can + // follow a pivot entry and return the new position + KeyType enteredKey = Extractor::extract(*entry); + expand(); + return std::make_pair(find(enteredKey), true); + } + + checkTableConsistency(); + + return std::make_pair(makeKnownGoodIterator(entry), true); + } + + template + inline void HashTable::reinsert(ValueType& entry) + { + ASSERT(m_table); + ASSERT(!lookupForWriting(Extractor::extract(entry)).second); + ASSERT(!isDeletedBucket(*(lookupForWriting(Extractor::extract(entry)).first))); +#if DUMP_HASHTABLE_STATS + ++HashTableStats::numReinserts; +#endif + + Mover::move(entry, *(lookupForWriting(Extractor::extract(entry)).first)); + } + + template + template + typename HashTable::iterator HashTable::find(const T& key) + { + if (!m_table) + return end(); + + ValueType* entry = lookup(key); + if (!entry) + return end(); + + return makeKnownGoodIterator(entry); + } + + template + template + typename HashTable::const_iterator HashTable::find(const T& key) const + { + if (!m_table) + return end(); + + ValueType* entry = const_cast(this)->lookup(key); + if (!entry) + return end(); + + return makeKnownGoodConstIterator(entry); + } + + template + template + bool HashTable::contains(const T& key) const + { + if (!m_table) + return false; + + return const_cast(this)->lookup(key); + } + + template + void HashTable::removeAndInvalidateWithoutEntryConsistencyCheck(ValueType* pos) + { + invalidateIterators(); + remove(pos); + } + + template + void HashTable::removeAndInvalidate(ValueType* pos) + { + invalidateIterators(); + checkTableConsistency(); + remove(pos); + } + + template + void HashTable::remove(ValueType* pos) + { +#if DUMP_HASHTABLE_STATS + ++HashTableStats::numRemoves; +#endif + + deleteBucket(*pos); + ++m_deletedCount; + --m_keyCount; + + if (shouldShrink()) + shrink(); + + checkTableConsistency(); + } + + template + inline void HashTable::remove(iterator it) + { + if (it == end()) + return; + + removeAndInvalidate(const_cast(it.m_iterator.m_position)); + } + + template + inline void HashTable::removeWithoutEntryConsistencyCheck(iterator it) + { + if (it == end()) + return; + + removeAndInvalidateWithoutEntryConsistencyCheck(const_cast(it.m_iterator.m_position)); + } + + template + inline void HashTable::remove(const KeyType& key) + { + remove(find(key)); + } + + template + Value *HashTable::allocateTable(int size) + { + // would use a template member function with explicit specializations here, but + // gcc doesn't appear to support that + if (Traits::emptyValueIsZero) + return static_cast(fastZeroedMalloc(size * sizeof(ValueType))); + ValueType* result = static_cast(fastMalloc(size * sizeof(ValueType))); + for (int i = 0; i < size; i++) + initializeBucket(result[i]); + return result; + } + + template + void HashTable::deallocateTable(ValueType *table, int size) + { + if (Traits::needsDestruction) + for (int i = 0; i < size; ++i) + table[i].~ValueType(); + fastFree(table); + } + + template + void HashTable::expand() + { + int newSize; + if (m_tableSize == 0) + newSize = m_minTableSize; + else if (mustRehashInPlace()) + newSize = m_tableSize; + else + newSize = m_tableSize * 2; + + rehash(newSize); + } + + template + void HashTable::rehash(int newTableSize) + { + checkTableConsistencyExceptSize(); + + int oldTableSize = m_tableSize; + ValueType *oldTable = m_table; + +#if DUMP_HASHTABLE_STATS + if (oldTableSize != 0) + ++HashTableStats::numRehashes; +#endif + + m_tableSize = newTableSize; + m_tableSizeMask = newTableSize - 1; + m_table = allocateTable(newTableSize); + + for (int i = 0; i != oldTableSize; ++i) + if (!isEmptyOrDeletedBucket(oldTable[i])) + reinsert(oldTable[i]); + + m_deletedCount = 0; + + deallocateTable(oldTable, oldTableSize); + + checkTableConsistency(); + } + + template + void HashTable::clear() + { + invalidateIterators(); + deallocateTable(m_table, m_tableSize); + m_table = 0; + m_tableSize = 0; + m_tableSizeMask = 0; + m_keyCount = 0; + } + + template + HashTable::HashTable(const HashTable& other) + : m_table(0) + , m_tableSize(0) + , m_tableSizeMask(0) + , m_keyCount(0) + , m_deletedCount(0) +#if CHECK_HASHTABLE_ITERATORS + , m_iterators(0) +#endif + { + // Copy the hash table the dumb way, by adding each element to the new table. + // It might be more efficient to copy the table slots, but it's not clear that efficiency is needed. + const_iterator end = other.end(); + for (const_iterator it = other.begin(); it != end; ++it) + add(*it); + } + + template + void HashTable::swap(HashTable& other) + { + invalidateIterators(); + other.invalidateIterators(); + + ValueType *tmp_table = m_table; + m_table = other.m_table; + other.m_table = tmp_table; + + int tmp_tableSize = m_tableSize; + m_tableSize = other.m_tableSize; + other.m_tableSize = tmp_tableSize; + + int tmp_tableSizeMask = m_tableSizeMask; + m_tableSizeMask = other.m_tableSizeMask; + other.m_tableSizeMask = tmp_tableSizeMask; + + int tmp_keyCount = m_keyCount; + m_keyCount = other.m_keyCount; + other.m_keyCount = tmp_keyCount; + + int tmp_deletedCount = m_deletedCount; + m_deletedCount = other.m_deletedCount; + other.m_deletedCount = tmp_deletedCount; + } + + template + HashTable& HashTable::operator=(const HashTable& other) + { + HashTable tmp(other); + swap(tmp); + return *this; + } + +#if CHECK_HASHTABLE_CONSISTENCY + + template + void HashTable::checkTableConsistency() const + { + checkTableConsistencyExceptSize(); + ASSERT(!shouldExpand()); + ASSERT(!shouldShrink()); + } + + template + void HashTable::checkTableConsistencyExceptSize() const + { + if (!m_table) + return; + + int count = 0; + int deletedCount = 0; + for (int j = 0; j < m_tableSize; ++j) { + ValueType *entry = m_table + j; + if (isEmptyBucket(*entry)) + continue; + + if (isDeletedBucket(*entry)) { + ++deletedCount; + continue; + } + + const_iterator it = find(Extractor::extract(*entry)); + ASSERT(entry == it.m_position); + ++count; + } + + ASSERT(count == m_keyCount); + ASSERT(deletedCount == m_deletedCount); + ASSERT(m_tableSize >= m_minTableSize); + ASSERT(m_tableSizeMask); + ASSERT(m_tableSize == m_tableSizeMask + 1); + } + +#endif // CHECK_HASHTABLE_CONSISTENCY + +#if CHECK_HASHTABLE_ITERATORS + + template + void HashTable::invalidateIterators() + { + const_iterator* next; + for (const_iterator* p = m_iterators; p; p = next) { + next = p->m_next; + p->m_table = 0; + p->m_next = 0; + p->m_previous = 0; + } + m_iterators = 0; + } + + template + void addIterator(const HashTable* table, + HashTableConstIterator* it) + { + it->m_table = table; + it->m_previous = 0; + + // Insert iterator at head of doubly-linked list of iterators. + if (!table) { + it->m_next = 0; + } else { + ASSERT(table->m_iterators != it); + it->m_next = table->m_iterators; + table->m_iterators = it; + if (it->m_next) { + ASSERT(!it->m_next->m_previous); + it->m_next->m_previous = it; + } + } + } + + template + void removeIterator(HashTableConstIterator* it) + { + typedef HashTable HashTableType; + typedef HashTableConstIterator const_iterator; + + // Delete iterator from doubly-linked list of iterators. + if (!it->m_table) { + ASSERT(!it->m_next); + ASSERT(!it->m_previous); + } else { + if (it->m_next) { + ASSERT(it->m_next->m_previous == it); + it->m_next->m_previous = it->m_previous; + } + if (it->m_previous) { + ASSERT(it->m_table->m_iterators != it); + ASSERT(it->m_previous->m_next == it); + it->m_previous->m_next = it->m_next; + } else { + ASSERT(it->m_table->m_iterators == it); + it->m_table->m_iterators = it->m_next; + } + } + + it->m_table = 0; + it->m_next = 0; + it->m_previous = 0; + } + +#endif // CHECK_HASHTABLE_ITERATORS + + // iterator adapters + + template struct HashTableConstIteratorAdapter { + HashTableConstIteratorAdapter(const typename HashTableType::const_iterator& impl) : m_impl(impl) {} + + const ValueType* get() const { return (const ValueType*)m_impl.get(); } + const ValueType& operator*() const { return *get(); } + const ValueType* operator->() const { return get(); } + + HashTableConstIteratorAdapter& operator++() { ++m_impl; return *this; } + // postfix ++ intentionally omitted + + typename HashTableType::const_iterator m_impl; + }; + + template struct HashTableIteratorAdapter { + HashTableIteratorAdapter(const typename HashTableType::iterator& impl) : m_impl(impl) {} + + ValueType* get() const { return (ValueType*)m_impl.get(); } + ValueType& operator*() const { return *get(); } + ValueType* operator->() const { return get(); } + + HashTableIteratorAdapter& operator++() { ++m_impl; return *this; } + // postfix ++ intentionally omitted + + operator HashTableConstIteratorAdapter() { + typename HashTableType::const_iterator i = m_impl; + return i; + } + + typename HashTableType::iterator m_impl; + }; + + template + inline bool operator==(const HashTableConstIteratorAdapter& a, const HashTableConstIteratorAdapter& b) + { + return a.m_impl == b.m_impl; + } + + template + inline bool operator!=(const HashTableConstIteratorAdapter& a, const HashTableConstIteratorAdapter& b) + { + return a.m_impl != b.m_impl; + } + + template + inline bool operator==(const HashTableIteratorAdapter& a, const HashTableIteratorAdapter& b) + { + return a.m_impl == b.m_impl; + } + + template + inline bool operator!=(const HashTableIteratorAdapter& a, const HashTableIteratorAdapter& b) + { + return a.m_impl != b.m_impl; + } + + // reference count manager + + template struct NeedsRef { + static const bool value = ValueTraits::needsRef && !ValueStorageTraits::needsRef; + }; + template + struct NeedsRef, ValueStorageTraits> { + typedef typename ValueStorageTraits::FirstTraits FirstStorageTraits; + typedef typename ValueStorageTraits::SecondTraits SecondStorageTraits; + static const bool firstNeedsRef = NeedsRef::value; + static const bool secondNeedsRef = NeedsRef::value; + static const bool value = firstNeedsRef || secondNeedsRef; + }; + + template struct RefCounterBase; + + template + struct RefCounterBase { + typedef typename ValueStorageTraits::TraitType ValueStorageType; + static void ref(const ValueStorageType&) { } + static void deref(const ValueStorageType&) { } + }; + + template + struct RefCounterBase { + typedef typename ValueStorageTraits::TraitType ValueStorageType; + static void ref(const ValueStorageType& v) { ValueTraits::ref(v); } + static void deref(const ValueStorageType& v) { ValueTraits::deref(v); } + }; + + template struct RefCounter { + typedef typename ValueTraits::TraitType ValueType; + typedef typename ValueStorageTraits::TraitType ValueStorageType; + static const bool needsRef = NeedsRef::value; + typedef RefCounterBase Base; + static void ref(const ValueStorageType& v) { Base::ref(v); } + static void deref(const ValueStorageType& v) { Base::deref(v); } + }; + + template + struct RefCounter, ValueStorageTraits> { + typedef typename FirstTraits::TraitType FirstType; + typedef typename SecondTraits::TraitType SecondType; + typedef typename ValueStorageTraits::FirstTraits FirstStorageTraits; + typedef typename ValueStorageTraits::SecondTraits SecondStorageTraits; + typedef typename ValueStorageTraits::TraitType ValueStorageType; + static const bool firstNeedsRef = NeedsRef::value; + static const bool secondNeedsRef = NeedsRef::value; + typedef RefCounterBase FirstBase; + typedef RefCounterBase SecondBase; + static void ref(const ValueStorageType& v) { + FirstBase::ref(v.first); + SecondBase::ref(v.second); + } + static void deref(const ValueStorageType& v) { + FirstBase::deref(v.first); + SecondBase::deref(v.second); + } + }; + + template struct HashTableRefCounterBase; + + template + struct HashTableRefCounterBase + { + static void refAll(HashTableType&) { } + static void derefAll(HashTableType&) { } + }; + + template + struct HashTableRefCounterBase + { + typedef typename HashTableType::iterator iterator; + typedef RefCounter ValueRefCounter; + static void refAll(HashTableType&); + static void derefAll(HashTableType&); + }; + + template + void HashTableRefCounterBase::refAll(HashTableType& table) + { + iterator end = table.end(); + for (iterator it = table.begin(); it != end; ++it) + ValueRefCounter::ref(*it); + } + + template + void HashTableRefCounterBase::derefAll(HashTableType& table) + { + iterator end = table.end(); + for (iterator it = table.begin(); it != end; ++it) + ValueRefCounter::deref(*it); + } + + template struct HashTableRefCounter { + static const bool needsRef = NeedsRef::value; + typedef HashTableRefCounterBase Base; + static void refAll(HashTableType& table) { Base::refAll(table); } + static void derefAll(HashTableType& table) { Base::derefAll(table); } + }; + + // helper template for HashMap and HashSet. + template struct Assigner; + + template struct Assigner { + typedef union { + FromType m_from; + ToType m_to; + } UnionType; + + static void assign(const FromType& from, ToType& to) { reinterpret_cast(&to)->m_from = from; } + }; + + template struct Assigner { + static void assign(const FromType& from, ToType& to) + { + ToType oldTo = to; + memcpy(&to, &from, sizeof(FromType)); + FromTraits::ref(to); + FromTraits::deref(oldTo); + } + }; + + template struct Assigner { + static void assign(const FromType& from, FromType& to) { to = from; } + }; + + template struct Assigner { + static void assign(const FromType& from, FromType& to) { to = from; } + }; + +} // namespace WTF + +#include "HashIterators.h" + +#endif // WTF_HashTable_h diff --git a/wtf/HashTraits.h b/wtf/HashTraits.h new file mode 100644 index 0000000..5f35278 --- /dev/null +++ b/wtf/HashTraits.h @@ -0,0 +1,254 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2005, 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_HashTraits_h +#define WTF_HashTraits_h + +#include "Assertions.h" +#include "HashFunctions.h" +#include +#include + +namespace WTF { + + using std::pair; + using std::make_pair; + + template struct IsInteger { static const bool value = false; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + template<> struct IsInteger { static const bool value = true; }; + + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_bool_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_char_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_signed_char_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_char_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_short_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_short_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_int_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_int_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_long_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_long_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_long_long_true); + COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_long_long_true); + + COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_char_pointer_false); + COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_const_char_pointer_false); + COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_volatile_char_pointer__false); + COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_double_false); + COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_float_false); + + template struct HashTraits; + + template struct GenericHashTraitsBase; + template struct GenericHashTraitsBase { + typedef T TraitType; + typedef HashTraits::SignedType> StorageTraits; + static const bool emptyValueIsZero = true; + static const bool needsDestruction = false; + }; + template struct GenericHashTraitsBase { + typedef T TraitType; + typedef HashTraits StorageTraits; + static const bool emptyValueIsZero = false; + static const bool needsDestruction = true; + }; + + template struct GenericHashTraits : GenericHashTraitsBase::value, T> { + static T emptyValue() { return T(); } + static const bool needsRef = false; + }; + + template struct HashTraits : GenericHashTraits { }; + + // signed integer traits may not be appropriate for all uses since they disallow 0 and -1 as keys + template<> struct HashTraits : GenericHashTraits { + static signed char deletedValue() { return -1; } + }; + template<> struct HashTraits : GenericHashTraits { + static short deletedValue() { return -1; } + }; + template<> struct HashTraits : GenericHashTraits { + static int deletedValue() { return -1; } + }; + template<> struct HashTraits : GenericHashTraits { + static unsigned int deletedValue() { return static_cast(-1); } + }; + template<> struct HashTraits : GenericHashTraits { + static long deletedValue() { return -1; } + }; + template<> struct HashTraits : GenericHashTraits { + static unsigned long deletedValue() { return static_cast(-1); } + }; + template<> struct HashTraits : GenericHashTraits { + static long long deletedValue() { return -1; } + }; + template<> struct HashTraits : GenericHashTraits { + static unsigned long long deletedValue() { return static_cast(-1); } + }; + + template struct FloatHashTraits { + typedef T TraitType; + typedef HashTraits StorageTraits; + static T emptyValue() { return std::numeric_limits::infinity(); } + static T deletedValue() { return -std::numeric_limits::infinity(); } + static const bool emptyValueIsZero = false; + static const bool needsDestruction = false; + static const bool needsRef = false; + }; + template<> struct HashTraits : FloatHashTraits { + }; + template<> struct HashTraits : FloatHashTraits { + }; + + template struct HashTraits : GenericHashTraits { + typedef HashTraits::SignedType> StorageTraits; + static const bool emptyValueIsZero = true; + static const bool needsDestruction = false; + static P* deletedValue() { return reinterpret_cast(-1); } + }; + + template struct HashTraits > : GenericHashTraits > { + typedef HashTraits::SignedType> StorageTraits; + typedef typename StorageTraits::TraitType StorageType; + static const bool emptyValueIsZero = true; + static const bool needsRef = true; + + typedef union { + P* m_p; + StorageType m_s; + } UnionType; + + static void ref(const StorageType& s) + { + if (const P* p = reinterpret_cast(&s)->m_p) + const_cast(p)->ref(); + } + static void deref(const StorageType& s) + { + if (const P* p = reinterpret_cast(&s)->m_p) + const_cast(p)->deref(); + } + }; + + // template to set deleted values + + template struct DeletedValueAssigner { + static void assignDeletedValue(typename Traits::TraitType& location) { location = Traits::deletedValue(); } + }; + + template inline void assignDeleted(T& location) + { + DeletedValueAssigner::assignDeletedValue(location); + } + + // special traits for pairs, helpful for their use in HashMap implementation + + template struct PairHashTraits; + + template + struct PairBaseHashTraits : GenericHashTraits > { + typedef FirstTraitsArg FirstTraits; + typedef SecondTraitsArg SecondTraits; + typedef pair TraitType; + + typedef PairHashTraits StorageTraits; + + static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero; + + static TraitType emptyValue() + { + return make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); + } + }; + + template + struct PairHashTraits : PairBaseHashTraits { + typedef pair TraitType; + + static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction; + + static TraitType deletedValue() + { + return TraitType(FirstTraits::deletedValue(), SecondTraits::emptyValue()); + } + + static void assignDeletedValue(TraitType& location) + { + assignDeleted(location.first); + location.second = SecondTraits::emptyValue(); + } + }; + + template + struct HashTraits > : public PairHashTraits, HashTraits > { }; + + template + struct DeletedValueAssigner > + { + static void assignDeletedValue(pair& location) + { + PairHashTraits::assignDeletedValue(location); + } + }; + + template + struct DeletedValueAssigner > > + { + static void assignDeletedValue(pair& location) + { + HashTraits >::assignDeletedValue(location); + } + }; + + // hash functions and traits that are equivalent (for code sharing) + + template struct HashKeyStorageTraits { + typedef HashArg Hash; + typedef TraitsArg Traits; + }; + template struct HashKeyStorageTraits, HashTraits > { + typedef typename IntTypes::SignedType IntType; + typedef IntHash Hash; + typedef HashTraits Traits; + }; + template struct HashKeyStorageTraits >, HashTraits > > { + typedef typename IntTypes::SignedType IntType; + typedef IntHash Hash; + typedef HashTraits Traits; + }; + +} // namespace WTF + +using WTF::HashTraits; +using WTF::PairHashTraits; + +#endif // WTF_HashTraits_h diff --git a/wtf/ListHashSet.h b/wtf/ListHashSet.h new file mode 100644 index 0000000..3172943 --- /dev/null +++ b/wtf/ListHashSet.h @@ -0,0 +1,576 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_ListHashSet_h +#define WTF_ListHashSet_h + +#include "Assertions.h" +#include "HashSet.h" +#include "OwnPtr.h" + +namespace WTF { + + // ListHashSet: Just like HashSet, this class provides a Set + // interface - a collection of unique objects with O(1) insertion, + // removal and test for containership. However, it also has an + // order - iterating it will always give back values in the order + // in which they are added. + + // In theory it would be possible to add prepend, insertAfter, insertBefore, + // and an append that moves the element to the end even if already present, + // but unclear yet if these are needed. + + template class ListHashSet; + + template struct IdentityExtractor; + + template + void deleteAllValues(const ListHashSet&); + + template class ListHashSetIterator; + template class ListHashSetConstIterator; + + template struct ListHashSetNode; + template struct ListHashSetNodeAllocator; + template struct ListHashSetNodeHashFunctions; + + template::Hash> class ListHashSet { + private: + typedef ListHashSetNode Node; + typedef ListHashSetNodeAllocator NodeAllocator; + + typedef HashTraits NodeTraits; + typedef ListHashSetNodeHashFunctions NodeHash; + + typedef HashTable, NodeHash, NodeTraits, NodeTraits> ImplType; + + typedef HashArg HashFunctions; + + public: + typedef ValueArg ValueType; + typedef ListHashSetIterator iterator; + typedef ListHashSetConstIterator const_iterator; + + friend class ListHashSetConstIterator; + + ListHashSet(); + ListHashSet(const ListHashSet&); + ListHashSet& operator=(const ListHashSet&); + ~ListHashSet(); + + void swap(ListHashSet&); + + int size() const; + int capacity() const; + bool isEmpty() const; + + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + + iterator find(const ValueType&); + const_iterator find(const ValueType&) const; + bool contains(const ValueType&) const; + + // the return value is a pair of an interator to the new value's location, + // and a bool that is true if an new entry was added + pair add(const ValueType&); + + void remove(const ValueType&); + void remove(iterator); + void clear(); + + private: + void unlinkAndDelete(Node*); + void appendNode(Node*); + void deleteAllNodes(); + iterator makeIterator(Node*); + const_iterator makeConstIterator(Node*) const; + + friend void deleteAllValues<>(const ListHashSet&); + + ImplType m_impl; + Node* m_head; + Node* m_tail; + OwnPtr m_allocator; + }; + + template struct ListHashSetNodeAllocator { + typedef ListHashSetNode Node; + typedef ListHashSetNodeAllocator NodeAllocator; + + ListHashSetNodeAllocator() + : m_freeList(pool()) + , m_isDoneWithInitialFreeList(false) + { + memset(m_pool.pool, 0, sizeof(m_pool.pool)); + } + + Node* allocate() + { + Node* result = m_freeList; + + if (!result) + return static_cast(fastMalloc(sizeof(Node))); + + ASSERT(!result->m_isAllocated); + + Node* next = result->m_next; + ASSERT(!next || !next->m_isAllocated); + if (!next && !m_isDoneWithInitialFreeList) { + next = result + 1; + if (next == pastPool()) { + m_isDoneWithInitialFreeList = true; + next = 0; + } else { + ASSERT(inPool(next)); + ASSERT(!next->m_isAllocated); + } + } + m_freeList = next; + + return result; + } + + void deallocate(Node* node) + { + if (inPool(node)) { +#ifndef NDEBUG + node->m_isAllocated = false; +#endif + node->m_next = m_freeList; + m_freeList = node; + return; + } + + fastFree(node); + } + + private: + Node* pool() { return reinterpret_cast(m_pool.pool); } + Node* pastPool() { return pool() + m_poolSize; } + + bool inPool(Node* node) + { + return node >= pool() && node < pastPool(); + } + + Node* m_freeList; + bool m_isDoneWithInitialFreeList; + static const size_t m_poolSize = 256; + union { + char pool[sizeof(Node) * m_poolSize]; + double forAlignment; + } m_pool; + }; + + template struct ListHashSetNode { + typedef ListHashSetNodeAllocator NodeAllocator; + + ListHashSetNode(ValueArg value) + : m_value(value) + , m_prev(0) + , m_next(0) +#ifndef NDEBUG + , m_isAllocated(true) +#endif + { + } + + void* operator new(size_t, NodeAllocator* allocator) + { + return allocator->allocate(); + } + void destroy(NodeAllocator* allocator) + { + this->~ListHashSetNode(); + allocator->deallocate(this); + } + + ValueArg m_value; + ListHashSetNode* m_prev; + ListHashSetNode* m_next; + +#ifndef NDEBUG + bool m_isAllocated; +#endif + }; + + template struct ListHashSetNodeHashFunctions { + typedef ListHashSetNode Node; + + static unsigned hash(Node* const& key) { return HashArg::hash(key->m_value); } + static bool equal(Node* const& a, Node* const& b) { return HashArg::equal(a->m_value, b->m_value); } + static const bool safeToCompareToEmptyOrDeleted = false; + }; + + template class ListHashSetIterator { + private: + typedef ListHashSet ListHashSetType; + typedef ListHashSetIterator iterator; + typedef ListHashSetConstIterator const_iterator; + typedef ListHashSetNode Node; + typedef ValueArg ValueType; + typedef ValueType& ReferenceType; + typedef ValueType* PointerType; + + friend class ListHashSet; + + ListHashSetIterator(const ListHashSetType* set, Node* position) : m_iterator(set, position) { } + + public: + ListHashSetIterator() { } + + // default copy, assignment and destructor are OK + + PointerType get() const { return const_cast(m_iterator.get()); } + ReferenceType operator*() const { return *get(); } + PointerType operator->() const { return get(); } + + iterator& operator++() { ++m_iterator; return *this; } + + // postfix ++ intentionally omitted + + iterator& operator--() { --m_iterator; return *this; } + + // postfix -- intentionally omitted + + // Comparison. + bool operator==(const iterator& other) const { return m_iterator == other.m_iterator; } + bool operator!=(const iterator& other) const { return m_iterator != other.m_iterator; } + + operator const_iterator() const { return m_iterator; } + + private: + Node* node() { return m_iterator.node(); } + + const_iterator m_iterator; + }; + + template class ListHashSetConstIterator { + private: + typedef ListHashSet ListHashSetType; + typedef ListHashSetIterator iterator; + typedef ListHashSetConstIterator const_iterator; + typedef ListHashSetNode Node; + typedef ValueArg ValueType; + typedef const ValueType& ReferenceType; + typedef const ValueType* PointerType; + + friend class ListHashSet; + friend class ListHashSetIterator; + + ListHashSetConstIterator(const ListHashSetType* set, Node* position) + : m_set(set) + , m_position(position) + { + } + + public: + ListHashSetConstIterator() + { + } + + PointerType get() const + { + return &m_position->m_value; + } + ReferenceType operator*() const { return *get(); } + PointerType operator->() const { return get(); } + + const_iterator& operator++() + { + ASSERT(m_position != 0); + m_position = m_position->m_next; + return *this; + } + + // postfix ++ intentionally omitted + + const_iterator& operator--() + { + ASSERT(m_position != m_set->m_head); + m_position = m_position->m_prev; + return *this; + } + + // postfix -- intentionally omitted + + // Comparison. + bool operator==(const const_iterator& other) const + { + return m_position == other.m_position; + } + bool operator!=(const const_iterator& other) const + { + return m_position != other.m_position; + } + + private: + Node* node() { return m_position; } + + const ListHashSetType* m_set; + Node* m_position; + }; + + + template + struct ListHashSetTranslator { + private: + typedef ListHashSetNode Node; + typedef ListHashSetNodeAllocator NodeAllocator; + public: + static unsigned hash(const ValueType& key) { return HashFunctions::hash(key); } + static bool equal(Node* const& a, const ValueType& b) { return HashFunctions::equal(a->m_value, b); } + static void translate(Node*& location, const ValueType& key, NodeAllocator* allocator) + { + location = new (allocator) Node(key); + } + }; + + template + inline ListHashSet::ListHashSet() + : m_head(0) + , m_tail(0) + , m_allocator(new NodeAllocator) + { + } + + template + inline ListHashSet::ListHashSet(const ListHashSet& other) + : m_head(0) + , m_tail(0) + , m_allocator(new NodeAllocator) + { + const_iterator end = other.end(); + for (const_iterator it = other.begin(); it != end; ++it) + add(*it); + } + + template + inline ListHashSet& ListHashSet::operator=(const ListHashSet& other) + { + ListHashSet tmp(other); + swap(tmp); + return *this; + } + + template + inline void ListHashSet::swap(ListHashSet& other) + { + m_impl.swap(other.m_impl); + std::swap(m_head, other.m_head); + std::swap(m_tail, other.m_tail); + m_allocator.swap(other.m_allocator); + return *this; + } + + template + inline ListHashSet::~ListHashSet() + { + deleteAllNodes(); + } + + template + inline int ListHashSet::size() const + { + return m_impl.size(); + } + + template + inline int ListHashSet::capacity() const + { + return m_impl.capacity(); + } + + template + inline bool ListHashSet::isEmpty() const + { + return m_impl.isEmpty(); + } + + template + inline typename ListHashSet::iterator ListHashSet::begin() + { + return makeIterator(m_head); + } + + template + inline typename ListHashSet::iterator ListHashSet::end() + { + return makeIterator(0); + } + + template + inline typename ListHashSet::const_iterator ListHashSet::begin() const + { + return makeConstIterator(m_head); + } + + template + inline typename ListHashSet::const_iterator ListHashSet::end() const + { + return makeConstIterator(0); + } + + template + inline typename ListHashSet::iterator ListHashSet::find(const ValueType& value) + { + typedef ListHashSetTranslator Translator; + typename ImplType::iterator it = m_impl.template find(value); + if (it == m_impl.end()) + return end(); + return makeIterator(*it); + } + + template + inline typename ListHashSet::const_iterator ListHashSet::find(const ValueType& value) const + { + typedef ListHashSetTranslator Translator; + typename ImplType::const_iterator it = m_impl.template find(value); + if (it == m_impl.end()) + return end(); + return makeConstIterator(*it); + } + + template + inline bool ListHashSet::contains(const ValueType& value) const + { + typedef ListHashSetTranslator Translator; + return m_impl.template contains(value); + } + + template + pair::iterator, bool> ListHashSet::add(const ValueType &value) + { + typedef ListHashSetTranslator Translator; + pair result = m_impl.template add(value, m_allocator.get()); + if (result.second) + appendNode(*result.first); + return std::make_pair(makeIterator(*result.first), result.second); + } + + template + inline void ListHashSet::remove(iterator it) + { + if (it == end()) + return; + m_impl.remove(it.node()); + unlinkAndDelete(it.node()); + } + + template + inline void ListHashSet::remove(const ValueType& value) + { + remove(find(value)); + } + + template + inline void ListHashSet::clear() + { + deleteAllNodes(); + m_impl.clear(); + m_head = 0; + m_tail = 0; + } + + template + void ListHashSet::unlinkAndDelete(Node* node) + { + if (!node->m_prev) { + ASSERT(node == m_head); + m_head = node->m_next; + } else { + ASSERT(node != m_head); + node->m_prev->m_next = node->m_next; + } + + if (!node->m_next) { + ASSERT(node == m_tail); + m_tail = node->m_prev; + } else { + ASSERT(node != m_tail); + node->m_next->m_prev = node->m_prev; + } + + node->destroy(m_allocator.get()); + } + + template + void ListHashSet::appendNode(Node* node) + { + node->m_prev = m_tail; + node->m_next = 0; + + if (m_tail) { + ASSERT(m_head); + m_tail->m_next = node; + } else { + ASSERT(!m_head); + m_head = node; + } + + m_tail = node; + } + + template + void ListHashSet::deleteAllNodes() + { + if (!m_head) + return; + + for (Node* node = m_head, *next = m_head->m_next; node; node = next, next = node ? node->m_next : 0) + node->destroy(m_allocator.get()); + } + + template + inline ListHashSetIterator ListHashSet::makeIterator(Node* position) + { + return ListHashSetIterator(this, position); + } + + template + inline ListHashSetConstIterator ListHashSet::makeConstIterator(Node* position) const + { + return ListHashSetConstIterator(this, position); + } + + template + void deleteAllValues(HashTableType& collection) + { + typedef typename HashTableType::const_iterator iterator; + iterator end = collection.end(); + for (iterator it = collection.begin(); it != end; ++it) + delete (*it)->m_value; + } + + template + inline void deleteAllValues(const ListHashSet& collection) + { + deleteAllValues::ValueType>(collection.m_impl); + } + +} // namespace WTF + +using WTF::ListHashSet; + +#endif /* WTF_ListHashSet_h */ diff --git a/wtf/ListRefPtr.h b/wtf/ListRefPtr.h new file mode 100644 index 0000000..0f807b0 --- /dev/null +++ b/wtf/ListRefPtr.h @@ -0,0 +1,61 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2005, 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_ListRefPtr_h +#define WTF_ListRefPtr_h + +#include + +namespace WTF { + + // Specialized version of RefPtr desgined for use in singly-linked lists. + // Derefs the list iteratively to avoid recursive derefing that can overflow the stack. + template class ListRefPtr : public RefPtr { + public: + ListRefPtr() : RefPtr() {} + ListRefPtr(T* ptr) : RefPtr(ptr) {} + ListRefPtr(const RefPtr& o) : RefPtr(o) {} + // see comment in PassRefPtr.h for why this takes const reference + template ListRefPtr(const PassRefPtr& o) : RefPtr(o) {} + + ~ListRefPtr() { + RefPtr reaper = this->release(); + while (reaper && reaper->refcount() == 1) + reaper = reaper->releaseNext(); // implicitly protects reaper->next, then derefs reaper + } + + ListRefPtr& operator=(T* optr) { RefPtr::operator=(optr); return *this; } + ListRefPtr& operator=(const RefPtr& o) { RefPtr::operator=(o); return *this; } + ListRefPtr& operator=(const PassRefPtr& o) { RefPtr::operator=(o); return *this; } + template ListRefPtr& operator=(const RefPtr& o) { RefPtr::operator=(o); return *this; } + template ListRefPtr& operator=(const PassRefPtr& o) { RefPtr::operator=(o); return *this; } + }; + + template inline T* getPtr(const ListRefPtr& p) + { + return p.get(); + } + +} // namespace WTF + +using WTF::ListRefPtr; + +#endif // WTF_ListRefPtr_h diff --git a/wtf/MallocZoneSupport.h b/wtf/MallocZoneSupport.h new file mode 100644 index 0000000..62df145 --- /dev/null +++ b/wtf/MallocZoneSupport.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef MallocZoneSupport_h +#define MallocZoneSupport_h + +#include + +namespace WTF { + +class RemoteMemoryReader { + task_t m_task; + memory_reader_t* m_reader; + +public: + RemoteMemoryReader(task_t task, memory_reader_t* reader) + : m_task(task) + , m_reader(reader) + { } + + void* operator()(vm_address_t address, size_t size) const + { + void* output; + kern_return_t err = (*m_reader)(m_task, address, size, static_cast(&output)); + ASSERT(!err); + if (err) + output = 0; + return output; + } + + template + T* operator()(T* address, size_t size=sizeof(T)) const + { + return static_cast((*this)(reinterpret_cast(address), size)); + } +}; + +} // namespace WTF + +#endif // MallocZoneSupport_h diff --git a/wtf/MathExtras.h b/wtf/MathExtras.h new file mode 100644 index 0000000..75991f0 --- /dev/null +++ b/wtf/MathExtras.h @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_MathExtras_h +#define WTF_MathExtras_h + +#include +#include +#include + +#if PLATFORM(SOLARIS) && COMPILER(GCC) +#include +#endif + +#if COMPILER(MSVC) + +#include +#include + +#if HAVE(FLOAT_H) +#include +#endif + +#endif + +#ifndef M_PI +const double piDouble = 3.14159265358979323846; +const float piFloat = 3.14159265358979323846f; +#else +const double piDouble = M_PI; +const float piFloat = static_cast(M_PI); +#endif + +#ifndef M_PI_4 +const double piOverFourDouble = 0.785398163397448309616; +const float piOverFourFloat = 0.785398163397448309616f; +#else +const double piOverFourDouble = M_PI_4; +const float piOverFourFloat = static_cast(M_PI_4); +#endif + +#if PLATFORM(SOLARIS) && COMPILER(GCC) + +#ifndef isfinite +inline bool isfinite(double x) { return finite(x) && !isnand(x); } +#endif +#ifndef isinf +inline bool isinf(double x) { return !finite(x) && !isnand(x); } +#endif +#ifndef signbit +inline bool signbit(double x) { return x < 0.0; } // FIXME: Wrong for negative 0. +#endif + +#endif + +#if COMPILER(MSVC) + +inline bool isinf(double num) { return !_finite(num) && !_isnan(num); } +inline bool isnan(double num) { return !!_isnan(num); } +inline long lround(double num) { return static_cast(num > 0 ? num + 0.5 : ceil(num - 0.5)); } +inline long lroundf(float num) { return static_cast(num > 0 ? num + 0.5f : ceilf(num - 0.5f)); } +inline double round(double num) { return num > 0 ? floor(num + 0.5) : ceil(num - 0.5); } +inline float roundf(float num) { return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f); } +inline bool signbit(double num) { return _copysign(1.0, num) < 0; } +inline double trunc(double num) { return num > 0 ? floor(num) : ceil(num); } + +inline double nextafter(double x, double y) { return _nextafter(x, y); } +inline float nextafterf(float x, float y) { return x > y ? x - FLT_EPSILON : x + FLT_EPSILON; } + +inline double copysign(double x, double y) { return _copysign(x, y); } +inline int isfinite(double x) { return _finite(x); } + +// Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN instead of specific values. +inline double wtf_atan2(double x, double y) +{ + static double posInf = std::numeric_limits::infinity(); + static double negInf = -std::numeric_limits::infinity(); + static double nan = std::numeric_limits::quiet_NaN(); + + double result = nan; + + if (x == posInf && y == posInf) + result = piOverFourDouble; + else if (x == posInf && y == negInf) + result = 3 * piOverFourDouble; + else if (x == negInf && y == posInf) + result = -piOverFourDouble; + else if (x == negInf && y == negInf) + result = -3 * piOverFourDouble; + else + result = ::atan2(x, y); + + return result; +} + +// Work around a bug in the Microsoft CRT, where fmod(x, +-infinity) yields NaN instead of x. +inline double wtf_fmod(double x, double y) { return (!isinf(x) && isinf(y)) ? x : fmod(x, y); } + +// Work around a bug in the Microsoft CRT, where pow(NaN, 0) yields NaN instead of 1. +inline double wtf_pow(double x, double y) { return y == 0 ? 1 : pow(x, y); } + +#define atan2(x, y) wtf_atan2(x, y) +#define fmod(x, y) wtf_fmod(x, y) +#define pow(x, y) wtf_pow(x, y) + +#if defined(_CRT_RAND_S) +// Initializes the random number generator. +inline void wtf_random_init() +{ + // No need to initialize for rand_s. +} + +// Returns a pseudo-random number in the range [0, 1). +inline double wtf_random() +{ + unsigned u; + rand_s(&u); + + return static_cast(u) / (static_cast(UINT_MAX) + 1.0); +} +#endif // _CRT_RAND_S + +#endif // COMPILER(MSVC) + +#if !COMPILER(MSVC) || !defined(_CRT_RAND_S) + +// Initializes the random number generator. +inline void wtf_random_init() +{ + srand(static_cast(time(0))); +} + +// Returns a pseudo-random number in the range [0, 1). +inline double wtf_random() +{ + return static_cast(rand()) / (static_cast(RAND_MAX) + 1.0); +} + +#endif // #if COMPILER(MSVC) + +inline double deg2rad(double d) { return d * piDouble / 180.0; } +inline double rad2deg(double r) { return r * 180.0 / piDouble; } +inline double deg2grad(double d) { return d * 400.0 / 360.0; } +inline double grad2deg(double g) { return g * 360.0 / 400.0; } +inline double rad2grad(double r) { return r * 200.0 / piDouble; } +inline double grad2rad(double g) { return g * piDouble / 200.0; } + +inline float deg2rad(float d) { return d * piFloat / 180.0f; } +inline float rad2deg(float r) { return r * 180.0f / piFloat; } +inline float deg2grad(float d) { return d * 400.0f / 360.0f; } +inline float grad2deg(float g) { return g * 360.0f / 400.0f; } +inline float rad2grad(float r) { return r * 200.0f / piFloat; } +inline float grad2rad(float g) { return g * piFloat / 200.0f; } + +#endif // #ifndef WTF_MathExtras_h diff --git a/wtf/Noncopyable.h b/wtf/Noncopyable.h new file mode 100644 index 0000000..358b0a7 --- /dev/null +++ b/wtf/Noncopyable.h @@ -0,0 +1,42 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_Noncopyable_h +#define WTF_Noncopyable_h + +// We don't want argument-dependent lookup to pull in everything from the WTF +// namespace when you use Noncopyable, so put it in its own namespace. + +namespace WTFNoncopyable { + + class Noncopyable { + Noncopyable(const Noncopyable&); + Noncopyable& operator=(const Noncopyable&); + protected: + Noncopyable() { } + ~Noncopyable() { } + }; + +} // namespace WTFNoncopyable + +using WTFNoncopyable::Noncopyable; + +#endif // WTF_Noncopyable_h diff --git a/wtf/OwnArrayPtr.h b/wtf/OwnArrayPtr.h new file mode 100644 index 0000000..2b6c7dc --- /dev/null +++ b/wtf/OwnArrayPtr.h @@ -0,0 +1,72 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_OwnArrayPtr_h +#define WTF_OwnArrayPtr_h + +#include +#include +#include + +namespace WTF { + + template class OwnArrayPtr : Noncopyable { + public: + explicit OwnArrayPtr(T* ptr = 0) : m_ptr(ptr) { } + ~OwnArrayPtr() { safeDelete(); } + + T* get() const { return m_ptr; } + T* release() { T* ptr = m_ptr; m_ptr = 0; return ptr; } + + void set(T* ptr) { ASSERT(m_ptr != ptr); safeDelete(); m_ptr = ptr; } + void clear() { safeDelete(); m_ptr = 0; } + + T& operator*() const { ASSERT(m_ptr); return *m_ptr; } + T* operator->() const { ASSERT(m_ptr); return m_ptr; } + + T& operator[](std::ptrdiff_t i) const { ASSERT(m_ptr); ASSERT(i >= 0); return m_ptr[i]; } + + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef T* OwnArrayPtr::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &OwnArrayPtr::m_ptr : 0; } + + void swap(OwnArrayPtr& o) { std::swap(m_ptr, o.m_ptr); } + + private: + void safeDelete() { typedef char known[sizeof(T) ? 1 : -1]; if (sizeof(known)) delete [] m_ptr; } + + T* m_ptr; + }; + + template inline void swap(OwnArrayPtr& a, OwnArrayPtr& b) { a.swap(b); } + + template inline T* getPtr(const OwnArrayPtr& p) + { + return p.get(); + } + +} // namespace WTF + +using WTF::OwnArrayPtr; + +#endif // WTF_OwnArrayPtr_h diff --git a/wtf/OwnPtr.h b/wtf/OwnPtr.h new file mode 100644 index 0000000..b46969d --- /dev/null +++ b/wtf/OwnPtr.h @@ -0,0 +1,124 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_OwnPtr_h +#define WTF_OwnPtr_h + +#include +#include +#include + +#if PLATFORM(WIN) + +typedef struct HBITMAP__* HBITMAP; +typedef struct HBRUSH__* HBRUSH; +typedef struct HFONT__* HFONT; +typedef struct HPALETTE__* HPALETTE; +typedef struct HPEN__* HPEN; +typedef struct HRGN__* HRGN; + +#endif + +namespace WTF { + + // Unlike most of our smart pointers, OwnPtr can take either the pointer type or the pointed-to type. + + // FIXME: Share a single RemovePointer class template with RetainPtr. + template struct OwnPtrRemovePointer { typedef T type; }; + template struct OwnPtrRemovePointer { typedef T type; }; + + template inline void deleteOwnedPtr(T* ptr) + { + typedef char known[sizeof(T) ? 1 : -1]; + if (sizeof(known)) + delete ptr; + } + +#if PLATFORM(WIN) + void deleteOwnedPtr(HBITMAP); + void deleteOwnedPtr(HBRUSH); + void deleteOwnedPtr(HFONT); + void deleteOwnedPtr(HPALETTE); + void deleteOwnedPtr(HPEN); + void deleteOwnedPtr(HRGN); +#endif + + template class OwnPtr : Noncopyable { + public: + typedef typename OwnPtrRemovePointer::type ValueType; + typedef ValueType* PtrType; + + explicit OwnPtr(PtrType ptr = 0) : m_ptr(ptr) { } + ~OwnPtr() { deleteOwnedPtr(m_ptr); } + + PtrType get() const { return m_ptr; } + PtrType release() { PtrType ptr = m_ptr; m_ptr = 0; return ptr; } + + void set(PtrType ptr) { ASSERT(!ptr || m_ptr != ptr); deleteOwnedPtr(m_ptr); m_ptr = ptr; } + void clear() { deleteOwnedPtr(m_ptr); m_ptr = 0; } + + ValueType& operator*() const { ASSERT(m_ptr); return *m_ptr; } + PtrType operator->() const { ASSERT(m_ptr); return m_ptr; } + + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef PtrType OwnPtr::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &OwnPtr::m_ptr : 0; } + + void swap(OwnPtr& o) { std::swap(m_ptr, o.m_ptr); } + + private: + PtrType m_ptr; + }; + + template inline void swap(OwnPtr& a, OwnPtr& b) { a.swap(b); } + + template inline bool operator==(const OwnPtr& a, U* b) + { + return a.get() == b; + } + + template inline bool operator==(T* a, const OwnPtr& b) + { + return a == b.get(); + } + + template inline bool operator!=(const OwnPtr& a, U* b) + { + return a.get() != b; + } + + template inline bool operator!=(T* a, const OwnPtr& b) + { + return a != b.get(); + } + + template inline typename OwnPtr::PtrType getPtr(const OwnPtr& p) + { + return p.get(); + } + +} // namespace WTF + +using WTF::OwnPtr; + +#endif // WTF_OwnPtr_h diff --git a/wtf/OwnPtrWin.cpp b/wtf/OwnPtrWin.cpp new file mode 100755 index 0000000..b08d7dc --- /dev/null +++ b/wtf/OwnPtrWin.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "OwnPtr.h" + +#include + +namespace WTF { + +void deleteOwnedPtr(HBITMAP ptr) +{ + if (ptr) + DeleteObject(ptr); +} + +void deleteOwnedPtr(HBRUSH ptr) +{ + if (ptr) + DeleteObject(ptr); +} + +void deleteOwnedPtr(HFONT ptr) +{ + if (ptr) + DeleteObject(ptr); +} + +void deleteOwnedPtr(HPALETTE ptr) +{ + if (ptr) + DeleteObject(ptr); +} + +void deleteOwnedPtr(HPEN ptr) +{ + if (ptr) + DeleteObject(ptr); +} + +void deleteOwnedPtr(HRGN ptr) +{ + if (ptr) + DeleteObject(ptr); +} + +} diff --git a/wtf/PassRefPtr.h b/wtf/PassRefPtr.h new file mode 100644 index 0000000..25b9906 --- /dev/null +++ b/wtf/PassRefPtr.h @@ -0,0 +1,193 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_PassRefPtr_h +#define WTF_PassRefPtr_h + +#include "AlwaysInline.h" + +namespace WTF { + + template class RefPtr; + template class PassRefPtr; + template PassRefPtr adoptRef(T*); + + template class PassRefPtr { + public: + PassRefPtr() : m_ptr(0) {} + PassRefPtr(T* ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); } + // It somewhat breaks the type system to allow transfer of ownership out of + // a const PassRefPtr. However, it makes it much easier to work with PassRefPtr + // temporaries, and we don't really have a need to use real const PassRefPtrs + // anyway. + PassRefPtr(const PassRefPtr& o) : m_ptr(o.releaseRef()) {} + template PassRefPtr(const PassRefPtr& o) : m_ptr(o.releaseRef()) { } + + ALWAYS_INLINE ~PassRefPtr() { if (T* ptr = m_ptr) ptr->deref(); } + + template + PassRefPtr(const RefPtr& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); } + + T* get() const { return m_ptr; } + + void clear() { if (T* ptr = m_ptr) ptr->deref(); m_ptr = 0; } + T* releaseRef() const { T* tmp = m_ptr; m_ptr = 0; return tmp; } + + T& operator*() const { return *m_ptr; } + T* operator->() const { return m_ptr; } + + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef T* PassRefPtr::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &PassRefPtr::m_ptr : 0; } + + PassRefPtr& operator=(T*); + PassRefPtr& operator=(const PassRefPtr&); + template PassRefPtr& operator=(const PassRefPtr&); + template PassRefPtr& operator=(const RefPtr&); + + friend PassRefPtr adoptRef(T*); + private: + // adopting constructor + PassRefPtr(T* ptr, bool) : m_ptr(ptr) {} + mutable T* m_ptr; + }; + + template template inline PassRefPtr& PassRefPtr::operator=(const RefPtr& o) + { + T* optr = o.get(); + if (optr) + optr->ref(); + T* ptr = m_ptr; + m_ptr = optr; + if (ptr) + ptr->deref(); + return *this; + } + + template inline PassRefPtr& PassRefPtr::operator=(T* optr) + { + if (optr) + optr->ref(); + T* ptr = m_ptr; + m_ptr = optr; + if (ptr) + ptr->deref(); + return *this; + } + + template inline PassRefPtr& PassRefPtr::operator=(const PassRefPtr& ref) + { + T* ptr = m_ptr; + m_ptr = ref.releaseRef(); + if (ptr) + ptr->deref(); + return *this; + } + + template template inline PassRefPtr& PassRefPtr::operator=(const PassRefPtr& ref) + { + T* ptr = m_ptr; + m_ptr = ref.releaseRef(); + if (ptr) + ptr->deref(); + return *this; + } + + template inline bool operator==(const PassRefPtr& a, const PassRefPtr& b) + { + return a.get() == b.get(); + } + + template inline bool operator==(const PassRefPtr& a, const RefPtr& b) + { + return a.get() == b.get(); + } + + template inline bool operator==(const RefPtr& a, const PassRefPtr& b) + { + return a.get() == b.get(); + } + + template inline bool operator==(const PassRefPtr& a, U* b) + { + return a.get() == b; + } + + template inline bool operator==(T* a, const PassRefPtr& b) + { + return a == b.get(); + } + + template inline bool operator!=(const PassRefPtr& a, const PassRefPtr& b) + { + return a.get() != b.get(); + } + + template inline bool operator!=(const PassRefPtr& a, const RefPtr& b) + { + return a.get() != b.get(); + } + + template inline bool operator!=(const RefPtr& a, const PassRefPtr& b) + { + return a.get() != b.get(); + } + + template inline bool operator!=(const PassRefPtr& a, U* b) + { + return a.get() != b; + } + + template inline bool operator!=(T* a, const PassRefPtr& b) + { + return a != b.get(); + } + + template inline PassRefPtr adoptRef(T* p) + { + return PassRefPtr(p, true); + } + + template inline PassRefPtr static_pointer_cast(const PassRefPtr& p) + { + return adoptRef(static_cast(p.releaseRef())); + } + + template inline PassRefPtr const_pointer_cast(const PassRefPtr& p) + { + return adoptRef(const_cast(p.releaseRef())); + } + + template inline T* getPtr(const PassRefPtr& p) + { + return p.get(); + } + +} // namespace WTF + +using WTF::PassRefPtr; +using WTF::adoptRef; +using WTF::static_pointer_cast; +using WTF::const_pointer_cast; + +#endif // WTF_PassRefPtr_h diff --git a/wtf/Platform.h b/wtf/Platform.h new file mode 100644 index 0000000..c230933 --- /dev/null +++ b/wtf/Platform.h @@ -0,0 +1,309 @@ +/* -*- mode: c++; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_Platform_h +#define WTF_Platform_h + +/* PLATFORM handles OS, operating environment, graphics API, and CPU */ +#define PLATFORM(WTF_FEATURE) (defined( WTF_PLATFORM_##WTF_FEATURE ) && WTF_PLATFORM_##WTF_FEATURE) +#define COMPILER(WTF_FEATURE) (defined( WTF_COMPILER_##WTF_FEATURE ) && WTF_COMPILER_##WTF_FEATURE) +#define HAVE(WTF_FEATURE) (defined( HAVE_##WTF_FEATURE ) && HAVE_##WTF_FEATURE) +#define USE(WTF_FEATURE) (defined( WTF_USE_##WTF_FEATURE ) && WTF_USE_##WTF_FEATURE) +#define ENABLE(WTF_FEATURE) (defined( ENABLE_##WTF_FEATURE ) && ENABLE_##WTF_FEATURE) + +/* Operating systems - low-level dependencies */ + +/* PLATFORM(DARWIN) */ +/* Operating system level dependencies for Mac OS X / Darwin that should */ +/* be used regardless of operating environment */ +#ifdef __APPLE__ +#define WTF_PLATFORM_DARWIN 1 +#endif + +/* PLATFORM(WIN_OS) */ +/* Operating system level dependencies for Windows that should be used */ +/* regardless of operating environment */ +#if defined(WIN32) || defined(_WIN32) +#define WTF_PLATFORM_WIN_OS 1 +#endif + +/* PLATFORM(FREEBSD) */ +/* Operating system level dependencies for FreeBSD-like systems that */ +/* should be used regardless of operating environment */ +#ifdef __FreeBSD__ +#define WTF_PLATFORM_FREEBSD 1 +#endif + +/* PLATFORM(SOLARIS) */ +/* Operating system level dependencies for Solaris that should be used */ +/* regardless of operating environment */ +#if defined(sun) || defined(__sun) +#define WTF_PLATFORM_SOLARIS 1 +#endif + +/* PLATFORM(UNIX) */ +/* Operating system level dependencies for Unix-like systems that */ +/* should be used regardless of operating environment */ +#if PLATFORM(DARWIN) \ + || PLATFORM(FREEBSD) \ + || defined(unix) \ + || defined(__unix) \ + || defined(__unix__) \ + || defined (__NetBSD__) \ + || defined(_AIX) +#define WTF_PLATFORM_UNIX 1 +#endif + +/* Operating environments */ + +/* PLATFORM(QT) */ +/* PLATFORM(GTK) */ +/* PLATFORM(MAC) */ +/* PLATFORM(WIN) */ +#if defined(BUILDING_QT__) +#define WTF_PLATFORM_QT 1 + +/* PLATFORM(KDE) */ +#if defined(BUILDING_KDE__) +#define WTF_PLATFORM_KDE 1 +#endif + +#elif defined(BUILDING_WX__) +#define WTF_PLATFORM_WX 1 +#elif defined(BUILDING_GTK__) +#define WTF_PLATFORM_GTK 1 +#elif PLATFORM(DARWIN) +#define WTF_PLATFORM_MAC 1 +#elif PLATFORM(WIN_OS) +#define WTF_PLATFORM_WIN 1 +#endif + +/* Graphics engines */ + +/* PLATFORM(CG) */ +/* PLATFORM(CAIRO) */ +#if PLATFORM(MAC) +#define WTF_PLATFORM_CG 1 +#define WTF_PLATFORM_CI 1 +#elif !PLATFORM(QT) && !PLATFORM(WX) +#define WTF_PLATFORM_CAIRO 1 +#endif + + +#ifdef __S60__ +// we are cross-compiling, it is not really windows +#undef WTF_PLATFORM_WIN_OS +#undef WTF_PLATFORM_WIN +#undef WTF_PLATFORM_CAIRO +#define WTF_PLATFORM_S60 1 +#define WTF_PLATFORM_SYMBIAN 1 +#endif + +/* CPU */ + +/* PLATFORM(PPC) */ +#if defined(__ppc__) \ + || defined(__PPC__) \ + || defined(__powerpc__) \ + || defined(__powerpc) \ + || defined(__POWERPC__) \ + || defined(_M_PPC) \ + || defined(__PPC) +#define WTF_PLATFORM_PPC 1 +#define WTF_PLATFORM_BIG_ENDIAN 1 +#endif + +/* PLATFORM(PPC64) */ +#if defined(__ppc64__) \ + || defined(__PPC64__) +#define WTF_PLATFORM_PPC64 1 +#define WTF_PLATFORM_BIG_ENDIAN 1 +#endif + +/* PLATFORM(ARM) */ +#if defined(arm) \ + || defined(__arm__) +#define WTF_PLATFORM_ARM 1 +#if defined(__ARMEB__) +#define WTF_PLATFORM_BIG_ENDIAN 1 +#elif !defined(__ARM_EABI__) && !defined(__ARMEB__) && !defined(__ARMEL__) +#define WTF_PLATFORM_MIDDLE_ENDIAN 1 +#endif +#if !defined(__ARM_EABI__) +#define WTF_PLATFORM_FORCE_PACK 1 +#endif +#endif + +/* PLATFORM(X86) */ +#if defined(__i386__) \ + || defined(i386) \ + || defined(_M_IX86) \ + || defined(_X86_) \ + || defined(__THW_INTEL) +#define WTF_PLATFORM_X86 1 +#endif + +/* PLATFORM(X86_64) */ +#if defined(__x86_64__) \ + || defined(__ia64__) \ + || defined(_M_X64) +#define WTF_PLATFORM_X86_64 1 +#endif + +/* PLATFORM(MAC) */ +#if PLATFORM(DARWIN) +#define WTF_PLATFORM_CG 1 +#define WTF_PLATFORM_MAC 1 +#include +#endif + +/* PLATFORM(IPHONE) */ +#if TARGET_OS_EMBEDDED || TARGET_OS_IPHONE +#define WTF_PLATFORM_IPHONE 1 +#endif + +/* PLATFORM(IPHONE_SIMULATOR) */ +#if TARGET_IPHONE_SIMULATOR +#define WTF_PLATFORM_IPHONE 1 +#define WTF_PLATFORM_IPHONE_SIMULATOR 1 +#else +#define WTF_PLATFORM_IPHONE_SIMULATOR 0 +#endif + +/* Compiler */ + +/* COMPILER(MSVC) */ +#if defined(_MSC_VER) +#define WTF_COMPILER_MSVC 1 +#if _MSC_VER < 1400 +#define WTF_COMPILER_MSVC7 1 +#endif +#endif + +/* COMPILER(GCC) */ +#if defined(__GNUC__) +#define WTF_COMPILER_GCC 1 +#endif + +/* COMPILER(BORLAND) */ +/* not really fully supported - is this relevant any more? */ +#if defined(__BORLANDC__) +#define WTF_COMPILER_BORLAND 1 +#endif + +/* COMPILER(CYGWIN) */ +/* not really fully supported - is this relevant any more? */ +#if defined(__CYGWIN__) +#define WTF_COMPILER_CYGWIN 1 +#endif + +/* multiple threads only supported on Mac for now */ +#define WTF_USE_MULTIPLE_THREADS 1 + +/* for Unicode, KDE uses Qt, everything else uses ICU */ +#if PLATFORM(KDE) || PLATFORM(QT) +#define WTF_USE_QT4_UNICODE 1 +#elif PLATFORM(SYMBIAN) +#define WTF_USE_SYMBIAN_UNICODE 1 +#else +#define WTF_USE_ICU_UNICODE 1 +#endif + +#if PLATFORM(IPHONE_SIMULATOR) +#define ENABLE_WEB_SCRIPT_DEBUG_SERVER 1 +#else +#define ENABLE_WEB_SCRIPT_DEBUG_SERVER 0 +#endif + +#define WTF_PLATFORM_CF 1 +#define WTF_USE_PTHREADS 1 + +#define ENABLE_FTPDIR 1 +#define ENABLE_JAVA_BINDINGS 0 +#define ENABLE_ICONDATABASE 0 +#define ENABLE_NETSCAPE_API 0 +#define ENABLE_TOUCH_EVENTS 1 +#define ENABLE_DASHBOARD_SUPPORT 0 +#define ENABLE_IPHONE_PPT 1 + +#if !defined(WTF_PLATFORM_IPHONE) +#define WTF_PLATFORM_IPHONE 0 +#endif + +#if PLATFORM(DARWIN) && defined(__LP64__) +#define ENABLE_NETSCAPE_API 0 +#endif + +#if PLATFORM(WIN) +#define WTF_USE_WININET 1 +#endif + +#if PLATFORM(WX) +#define WTF_USE_CURL 1 +#define WTF_USE_PTHREADS 1 +#endif + +#if PLATFORM(QT) +#define USE_SYSTEM_MALLOC 1 +#endif + +#if !defined(ENABLE_FTPDIR) +#define ENABLE_FTPDIR 1 +#endif + +#if !defined(ENABLE_JAVA_BINDINGS) +#define ENABLE_JAVA_BINDINGS 1 +#endif + +#if !defined(ENABLE_ICONDATABASE) +#define ENABLE_ICONDATABASE 1 +#endif + +#if !defined(ENABLE_DATABASE) +#define ENABLE_DATABASE 1 +#endif + +#if !defined(ENABLE_FTPDIR) +#define ENABLE_FTPDIR 1 +#endif + +#if !defined(ENABLE_NETSCAPE_API) +#define ENABLE_NETSCAPE_API 1 +#endif + +#if !defined(ENABLE_TOUCH_EVENTS) +#define ENABLE_TOUCH_EVENTS 0 +#endif + +#if !defined(ENABLE_DASHBOARD_SUPPORT) +#define ENABLE_DASHBOARD_SUPPORT 1 +#endif + +#if !defined(ENABLE_IPHONE_PPT) +#define ENABLE_IPHONE_PPT 0 +#endif + +#endif /* WTF_Platform_h */ diff --git a/wtf/RefCounted.h b/wtf/RefCounted.h new file mode 100644 index 0000000..dc93b11 --- /dev/null +++ b/wtf/RefCounted.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef RefCounted_h +#define RefCounted_h + +#include +#include + +namespace WTF { + +template class RefCounted : Noncopyable { +public: + RefCounted(int initialRefCount = 0) + : m_refCount(initialRefCount) +#ifndef NDEBUG + , m_deletionHasBegun(false) +#endif + { + } + + void ref() + { + ASSERT(!m_deletionHasBegun); + ++m_refCount; + } + + void deref() + { + ASSERT(!m_deletionHasBegun); + ASSERT(m_refCount > 0); + if (m_refCount == 1) { +#ifndef NDEBUG + m_deletionHasBegun = true; +#endif + delete static_cast(this); + } else + --m_refCount; + } + + bool hasOneRef() + { + ASSERT(!m_deletionHasBegun); + return m_refCount == 1; + } + + int refCount() const + { + return m_refCount; + } + +private: + int m_refCount; +#ifndef NDEBUG + bool m_deletionHasBegun; +#endif +}; + +} // namespace WTF + +using WTF::RefCounted; + +#endif // RefCounted_h diff --git a/wtf/RefPtr.h b/wtf/RefPtr.h new file mode 100644 index 0000000..d43a071 --- /dev/null +++ b/wtf/RefPtr.h @@ -0,0 +1,194 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_RefPtr_h +#define WTF_RefPtr_h + +#include +#include "AlwaysInline.h" + +namespace WTF { + + enum PlacementNewAdoptType { PlacementNewAdopt }; + + template class PassRefPtr; + + template class RefPtr { + public: + RefPtr() : m_ptr(0) {} + RefPtr(T* ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); } + RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { if (T* ptr = m_ptr) ptr->ref(); } + // see comment in PassRefPtr.h for why this takes const reference + template RefPtr(const PassRefPtr&); + + // Special constructor for cases where we overwrite an object in place. + RefPtr(PlacementNewAdoptType) { } + + ~RefPtr() { if (T* ptr = m_ptr) ptr->deref(); } + + template RefPtr(const RefPtr& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); } + + T* get() const { return m_ptr; } + + void clear() { if (T* ptr = m_ptr) ptr->deref(); m_ptr = 0; } + PassRefPtr release() { PassRefPtr tmp = adoptRef(m_ptr); m_ptr = 0; return tmp; } + + T& operator*() const { return *m_ptr; } + ALWAYS_INLINE T *operator->() const { return m_ptr; } + + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef T* RefPtr::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &RefPtr::m_ptr : 0; } + + RefPtr& operator=(const RefPtr&); + RefPtr& operator=(T*); + RefPtr& operator=(const PassRefPtr&); + template RefPtr& operator=(const RefPtr&); + template RefPtr& operator=(const PassRefPtr&); + + void swap(RefPtr&); + + private: + T* m_ptr; + }; + + template template inline RefPtr::RefPtr(const PassRefPtr& o) + : m_ptr(o.releaseRef()) + { + } + + template inline RefPtr& RefPtr::operator=(const RefPtr& o) + { + T* optr = o.get(); + if (optr) + optr->ref(); + T* ptr = m_ptr; + m_ptr = optr; + if (ptr) + ptr->deref(); + return *this; + } + + template template inline RefPtr& RefPtr::operator=(const RefPtr& o) + { + T* optr = o.get(); + if (optr) + optr->ref(); + T* ptr = m_ptr; + m_ptr = optr; + if (ptr) + ptr->deref(); + return *this; + } + + template inline RefPtr& RefPtr::operator=(T* optr) + { + if (optr) + optr->ref(); + T* ptr = m_ptr; + m_ptr = optr; + if (ptr) + ptr->deref(); + return *this; + } + + template inline RefPtr& RefPtr::operator=(const PassRefPtr& o) + { + T* ptr = m_ptr; + m_ptr = o.releaseRef(); + if (ptr) + ptr->deref(); + return *this; + } + + template template inline RefPtr& RefPtr::operator=(const PassRefPtr& o) + { + T* ptr = m_ptr; + m_ptr = o.releaseRef(); + if (ptr) + ptr->deref(); + return *this; + } + + template inline void RefPtr::swap(RefPtr& o) + { + std::swap(m_ptr, o.m_ptr); + } + + template inline void swap(RefPtr& a, RefPtr& b) + { + a.swap(b); + } + + template inline bool operator==(const RefPtr& a, const RefPtr& b) + { + return a.get() == b.get(); + } + + template inline bool operator==(const RefPtr& a, U* b) + { + return a.get() == b; + } + + template inline bool operator==(T* a, const RefPtr& b) + { + return a == b.get(); + } + + template inline bool operator!=(const RefPtr& a, const RefPtr& b) + { + return a.get() != b.get(); + } + + template inline bool operator!=(const RefPtr& a, U* b) + { + return a.get() != b; + } + + template inline bool operator!=(T* a, const RefPtr& b) + { + return a != b.get(); + } + + template inline RefPtr static_pointer_cast(const RefPtr& p) + { + return RefPtr(static_cast(p.get())); + } + + template inline RefPtr const_pointer_cast(const RefPtr& p) + { + return RefPtr(const_cast(p.get())); + } + + template inline T* getPtr(const RefPtr& p) + { + return p.get(); + } + +} // namespace WTF + +using WTF::RefPtr; +using WTF::static_pointer_cast; +using WTF::const_pointer_cast; + +#endif // WTF_RefPtr_h diff --git a/wtf/RefPtrHashMap.h b/wtf/RefPtrHashMap.h new file mode 100644 index 0000000..0515a24 --- /dev/null +++ b/wtf/RefPtrHashMap.h @@ -0,0 +1,370 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +namespace WTF { + + // This specialization is a direct copy of HashMap, with overloaded functions + // to allow for lookup by pointer instead of RefPtr, avoiding ref-count churn. + + // FIXME: Is there a better way to do this that doesn't just copy HashMap? + + template + class HashMap, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> { + private: + typedef KeyTraitsArg KeyTraits; + typedef MappedTraitsArg MappedTraits; + typedef PairBaseHashTraits ValueTraits; + + public: + typedef typename KeyTraits::TraitType KeyType; + typedef T* RawKeyType; + typedef typename MappedTraits::TraitType MappedType; + typedef typename ValueTraits::TraitType ValueType; + + private: + typedef HashArg HashFunctions; + + typedef typename HashKeyStorageTraits::Hash StorageHashFunctions; + + typedef typename HashKeyStorageTraits::Traits KeyStorageTraits; + typedef typename MappedTraits::StorageTraits MappedStorageTraits; + typedef PairHashTraits ValueStorageTraits; + + typedef typename KeyStorageTraits::TraitType KeyStorageType; + typedef typename MappedStorageTraits::TraitType MappedStorageType; + typedef typename ValueStorageTraits::TraitType ValueStorageType; + + typedef HashTable, + StorageHashFunctions, ValueStorageTraits, KeyStorageTraits> HashTableType; + + public: + typedef HashTableIteratorAdapter iterator; + typedef HashTableConstIteratorAdapter const_iterator; + + HashMap(); + HashMap(const HashMap&); + HashMap& operator=(const HashMap&); + ~HashMap(); + + void swap(HashMap&); + + int size() const; + int capacity() const; + bool isEmpty() const; + + // iterators iterate over pairs of keys and values + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + + iterator find(const KeyType&); + iterator find(RawKeyType); + const_iterator find(const KeyType&) const; + const_iterator find(RawKeyType) const; + bool contains(const KeyType&) const; + bool contains(RawKeyType) const; + MappedType get(const KeyType&) const; + MappedType get(RawKeyType) const; + + // replaces value but not key if key is already present + // return value is a pair of the iterator to the key location, + // and a boolean that's true if a new value was actually added + pair set(const KeyType&, const MappedType&); + pair set(RawKeyType, const MappedType&); + + // does nothing if key is already present + // return value is a pair of the iterator to the key location, + // and a boolean that's true if a new value was actually added + pair add(const KeyType&, const MappedType&); + pair add(RawKeyType, const MappedType&); + + void remove(const KeyType&); + void remove(RawKeyType); + void remove(iterator); + void clear(); + + MappedType take(const KeyType&); // efficient combination of get with remove + MappedType take(RawKeyType); // efficient combination of get with remove + + private: + pair inlineAdd(const KeyType&, const MappedType&); + pair inlineAdd(RawKeyType, const MappedType&); + void refAll(); + void derefAll(); + + HashTableType m_impl; + }; + + template + inline void HashMap, U, V, W, X>::refAll() + { + HashTableRefCounter::refAll(m_impl); + } + + template + inline void HashMap, U, V, W, X>::derefAll() + { + HashTableRefCounter::derefAll(m_impl); + } + + template + inline HashMap, U, V, W, X>::HashMap() + { + } + + template + inline HashMap, U, V, W, X>::HashMap(const HashMap& other) + : m_impl(other.m_impl) + { + refAll(); + } + + template + inline HashMap, U, V, W, X>& HashMap, U, V, W, X>::operator=(const HashMap& other) + { + HashMap tmp(other); + swap(tmp); + return *this; + } + + template + inline void HashMap, U, V, W, X>::swap(HashMap& other) + { + m_impl.swap(other.m_impl); + } + + template + inline HashMap, U, V, W, X>::~HashMap() + { + derefAll(); + } + + template + inline int HashMap, U, V, W, X>::size() const + { + return m_impl.size(); + } + + template + inline int HashMap, U, V, W, X>::capacity() const + { + return m_impl.capacity(); + } + + template + inline bool HashMap, U, V, W, X>::isEmpty() const + { + return m_impl.isEmpty(); + } + + template + inline typename HashMap, U, V, W, X>::iterator HashMap, U, V, W, X>::begin() + { + return m_impl.begin(); + } + + template + inline typename HashMap, U, V, W, X>::iterator HashMap, U, V, W, X>::end() + { + return m_impl.end(); + } + + template + inline typename HashMap, U, V, W, X>::const_iterator HashMap, U, V, W, X>::begin() const + { + return m_impl.begin(); + } + + template + inline typename HashMap, U, V, W, X>::const_iterator HashMap, U, V, W, X>::end() const + { + return m_impl.end(); + } + + template + inline typename HashMap, U, V, W, X>::iterator HashMap, U, V, W, X>::find(const KeyType& key) + { + return m_impl.find(*(const KeyStorageType*)&key); + } + + template + inline typename HashMap, U, V, W, X>::iterator HashMap, U, V, W, X>::find(RawKeyType key) + { + return m_impl.find(*(const KeyStorageType*)&key); + } + + template + inline typename HashMap, U, V, W, X>::const_iterator HashMap, U, V, W, X>::find(const KeyType& key) const + { + return m_impl.find(*(const KeyStorageType*)&key); + } + + template + inline typename HashMap, U, V, W, X>::const_iterator HashMap, U, V, W, X>::find(RawKeyType key) const + { + return m_impl.find(*(const KeyStorageType*)&key); + } + + template + inline bool HashMap, U, V, W, X>::contains(const KeyType& key) const + { + return m_impl.contains(*(const KeyStorageType*)&key); + } + + template + inline bool HashMap, U, V, W, X>::contains(RawKeyType key) const + { + return m_impl.contains(*(const KeyStorageType*)&key); + } + + template + inline pair, U, V, W, X>::iterator, bool> + HashMap, U, V, W, X>::inlineAdd(const KeyType& key, const MappedType& mapped) + { + const bool canReplaceDeletedKey = !KeyTraits::needsDestruction || KeyStorageTraits::needsDestruction; + typedef HashMapTranslator TranslatorType; + return m_impl.template add(key, mapped); + } + + template + inline pair, U, V, W, X>::iterator, bool> + HashMap, U, V, W, X>::inlineAdd(RawKeyType key, const MappedType& mapped) + { + return inlineAdd(*(const KeyType*)&key, mapped); + } + + template + pair, U, V, W, X>::iterator, bool> + HashMap, U, V, W, X>::set(const KeyType& key, const MappedType& mapped) + { + pair result = inlineAdd(key, mapped); + if (!result.second) + // add call above didn't change anything, so set the mapped value + result.first->second = mapped; + return result; + } + + template + pair, U, V, W, X>::iterator, bool> + HashMap, U, V, W, X>::set(RawKeyType key, const MappedType& mapped) + { + pair result = inlineAdd(key, mapped); + if (!result.second) + // add call above didn't change anything, so set the mapped value + result.first->second = mapped; + return result; + } + + template + pair, U, V, W, X>::iterator, bool> + HashMap, U, V, W, X>::add(const KeyType& key, const MappedType& mapped) + { + return inlineAdd(key, mapped); + } + + template + pair, U, V, W, X>::iterator, bool> + HashMap, U, V, W, X>::add(RawKeyType key, const MappedType& mapped) + { + return inlineAdd(key, mapped); + } + + template + typename HashMap, U, V, W, MappedTraits>::MappedType + HashMap, U, V, W, MappedTraits>::get(const KeyType& key) const + { + if (m_impl.isEmpty()) + return MappedTraits::emptyValue(); + ValueStorageType* entry = const_cast(m_impl).lookup(*(const KeyStorageType*)&key); + if (!entry) + return MappedTraits::emptyValue(); + return ((ValueType *)entry)->second; + } + + template + typename HashMap, U, V, W, MappedTraits>::MappedType + HashMap, U, V, W, MappedTraits>::get(RawKeyType key) const + { + if (m_impl.isEmpty()) + return MappedTraits::emptyValue(); + ValueStorageType* entry = const_cast(m_impl).lookup(*(const KeyStorageType*)&key); + if (!entry) + return MappedTraits::emptyValue(); + return ((ValueType *)entry)->second; + } + + template + inline void HashMap, U, V, W, X>::remove(iterator it) + { + if (it.m_impl == m_impl.end()) + return; + m_impl.checkTableConsistency(); + RefCounter::deref(*it.m_impl); + m_impl.removeWithoutEntryConsistencyCheck(it.m_impl); + } + + template + inline void HashMap, U, V, W, X>::remove(const KeyType& key) + { + remove(find(key)); + } + + template + inline void HashMap, U, V, W, X>::remove(RawKeyType key) + { + remove(find(key)); + } + + template + inline void HashMap, U, V, W, X>::clear() + { + derefAll(); + m_impl.clear(); + } + + template + typename HashMap, U, V, W, MappedTraits>::MappedType + HashMap, U, V, W, MappedTraits>::take(const KeyType& key) + { + // This can probably be made more efficient to avoid ref/deref churn. + iterator it = find(key); + if (it == end()) + return MappedTraits::emptyValue(); + typename HashMap, U, V, W, MappedTraits>::MappedType result = it->second; + remove(it); + return result; + } + + template + typename HashMap, U, V, W, MappedTraits>::MappedType + HashMap, U, V, W, MappedTraits>::take(RawKeyType key) + { + // This can probably be made more efficient to avoid ref/deref churn. + iterator it = find(key); + if (it == end()) + return MappedTraits::emptyValue(); + typename HashMap, U, V, W, MappedTraits>::MappedType result = it->second; + remove(it); + return result; + } + +} // namespace WTF diff --git a/wtf/RetainPtr.h b/wtf/RetainPtr.h new file mode 100644 index 0000000..71260eb --- /dev/null +++ b/wtf/RetainPtr.h @@ -0,0 +1,212 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2005, 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef RetainPtr_h +#define RetainPtr_h + +#include +#include + +#ifdef __OBJC__ +#import +#endif + +namespace WTF { + + template struct RemovePointer { + typedef T type; + }; + + template struct RemovePointer { + typedef T type; + }; + + // Unlike most most of our smart pointers, RetainPtr can take either the pointer type or the pointed-to type, + // so both RetainPtr and RetainPtr will work. + + enum AdoptCFTag { AdoptCF }; + enum AdoptNSTag { AdoptNS }; + +#ifdef __OBJC__ + inline void adoptNSReference(id ptr) + { + if (ptr) { + CFRetain(ptr); + [ptr release]; + } + } +#endif + + template class RetainPtr { + public: + typedef typename RemovePointer::type ValueType; + typedef ValueType* PtrType; + + RetainPtr() : m_ptr(0) {} + RetainPtr(PtrType ptr) : m_ptr(ptr) { if (ptr) CFRetain(ptr); } + + RetainPtr(AdoptCFTag, PtrType ptr) : m_ptr(ptr) { } + RetainPtr(AdoptNSTag, PtrType ptr) : m_ptr(ptr) { adoptNSReference(ptr); } + + RetainPtr(const RetainPtr& o) : m_ptr(o.m_ptr) { if (PtrType ptr = m_ptr) CFRetain(ptr); } + + ~RetainPtr() { if (PtrType ptr = m_ptr) CFRelease(ptr); } + + template RetainPtr(const RetainPtr& o) : m_ptr(o.get()) { if (PtrType ptr = m_ptr) CFRetain(ptr); } + + PtrType get() const { return m_ptr; } + + PtrType releaseRef() { PtrType tmp = m_ptr; m_ptr = 0; return tmp; } + + PtrType operator->() const { return m_ptr; } + + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef PtrType RetainPtr::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &RetainPtr::m_ptr : 0; } + + RetainPtr& operator=(const RetainPtr&); + template RetainPtr& operator=(const RetainPtr&); + RetainPtr& operator=(PtrType); + template RetainPtr& operator=(U*); + + void adoptCF(PtrType); + void adoptNS(PtrType); + + void swap(RetainPtr&); + + private: + PtrType m_ptr; + }; + + template inline RetainPtr& RetainPtr::operator=(const RetainPtr& o) + { + PtrType optr = o.get(); + if (optr) + CFRetain(optr); + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + CFRelease(ptr); + return *this; + } + + template template inline RetainPtr& RetainPtr::operator=(const RetainPtr& o) + { + PtrType optr = o.get(); + if (optr) + CFRetain(optr); + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + CFRelease(ptr); + return *this; + } + + template inline RetainPtr& RetainPtr::operator=(PtrType optr) + { + if (optr) + CFRetain(optr); + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + CFRelease(ptr); + return *this; + } + + template inline void RetainPtr::adoptCF(PtrType optr) + { + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + CFRelease(ptr); + } + + template inline void RetainPtr::adoptNS(PtrType optr) + { + adoptNSReference(optr); + + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + CFRelease(ptr); + } + + template template inline RetainPtr& RetainPtr::operator=(U* optr) + { + if (optr) + CFRetain(optr); + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + CFRelease(ptr); + return *this; + } + + template inline void RetainPtr::swap(RetainPtr& o) + { + std::swap(m_ptr, o.m_ptr); + } + + template inline void swap(RetainPtr& a, RetainPtr& b) + { + a.swap(b); + } + + template inline bool operator==(const RetainPtr& a, const RetainPtr& b) + { + return a.get() == b.get(); + } + + template inline bool operator==(const RetainPtr& a, U* b) + { + return a.get() == b; + } + + template inline bool operator==(T* a, const RetainPtr& b) + { + return a == b.get(); + } + + template inline bool operator!=(const RetainPtr& a, const RetainPtr& b) + { + return a.get() != b.get(); + } + + template inline bool operator!=(const RetainPtr& a, U* b) + { + return a.get() != b; + } + + template inline bool operator!=(T* a, const RetainPtr& b) + { + return a != b.get(); + } + +} // namespace WTF + +using WTF::AdoptCF; +using WTF::AdoptNS; +using WTF::RetainPtr; + +#endif // WTF_RetainPtr_h diff --git a/wtf/StringExtras.h b/wtf/StringExtras.h new file mode 100644 index 0000000..ca1c20c --- /dev/null +++ b/wtf/StringExtras.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_StringExtras_h +#define WTF_StringExtras_h + +#include +#include + +#if COMPILER(MSVC) + +inline int snprintf(char *str, size_t size, const char* format, ...) +{ + int result; + va_list args; + va_start(args, format); + result = _vsnprintf(str, size, format, args); + va_end(args); + return result; +} + +#if COMPILER(MSVC7) +// MSVC8 and above define this function +#define vsnprintf snprintf +#endif + +inline int strncasecmp(const char* s1, const char* s2, size_t len) { return strnicmp(s1, s2, len); } + +#endif + +#endif // WTF_StringExtras_h diff --git a/wtf/TCPackedCache.h b/wtf/TCPackedCache.h new file mode 100644 index 0000000..0464f8f --- /dev/null +++ b/wtf/TCPackedCache.h @@ -0,0 +1,234 @@ +// Copyright (c) 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- +// Author: Geoff Pike +// +// This file provides a minimal cache that can hold a pair +// with little if any wasted space. The types of the key and value +// must be unsigned integral types or at least have unsigned semantics +// for >>, casting, and similar operations. +// +// Synchronization is not provided. However, the cache is implemented +// as an array of cache entries whose type is chosen at compile time. +// If a[i] is atomic on your hardware for the chosen array type then +// raciness will not necessarily lead to bugginess. The cache entries +// must be large enough to hold a partial key and a value packed +// together. The partial keys are bit strings of length +// kKeybits - kHashbits, and the values are bit strings of length kValuebits. +// +// In an effort to use minimal space, every cache entry represents +// some pair; the class provides no way to mark a cache +// entry as empty or uninitialized. In practice, you may want to have +// reserved keys or values to get around this limitation. For example, in +// tcmalloc's PageID-to-sizeclass cache, a value of 0 is used as +// "unknown sizeclass." +// +// Usage Considerations +// -------------------- +// +// kHashbits controls the size of the cache. The best value for +// kHashbits will of course depend on the application. Perhaps try +// tuning the value of kHashbits by measuring different values on your +// favorite benchmark. Also remember not to be a pig; other +// programs that need resources may suffer if you are. +// +// The main uses for this class will be when performance is +// critical and there's a convenient type to hold the cache's +// entries. As described above, the number of bits required +// for a cache entry is (kKeybits - kHashbits) + kValuebits. Suppose +// kKeybits + kValuebits is 43. Then it probably makes sense to +// chose kHashbits >= 11 so that cache entries fit in a uint32. +// +// On the other hand, suppose kKeybits = kValuebits = 64. Then +// using this class may be less worthwhile. You'll probably +// be using 128 bits for each entry anyway, so maybe just pick +// a hash function, H, and use an array indexed by H(key): +// void Put(K key, V value) { a_[H(key)] = pair(key, value); } +// V GetOrDefault(K key, V default) { const pair &p = a_[H(key)]; ... } +// etc. +// +// Further Details +// --------------- +// +// For caches used only by one thread, the following is true: +// 1. For a cache c, +// (c.Put(key, value), c.GetOrDefault(key, 0)) == value +// and +// (c.Put(key, value), <...>, c.GetOrDefault(key, 0)) == value +// if the elided code contains no c.Put calls. +// +// 2. Has(key) will return false if no pair with that key +// has ever been Put. However, a newly initialized cache will have +// some pairs already present. When you create a new +// cache, you must specify an "initial value." The initialization +// procedure is equivalent to Clear(initial_value), which is +// equivalent to Put(k, initial_value) for all keys k from 0 to +// 2^kHashbits - 1. +// +// 3. If key and key' differ then the only way Put(key, value) may +// cause Has(key') to change is that Has(key') may change from true to +// false. Furthermore, a Put() call that doesn't change Has(key') +// doesn't change GetOrDefault(key', ...) either. +// +// Implementation details: +// +// This is a direct-mapped cache with 2^kHashbits entries; +// the hash function simply takes the low bits of the key. +// So, we don't have to store the low bits of the key in the entries. +// Instead, an entry is the high bits of a key and a value, packed +// together. E.g., a 20 bit key and a 7 bit value only require +// a uint16 for each entry if kHashbits >= 11. +// +// Alternatives to this scheme will be added as needed. + +#ifndef TCMALLOC_PACKED_CACHE_INL_H__ +#define TCMALLOC_PACKED_CACHE_INL_H__ + +#ifndef WTF_CHANGES +#include "base/basictypes.h" // for COMPILE_ASSERT +#include "base/logging.h" // for DCHECK +#endif + +#ifndef DCHECK_EQ +#define DCHECK_EQ(val1, val2) ASSERT((val1) == (val2)) +#endif + +// A safe way of doing "(1 << n) - 1" -- without worrying about overflow +// Note this will all be resolved to a constant expression at compile-time +#define N_ONES_(IntType, N) \ + ( (N) == 0 ? 0 : ((static_cast(1) << ((N)-1))-1 + \ + (static_cast(1) << ((N)-1))) ) + +// The types K and V provide upper bounds on the number of valid keys +// and values, but we explicitly require the keys to be less than +// 2^kKeybits and the values to be less than 2^kValuebits. The size of +// the table is controlled by kHashbits, and the type of each entry in +// the cache is T. See also the big comment at the top of the file. +template +class PackedCache { + public: + typedef uintptr_t K; + typedef size_t V; + static const size_t kHashbits = 12; + static const size_t kValuebits = 8; + + explicit PackedCache(V initial_value) { + COMPILE_ASSERT(kKeybits <= sizeof(K) * 8, key_size); + COMPILE_ASSERT(kValuebits <= sizeof(V) * 8, value_size); + COMPILE_ASSERT(kHashbits <= kKeybits, hash_function); + COMPILE_ASSERT(kKeybits - kHashbits + kValuebits <= kTbits, + entry_size_must_be_big_enough); + Clear(initial_value); + } + + void Put(K key, V value) { + DCHECK_EQ(key, key & kKeyMask); + DCHECK_EQ(value, value & kValueMask); + array_[Hash(key)] = static_cast(KeyToUpper(key) | value); + } + + bool Has(K key) const { + DCHECK_EQ(key, key & kKeyMask); + return KeyMatch(array_[Hash(key)], key); + } + + V GetOrDefault(K key, V default_value) const { + // As with other code in this class, we touch array_ as few times + // as we can. Assuming entries are read atomically (e.g., their + // type is uintptr_t on most hardware) then certain races are + // harmless. + DCHECK_EQ(key, key & kKeyMask); + T entry = array_[Hash(key)]; + return KeyMatch(entry, key) ? EntryToValue(entry) : default_value; + } + + void Clear(V value) { + DCHECK_EQ(value, value & kValueMask); + for (int i = 0; i < 1 << kHashbits; i++) { + array_[i] = static_cast(value); + } + } + + private: + // We are going to pack a value and the upper part of a key into + // an entry of type T. The UPPER type is for the upper part of a key, + // after the key has been masked and shifted for inclusion in an entry. + typedef T UPPER; + + static V EntryToValue(T t) { return t & kValueMask; } + + static UPPER EntryToUpper(T t) { return t & kUpperMask; } + + // If v is a V and u is an UPPER then you can create an entry by + // doing u | v. kHashbits determines where in a K to find the upper + // part of the key, and kValuebits determines where in the entry to put + // it. + static UPPER KeyToUpper(K k) { + const int shift = kHashbits - kValuebits; + // Assume kHashbits >= kValuebits. It would be easy to lift this assumption. + return static_cast(k >> shift) & kUpperMask; + } + + // This is roughly the inverse of KeyToUpper(). Some of the key has been + // thrown away, since KeyToUpper() masks off the low bits of the key. + static K UpperToPartialKey(UPPER u) { + DCHECK_EQ(u, u & kUpperMask); + const int shift = kHashbits - kValuebits; + // Assume kHashbits >= kValuebits. It would be easy to lift this assumption. + return static_cast(u) << shift; + } + + static size_t Hash(K key) { + return static_cast(key) & N_ONES_(size_t, kHashbits); + } + + // Does the entry's partial key match the relevant part of the given key? + static bool KeyMatch(T entry, K key) { + return ((KeyToUpper(key) ^ entry) & kUpperMask) == 0; + } + + static const size_t kTbits = 8 * sizeof(T); + static const int kUpperbits = kKeybits - kHashbits; + + // For masking a K. + static const K kKeyMask = N_ONES_(K, kKeybits); + + // For masking a T. + static const T kUpperMask = N_ONES_(T, kUpperbits) << kValuebits; + + // For masking a V or a T. + static const V kValueMask = N_ONES_(V, kValuebits); + + T array_[1 << kHashbits]; +}; + +#undef N_ONES_ + +#endif // TCMALLOC_PACKED_CACHE_INL_H__ diff --git a/wtf/TCPageMap.h b/wtf/TCPageMap.h new file mode 100644 index 0000000..21a87e4 --- /dev/null +++ b/wtf/TCPageMap.h @@ -0,0 +1,289 @@ +// Copyright (c) 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- +// Author: Sanjay Ghemawat +// +// A data structure used by the caching malloc. It maps from page# to +// a pointer that contains info about that page. We use two +// representations: one for 32-bit addresses, and another for 64 bit +// addresses. Both representations provide the same interface. The +// first representation is implemented as a flat array, the seconds as +// a three-level radix tree that strips away approximately 1/3rd of +// the bits every time. +// +// The BITS parameter should be the number of bits required to hold +// a page number. E.g., with 32 bit pointers and 4K pages (i.e., +// page offset fits in lower 12 bits), BITS == 20. + +#ifndef TCMALLOC_PAGEMAP_H__ +#define TCMALLOC_PAGEMAP_H__ + +#if HAVE(STDINT_H) +#include +#elif HAVE(INTTYPES_H) +#include +#else +#include +#endif + +#include + +#include "Assertions.h" + +// Single-level array +template +class TCMalloc_PageMap1 { + private: + void** array_; + + public: + typedef uintptr_t Number; + + void init(void* (*allocator)(size_t)) { + array_ = reinterpret_cast((*allocator)(sizeof(void*) << BITS)); + memset(array_, 0, sizeof(void*) << BITS); + } + + // Ensure that the map contains initialized entries "x .. x+n-1". + // Returns true if successful, false if we could not allocate memory. + bool Ensure(Number x, size_t n) { + // Nothing to do since flat array was allocate at start + return true; + } + + void PreallocateMoreMemory() {} + + // REQUIRES "k" is in range "[0,2^BITS-1]". + // REQUIRES "k" has been ensured before. + // + // Return the current value for KEY. Returns "Value()" if not + // yet set. + void* get(Number k) const { + return array_[k]; + } + + // REQUIRES "k" is in range "[0,2^BITS-1]". + // REQUIRES "k" has been ensured before. + // + // Sets the value for KEY. + void set(Number k, void* v) { + array_[k] = v; + } +}; + +// Two-level radix tree +template +class TCMalloc_PageMap2 { + private: + // Put 32 entries in the root and (2^BITS)/32 entries in each leaf. + static const int ROOT_BITS = 5; + static const int ROOT_LENGTH = 1 << ROOT_BITS; + + static const int LEAF_BITS = BITS - ROOT_BITS; + static const int LEAF_LENGTH = 1 << LEAF_BITS; + + // Leaf node + struct Leaf { + void* values[LEAF_LENGTH]; + }; + + Leaf* root_[ROOT_LENGTH]; // Pointers to 32 child nodes + void* (*allocator_)(size_t); // Memory allocator + + public: + typedef uintptr_t Number; + + void init(void* (*allocator)(size_t)) { + allocator_ = allocator; + memset(root_, 0, sizeof(root_)); + } + + void* get(Number k) const { + ASSERT(k >> BITS == 0); + const Number i1 = k >> LEAF_BITS; + const Number i2 = k & (LEAF_LENGTH-1); + return root_[i1]->values[i2]; + } + + void set(Number k, void* v) { + ASSERT(k >> BITS == 0); + const Number i1 = k >> LEAF_BITS; + const Number i2 = k & (LEAF_LENGTH-1); + root_[i1]->values[i2] = v; + } + + bool Ensure(Number start, size_t n) { + for (Number key = start; key <= start + n - 1; ) { + const Number i1 = key >> LEAF_BITS; + + // Make 2nd level node if necessary + if (root_[i1] == NULL) { + Leaf* leaf = reinterpret_cast((*allocator_)(sizeof(Leaf))); + if (leaf == NULL) return false; + memset(leaf, 0, sizeof(*leaf)); + root_[i1] = leaf; + } + + // Advance key past whatever is covered by this leaf node + key = ((key >> LEAF_BITS) + 1) << LEAF_BITS; + } + return true; + } + + void PreallocateMoreMemory() { + // Allocate enough to keep track of all possible pages + Ensure(0, 1 << BITS); + } + +#ifdef WTF_CHANGES + template + void visit(const Visitor& visitor, const MemoryReader& reader) + { + for (int i = 0; i < ROOT_LENGTH; i++) { + if (!root_[i]) + continue; + + Leaf* l = reader(reinterpret_cast(root_[i])); + for (int j = 0; j < LEAF_LENGTH; j += visitor.visit(l->values[j])) + ; + } + } +#endif +}; + +// Three-level radix tree +template +class TCMalloc_PageMap3 { + private: + // How many bits should we consume at each interior level + static const int INTERIOR_BITS = (BITS + 2) / 3; // Round-up + static const int INTERIOR_LENGTH = 1 << INTERIOR_BITS; + + // How many bits should we consume at leaf level + static const int LEAF_BITS = BITS - 2*INTERIOR_BITS; + static const int LEAF_LENGTH = 1 << LEAF_BITS; + + // Interior node + struct Node { + Node* ptrs[INTERIOR_LENGTH]; + }; + + // Leaf node + struct Leaf { + void* values[LEAF_LENGTH]; + }; + + Node* root_; // Root of radix tree + void* (*allocator_)(size_t); // Memory allocator + + Node* NewNode() { + Node* result = reinterpret_cast((*allocator_)(sizeof(Node))); + if (result != NULL) { + memset(result, 0, sizeof(*result)); + } + return result; + } + + public: + typedef uintptr_t Number; + + void init(void* (*allocator)(size_t)) { + allocator_ = allocator; + root_ = NewNode(); + } + + void* get(Number k) const { + ASSERT(k >> BITS == 0); + const Number i1 = k >> (LEAF_BITS + INTERIOR_BITS); + const Number i2 = (k >> LEAF_BITS) & (INTERIOR_LENGTH-1); + const Number i3 = k & (LEAF_LENGTH-1); + return reinterpret_cast(root_->ptrs[i1]->ptrs[i2])->values[i3]; + } + + void set(Number k, void* v) { + ASSERT(k >> BITS == 0); + const Number i1 = k >> (LEAF_BITS + INTERIOR_BITS); + const Number i2 = (k >> LEAF_BITS) & (INTERIOR_LENGTH-1); + const Number i3 = k & (LEAF_LENGTH-1); + reinterpret_cast(root_->ptrs[i1]->ptrs[i2])->values[i3] = v; + } + + bool Ensure(Number start, size_t n) { + for (Number key = start; key <= start + n - 1; ) { + const Number i1 = key >> (LEAF_BITS + INTERIOR_BITS); + const Number i2 = (key >> LEAF_BITS) & (INTERIOR_LENGTH-1); + + // Make 2nd level node if necessary + if (root_->ptrs[i1] == NULL) { + Node* n = NewNode(); + if (n == NULL) return false; + root_->ptrs[i1] = n; + } + + // Make leaf node if necessary + if (root_->ptrs[i1]->ptrs[i2] == NULL) { + Leaf* leaf = reinterpret_cast((*allocator_)(sizeof(Leaf))); + if (leaf == NULL) return false; + memset(leaf, 0, sizeof(*leaf)); + root_->ptrs[i1]->ptrs[i2] = reinterpret_cast(leaf); + } + + // Advance key past whatever is covered by this leaf node + key = ((key >> LEAF_BITS) + 1) << LEAF_BITS; + } + return true; + } + + void PreallocateMoreMemory() { + } + +#ifdef WTF_CHANGES + template + void visit(const Visitor& visitor, const MemoryReader& reader) { + Node* root = reader(root_); + for (int i = 0; i < INTERIOR_LENGTH; i++) { + if (!root->ptrs[i]) + continue; + + Node* n = reader(root->ptrs[i]); + for (int j = 0; j < INTERIOR_LENGTH; j++) { + if (!n->ptrs[j]) + continue; + + Leaf* l = reader(reinterpret_cast(n->ptrs[j])); + for (int k = 0; k < LEAF_LENGTH; k += visitor.visit(l->values[k])) + ; + } + } + } +#endif +}; + +#endif // TCMALLOC_PAGEMAP_H__ diff --git a/wtf/TCSpinLock.h b/wtf/TCSpinLock.h new file mode 100644 index 0000000..2bfc14b --- /dev/null +++ b/wtf/TCSpinLock.h @@ -0,0 +1,234 @@ +// Copyright (c) 2005, 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- +// Author: Sanjay Ghemawat + +#ifndef TCMALLOC_INTERNAL_SPINLOCK_H__ +#define TCMALLOC_INTERNAL_SPINLOCK_H__ + +#if (PLATFORM(X86) || PLATFORM(PPC)) && (COMPILER(GCC) || COMPILER(MSVC)) + +#include /* For nanosleep() */ + +#include /* For sched_yield() */ + +#if HAVE(STDINT_H) +#include +#elif HAVE(INTTYPES_H) +#include +#else +#include +#endif +#include /* for abort() */ + +#if COMPILER(MSVC) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#endif + +static void TCMalloc_SlowLock(volatile unsigned int* lockword); + +// The following is a struct so that it can be initialized at compile time +struct TCMalloc_SpinLock { + + inline void Lock() { + int r; +#if COMPILER(GCC) +#if PLATFORM(X86) + __asm__ __volatile__ + ("xchgl %0, %1" + : "=r"(r), "=m"(lockword_) + : "0"(1), "m"(lockword_) + : "memory"); +#else + volatile unsigned int *lockword_ptr = &lockword_; + __asm__ __volatile__ + ("1: lwarx %0, 0, %1\n\t" + "stwcx. %2, 0, %1\n\t" + "bne- 1b\n\t" + "isync" + : "=&r" (r), "=r" (lockword_ptr) + : "r" (1), "1" (lockword_ptr) + : "memory"); +#endif +#elif COMPILER(MSVC) + __asm { + mov eax, this ; store &lockword_ (which is this+0) in eax + mov ebx, 1 ; store 1 in ebx + xchg [eax], ebx ; exchange lockword_ and 1 + mov r, ebx ; store old value of lockword_ in r + } +#endif + if (r) TCMalloc_SlowLock(&lockword_); + } + + inline void Unlock() { +#if COMPILER(GCC) +#if PLATFORM(X86) + __asm__ __volatile__ + ("movl $0, %0" + : "=m"(lockword_) + : "m" (lockword_) + : "memory"); +#else + __asm__ __volatile__ + ("isync\n\t" + "eieio\n\t" + "stw %1, %0" +#if PLATFORM(DARWIN) + : "=o" (lockword_) +#else + : "=m" (lockword_) +#endif + : "r" (0) + : "memory"); +#endif +#elif COMPILER(MSVC) + __asm { + mov eax, this ; store &lockword_ (which is this+0) in eax + mov [eax], 0 ; set lockword_ to 0 + } +#endif + } + // Report if we think the lock can be held by this thread. + // When the lock is truly held by the invoking thread + // we will always return true. + // Indended to be used as CHECK(lock.IsHeld()); + inline bool IsHeld() const { + return lockword_ != 0; + } + + inline void Init() { lockword_ = 0; } + + volatile unsigned int lockword_; +}; + +#define SPINLOCK_INITIALIZER { 0 } + +static void TCMalloc_SlowLock(volatile unsigned int* lockword) { + sched_yield(); // Yield immediately since fast path failed + while (true) { + int r; +#if COMPILER(GCC) +#if PLATFORM(X86) + __asm__ __volatile__ + ("xchgl %0, %1" + : "=r"(r), "=m"(*lockword) + : "0"(1), "m"(*lockword) + : "memory"); + +#else + int tmp = 1; + __asm__ __volatile__ + ("1: lwarx %0, 0, %1\n\t" + "stwcx. %2, 0, %1\n\t" + "bne- 1b\n\t" + "isync" + : "=&r" (r), "=r" (lockword) + : "r" (tmp), "1" (lockword) + : "memory"); +#endif +#elif COMPILER(MSVC) + __asm { + mov eax, lockword ; assign lockword into eax + mov ebx, 1 ; assign 1 into ebx + xchg [eax], ebx ; exchange *lockword and 1 + mov r, ebx ; store old value of *lockword in r + } +#endif + if (!r) { + return; + } + + // This code was adapted from the ptmalloc2 implementation of + // spinlocks which would sched_yield() upto 50 times before + // sleeping once for a few milliseconds. Mike Burrows suggested + // just doing one sched_yield() outside the loop and always + // sleeping after that. This change helped a great deal on the + // performance of spinlocks under high contention. A test program + // with 10 threads on a dual Xeon (four virtual processors) went + // from taking 30 seconds to 16 seconds. + + // Sleep for a few milliseconds +#if COMPILER(MSVC) + Sleep(2); +#else + struct timespec tm; + tm.tv_sec = 0; + tm.tv_nsec = 2000001; + nanosleep(&tm, NULL); +#endif + } +} + +#else + +#include + +// Portable version +struct TCMalloc_SpinLock { + pthread_mutex_t private_lock_; + + inline void Init() { + if (pthread_mutex_init(&private_lock_, NULL) != 0) abort(); + } + inline void Finalize() { + if (pthread_mutex_destroy(&private_lock_) != 0) abort(); + } + inline void Lock() { + if (pthread_mutex_lock(&private_lock_) != 0) abort(); + } + inline void Unlock() { + if (pthread_mutex_unlock(&private_lock_) != 0) abort(); + } +}; + +#define SPINLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER } + +#endif + +// Corresponding locker object that arranges to acquire a spinlock for +// the duration of a C++ scope. +class TCMalloc_SpinLockHolder { + private: + TCMalloc_SpinLock* lock_; + public: + inline explicit TCMalloc_SpinLockHolder(TCMalloc_SpinLock* l) + : lock_(l) { l->Lock(); } + inline ~TCMalloc_SpinLockHolder() { lock_->Unlock(); } +}; + +// Short-hands for convenient use by tcmalloc.cc +typedef TCMalloc_SpinLock SpinLock; +typedef TCMalloc_SpinLockHolder SpinLockHolder; + +#endif // TCMALLOC_INTERNAL_SPINLOCK_H__ diff --git a/wtf/TCSystemAlloc.cpp b/wtf/TCSystemAlloc.cpp new file mode 100644 index 0000000..8140fd3 --- /dev/null +++ b/wtf/TCSystemAlloc.cpp @@ -0,0 +1,436 @@ +// Copyright (c) 2005, 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- +// Author: Sanjay Ghemawat + +#include "config.h" +#if HAVE(STDINT_H) +#include +#elif HAVE(INTTYPES_H) +#include +#else +#include +#endif +#if PLATFORM(WIN_OS) +#include "windows.h" +#else +#include +#include +#include +#endif +#include +#include "Assertions.h" +#include "TCSystemAlloc.h" +#include "TCSpinLock.h" +#include "UnusedParam.h" + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +#if PLATFORM(DARWIN) && defined(VM_MEMORY_TCMALLOC) +static const int mmapFileDescriptor = VM_MAKE_TAG(VM_MEMORY_TCMALLOC); +#else +static const int mmapFileDescriptor = -1; +#endif + +// Structure for discovering alignment +union MemoryAligner { + void* p; + double d; + size_t s; +}; + +static SpinLock spinlock = SPINLOCK_INITIALIZER; + +// Page size is initialized on demand +static size_t pagesize = 0; + +// Configuration parameters. +// +// if use_devmem is true, either use_sbrk or use_mmap must also be true. +// For 2.2 kernels, it looks like the sbrk address space (500MBish) and +// the mmap address space (1300MBish) are disjoint, so we need both allocators +// to get as much virtual memory as possible. +#ifndef WTF_CHANGES +static bool use_devmem = false; +#endif + +#if HAVE(SBRK) +static bool use_sbrk = false; +#endif + +#if HAVE(MMAP) +static bool use_mmap = true; +#endif + +#if HAVE(VIRTUALALLOC) +static bool use_VirtualAlloc = true; +#endif + +// Flags to keep us from retrying allocators that failed. +static bool devmem_failure = false; +static bool sbrk_failure = false; +static bool mmap_failure = false; +static bool VirtualAlloc_failure = false; + +#ifndef WTF_CHANGES +DEFINE_int32(malloc_devmem_start, 0, + "Physical memory starting location in MB for /dev/mem allocation." + " Setting this to 0 disables /dev/mem allocation"); +DEFINE_int32(malloc_devmem_limit, 0, + "Physical memory limit location in MB for /dev/mem allocation." + " Setting this to 0 means no limit."); +#else +static const int32_t FLAGS_malloc_devmem_start = 0; +static const int32_t FLAGS_malloc_devmem_limit = 0; +#endif + +#if HAVE(SBRK) + +static void* TrySbrk(size_t size, size_t *actual_size, size_t alignment) { + size = ((size + alignment - 1) / alignment) * alignment; + + // could theoretically return the "extra" bytes here, but this + // is simple and correct. + if (actual_size) + *actual_size = size; + + void* result = sbrk(size); + if (result == reinterpret_cast(-1)) { + sbrk_failure = true; + return NULL; + } + + // Is it aligned? + uintptr_t ptr = reinterpret_cast(result); + if ((ptr & (alignment-1)) == 0) return result; + + // Try to get more memory for alignment + size_t extra = alignment - (ptr & (alignment-1)); + void* r2 = sbrk(extra); + if (reinterpret_cast(r2) == (ptr + size)) { + // Contiguous with previous result + return reinterpret_cast(ptr + extra); + } + + // Give up and ask for "size + alignment - 1" bytes so + // that we can find an aligned region within it. + result = sbrk(size + alignment - 1); + if (result == reinterpret_cast(-1)) { + sbrk_failure = true; + return NULL; + } + ptr = reinterpret_cast(result); + if ((ptr & (alignment-1)) != 0) { + ptr += alignment - (ptr & (alignment-1)); + } + return reinterpret_cast(ptr); +} + +#endif /* HAVE(SBRK) */ + +#if HAVE(MMAP) + +static void* TryMmap(size_t size, size_t *actual_size, size_t alignment) { + // Enforce page alignment + if (pagesize == 0) pagesize = getpagesize(); + if (alignment < pagesize) alignment = pagesize; + size = ((size + alignment - 1) / alignment) * alignment; + + // could theoretically return the "extra" bytes here, but this + // is simple and correct. + if (actual_size) + *actual_size = size; + + // Ask for extra memory if alignment > pagesize + size_t extra = 0; + if (alignment > pagesize) { + extra = alignment - pagesize; + } + void* result = mmap(NULL, size + extra, + PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS, + mmapFileDescriptor, 0); + if (result == reinterpret_cast(MAP_FAILED)) { + mmap_failure = true; + return NULL; + } + + // Adjust the return memory so it is aligned + uintptr_t ptr = reinterpret_cast(result); + size_t adjust = 0; + if ((ptr & (alignment - 1)) != 0) { + adjust = alignment - (ptr & (alignment - 1)); + } + + // Return the unused memory to the system + if (adjust > 0) { + munmap(reinterpret_cast(ptr), adjust); + } + if (adjust < extra) { + munmap(reinterpret_cast(ptr + adjust + size), extra - adjust); + } + + ptr += adjust; + return reinterpret_cast(ptr); +} + +#endif /* HAVE(MMAP) */ + +#if HAVE(VIRTUALALLOC) + +static void* TryVirtualAlloc(size_t size, size_t *actual_size, size_t alignment) { + // Enforce page alignment + if (pagesize == 0) { + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); + pagesize = system_info.dwPageSize; + } + + if (alignment < pagesize) alignment = pagesize; + size = ((size + alignment - 1) / alignment) * alignment; + + // could theoretically return the "extra" bytes here, but this + // is simple and correct. + if (actual_size) + *actual_size = size; + + // Ask for extra memory if alignment > pagesize + size_t extra = 0; + if (alignment > pagesize) { + extra = alignment - pagesize; + } + void* result = VirtualAlloc(NULL, size + extra, + MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE); + + if (result == NULL) { + VirtualAlloc_failure = true; + return NULL; + } + + // Adjust the return memory so it is aligned + uintptr_t ptr = reinterpret_cast(result); + size_t adjust = 0; + if ((ptr & (alignment - 1)) != 0) { + adjust = alignment - (ptr & (alignment - 1)); + } + + // Return the unused memory to the system - we'd like to release but the best we can do + // is decommit, since Windows only lets you free the whole allocation. + if (adjust > 0) { + VirtualFree(reinterpret_cast(ptr), adjust, MEM_DECOMMIT); + } + if (adjust < extra) { + VirtualFree(reinterpret_cast(ptr + adjust + size), extra-adjust, MEM_DECOMMIT); + } + + ptr += adjust; + return reinterpret_cast(ptr); +} + +#endif /* HAVE(MMAP) */ + +#ifndef WTF_CHANGES +static void* TryDevMem(size_t size, size_t *actual_size, size_t alignment) { + static bool initialized = false; + static off_t physmem_base; // next physical memory address to allocate + static off_t physmem_limit; // maximum physical address allowed + static int physmem_fd; // file descriptor for /dev/mem + + // Check if we should use /dev/mem allocation. Note that it may take + // a while to get this flag initialized, so meanwhile we fall back to + // the next allocator. (It looks like 7MB gets allocated before + // this flag gets initialized -khr.) + if (FLAGS_malloc_devmem_start == 0) { + // NOTE: not a devmem_failure - we'd like TCMalloc_SystemAlloc to + // try us again next time. + return NULL; + } + + if (!initialized) { + physmem_fd = open("/dev/mem", O_RDWR); + if (physmem_fd < 0) { + devmem_failure = true; + return NULL; + } + physmem_base = FLAGS_malloc_devmem_start*1024LL*1024LL; + physmem_limit = FLAGS_malloc_devmem_limit*1024LL*1024LL; + initialized = true; + } + + // Enforce page alignment + if (pagesize == 0) pagesize = getpagesize(); + if (alignment < pagesize) alignment = pagesize; + size = ((size + alignment - 1) / alignment) * alignment; + + // could theoretically return the "extra" bytes here, but this + // is simple and correct. + if (actual_size) + *actual_size = size; + + // Ask for extra memory if alignment > pagesize + size_t extra = 0; + if (alignment > pagesize) { + extra = alignment - pagesize; + } + + // check to see if we have any memory left + if (physmem_limit != 0 && physmem_base + size + extra > physmem_limit) { + devmem_failure = true; + return NULL; + } + void *result = mmap(0, size + extra, PROT_WRITE|PROT_READ, + MAP_SHARED, physmem_fd, physmem_base); + if (result == reinterpret_cast(MAP_FAILED)) { + devmem_failure = true; + return NULL; + } + uintptr_t ptr = reinterpret_cast(result); + + // Adjust the return memory so it is aligned + size_t adjust = 0; + if ((ptr & (alignment - 1)) != 0) { + adjust = alignment - (ptr & (alignment - 1)); + } + + // Return the unused virtual memory to the system + if (adjust > 0) { + munmap(reinterpret_cast(ptr), adjust); + } + if (adjust < extra) { + munmap(reinterpret_cast(ptr + adjust + size), extra - adjust); + } + + ptr += adjust; + physmem_base += adjust + size; + + return reinterpret_cast(ptr); +} +#endif + +void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, size_t alignment) { + // Discard requests that overflow + if (size + alignment < size) return NULL; + + SpinLockHolder lock_holder(&spinlock); + + // Enforce minimum alignment + if (alignment < sizeof(MemoryAligner)) alignment = sizeof(MemoryAligner); + + // Try twice, once avoiding allocators that failed before, and once + // more trying all allocators even if they failed before. + for (int i = 0; i < 2; i++) { + +#ifndef WTF_CHANGES + if (use_devmem && !devmem_failure) { + void* result = TryDevMem(size, actual_size, alignment); + if (result != NULL) return result; + } +#endif + +#if HAVE(SBRK) + if (use_sbrk && !sbrk_failure) { + void* result = TrySbrk(size, actual_size, alignment); + if (result != NULL) return result; + } +#endif + +#if HAVE(MMAP) + if (use_mmap && !mmap_failure) { + void* result = TryMmap(size, actual_size, alignment); + if (result != NULL) return result; + } +#endif + +#if HAVE(VIRTUALALLOC) + if (use_VirtualAlloc && !VirtualAlloc_failure) { + void* result = TryVirtualAlloc(size, actual_size, alignment); + if (result != NULL) return result; + } +#endif + + // nothing worked - reset failure flags and try again + devmem_failure = false; + sbrk_failure = false; + mmap_failure = false; + VirtualAlloc_failure = false; + } + return NULL; +} + +void TCMalloc_SystemRelease(void* start, size_t length) +{ + UNUSED_PARAM(start); + UNUSED_PARAM(length); +#if HAVE(MADV_DONTNEED) + if (FLAGS_malloc_devmem_start) { + // It's not safe to use MADV_DONTNEED if we've been mapping + // /dev/mem for heap memory + return; + } + if (pagesize == 0) pagesize = getpagesize(); + const size_t pagemask = pagesize - 1; + + size_t new_start = reinterpret_cast(start); + size_t end = new_start + length; + size_t new_end = end; + + // Round up the starting address and round down the ending address + // to be page aligned: + new_start = (new_start + pagesize - 1) & ~pagemask; + new_end = new_end & ~pagemask; + + ASSERT((new_start & pagemask) == 0); + ASSERT((new_end & pagemask) == 0); + ASSERT(new_start >= reinterpret_cast(start)); + ASSERT(new_end <= end); + + if (new_end > new_start) { + // Note -- ignoring most return codes, because if this fails it + // doesn't matter... + while (madvise(reinterpret_cast(new_start), new_end - new_start, + MADV_DONTNEED) == -1 && + errno == EAGAIN) { + // NOP + } + return; + } +#endif + +#if HAVE(MMAP) + void *newAddress = mmap(start, length, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, mmapFileDescriptor, 0); + UNUSED_PARAM(newAddress); + // If the mmap failed then that's ok, we just won't return the memory to the system. + ASSERT(newAddress == start || newAddress == reinterpret_cast(MAP_FAILED)); + return; +#endif +} diff --git a/wtf/TCSystemAlloc.h b/wtf/TCSystemAlloc.h new file mode 100644 index 0000000..a4d14ed --- /dev/null +++ b/wtf/TCSystemAlloc.h @@ -0,0 +1,65 @@ +// Copyright (c) 2005, 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- +// Author: Sanjay Ghemawat +// +// Routine that uses sbrk/mmap to allocate memory from the system. +// Useful for implementing malloc. + +#ifndef TCMALLOC_SYSTEM_ALLOC_H__ +#define TCMALLOC_SYSTEM_ALLOC_H__ + +// REQUIRES: "alignment" is a power of two or "0" to indicate default alignment +// +// Allocate and return "N" bytes of zeroed memory. +// +// If actual_bytes is NULL then the returned memory is exactly the +// requested size. If actual bytes is non-NULL then the allocator +// may optionally return more bytes than asked for (i.e. return an +// entire "huge" page if a huge page allocator is in use). +// +// The returned pointer is a multiple of "alignment" if non-zero. +// +// Returns NULL when out of memory. +extern void* TCMalloc_SystemAlloc(size_t bytes, size_t *actual_bytes, + size_t alignment = 0); + +// This call is a hint to the operating system that the pages +// contained in the specified range of memory will not be used for a +// while, and can be released for use by other processes or the OS. +// Pages which are released in this way may be destroyed (zeroed) by +// the OS. The benefit of this function is that it frees memory for +// use by the system, the cost is that the pages are faulted back into +// the address space next time they are touched, which can impact +// performance. (Only pages fully covered by the memory region will +// be released, partial pages will not.) +extern void TCMalloc_SystemRelease(void* start, size_t length); + +#endif /* TCMALLOC_SYSTEM_ALLOC_H__ */ diff --git a/wtf/UnusedParam.h b/wtf/UnusedParam.h new file mode 100644 index 0000000..a599110 --- /dev/null +++ b/wtf/UnusedParam.h @@ -0,0 +1,30 @@ +/* -*- mode: c++; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_UnusedParam_h +#define WTF_UnusedParam_h + +/* don't use this for C++, it should only be used in plain C files or + ObjC methods, where leaving off the parameter name is not allowed. */ + +#define UNUSED_PARAM(x) (void)x + +#endif // WTF_UnusedParam_h diff --git a/wtf/Vector.h b/wtf/Vector.h new file mode 100644 index 0000000..cd6eced --- /dev/null +++ b/wtf/Vector.h @@ -0,0 +1,835 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_Vector_h +#define WTF_Vector_h + +#include "Assertions.h" +#include "FastMalloc.h" +#include "Noncopyable.h" +#include "VectorTraits.h" +#include +#include +#include +#include + +namespace WTF { + + using std::min; + using std::max; + + template + class VectorDestructor; + + template + struct VectorDestructor + { + static void destruct(T*, T*) {} + }; + + template + struct VectorDestructor + { + static void destruct(T* begin, T* end) + { + for (T* cur = begin; cur != end; ++cur) + cur->~T(); + } + }; + + template + class VectorInitializer; + + template + struct VectorInitializer + { + static void initialize(T*, T*) {} + }; + + template + struct VectorInitializer + { + static void initialize(T* begin, T* end) + { + for (T* cur = begin; cur != end; ++cur) + new (cur) T; + } + }; + + template + struct VectorInitializer + { + static void initialize(T* begin, T* end) + { + memset(begin, 0, reinterpret_cast(end) - reinterpret_cast(begin)); + } + }; + + template + class VectorMover; + + template + struct VectorMover + { + static void move(const T* src, const T* srcEnd, T* dst) + { + while (src != srcEnd) { + new (dst) T(*src); + src->~T(); + ++dst; + ++src; + } + } + static void moveOverlapping(const T* src, const T* srcEnd, T* dst) + { + if (src > dst) + move(src, srcEnd, dst); + else { + T* dstEnd = dst + (srcEnd - src); + while (src != srcEnd) { + --srcEnd; + --dstEnd; + new (dstEnd) T(*srcEnd); + srcEnd->~T(); + } + } + } + }; + + template + struct VectorMover + { + static void move(const T* src, const T* srcEnd, T* dst) + { + memcpy(dst, src, reinterpret_cast(srcEnd) - reinterpret_cast(src)); + } + static void moveOverlapping(const T* src, const T* srcEnd, T* dst) + { + memmove(dst, src, reinterpret_cast(srcEnd) - reinterpret_cast(src)); + } + }; + + template + class VectorCopier; + + template + struct VectorCopier + { + static void uninitializedCopy(const T* src, const T* srcEnd, T* dst) + { + while (src != srcEnd) { + new (dst) T(*src); + ++dst; + ++src; + } + } + }; + + template + struct VectorCopier + { + static void uninitializedCopy(const T* src, const T* srcEnd, T* dst) + { + memcpy(dst, src, reinterpret_cast(srcEnd) - reinterpret_cast(src)); + } + }; + + template + class VectorFiller; + + template + struct VectorFiller + { + static void uninitializedFill(T* dst, T* dstEnd, const T& val) + { + while (dst != dstEnd) { + new (dst) T(val); + ++dst; + } + } + }; + + template + struct VectorFiller + { + static void uninitializedFill(T* dst, T* dstEnd, const T& val) + { + ASSERT(sizeof(T) == sizeof(char)); + memset(dst, val, dstEnd - dst); + } + }; + + template + class VectorComparer; + + template + struct VectorComparer + { + static bool compare(const T* a, const T* b, size_t size) + { + for (size_t i = 0; i < size; ++i) + if (a[i] != b[i]) + return false; + return true; + } + }; + + template + struct VectorComparer + { + static bool compare(const T* a, const T* b, size_t size) + { + return memcmp(a, b, sizeof(T) * size) == 0; + } + }; + + template + struct VectorTypeOperations + { + static void destruct(T* begin, T* end) + { + VectorDestructor::needsDestruction, T>::destruct(begin, end); + } + + static void initialize(T* begin, T* end) + { + VectorInitializer::needsInitialization, VectorTraits::canInitializeWithMemset, T>::initialize(begin, end); + } + + static void move(const T* src, const T* srcEnd, T* dst) + { + VectorMover::canMoveWithMemcpy, T>::move(src, srcEnd, dst); + } + + static void moveOverlapping(const T* src, const T* srcEnd, T* dst) + { + VectorMover::canMoveWithMemcpy, T>::moveOverlapping(src, srcEnd, dst); + } + + static void uninitializedCopy(const T* src, const T* srcEnd, T* dst) + { + VectorCopier::canCopyWithMemcpy, T>::uninitializedCopy(src, srcEnd, dst); + } + + static void uninitializedFill(T* dst, T* dstEnd, const T& val) + { + VectorFiller::canFillWithMemset, T>::uninitializedFill(dst, dstEnd, val); + } + + static bool compare(const T* a, const T* b, size_t size) + { + return VectorComparer::canCompareWithMemcmp, T>::compare(a, b, size); + } + }; + + template + class VectorBufferBase : Noncopyable { + public: + void allocateBuffer(size_t newCapacity) + { + ASSERT(newCapacity >= m_capacity); + m_capacity = newCapacity; + if (newCapacity > std::numeric_limits::max() / sizeof(T)) + CRASH(); + m_buffer = static_cast(fastMalloc(newCapacity * sizeof(T))); + } + + void deallocateBuffer(T* bufferToDeallocate) + { + fastFree(bufferToDeallocate); + } + + T* buffer() { return m_buffer; } + const T* buffer() const { return m_buffer; } + size_t capacity() const { return m_capacity; } + + T* releaseBuffer() + { + T* buffer = m_buffer; + m_buffer = 0; + m_capacity = 0; + return buffer; + } + + protected: + VectorBufferBase() + : m_buffer(0) + , m_capacity(0) + { + } + + VectorBufferBase(T* buffer, size_t capacity) + : m_buffer(buffer) + , m_capacity(capacity) + { + } + + ~VectorBufferBase() + { + // FIXME: It would be nice to find a way to ASSERT that m_buffer hasn't leaked here. + } + + T* m_buffer; + size_t m_capacity; + }; + + template + class VectorBuffer; + + template + class VectorBuffer : private VectorBufferBase { + private: + typedef VectorBufferBase Base; + public: + VectorBuffer() + { + } + + VectorBuffer(size_t capacity) + { + allocateBuffer(capacity); + } + + ~VectorBuffer() + { + deallocateBuffer(buffer()); + } + + void swap(VectorBuffer& other) + { + std::swap(m_buffer, other.m_buffer); + std::swap(m_capacity, other.m_capacity); + } + + using Base::allocateBuffer; + using Base::deallocateBuffer; + + using Base::buffer; + using Base::capacity; + + using Base::releaseBuffer; + private: + using Base::m_buffer; + using Base::m_capacity; + }; + + template + class VectorBuffer : private VectorBufferBase { + private: + typedef VectorBufferBase Base; + public: + VectorBuffer() + : Base(inlineBuffer(), inlineCapacity) + { + } + + VectorBuffer(size_t capacity) + : Base(inlineBuffer(), inlineCapacity) + { + if (capacity > inlineCapacity) + allocateBuffer(capacity); + } + + ~VectorBuffer() + { + deallocateBuffer(buffer()); + } + + using Base::allocateBuffer; + + void deallocateBuffer(T* bufferToDeallocate) + { + if (bufferToDeallocate == inlineBuffer()) + return; + Base::deallocateBuffer(bufferToDeallocate); + } + + using Base::buffer; + using Base::capacity; + + T* releaseBuffer() + { + if (buffer() == inlineBuffer()) + return 0; + return Base::releaseBuffer(); + } + + private: + using Base::m_buffer; + using Base::m_capacity; + + static const size_t m_inlineBufferSize = inlineCapacity * sizeof(T); +#if PLATFORM(ARM) + T *inlineBuffer() { return reinterpret_cast((void*)((&m_inlineBuffer))); } + + __attribute__ ((aligned (4))) char m_inlineBuffer[m_inlineBufferSize]; +#else + T* inlineBuffer() { return reinterpret_cast(&m_inlineBuffer); } + + // FIXME: Nothing guarantees this buffer is appropriately aligned to hold objects of type T. + char m_inlineBuffer[m_inlineBufferSize]; +#endif + }; + + template + class Vector { + private: + typedef VectorBuffer Buffer; + typedef VectorTypeOperations TypeOperations; + + public: + typedef T ValueType; + + typedef T* iterator; + typedef const T* const_iterator; + + Vector() + : m_size(0) + { + } + + explicit Vector(size_t size) + : m_size(size) + , m_buffer(size) + { + TypeOperations::initialize(begin(), end()); + } + + ~Vector() + { + clear(); + } + + Vector(const Vector&); + template + Vector(const Vector&); + + Vector& operator=(const Vector&); + template + Vector& operator=(const Vector&); + + size_t size() const { return m_size; } + size_t capacity() const { return m_buffer.capacity(); } + bool isEmpty() const { return !size(); } + + T& at(size_t i) + { + ASSERT(i < size()); + return m_buffer.buffer()[i]; + } + const T& at(size_t i) const + { + ASSERT(i < size()); + return m_buffer.buffer()[i]; + } + + T& operator[](size_t i) { return at(i); } + const T& operator[](size_t i) const { return at(i); } + + T* data() { return m_buffer.buffer(); } + const T* data() const { return m_buffer.buffer(); } + + iterator begin() { return data(); } + iterator end() { return begin() + m_size; } + const_iterator begin() const { return data(); } + const_iterator end() const { return begin() + m_size; } + + T& first() { return at(0); } + const T& first() const { return at(0); } + T& last() { return at(size() - 1); } + const T& last() const { return at(size() - 1); } + + void shrink(size_t size); + void grow(size_t size); + void resize(size_t size); + void reserveCapacity(size_t newCapacity); + + void clear() { if (m_size) shrink(0); } + + template void append(const U*, size_t); + template void append(const U&); + template void uncheckedAppend(const U& val); + template void append(const Vector&); + + template void insert(size_t position, const U*, size_t); + template void insert(size_t position, const U&); + template void insert(size_t position, const Vector&); + + template void prepend(const U*, size_t); + template void prepend(const U&); + template void prepend(const Vector&); + + void remove(size_t position); + + void removeLast() + { + ASSERT(!isEmpty()); + shrink(size() - 1); + } + + Vector(size_t size, const T& val) + : m_size(size) + , m_buffer(size) + { + TypeOperations::uninitializedFill(begin(), end(), val); + } + + void fill(const T&, size_t); + void fill(const T& val) { fill(val, size()); } + + template void appendRange(Iterator start, Iterator end); + + T* releaseBuffer(); + + void swap(Vector& other) + { + std::swap(m_size, other.m_size); + m_buffer.swap(other.m_buffer); + } + + private: + void expandCapacity(size_t newMinCapacity); + const T* expandCapacity(size_t newMinCapacity, const T*); + template U* expandCapacity(size_t newMinCapacity, U*); + + size_t m_size; + Buffer m_buffer; + }; + + template + Vector::Vector(const Vector& other) + : m_size(other.size()) + , m_buffer(other.capacity()) + { + TypeOperations::uninitializedCopy(other.begin(), other.end(), begin()); + } + + template + template + Vector::Vector(const Vector& other) + : m_size(other.size()) + , m_buffer(other.capacity()) + { + TypeOperations::uninitializedCopy(other.begin(), other.end(), begin()); + } + + template + Vector& Vector::operator=(const Vector& other) + { + if (&other == this) + return *this; + + if (size() > other.size()) + shrink(other.size()); + else if (other.size() > capacity()) { + clear(); + reserveCapacity(other.size()); + } + + std::copy(other.begin(), other.begin() + size(), begin()); + TypeOperations::uninitializedCopy(other.begin() + size(), other.end(), end()); + m_size = other.size(); + + return *this; + } + + template + template + Vector& Vector::operator=(const Vector& other) + { + if (&other == this) + return *this; + + if (size() > other.size()) + shrink(other.size()); + else if (other.size() > capacity()) { + clear(); + reserveCapacity(other.size()); + } + + std::copy(other.begin(), other.begin() + size(), begin()); + TypeOperations::uninitializedCopy(other.begin() + size(), other.end(), end()); + m_size = other.size(); + + return *this; + } + + template + void Vector::fill(const T& val, size_t newSize) + { + if (size() > newSize) + shrink(newSize); + else if (newSize > capacity()) { + clear(); + reserveCapacity(newSize); + } + + std::fill(begin(), end(), val); + TypeOperations::uninitializedFill(end(), begin() + newSize, val); + m_size = newSize; + } + + template + template + void Vector::appendRange(Iterator start, Iterator end) + { + for (Iterator it = start; it != end; ++it) + append(*it); + } + + template + void Vector::expandCapacity(size_t newMinCapacity) + { + reserveCapacity(max(newMinCapacity, max(static_cast(16), capacity() + capacity() / 4 + 1))); + } + + template + const T* Vector::expandCapacity(size_t newMinCapacity, const T* ptr) + { + if (ptr < begin() || ptr >= end()) { + expandCapacity(newMinCapacity); + return ptr; + } + size_t index = ptr - begin(); + expandCapacity(newMinCapacity); + return begin() + index; + } + + template template + inline U* Vector::expandCapacity(size_t newMinCapacity, U* ptr) + { + expandCapacity(newMinCapacity); + return ptr; + } + + template + void Vector::resize(size_t size) + { + if (size <= m_size) + TypeOperations::destruct(begin() + size, end()); + else { + if (size > capacity()) + expandCapacity(size); + TypeOperations::initialize(end(), begin() + size); + } + + m_size = size; + } + + template + void Vector::shrink(size_t size) + { + ASSERT(size <= m_size); + TypeOperations::destruct(begin() + size, end()); + m_size = size; + } + + template + void Vector::grow(size_t size) + { + ASSERT(size >= m_size); + if (size > capacity()) + expandCapacity(size); + TypeOperations::initialize(end(), begin() + size); + m_size = size; + } + + template + void Vector::reserveCapacity(size_t newCapacity) + { + if (newCapacity <= capacity()) + return; + T* oldBuffer = begin(); + T* oldEnd = end(); + m_buffer.allocateBuffer(newCapacity); + TypeOperations::move(oldBuffer, oldEnd, begin()); + m_buffer.deallocateBuffer(oldBuffer); + } + + // Templatizing these is better than just letting the conversion happen implicitly, + // because for instance it allows a PassRefPtr to be appended to a RefPtr vector + // without refcount thrash. + + template template + void Vector::append(const U* data, size_t dataSize) + { + size_t newSize = m_size + dataSize; + if (newSize > capacity()) + data = expandCapacity(newSize, data); + T* dest = end(); + for (size_t i = 0; i < dataSize; ++i) + new (&dest[i]) T(data[i]); + m_size = newSize; + } + + template template + inline void Vector::append(const U& val) + { + const U* ptr = &val; + if (size() == capacity()) + ptr = expandCapacity(size() + 1, ptr); + +#if COMPILER(MSVC7) + // FIXME: MSVC7 generates compilation errors when trying to assign + // a pointer to a Vector of its base class (i.e. can't downcast). So far + // I've been unable to determine any logical reason for this, so I can + // only assume it is a bug with the compiler. Casting is a bad solution, + // however, because it subverts implicit conversions, so a better + // one is needed. + new (end()) T(static_cast(*ptr)); +#else + new (end()) T(*ptr); +#endif + ++m_size; + } + + // This version of append saves a branch in the case where you know that the + // vector's capacity is large enough for the append to succeed. + + template template + inline void Vector::uncheckedAppend(const U& val) + { + ASSERT(size() < capacity()); + const U* ptr = &val; + new (end()) T(*ptr); + ++m_size; + } + + template template + inline void Vector::append(const Vector& val) + { + append(val.begin(), val.size()); + } + + template template + void Vector::insert(size_t position, const U* data, size_t dataSize) + { + ASSERT(position <= size()); + size_t newSize = m_size + dataSize; + if (newSize > capacity()) + data = expandCapacity(newSize, data); + T* spot = begin() + position; + TypeOperations::moveOverlapping(spot, end(), spot + dataSize); + for (size_t i = 0; i < dataSize; ++i) + new (&spot[i]) T(data[i]); + m_size = newSize; + } + + template template + inline void Vector::insert(size_t position, const U& val) + { + ASSERT(position <= size()); + const U* data = &val; + if (size() == capacity()) + data = expandCapacity(size() + 1, data); + T* spot = begin() + position; + TypeOperations::moveOverlapping(spot, end(), spot + 1); + new (spot) T(*data); + ++m_size; + } + + template template + inline void Vector::insert(size_t position, const Vector& val) + { + insert(position, val.begin(), val.size()); + } + + template template + void Vector::prepend(const U* data, size_t dataSize) + { + insert(0, data, dataSize); + } + + template template + inline void Vector::prepend(const U& val) + { + insert(0, val); + } + + template template + inline void Vector::prepend(const Vector& val) + { + insert(0, val.begin(), val.size()); + } + + template + inline void Vector::remove(size_t position) + { + ASSERT(position < size()); + T* spot = begin() + position; + spot->~T(); + TypeOperations::moveOverlapping(spot + 1, end(), spot); + --m_size; + } + + template + inline T* Vector::releaseBuffer() + { + T* buffer = m_buffer.releaseBuffer(); + if (inlineCapacity && !buffer && m_size) { + // If the vector had some data, but no buffer to release, + // that means it was using the inline buffer. In that case, + // we create a brand new buffer so the caller always gets one. + size_t bytes = m_size * sizeof(T); + buffer = static_cast(fastMalloc(bytes)); + memcpy(buffer, data(), bytes); + } + ASSERT(buffer); + m_size = 0; + return buffer; + } + + template + void deleteAllValues(const Vector& collection) + { + typedef typename Vector::const_iterator iterator; + iterator end = collection.end(); + for (iterator it = collection.begin(); it != end; ++it) + delete *it; + } + + template + inline void swap(Vector& a, Vector& b) + { + a.swap(b); + } + + template + bool operator==(const Vector& a, const Vector& b) + { + if (a.size() != b.size()) + return false; + + return VectorTypeOperations::compare(a.data(), b.data(), a.size()); + } + + template + inline bool operator!=(const Vector& a, const Vector& b) + { + return !(a == b); + } + + +} // namespace WTF + +using WTF::Vector; + +#endif // WTF_Vector_h diff --git a/wtf/VectorTraits.h b/wtf/VectorTraits.h new file mode 100644 index 0000000..c62a0bf --- /dev/null +++ b/wtf/VectorTraits.h @@ -0,0 +1,117 @@ +// -*- mode: c++; c-basic-offset: 4 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WTF_VectorTraits_h +#define WTF_VectorTraits_h + +#include "RefPtr.h" +#include + +using std::pair; + +namespace WTF { + + template struct IsPod { static const bool value = false; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template <> struct IsPod { static const bool value = true; }; + template struct IsPod

{ static const bool value = true; }; + + template + class VectorTraitsBase; + + template + struct VectorTraitsBase + { + static const bool needsDestruction = true; + static const bool needsInitialization = true; + static const bool canInitializeWithMemset = false; + static const bool canMoveWithMemcpy = false; + static const bool canCopyWithMemcpy = false; + static const bool canFillWithMemset = false; + static const bool canCompareWithMemcmp = false; + }; + + template + struct VectorTraitsBase + { + static const bool needsDestruction = false; + static const bool needsInitialization = false; + static const bool canInitializeWithMemset = false; + static const bool canMoveWithMemcpy = true; + static const bool canCopyWithMemcpy = true; + static const bool canFillWithMemset = sizeof(T) == sizeof(char); + static const bool canCompareWithMemcmp = true; + }; + + template + struct VectorTraits : VectorTraitsBase::value, T> { }; + + struct SimpleClassVectorTraits + { + static const bool needsDestruction = true; + static const bool needsInitialization = true; + static const bool canInitializeWithMemset = true; + static const bool canMoveWithMemcpy = true; + static const bool canCopyWithMemcpy = false; + static const bool canFillWithMemset = false; + static const bool canCompareWithMemcmp = true; + }; + + // we know RefPtr is simple enough that initializing to 0 and moving with memcpy + // (and then not destructing the original) will totally work + template + struct VectorTraits > : SimpleClassVectorTraits { }; + + template + struct VectorTraits > + { + typedef VectorTraits FirstTraits; + typedef VectorTraits SecondTraits; + + static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction; + static const bool needsInitialization = FirstTraits::needsInitialization || SecondTraits::needsInitialization; + static const bool canInitializeWithMemset = FirstTraits::canInitializeWithMemset && SecondTraits::canInitializeWithMemset; + static const bool canMoveWithMemcpy = FirstTraits::canMoveWithMemcpy && SecondTraits::canMoveWithMemcpy; + static const bool canCopyWithMemcpy = FirstTraits::canCopyWithMemcpy && SecondTraits::canCopyWithMemcpy; + static const bool canFillWithMemset = false; + static const bool canCompareWithMemcmp = FirstTraits::canCompareWithMemcmp && SecondTraits::canCompareWithMemcmp; + }; + +} // namespace WTF + +using WTF::VectorTraits; +using WTF::SimpleClassVectorTraits; + +#endif // WTF_VectorTraits_h diff --git a/wtf/unicode/UTF8.cpp b/wtf/unicode/UTF8.cpp new file mode 100644 index 0000000..9e713fe --- /dev/null +++ b/wtf/unicode/UTF8.cpp @@ -0,0 +1,303 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "UTF8.h" + +namespace WTF { +namespace Unicode { + +inline int inlineUTF8SequenceLengthNonASCII(char b0) +{ + if ((b0 & 0xC0) != 0xC0) + return 0; + if ((b0 & 0xE0) == 0xC0) + return 2; + if ((b0 & 0xF0) == 0xE0) + return 3; + if ((b0 & 0xF8) == 0xF0) + return 4; + return 0; +} + +inline int inlineUTF8SequenceLength(char b0) +{ + return (b0 & 0x80) == 0 ? 1 : inlineUTF8SequenceLengthNonASCII(b0); +} + +int UTF8SequenceLength(char b0) +{ + return (b0 & 0x80) == 0 ? 1 : inlineUTF8SequenceLengthNonASCII(b0); +} + +int decodeUTF8Sequence(const char* sequence) +{ + // Handle 0-byte sequences (never valid). + const unsigned char b0 = sequence[0]; + const int length = inlineUTF8SequenceLength(b0); + if (length == 0) + return -1; + + // Handle 1-byte sequences (plain ASCII). + const unsigned char b1 = sequence[1]; + if (length == 1) { + if (b1) + return -1; + return b0; + } + + // Handle 2-byte sequences. + if ((b1 & 0xC0) != 0x80) + return -1; + const unsigned char b2 = sequence[2]; + if (length == 2) { + if (b2) + return -1; + const int c = ((b0 & 0x1F) << 6) | (b1 & 0x3F); + if (c < 0x80) + return -1; + return c; + } + + // Handle 3-byte sequences. + if ((b2 & 0xC0) != 0x80) + return -1; + const unsigned char b3 = sequence[3]; + if (length == 3) { + if (b3) + return -1; + const int c = ((b0 & 0xF) << 12) | ((b1 & 0x3F) << 6) | (b2 & 0x3F); + if (c < 0x800) + return -1; + // UTF-16 surrogates should never appear in UTF-8 data. + if (c >= 0xD800 && c <= 0xDFFF) + return -1; + return c; + } + + // Handle 4-byte sequences. + if ((b3 & 0xC0) != 0x80) + return -1; + const unsigned char b4 = sequence[4]; + if (length == 4) { + if (b4) + return -1; + const int c = ((b0 & 0x7) << 18) | ((b1 & 0x3F) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F); + if (c < 0x10000 || c > 0x10FFFF) + return -1; + return c; + } + + return -1; +} + +// Once the bits are split out into bytes of UTF-8, this is a mask OR-ed +// into the first byte, depending on how many bytes follow. There are +// as many entries in this table as there are UTF-8 sequence types. +// (I.e., one byte sequence, two byte... etc.). Remember that sequencs +// for *legal* UTF-8 will be 4 or fewer bytes total. +static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + +ConversionResult convertUTF16ToUTF8( + const UChar** sourceStart, const UChar* sourceEnd, + char** targetStart, char* targetEnd, bool strict) +{ + ConversionResult result = conversionOK; + const UChar* source = *sourceStart; + char* target = *targetStart; + while (source < sourceEnd) { + UChar32 ch; + unsigned short bytesToWrite = 0; + const UChar32 byteMask = 0xBF; + const UChar32 byteMark = 0x80; + const UChar* oldSource = source; // In case we have to back up because of target overflow. + ch = static_cast(*source++); + // If we have a surrogate pair, convert to UChar32 first. + if (ch >= 0xD800 && ch <= 0xDBFF) { + // If the 16 bits following the high surrogate are in the source buffer... + if (source < sourceEnd) { + UChar32 ch2 = static_cast(*source); + // If it's a low surrogate, convert to UChar32. + if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) { + ch = ((ch - 0xD800) << 10) + (ch2 - 0xDC00) + 0x0010000; + ++source; + } else if (strict) { // it's an unpaired high surrogate + --source; // return to the illegal value itself + result = sourceIllegal; + break; + } + } else { // We don't have the 16 bits following the high surrogate. + --source; // return to the high surrogate + result = sourceExhausted; + break; + } + } else if (strict) { + // UTF-16 surrogate values are illegal in UTF-32 + if (ch >= 0xDC00 && ch <= 0xDFFF) { + --source; // return to the illegal value itself + result = sourceIllegal; + break; + } + } + // Figure out how many bytes the result will require + if (ch < (UChar32)0x80) { + bytesToWrite = 1; + } else if (ch < (UChar32)0x800) { + bytesToWrite = 2; + } else if (ch < (UChar32)0x10000) { + bytesToWrite = 3; + } else if (ch < (UChar32)0x110000) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = 0xFFFD; + } + + target += bytesToWrite; + if (target > targetEnd) { + source = oldSource; // Back up source pointer! + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { // note: everything falls through. + case 4: *--target = (char)((ch | byteMark) & byteMask); ch >>= 6; + case 3: *--target = (char)((ch | byteMark) & byteMask); ch >>= 6; + case 2: *--target = (char)((ch | byteMark) & byteMask); ch >>= 6; + case 1: *--target = (char)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +// This must be called with the length pre-determined by the first byte. +// If presented with a length > 4, this returns false. The Unicode +// definition of UTF-8 goes up to 4-byte sequences. +static bool isLegalUTF8(const unsigned char* source, int length) +{ + unsigned char a; + const unsigned char* srcptr = source + length; + switch (length) { + default: return false; + // Everything else falls through when "true"... + case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: if ((a = (*--srcptr)) > 0xBF) return false; + + switch (*source) { + // no fall-through in this inner switch + case 0xE0: if (a < 0xA0) return false; break; + case 0xED: if (a > 0x9F) return false; break; + case 0xF0: if (a < 0x90) return false; break; + case 0xF4: if (a > 0x8F) return false; break; + default: if (a < 0x80) return false; + } + + case 1: if (*source >= 0x80 && *source < 0xC2) return false; + } + if (*source > 0xF4) + return false; + return true; +} + +// Magic values subtracted from a buffer value during UTF8 conversion. +// This table contains as many values as there might be trailing bytes +// in a UTF-8 sequence. +static const UChar32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; + +ConversionResult convertUTF8ToUTF16( + const char** sourceStart, const char* sourceEnd, + UChar** targetStart, UChar* targetEnd, bool strict) +{ + ConversionResult result = conversionOK; + const char* source = *sourceStart; + UChar* target = *targetStart; + while (source < sourceEnd) { + UChar32 ch = 0; + int extraBytesToRead = UTF8SequenceLength(*source) - 1; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + // Do this check whether lenient or strict + if (!isLegalUTF8(reinterpret_cast(source), extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + // The cases all fall through. + switch (extraBytesToRead) { + case 5: ch += static_cast(*source++); ch <<= 6; // remember, illegal UTF-8 + case 4: ch += static_cast(*source++); ch <<= 6; // remember, illegal UTF-8 + case 3: ch += static_cast(*source++); ch <<= 6; + case 2: ch += static_cast(*source++); ch <<= 6; + case 1: ch += static_cast(*source++); ch <<= 6; + case 0: ch += static_cast(*source++); + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead + 1); // Back up source pointer! + result = targetExhausted; break; + } + if (ch <= 0xFFFF) { + // UTF-16 surrogate values are illegal in UTF-32 + if (ch >= 0xD800 && ch <= 0xDFFF) { + if (strict) { + source -= (extraBytesToRead + 1); // return to the illegal value itself + result = sourceIllegal; + break; + } else + *target++ = 0xFFFD; + } else + *target++ = (UChar)ch; // normal case + } else if (ch > 0x10FFFF) { + if (strict) { + result = sourceIllegal; + source -= (extraBytesToRead + 1); // return to the start + break; // Bail out; shouldn't continue + } else + *target++ = 0xFFFD; + } else { + // target is a character in range 0xFFFF - 0x10FFFF + if (target + 1 >= targetEnd) { + source -= (extraBytesToRead + 1); // Back up source pointer! + result = targetExhausted; + break; + } + ch -= 0x0010000UL; + *target++ = (UChar)((ch >> 10) + 0xD800); + *target++ = (UChar)((ch & 0x03FF) + 0xDC00); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +} +} diff --git a/wtf/unicode/UTF8.h b/wtf/unicode/UTF8.h new file mode 100644 index 0000000..a5ed93e --- /dev/null +++ b/wtf/unicode/UTF8.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_UTF8_h +#define WTF_UTF8_h + +#include "Unicode.h" + +namespace WTF { + namespace Unicode { + + // Given a first byte, gives the length of the UTF-8 sequence it begins. + // Returns 0 for bytes that are not legal starts of UTF-8 sequences. + // Only allows sequences of up to 4 bytes, since that works for all Unicode characters (U-00000000 to U-0010FFFF). + int UTF8SequenceLength(char); + + // Takes a null-terminated C-style string with a UTF-8 sequence in it and converts it to a character. + // Only allows Unicode characters (U-00000000 to U-0010FFFF). + // Returns -1 if the sequence is not valid (including presence of extra bytes). + int decodeUTF8Sequence(const char*); + + typedef enum { + conversionOK, // conversion successful + sourceExhausted, // partial character in source, but hit end + targetExhausted, // insuff. room in target for conversion + sourceIllegal // source sequence is illegal/malformed + } ConversionResult; + + // These conversion functions take a "strict" argument. When this + // flag is set to strict, both irregular sequences and isolated surrogates + // will cause an error. When the flag is set to lenient, both irregular + // sequences and isolated surrogates are converted. + // + // Whether the flag is strict or lenient, all illegal sequences will cause + // an error return. This includes sequences such as: , , + // or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code + // must check for illegal sequences. + // + // When the flag is set to lenient, characters over 0x10FFFF are converted + // to the replacement character; otherwise (when the flag is set to strict) + // they constitute an error. + + ConversionResult convertUTF8ToUTF16( + const char** sourceStart, const char* sourceEnd, + UChar** targetStart, UChar* targetEnd, bool strict = true); + + ConversionResult convertUTF16ToUTF8( + const UChar** sourceStart, const UChar* sourceEnd, + char** targetStart, char* targetEnd, bool strict = true); + } +} + +#endif // WTF_UTF8_h diff --git a/wtf/unicode/Unicode.h b/wtf/unicode/Unicode.h new file mode 100644 index 0000000..f890afc --- /dev/null +++ b/wtf/unicode/Unicode.h @@ -0,0 +1,37 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2006 George Staikos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_UNICODE_H +#define KJS_UNICODE_H + +#include + +#if USE(QT4_UNICODE) +#include "qt4/UnicodeQt4.h" +#elif USE(ICU_UNICODE) +#include +#else +#error "Unknown Unicode implementation" +#endif + +#endif +// vim: ts=2 sw=2 et diff --git a/wtf/unicode/icu/UnicodeIcu.h b/wtf/unicode/icu/UnicodeIcu.h new file mode 100644 index 0000000..cc9ab8c --- /dev/null +++ b/wtf/unicode/icu/UnicodeIcu.h @@ -0,0 +1,239 @@ +// -*- c-basic-offset: 2 -*- +/* + * This file is part of the KDE libraries + * Copyright (C) 2006 George Staikos + * Copyright (C) 2006 Alexey Proskuryakov + * Copyright (C) 2007 Apple Computer, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_UNICODE_ICU_H +#define KJS_UNICODE_ICU_H + +#include +#include +#include + +#include + +namespace WTF { + namespace Unicode { + + enum Direction { + LeftToRight = U_LEFT_TO_RIGHT, + RightToLeft = U_RIGHT_TO_LEFT, + EuropeanNumber = U_EUROPEAN_NUMBER, + EuropeanNumberSeparator = U_EUROPEAN_NUMBER_SEPARATOR, + EuropeanNumberTerminator = U_EUROPEAN_NUMBER_TERMINATOR, + ArabicNumber = U_ARABIC_NUMBER, + CommonNumberSeparator = U_COMMON_NUMBER_SEPARATOR, + BlockSeparator = U_BLOCK_SEPARATOR, + SegmentSeparator = U_SEGMENT_SEPARATOR, + WhiteSpaceNeutral = U_WHITE_SPACE_NEUTRAL, + OtherNeutral = U_OTHER_NEUTRAL, + LeftToRightEmbedding = U_LEFT_TO_RIGHT_EMBEDDING, + LeftToRightOverride = U_LEFT_TO_RIGHT_OVERRIDE, + RightToLeftArabic = U_RIGHT_TO_LEFT_ARABIC, + RightToLeftEmbedding = U_RIGHT_TO_LEFT_EMBEDDING, + RightToLeftOverride = U_RIGHT_TO_LEFT_OVERRIDE, + PopDirectionalFormat = U_POP_DIRECTIONAL_FORMAT, + NonSpacingMark = U_DIR_NON_SPACING_MARK, + BoundaryNeutral = U_BOUNDARY_NEUTRAL + }; + + enum DecompositionType { + DecompositionNone = U_DT_NONE, + DecompositionCanonical = U_DT_CANONICAL, + DecompositionCompat = U_DT_COMPAT, + DecompositionCircle = U_DT_CIRCLE, + DecompositionFinal = U_DT_FINAL, + DecompositionFont = U_DT_FONT, + DecompositionFraction = U_DT_FRACTION, + DecompositionInitial = U_DT_INITIAL, + DecompositionIsolated = U_DT_ISOLATED, + DecompositionMedial = U_DT_MEDIAL, + DecompositionNarrow = U_DT_NARROW, + DecompositionNoBreak = U_DT_NOBREAK, + DecompositionSmall = U_DT_SMALL, + DecompositionSquare = U_DT_SQUARE, + DecompositionSub = U_DT_SUB, + DecompositionSuper = U_DT_SUPER, + DecompositionVertical = U_DT_VERTICAL, + DecompositionWide = U_DT_WIDE, + }; + + enum CharCategory { + NoCategory = 0, + Other_NotAssigned = U_MASK(U_GENERAL_OTHER_TYPES), + Letter_Uppercase = U_MASK(U_UPPERCASE_LETTER), + Letter_Lowercase = U_MASK(U_LOWERCASE_LETTER), + Letter_Titlecase = U_MASK(U_TITLECASE_LETTER), + Letter_Modifier = U_MASK(U_MODIFIER_LETTER), + Letter_Other = U_MASK(U_OTHER_LETTER), + + Mark_NonSpacing = U_MASK(U_NON_SPACING_MARK), + Mark_Enclosing = U_MASK(U_ENCLOSING_MARK), + Mark_SpacingCombining = U_MASK(U_COMBINING_SPACING_MARK), + + Number_DecimalDigit = U_MASK(U_DECIMAL_DIGIT_NUMBER), + Number_Letter = U_MASK(U_LETTER_NUMBER), + Number_Other = U_MASK(U_OTHER_NUMBER), + + Separator_Space = U_MASK(U_SPACE_SEPARATOR), + Separator_Line = U_MASK(U_LINE_SEPARATOR), + Separator_Paragraph = U_MASK(U_PARAGRAPH_SEPARATOR), + + Other_Control = U_MASK(U_CONTROL_CHAR), + Other_Format = U_MASK(U_FORMAT_CHAR), + Other_PrivateUse = U_MASK(U_PRIVATE_USE_CHAR), + Other_Surrogate = U_MASK(U_SURROGATE), + + Punctuation_Dash = U_MASK(U_DASH_PUNCTUATION), + Punctuation_Open = U_MASK(U_START_PUNCTUATION), + Punctuation_Close = U_MASK(U_END_PUNCTUATION), + Punctuation_Connector = U_MASK(U_CONNECTOR_PUNCTUATION), + Punctuation_Other = U_MASK(U_OTHER_PUNCTUATION), + + Symbol_Math = U_MASK(U_MATH_SYMBOL), + Symbol_Currency = U_MASK(U_CURRENCY_SYMBOL), + Symbol_Modifier = U_MASK(U_MODIFIER_SYMBOL), + Symbol_Other = U_MASK(U_OTHER_SYMBOL), + + Punctuation_InitialQuote = U_MASK(U_INITIAL_PUNCTUATION), + Punctuation_FinalQuote = U_MASK(U_FINAL_PUNCTUATION) + }; + + inline UChar32 foldCase(UChar32 c) + { + return u_foldCase(c, U_FOLD_CASE_DEFAULT); + } + + inline int foldCase(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) + { + UErrorCode status = U_ZERO_ERROR; + int realLength = u_strFoldCase(result, resultLength, src, srcLength, U_FOLD_CASE_DEFAULT, &status); + *error = !U_SUCCESS(status); + return realLength; + } + + inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) + { + UErrorCode status = U_ZERO_ERROR; + int realLength = u_strToLower(result, resultLength, src, srcLength, "", &status); + *error = !!U_FAILURE(status); + return realLength; + } + + inline UChar32 toLower(UChar32 c) + { + return u_tolower(c); + } + + inline UChar32 toUpper(UChar32 c) + { + return u_toupper(c); + } + + inline int toUpper(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) + { + UErrorCode status = U_ZERO_ERROR; + int realLength = u_strToUpper(result, resultLength, src, srcLength, "", &status); + *error = !!U_FAILURE(status); + return realLength; + } + + inline UChar32 toTitleCase(UChar32 c) + { + return u_totitle(c); + } + + inline bool isArabicChar(UChar32 c) + { + return ublock_getCode(c) == UBLOCK_ARABIC; + } + + inline bool isFormatChar(UChar32 c) + { + return u_charType(c) == U_FORMAT_CHAR; + } + + inline bool isSeparatorSpace(UChar32 c) + { + return u_charType(c) == U_SPACE_SEPARATOR; + } + + inline bool isPrintableChar(UChar32 c) + { + return !!u_isprint(c); + } + + inline bool isDigit(UChar32 c) + { + return !!u_isdigit(c); + } + + inline bool isPunct(UChar32 c) + { + return !!u_ispunct(c); + } + + inline UChar32 mirroredChar(UChar32 c) + { + return u_charMirror(c); + } + + inline CharCategory category(UChar32 c) + { + return static_cast(U_GET_GC_MASK(c)); + } + + inline Direction direction(UChar32 c) + { + return static_cast(u_charDirection(c)); + } + + inline bool isLower(UChar32 c) + { + return !!u_islower(c); + } + + inline int digitValue(UChar32 c) + { + return u_charDigitValue(c); + } + + inline uint8_t combiningClass(UChar32 c) + { + return u_getCombiningClass(c); + } + + inline DecompositionType decompositionType(UChar32 c) + { + return static_cast(u_getIntPropertyValue(c, UCHAR_DECOMPOSITION_TYPE)); + } + + inline int umemcasecmp(const UChar* a, const UChar* b, int len) + { + return u_memcasecmp(a, b, len, U_FOLD_CASE_DEFAULT); + } + + } +} + +#endif +// vim: ts=2 sw=2 et diff --git a/wtf/unicode/qt4/UnicodeQt4.h b/wtf/unicode/qt4/UnicodeQt4.h new file mode 100644 index 0000000..0fbd869 --- /dev/null +++ b/wtf/unicode/qt4/UnicodeQt4.h @@ -0,0 +1,547 @@ +/* + * This file is part of the KDE libraries + * Copyright (C) 2006 George Staikos + * Copyright (C) 2006 Alexey Proskuryakov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef KJS_UNICODE_QT4_H +#define KJS_UNICODE_QT4_H + +#include +#include + +#include + +#include + +#if QT_VERSION >= 0x040300 +namespace QUnicodeTables { + struct Properties { + ushort category : 8; + ushort line_break_class : 8; + ushort direction : 8; + ushort combiningClass :8; + ushort joining : 2; + signed short digitValue : 6; /* 5 needed */ + ushort unicodeVersion : 4; + ushort lowerCaseSpecial : 1; + ushort upperCaseSpecial : 1; + ushort titleCaseSpecial : 1; + ushort caseFoldSpecial : 1; /* currently unused */ + signed short mirrorDiff : 16; + signed short lowerCaseDiff : 16; + signed short upperCaseDiff : 16; + signed short titleCaseDiff : 16; + signed short caseFoldDiff : 16; + }; + Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4); + Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2); +} +#endif + +// ugly hack to make UChar compatible with JSChar in API/JSStringRef.h +#if defined(Q_OS_WIN) +typedef wchar_t UChar; +#else +typedef uint16_t UChar; +#endif +typedef uint32_t UChar32; + +// some defines from ICU + +#define U16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800) +#define U16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00) +#define U16_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000) +#define U16_GET_SUPPLEMENTARY(lead, trail) \ + (((UChar32)(lead)<<10UL)+(UChar32)(trail)-U16_SURROGATE_OFFSET) + +#define U16_LEAD(supplementary) (UChar)(((supplementary)>>10)+0xd7c0) +#define U16_TRAIL(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00) + +#define U_IS_SURROGATE(c) (((c)&0xfffff800)==0xd800) +#define U16_IS_SINGLE(c) !U_IS_SURROGATE(c) +#define U16_IS_SURROGATE(c) U_IS_SURROGATE(c) +#define U16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0) + +#define U16_NEXT(s, i, length, c) { \ + (c)=(s)[(i)++]; \ + if(U16_IS_LEAD(c)) { \ + uint16_t __c2; \ + if((i)<(length) && U16_IS_TRAIL(__c2=(s)[(i)])) { \ + ++(i); \ + (c)=U16_GET_SUPPLEMENTARY((c), __c2); \ + } \ + } \ +} + +#define U_MASK(x) ((uint32_t)1<<(x)) + +namespace WTF { + namespace Unicode { + + enum Direction { + LeftToRight = QChar::DirL, + RightToLeft = QChar::DirR, + EuropeanNumber = QChar::DirEN, + EuropeanNumberSeparator = QChar::DirES, + EuropeanNumberTerminator = QChar::DirET, + ArabicNumber = QChar::DirAN, + CommonNumberSeparator = QChar::DirCS, + BlockSeparator = QChar::DirB, + SegmentSeparator = QChar::DirS, + WhiteSpaceNeutral = QChar::DirWS, + OtherNeutral = QChar::DirON, + LeftToRightEmbedding = QChar::DirLRE, + LeftToRightOverride = QChar::DirLRO, + RightToLeftArabic = QChar::DirAL, + RightToLeftEmbedding = QChar::DirRLE, + RightToLeftOverride = QChar::DirRLO, + PopDirectionalFormat = QChar::DirPDF, + NonSpacingMark = QChar::DirNSM, + BoundaryNeutral = QChar::DirBN + }; + + enum DecompositionType { + DecompositionNone = QChar::NoDecomposition, + DecompositionCanonical = QChar::Canonical, + DecompositionCompat = QChar::Compat, + DecompositionCircle = QChar::Circle, + DecompositionFinal = QChar::Final, + DecompositionFont = QChar::Font, + DecompositionFraction = QChar::Fraction, + DecompositionInitial = QChar::Initial, + DecompositionIsolated = QChar::Isolated, + DecompositionMedial = QChar::Medial, + DecompositionNarrow = QChar::Narrow, + DecompositionNoBreak = QChar::NoBreak, + DecompositionSmall = QChar::Small, + DecompositionSquare = QChar::Square, + DecompositionSub = QChar::Sub, + DecompositionSuper = QChar::Super, + DecompositionVertical = QChar::Vertical, + DecompositionWide = QChar::Wide + }; + + enum CharCategory { + NoCategory = 0, + Mark_NonSpacing = U_MASK(QChar::Mark_NonSpacing), + Mark_SpacingCombining = U_MASK(QChar::Mark_SpacingCombining), + Mark_Enclosing = U_MASK(QChar::Mark_Enclosing), + Number_DecimalDigit = U_MASK(QChar::Number_DecimalDigit), + Number_Letter = U_MASK(QChar::Number_Letter), + Number_Other = U_MASK(QChar::Number_Other), + Separator_Space = U_MASK(QChar::Separator_Space), + Separator_Line = U_MASK(QChar::Separator_Line), + Separator_Paragraph = U_MASK(QChar::Separator_Paragraph), + Other_Control = U_MASK(QChar::Other_Control), + Other_Format = U_MASK(QChar::Other_Format), + Other_Surrogate = U_MASK(QChar::Other_Surrogate), + Other_PrivateUse = U_MASK(QChar::Other_PrivateUse), + Other_NotAssigned = U_MASK(QChar::Other_NotAssigned), + Letter_Uppercase = U_MASK(QChar::Letter_Uppercase), + Letter_Lowercase = U_MASK(QChar::Letter_Lowercase), + Letter_Titlecase = U_MASK(QChar::Letter_Titlecase), + Letter_Modifier = U_MASK(QChar::Letter_Modifier), + Letter_Other = U_MASK(QChar::Letter_Other), + Punctuation_Connector = U_MASK(QChar::Punctuation_Connector), + Punctuation_Dash = U_MASK(QChar::Punctuation_Dash), + Punctuation_Open = U_MASK(QChar::Punctuation_Open), + Punctuation_Close = U_MASK(QChar::Punctuation_Close), + Punctuation_InitialQuote = U_MASK(QChar::Punctuation_InitialQuote), + Punctuation_FinalQuote = U_MASK(QChar::Punctuation_FinalQuote), + Punctuation_Other = U_MASK(QChar::Punctuation_Other), + Symbol_Math = U_MASK(QChar::Symbol_Math), + Symbol_Currency = U_MASK(QChar::Symbol_Currency), + Symbol_Modifier = U_MASK(QChar::Symbol_Modifier), + Symbol_Other = U_MASK(QChar::Symbol_Other), + }; + + +#if QT_VERSION >= 0x040300 + // FIXME: handle surrogates correctly in all methods + + inline UChar32 toLower(UChar32 ch) + { + return QChar::toLower(ch); + } + + inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) + { + const UChar *e = src + srcLength; + const UChar *s = src; + UChar *r = result; + UChar *re = result + resultLength; + + // this avoids one out of bounds check in the loop + if (QChar(*s).isLowSurrogate()) + *r++ = *s++; + + int needed = 0; + while (s < e && r < re) { + uint c = *s; + if (QChar(c).isLowSurrogate() && QChar(*(s - 1)).isHighSurrogate()) + c = QChar::surrogateToUcs4(*(s - 1), c); + const QUnicodeTables::Properties *prop = QUnicodeTables::properties(c); + if (prop->lowerCaseSpecial) { + QString qstring; + if (c < 0x10000) { + qstring += QChar(c); + } else { + qstring += QChar(*(s-1)); + qstring += QChar(*s); + } + qstring = qstring.toLower(); + for (int i = 0; i < qstring.length(); ++i) { + if (r == re) { + needed += qstring.length() - i; + break; + } + *r = qstring.at(i).unicode(); + ++r; + } + } else { + *r = *s + prop->lowerCaseDiff; + ++r; + } + ++s; + } + if (s < e) + needed += e - s; + *error = (needed != 0); + if (r < re) + *r = 0; + return (r - result) + needed; + } + + inline UChar32 toUpper(UChar32 ch) + { + return QChar::toUpper(ch); + } + + inline int toUpper(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) + { + const UChar *e = src + srcLength; + const UChar *s = src; + UChar *r = result; + UChar *re = result + resultLength; + + // this avoids one out of bounds check in the loop + if (QChar(*s).isLowSurrogate()) + *r++ = *s++; + + int needed = 0; + while (s < e && r < re) { + uint c = *s; + if (QChar(c).isLowSurrogate() && QChar(*(s - 1)).isHighSurrogate()) + c = QChar::surrogateToUcs4(*(s - 1), c); + const QUnicodeTables::Properties *prop = QUnicodeTables::properties(c); + if (prop->upperCaseSpecial) { + QString qstring; + if (c < 0x10000) { + qstring += QChar(c); + } else { + qstring += QChar(*(s-1)); + qstring += QChar(*s); + } + qstring = qstring.toUpper(); + for (int i = 0; i < qstring.length(); ++i) { + if (r == re) { + needed += qstring.length() - i; + break; + } + *r = qstring.at(i).unicode(); + ++r; + } + } else { + *r = *s + prop->upperCaseDiff; + ++r; + } + ++s; + } + if (s < e) + needed += e - s; + *error = (needed != 0); + if (r < re) + *r = 0; + return (r - result) + needed; + } + + inline int toTitleCase(UChar32 c) + { + return QChar::toTitleCase(c); + } + + inline UChar32 foldCase(UChar32 c) + { + return QChar::toCaseFolded(c); + } + + inline int foldCase(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) + { + // FIXME: handle special casing. Easiest with some low level API in Qt + *error = false; + if (resultLength < srcLength) { + *error = true; + return srcLength; + } + for (int i = 0; i < srcLength; ++i) + result[i] = QChar::toCaseFolded(src[i]); + return srcLength; + } + + inline bool isFormatChar(UChar32 c) + { + return QChar::category(c) == QChar::Other_Format; + } + + inline bool isArabicChar(UChar32 c) + { + return c >= 0x0600 && c <= 0x06FF; + } + + inline bool isPrintableChar(UChar32 c) + { + const uint test = U_MASK(QChar::Other_Control) | + U_MASK(QChar::Other_NotAssigned); + return !(U_MASK(QChar::category(c)) & test); + } + + inline bool isSeparatorSpace(UChar32 c) + { + return QChar::category(c) == QChar::Separator_Space; + } + + inline bool isPunct(UChar32 c) + { + const uint test = U_MASK(QChar::Punctuation_Connector) | + U_MASK(QChar::Punctuation_Dash) | + U_MASK(QChar::Punctuation_Open) | + U_MASK(QChar::Punctuation_Close) | + U_MASK(QChar::Punctuation_InitialQuote) | + U_MASK(QChar::Punctuation_FinalQuote) | + U_MASK(QChar::Punctuation_Other); + return U_MASK(QChar::category(c)) & test; + } + + inline bool isDigit(UChar32 c) + { + return QChar::category(c) == QChar::Number_DecimalDigit; + } + + inline bool isLower(UChar32 c) + { + return QChar::category(c) == QChar::Letter_Lowercase; + } + + inline int digitValue(UChar32 c) + { + return QChar::digitValue(c); + } + + inline UChar32 mirroredChar(UChar32 c) + { + return QChar::mirroredChar(c); + } + + inline uint8_t combiningClass(UChar32 c) + { + return QChar::combiningClass(c); + } + + inline DecompositionType decompositionType(UChar32 c) + { + return (DecompositionType)QChar::decompositionTag(c); + } + + inline int umemcasecmp(const UChar* a, const UChar* b, int len) + { + // handle surrogates correctly + for (int i = 0; i < len; ++i) { + uint c1 = QChar::toCaseFolded(a[i]); + uint c2 = QChar::toCaseFolded(b[i]); + if (c1 != c2) + return c1 - c2; + } + return 0; + } + + inline Direction direction(UChar32 c) + { + return (Direction)QChar::direction(c); + } + + inline CharCategory category(UChar32 c) + { + return (CharCategory) U_MASK(QChar::category(c)); + } + +#else + + inline UChar32 toLower(UChar32 ch) + { + if (ch > 0xffff) + return ch; + return QChar((unsigned short)ch).toLower().unicode(); + } + + inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) + { + *error = false; + if (resultLength < srcLength) { + *error = true; + return srcLength; + } + for (int i = 0; i < srcLength; ++i) + result[i] = QChar(src[i]).toLower().unicode(); + return srcLength; + } + + inline UChar32 toUpper(UChar32 ch) + { + if (ch > 0xffff) + return ch; + return QChar((unsigned short)ch).toUpper().unicode(); + } + + inline int toUpper(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) + { + *error = false; + if (resultLength < srcLength) { + *error = true; + return srcLength; + } + for (int i = 0; i < srcLength; ++i) + result[i] = QChar(src[i]).toUpper().unicode(); + return srcLength; + } + + inline int toTitleCase(UChar32 c) + { + if (c > 0xffff) + return c; + return QChar((unsigned short)c).toUpper().unicode(); + } + + inline UChar32 foldCase(UChar32 c) + { + if (c > 0xffff) + return c; + return QChar((unsigned short)c).toLower().unicode(); + } + + inline int foldCase(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) + { + return toLower(result, resultLength, src, srcLength, error); + } + + inline bool isFormatChar(UChar32 c) + { + return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Other_Format; + } + + inline bool isPrintableChar(UChar32 c) + { + return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPrint(); + } + + inline bool isArabicChar(UChar32 c) + { + return c >= 0x0600 && c <= 0x06FF; + } + + inline bool isSeparatorSpace(UChar32 c) + { + return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Separator_Space; + } + + inline bool isPunct(UChar32 c) + { + return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPunct(); + } + + inline bool isDigit(UChar32 c) + { + return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isDigit(); + } + + inline bool isLower(UChar32 c) + { + return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Letter_Lowercase; + } + + inline int digitValue(UChar32 c) + { + if (c > 0xffff) + return 0; + return QChar(c).digitValue(); + } + + inline UChar32 mirroredChar(UChar32 c) + { + if (c > 0xffff) + return c; + return QChar(c).mirroredChar().unicode(); + } + + inline uint8_t combiningClass(UChar32 c) + { + if (c > 0xffff) + return 0; + return QChar((unsigned short)c).combiningClass(); + } + + inline DecompositionType decompositionType(UChar32 c) + { + if (c > 0xffff) + return DecompositionNone; + return (DecompositionType)QChar(c).decompositionTag(); + } + + inline int umemcasecmp(const UChar* a, const UChar* b, int len) + { + for (int i = 0; i < len; ++i) { + QChar c1 = QChar(a[i]).toLower(); + QChar c2 = QChar(b[i]).toLower(); + if (c1 != c2) + return c1.unicode() - c2.unicode(); + } + return 0; + } + + inline Direction direction(UChar32 c) + { + if (c > 0xffff) + return LeftToRight; + return (Direction)QChar(c).direction(); + } + + inline CharCategory category(UChar32 c) + { + if (c > 0xffff) + return NoCategory; + return (CharCategory) U_MASK(QChar(c).category()); + } + +#endif + + } +} + +#endif +// vim: ts=2 sw=2 et -- 2.45.2